org.eclipse.equinox.simpleconfigurator_1.0.301.v20120914-163612

)V
    //   94: goto +25 -> 119
    //   97: aload 6
    //   99: aload_1
    //   100: invokestatic 343	org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils:parseBundleInfoLine	(Ljava/lang/String;Ljava/net/URI;)Lorg/eclipse/equinox/internal/simpleconfigurator/utils/BundleInfo;
    //   103: astore 7
    //   105: aload 7
    //   107: ifnull +12 -> 119
    //   110: aload_2
    //   111: aload 7
    //   113: invokeinterface 348 2 0
    //   118: pop
    //   119: aload 5
    //   121: invokevirtual 293	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   124: dup
    //   125: astore 6
    //   127: ifnonnull -66 -> 61
    //   130: goto +17 -> 147
    //   133: astore 8
    //   135: aload 5
    //   137: invokevirtual 291	java/io/BufferedReader:close	()V
    //   140: goto +4 -> 144
    //   143: pop
    //   144: aload 8
    //   146: athrow
    //   147: aload 5
    //   149: invokevirtual 291	java/io/BufferedReader:close	()V
    //   152: goto +4 -> 156
    //   155: pop
    //   156: aload_2
    //   157: areturn
    // Line number table:
    //   Java source line #56	-> byte code offset #0
    //   Java source line #58	-> byte code offset #8
    //   Java source line #59	-> byte code offset #17
    //   Java source line #60	-> byte code offset #23
    //   Java source line #64	-> byte code offset #58
    //   Java source line #65	-> byte code offset #61
    //   Java source line #67	-> byte code offset #68
    //   Java source line #68	-> byte code offset #76
    //   Java source line #70	-> byte code offset #79
    //   Java source line #71	-> byte code offset #89
    //   Java source line #72	-> byte code offset #94
    //   Java source line #75	-> byte code offset #97
    //   Java source line #76	-> byte code offset #105
    //   Java source line #77	-> byte code offset #110
    //   Java source line #64	-> byte code offset #119
    //   Java source line #79	-> byte code offset #133
    //   Java source line #81	-> byte code offset #135
    //   Java source line #82	-> byte code offset #143
    //   Java source line #85	-> byte code offset #144
    //   Java source line #81	-> byte code offset #147
    //   Java source line #82	-> byte code offset #155
    //   Java source line #86	-> byte code offset #156
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	158	0	stream	InputStream
    //   0	158	1	base	URI
    //   7	150	2	bundles	List
    //   16	32	3	bufferedStream	BufferedInputStream
    //   21	28	4	encoding	String
    //   56	92	5	r	java.io.BufferedReader
    //   61	37	6	line	String
    //   125	3	6	line	String
    //   147	1	6	line	String
    //   156	1	6	line	String
    //   103	9	7	bundleInfo	BundleInfo
    //   133	12	8	localObject	Object
    //   143	1	12	localIOException1	IOException
    //   155	1	13	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   58	133	133	finally
    //   135	140	143	java/io/IOException
    //   147	152	155	java/io/IOException
  }
  
  private static String determineEncoding(BufferedInputStream stream)
  {
    byte[] utfBytes = "#encoding=UTF-8".getBytes();
    byte[] buffer = new byte[utfBytes.length];
    
    int bytesRead = -1;
    stream.mark(utfBytes.length + 1);
    try
    {
      bytesRead = stream.read(buffer);
    }
    catch (IOException localIOException1) {}
    if ((bytesRead == utfBytes.length) && (Arrays.equals(utfBytes, buffer))) {
      return "UTF-8";
    }
    try
    {
      stream.reset();
    }
    catch (IOException localIOException2) {}
    return null;
  }
  
  public static void parseCommentLine(String line)
  {
    if (line.startsWith("#version="))
    {
      String version = line.substring("#version=".length()).trim();
      if (!COMPATIBLE_VERSION.equals(new Version(version))) {
        throw new IllegalArgumentException("Invalid version: " + version);
      }
    }
  }
  
  public static BundleInfo parseBundleInfoLine(String line, URI base)
  {
    StringTokenizer tok = new StringTokenizer(line, ",");
    int numberOfTokens = tok.countTokens();
    if (numberOfTokens < 5) {
      throw new IllegalArgumentException("Line does not contain at least 5 tokens: " + line);
    }
    String symbolicName = tok.nextToken().trim();
    String version = tok.nextToken().trim();
    URI location = parseLocation(tok.nextToken().trim());
    int startLevel = Integer.parseInt(tok.nextToken().trim());
    boolean markedAsStarted = Boolean.valueOf(tok.nextToken()).booleanValue();
    BundleInfo result = new BundleInfo(symbolicName, version, location, startLevel, markedAsStarted);
    if (!location.isAbsolute()) {
      result.setBaseLocation(base);
    }
    return result;
  }
  
  public static URI parseLocation(String location)
  {
    int encodedCommaIndex = location.indexOf("%2C");
    while (encodedCommaIndex != -1)
    {
      location = location.substring(0, encodedCommaIndex) + "," + location.substring(encodedCommaIndex + 3);
      encodedCommaIndex = location.indexOf("%2C");
    }
    if (File.separatorChar != '/')
    {
      int colon = location.indexOf(':');
      String scheme = colon < 0 ? null : location.substring(0, colon);
      if ((scheme == null) || (scheme.equals("file"))) {
        location = location.replace(File.separatorChar, '/');
      }
      if (scheme == null)
      {
        if ((location.startsWith("//")) && (!location.startsWith("//", 2))) {
          location = "//" + location;
        }
      }
      else if ((location.startsWith("//", colon + 1)) && (!location.startsWith("//", colon + 3))) {
        location = location.substring(0, colon + 3) + location.substring(colon + 1);
      }
    }
    try
    {
      URI uri = new URI(location);
      if (!uri.isOpaque()) {
        return uri;
      }
    }
    catch (URISyntaxException localURISyntaxException1)
    {
      try
      {
        return URIUtil.fromString(location);
      }
      catch (URISyntaxException localURISyntaxException2)
      {
        throw new IllegalArgumentException("Invalid location: " + location);
      }
    }
  }
  
  /* Error */
  public static void transferStreams(InputStream source, java.io.OutputStream destination)
    throws IOException
  {
    // Byte code:
    //   0: new 157	java/io/BufferedInputStream
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 289	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   8: astore_0
    //   9: new 158	java/io/BufferedOutputStream
    //   12: dup
    //   13: aload_1
    //   14: invokespecial 290	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   17: astore_1
    //   18: sipush 8192
    //   21: newarray <illegal type>
    //   23: astore_2
    //   24: iconst_m1
    //   25: istore_3
    //   26: aload_0
    //   27: aload_2
    //   28: invokevirtual 295	java/io/InputStream:read	([B)I
    //   31: dup
    //   32: istore_3
    //   33: iconst_m1
    //   34: if_icmpne +6 -> 40
    //   37: goto +34 -> 71
    //   40: aload_1
    //   41: aload_2
    //   42: iconst_0
    //   43: iload_3
    //   44: invokevirtual 299	java/io/OutputStream:write	([BII)V
    //   47: goto -23 -> 24
    //   50: astore 4
    //   52: aload_0
    //   53: invokevirtual 294	java/io/InputStream:close	()V
    //   56: goto +4 -> 60
    //   59: pop
    //   60: aload_1
    //   61: invokevirtual 298	java/io/OutputStream:close	()V
    //   64: goto +4 -> 68
    //   67: pop
    //   68: aload 4
    //   70: athrow
    //   71: aload_0
    //   72: invokevirtual 294	java/io/InputStream:close	()V
    //   75: goto +4 -> 79
    //   78: pop
    //   79: aload_1
    //   80: invokevirtual 298	java/io/OutputStream:close	()V
    //   83: goto +4 -> 87
    //   86: pop
    //   87: return
    // Line number table:
    //   Java source line #187	-> byte code offset #0
    //   Java source line #188	-> byte code offset #9
    //   Java source line #190	-> byte code offset #18
    //   Java source line #192	-> byte code offset #24
    //   Java source line #193	-> byte code offset #26
    //   Java source line #194	-> byte code offset #37
    //   Java source line #195	-> byte code offset #40
    //   Java source line #191	-> byte code offset #47
    //   Java source line #197	-> byte code offset #50
    //   Java source line #199	-> byte code offset #52
    //   Java source line #200	-> byte code offset #59
    //   Java source line #204	-> byte code offset #60
    //   Java source line #205	-> byte code offset #67
    //   Java source line #208	-> byte code offset #68
    //   Java source line #199	-> byte code offset #71
    //   Java source line #200	-> byte code offset #78
    //   Java source line #204	-> byte code offset #79
    //   Java source line #205	-> byte code offset #86
    //   Java source line #209	-> byte code offset #87
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	88	0	source	InputStream
    //   0	88	1	destination	java.io.OutputStream
    //   23	19	2	buffer	byte[]
    //   25	19	3	bytesRead	int
    //   50	19	4	localObject	Object
    //   59	1	5	localIOException1	IOException
    //   67	1	6	localIOException2	IOException
    //   78	1	7	localIOException3	IOException
    //   86	1	8	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   18	50	50	finally
    //   52	56	59	java/io/IOException
    //   60	64	67	java/io/IOException
    //   71	75	78	java/io/IOException
    //   79	83	86	java/io/IOException
  }
  
  public static String getBundleLocation(BundleInfo bundle, boolean useReference)
  {
    URI location = bundle.getLocation();
    String scheme = location.getScheme();
    String host = location.getHost();
    String path = location.getPath();
    if (location.getScheme() == null)
    {
      URI baseLocation = bundle.getBaseLocation();
      if ((baseLocation != null) && (baseLocation.getScheme() != null))
      {
        scheme = baseLocation.getScheme();
        host = baseLocation.getHost();
      }
    }
    String bundleLocation = null;
    try
    {
      URL bundleLocationURL = new URL(scheme, host, path);
      bundleLocation = bundleLocationURL.toExternalForm();
    }
    catch (MalformedURLException localMalformedURLException)
    {
      bundleLocation = location.toString();
    }
    if ((useReference) && (bundleLocation.startsWith("file:"))) {
      bundleLocation = "reference:" + bundleLocation;
    }
    return bundleLocation;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.HostSpecification;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

public class StateResolverUtils
{
  public static Bundle[] getAdditionalRefresh(Collection currentResolved, BundleContext context)
  {
    ServiceReference ref = context.getServiceReference(PlatformAdmin.class.getName());
    if (ref == null) {
      return new Bundle[0];
    }
    PlatformAdmin platformAdmin = (PlatformAdmin)context.getService(ref);
    if (platformAdmin == null) {
      return new Bundle[0];
    }
    try
    {
      State state = platformAdmin.getState(false);
      BundleDescription[] bundles = state.getBundles();
      HashSet results = new HashSet(bundles.length);
      getAdditionRefresh(bundles, state, currentResolved, results, context);
      return (Bundle[])results.toArray(new Bundle[results.size()]);
    }
    finally
    {
      context.ungetService(ref);
    }
  }
  
  private static void getAdditionRefresh(BundleDescription[] bundleDescriptions, State state, Collection currentResolved, Set results, BundleContext context)
  {
    for (int i = 0; i < bundleDescriptions.length; i++)
    {
      Bundle bundle = context.getBundle(bundleDescriptions[i].getBundleId());
      if (bundle != null) {
        if ((!bundleDescriptions[i].isResolved()) && (bundleDescriptions[i].getHost() != null))
        {
          ResolverError[] errors = state.getResolverErrors(bundleDescriptions[i]);
          for (int j = 0; j < errors.length; j++) {
            if ((errors[j].getType() & 0x10) != 0)
            {
              BundleDescription[] possibleHosts = state.getBundles(bundleDescriptions[i].getHost().getName());
              for (int k = 0; k < possibleHosts.length; k++)
              {
                Bundle hostBundle = context.getBundle(possibleHosts[k].getBundleId());
                if ((hostBundle != null) && (currentResolved.contains(hostBundle)) && (bundleDescriptions[i].getHost().isSatisfiedBy(possibleHosts[k]))) {
                  results.add(hostBundle);
                }
              }
            }
          }
        }
        else if ((currentResolved.contains(bundle)) && (bundleDescriptions[i].isResolved()))
        {
          ImportPackageSpecification[] imports = bundleDescriptions[i].getImportPackages();
          for (int j = 0; j < imports.length; j++) {
            if (("optional".equals(imports[j].getDirective("resolution"))) && (!imports[j].isResolved()) && (state.getStateHelper().isResolvable(imports[j])))
            {
              results.add(bundle);
              break;
            }
          }
          BundleSpecification[] requires = bundleDescriptions[i].getRequiredBundles();
          for (int j = 0; j < requires.length; j++) {
            if ((requires[j].isOptional()) && (!requires[j].isResolved()) && (state.getStateHelper().isResolvable(requires[j])))
            {
              results.add(bundle);
              break;
            }
          }
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.StateResolverUtils
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class URIUtil
{
  private static final String SCHEME_FILE = "file";
  private static final String UNC_PREFIX = "//";
  
  public static URI append(URI base, String extension)
  {
    try
    {
      String path = base.getPath();
      if (path == null) {
        return appendOpaque(base, extension);
      }
      if (path.endsWith("/"))
      {
        URI result = base.resolve(extension);
        
        String resultPath = result.getPath();
        if ((path.startsWith("//")) && ((resultPath == null) || (!resultPath.startsWith("//")))) {}
        return new URI(result.getScheme(), "///" + result.getSchemeSpecificPart(), result.getFragment());
      }
      path = path + "/" + extension;
      return new URI(base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), path, base.getQuery(), base.getFragment());
    }
    catch (URISyntaxException e)
    {
      throw new RuntimeException(e);
    }
  }
  
  private static URI appendOpaque(URI base, String extension)
    throws URISyntaxException
  {
    String ssp = base.getSchemeSpecificPart();
    if (ssp.endsWith("/")) {
      ssp = ssp + extension;
    } else {
      ssp = ssp + "/" + extension;
    }
    return new URI(base.getScheme(), ssp, base.getFragment());
  }
  
  public static URI fromString(String uriString)
    throws URISyntaxException
  {
    int colon = uriString.indexOf(':');
    int hash = uriString.lastIndexOf('#');
    boolean noHash = hash < 0;
    if (noHash) {
      hash = uriString.length();
    }
    String scheme = colon < 0 ? null : uriString.substring(0, colon);
    String ssp = uriString.substring(colon + 1, hash);
    String fragment = noHash ? null : uriString.substring(hash + 1);
    if ((scheme != null) && (scheme.equals("file")))
    {
      File file = new File(uriString.substring(5));
      if (file.isAbsolute()) {
        return file.toURI();
      }
      scheme = null;
      if (File.separatorChar != '/') {
        ssp = ssp.replace(File.separatorChar, '/');
      }
    }
    return new URI(scheme, ssp, fragment);
  }
  
  public static boolean sameURI(URI url1, URI url2)
  {
    if (url1 == url2) {
      return true;
    }
    if ((url1 == null) || (url2 == null)) {
      return false;
    }
    if (url1.equals(url2)) {
      return true;
    }
    if (url1.isAbsolute() != url2.isAbsolute()) {
      return false;
    }
    File file1 = toFile(url1);
    return file1 == null ? false : file1.equals(toFile(url2));
  }
  
  public static File toFile(URI uri)
  {
    try
    {
      if (!"file".equalsIgnoreCase(uri.getScheme())) {
        return null;
      }
      return new File(uri);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      String path = uri.getPath();
      if (path == null) {
        path = uri.getSchemeSpecificPart();
      }
      return new File(path);
    }
  }
  
  public static String toUnencodedString(URI uri)
  {
    StringBuffer result = new StringBuffer();
    String scheme = uri.getScheme();
    if (scheme != null) {
      result.append(scheme).append(':');
    }
    result.append(uri.getSchemeSpecificPart());
    String fragment = uri.getFragment();
    if (fragment != null) {
      result.append('#').append(fragment);
    }
    return result.toString();
  }
  
  public static URI toURI(URL url)
    throws URISyntaxException
  {
    if ("file".equals(url.getProtocol()))
    {
      String pathString = url.toExternalForm().substring(5);
      if (pathString.indexOf('/') != 0) {
        pathString = '/' + pathString;
      } else if ((pathString.startsWith("//")) && (!pathString.startsWith("//", 2))) {
        pathString = "//" + pathString;
      }
      return new URI("file", null, pathString, null);
    }
    try
    {
      return new URI(url.toExternalForm());
    }
    catch (URISyntaxException localURISyntaxException) {}
    return new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
  }
  
  public static URL toURL(URI uri)
    throws MalformedURLException
  {
    return new URL(uri.toString());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.URIUtil
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.simpleconfigurator.utils;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

public class Utils
{
  private static final String PATH_SEP = "/";
  
  public static URL checkFullUrl(URL url, String urlName)
    throws IllegalArgumentException
  {
    if (url == null) {
      throw new IllegalArgumentException(urlName + " is null");
    }
    if (!url.getProtocol().endsWith("file")) {
      return url;
    }
    File file = new File(url.getFile());
    if (!file.isAbsolute()) {
      throw new IllegalArgumentException(urlName + "(" + url + ") does not have absolute path");
    }
    if (file.getAbsolutePath().startsWith("/")) {
      return url;
    }
    try
    {
      return getUrl("file", null, "/" + file.getAbsolutePath());
    }
    catch (MalformedURLException localMalformedURLException)
    {
      throw new IllegalArgumentException(urlName + "(" + "file:" + "/" + file.getAbsolutePath() + ") is not fully quallified");
    }
  }
  
  public static void deleteDir(File file)
    throws IOException
  {
    if (file.isFile())
    {
      if (!file.delete()) {
        throw new IOException("Fail to delete File(" + file.getAbsolutePath() + ")");
      }
      return;
    }
    File[] children = file.listFiles();
    for (int i = 0; i < children.length; i++) {
      deleteDir(children[i]);
    }
    if (!file.delete()) {
      throw new IOException("Fail to delete Dir(" + file.getAbsolutePath() + ")");
    }
  }
  
  public static BundleInfo[] getBundleInfosFromList(List list)
  {
    if (list == null) {
      return new BundleInfo[0];
    }
    BundleInfo[] ret = new BundleInfo[list.size()];
    list.toArray(ret);
    return ret;
  }
  
  public static URL getUrl(String protocol, String host, String file)
    throws MalformedURLException
  {
    file = replaceAll(file, File.separator, "/");
    return new URL(protocol, host, file);
  }
  
  public static String removeLastCh(String target, char ch)
  {
    while (target.charAt(target.length() - 1) == ch) {
      target = target.substring(0, target.length() - 1);
    }
    return target;
  }
  
  public static String replaceAll(String st, String oldSt, String newSt)
  {
    int index = -1;
    while ((index = st.indexOf(oldSt)) != -1) {
      st = st.substring(0, index) + newSt + st.substring(index + oldSt.length());
    }
    return st;
  }
  
  public static void log(int level, Object obj, String method, String message, Throwable e)
  {
    String msg = "";
    if (method == null)
    {
      if (obj != null) {
        msg = "(" + obj.getClass().getName() + ")";
      }
    }
    else if (obj == null) {
      msg = "[" + method + "]" + message;
    } else {
      msg = "[" + method + "](" + obj.getClass().getName() + ")";
    }
    msg = msg + message;
    
    String levelSt = null;
    if (level == 1) {
      levelSt = "DEBUG";
    } else if (level == 2) {
      levelSt = "INFO";
    } else if (level == 3) {
      levelSt = "WARNING";
    } else if (level == 4) {
      levelSt = "ERROR";
    }
    System.err.println("[" + levelSt + "]" + msg);
    if (e != null) {
      e.printStackTrace();
    }
  }
  
  public static URL buildURL(String spec)
    throws MalformedURLException
  {
    if (spec == null) {
      throw new NullPointerException("URL spec is null.");
    }
    if (spec.startsWith("file:"))
    {
      File file = new File(spec.substring(5));
      if (file.isAbsolute()) {
        return file.toURL();
      }
    }
    return new URL(spec);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.simpleconfigurator.utils.Utils
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd