org.eclipse.emf.common_2.7.0.v20120127-1122

16:43:26.081 INFO  jd.cli.Main - Decompiling org.eclipse.emf.common_2.7.0.v20120127-1122.jar
package org.eclipse.emf.common;

import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.osgi.framework.Bundle;

public class CommonPlugin$Implementation
  extends EMFPlugin.EclipsePlugin
{
  public CommonPlugin$Implementation()
  {
    CommonPlugin.access$0(this);
  }
  
  protected static URI asLocalURI(URI uri)
  {
    try
    {
      String fragment = uri.fragment();
      URL url = FileLocator.toFileURL(new URL(uri.trimFragment().toString()));
      return fix(url, fragment);
    }
    catch (IOException localIOException) {}
    return uri;
  }
  
  protected static URI resolve(URI uri)
  {
    String fragment = uri.fragment();
    URI uriWithoutFragment = uri.trimFragment();
    String uriWithoutFragmentToString = uriWithoutFragment.toString();
    
    URL url = null;
    try
    {
      url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
    }
    catch (IOException exception1)
    {
      try
      {
        uriWithoutFragmentToString = URI.decode(uriWithoutFragmentToString);
        url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
      }
      catch (IOException localIOException1) {}
    }
    if (url != null) {
      try
      {
        return fix(url, fragment);
      }
      catch (IOException localIOException2) {}
    }
    return uri;
  }
  
  protected static URI fix(URL url, String fragment)
    throws IOException
  {
    URI result = 
      "file".equalsIgnoreCase(url.getProtocol()) ? 
      URI.createFileURI(URI.decode(url.getFile())) : 
      URI.createURI(url.toString());
    if (fragment != null) {
      result = result.appendFragment(fragment);
    }
    return result;
  }
  
  public static Class<?> loadClass(String pluginID, String className)
    throws ClassNotFoundException
  {
    Bundle bundle = Platform.getBundle(pluginID);
    if (bundle == null) {
      throw new ClassNotFoundException(className + " cannot be loaded because because bundle " + pluginID + " cannot be resolved");
    }
    return bundle.loadClass(className);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.CommonPlugin.Implementation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common;

import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.URI;
import org.osgi.framework.Bundle;

public final class CommonPlugin
  extends EMFPlugin
{
  public static final CommonPlugin INSTANCE = new CommonPlugin();
  private static Implementation plugin;
  private static final Method COLLATOR_GET_INSTANCE_METHOD;
  
  private CommonPlugin()
  {
    super(new ResourceLocator[0]);
  }
  
  public ResourceLocator getPluginResourceLocator()
  {
    return plugin;
  }
  
  public static Implementation getPlugin()
  {
    return plugin;
  }
  
  public static URI asLocalURI(URI uri)
  {
    return plugin == null ? uri : Implementation.asLocalURI(uri);
  }
  
  public static URI resolve(URI uri)
  {
    return plugin == null ? uri : Implementation.resolve(uri);
  }
  
  public static Class<?> loadClass(String pluginID, String className)
    throws ClassNotFoundException
  {
    return plugin == null ? Class.forName(className) : Implementation.loadClass(pluginID, className);
  }
  
  static
  {
    Method collatorGetInstanceMethod = null;
    try
    {
      Class<?> collatorClass = loadClass("com.ibm.icu", "com.ibm.icu.text.Collator");
      collatorGetInstanceMethod = collatorClass.getMethod("getInstance", new Class[] { Locale.class });
    }
    catch (Throwable localThrowable) {}
    COLLATOR_GET_INSTANCE_METHOD = collatorGetInstanceMethod;
  }
  
  public Comparator<String> getComparator()
  {
    return getComparator(Locale.getDefault());
  }
  
  public Comparator<String> getComparator(Locale locale)
  {
    if (COLLATOR_GET_INSTANCE_METHOD != null) {
      try
      {
        return (Comparator)COLLATOR_GET_INSTANCE_METHOD.invoke(null, new Object[] { locale });
      }
      catch (Throwable localThrowable) {}
    }
    return Collator.getInstance(locale);
  }
  
  public static class Implementation
    extends EMFPlugin.EclipsePlugin
  {
    public Implementation()
    {
      CommonPlugin.plugin = this;
    }
    
    protected static URI asLocalURI(URI uri)
    {
      try
      {
        String fragment = uri.fragment();
        URL url = FileLocator.toFileURL(new URL(uri.trimFragment().toString()));
        return fix(url, fragment);
      }
      catch (IOException localIOException) {}
      return uri;
    }
    
    protected static URI resolve(URI uri)
    {
      String fragment = uri.fragment();
      URI uriWithoutFragment = uri.trimFragment();
      String uriWithoutFragmentToString = uriWithoutFragment.toString();
      
      URL url = null;
      try
      {
        url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
      }
      catch (IOException exception1)
      {
        try
        {
          uriWithoutFragmentToString = URI.decode(uriWithoutFragmentToString);
          url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
        }
        catch (IOException localIOException1) {}
      }
      if (url != null) {
        try
        {
          return fix(url, fragment);
        }
        catch (IOException localIOException2) {}
      }
      return uri;
    }
    
    protected static URI fix(URL url, String fragment)
      throws IOException
    {
      URI result = 
        "file".equalsIgnoreCase(url.getProtocol()) ? 
        URI.createFileURI(URI.decode(url.getFile())) : 
        URI.createURI(url.toString());
      if (fragment != null) {
        result = result.appendFragment(fragment);
      }
      return result;
    }
    
    public static Class<?> loadClass(String pluginID, String className)
      throws ClassNotFoundException
    {
      Bundle bundle = Platform.getBundle(pluginID);
      if (bundle == null) {
        throw new ClassNotFoundException(className + " cannot be loaded because because bundle " + pluginID + " cannot be resolved");
      }
      return bundle.loadClass(className);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.CommonPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.MissingResourceException;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.emf.common.util.Logger;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.WrappedException;

public abstract class EMFPlugin$EclipsePlugin
  extends Plugin
  implements ResourceLocator, Logger, EMFPlugin.InternalEclipsePlugin
{
  protected EMFPlugin.InternalHelper helper;
  
  public EMFPlugin$EclipsePlugin()
  {
    helper = new EMFPlugin.InternalHelper(this);
  }
  
  @Deprecated
  public EMFPlugin$EclipsePlugin(IPluginDescriptor descriptor)
  {
    super(descriptor);
    helper = new EMFPlugin.InternalHelper(this);
  }
  
  public String getSymbolicName()
  {
    return helper.getSymbolicName();
  }
  
  public URL getBaseURL()
  {
    return helper.getBaseURL();
  }
  
  public Object getImage(String key)
  {
    try
    {
      return doGetImage(key);
    }
    catch (MalformedURLException exception)
    {
      throw new WrappedException(exception);
    }
    catch (IOException exception)
    {
      throw 
        new MissingResourceException(
        CommonPlugin.INSTANCE.getString("_UI_StringResourceNotFound_exception", new Object[] { key }), 
        getClass().getName(), 
        key);
    }
  }
  
  protected Object doGetImage(String key)
    throws IOException
  {
    return helper.getImage(key);
  }
  
  public String getString(String key)
  {
    return helper.getString(key, true);
  }
  
  public String getString(String key, boolean translate)
  {
    return helper.getString(key, translate);
  }
  
  public String getString(String key, Object[] substitutions)
  {
    return helper.getString(key, substitutions, true);
  }
  
  public String getString(String key, Object[] substitutions, boolean translate)
  {
    return helper.getString(key, substitutions, translate);
  }
  
  public void log(Object logEntry)
  {
    helper.log(logEntry);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.EMFPlugin.EclipsePlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common;

public abstract interface EMFPlugin$InternalEclipsePlugin
{
  public abstract String getSymbolicName();
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.EMFPlugin.InternalEclipsePlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.Bundle;

public class EMFPlugin$InternalHelper
{
  protected Plugin plugin;
  protected ResourceBundle resourceBundle;
  protected ResourceBundle untranslatedResourceBundle;
  
  public EMFPlugin$InternalHelper(Plugin plugin)
  {
    this.plugin = plugin;
  }
  
  protected Bundle getBundle()
  {
    return plugin.getBundle();
  }
  
  protected ILog getLog()
  {
    return plugin.getLog();
  }
  
  public String getSymbolicName()
  {
    return getBundle().getSymbolicName();
  }
  
  public URL getBaseURL()
  {
    return getBundle().getEntry("/");
  }
  
  public Object getImage(String key)
    throws IOException
  {
    URL url = new URL(getBaseURL() + "icons/" + key + EMFPlugin.access$0(key));
    InputStream inputStream = url.openStream();
    inputStream.close();
    return url;
  }
  
  public String getString(String key, boolean translate)
  {
    ResourceBundle bundle = translate ? resourceBundle : untranslatedResourceBundle;
    if (bundle == null) {
      if (translate)
      {
        bundle = resourceBundle = Platform.getResourceBundle(getBundle());
      }
      else
      {
        String resourceName = getBaseURL().toString() + "plugin.properties";
        try
        {
          InputStream inputStream = new URL(resourceName).openStream();
          bundle = untranslatedResourceBundle = new PropertyResourceBundle(inputStream);
          inputStream.close();
        }
        catch (IOException ioException)
        {
          throw new MissingResourceException("Missing properties: " + resourceName, getClass().getName(), "plugin.properties");
        }
      }
    }
    return bundle.getString(key);
  }
  
  public String getString(String key, Object[] substitutions, boolean translate)
  {
    return MessageFormat.format(getString(key, translate), substitutions);
  }
  
  public void log(Object logEntry)
  {
    if ((logEntry instanceof IStatus))
    {
      IStatus status = (IStatus)logEntry;
      getLog().log(status);
    }
    else
    {
      if (logEntry == null) {
        logEntry = new RuntimeException(getString("_UI_NullLogEntry_exception", true)).fillInStackTrace();
      }
      if ((logEntry instanceof Throwable))
      {
        Throwable throwable = (Throwable)logEntry;
        
        String message = throwable.getLocalizedMessage();
        if (message == null) {
          message = "";
        }
        getLog().log(new Status(2, getBundle().getSymbolicName(), 0, message, throwable));
      }
      else
      {
        getLog().log(new Status(2, getBundle().getSymbolicName(), 0, logEntry.toString(), null));
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.EMFPlugin.InternalHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.DelegatingResourceLocator;
import org.eclipse.emf.common.util.Logger;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.osgi.framework.Bundle;

public abstract class EMFPlugin
  extends DelegatingResourceLocator
  implements ResourceLocator, Logger
{
  public static final boolean IS_ECLIPSE_RUNNING;
  public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE;
  protected ResourceLocator[] delegateResourceLocators;
  
  static
  {
    boolean result = false;
    try
    {
      result = Platform.isRunning();
    }
    catch (Throwable localThrowable) {}
    IS_ECLIPSE_RUNNING = result;
    
    boolean result = false;
    if (IS_ECLIPSE_RUNNING) {
      try
      {
        Bundle resourcesBundle = Platform.getBundle("org.eclipse.core.resources");
        result = (resourcesBundle != null) && ((resourcesBundle.getState() & 0x2C) != 0);
      }
      catch (Throwable localThrowable1) {}
    }
    IS_RESOURCES_BUNDLE_AVAILABLE = result;
  }
  
  public EMFPlugin(ResourceLocator[] delegateResourceLocators)
  {
    this.delegateResourceLocators = delegateResourceLocators;
  }
  
  public abstract ResourceLocator getPluginResourceLocator();
  
  protected final ResourceLocator getPrimaryResourceLocator()
  {
    return getPluginResourceLocator();
  }
  
  protected ResourceLocator[] getDelegateResourceLocators()
  {
    return delegateResourceLocators;
  }
  
  public Logger getPluginLogger()
  {
    return (Logger)getPluginResourceLocator();
  }
  
  public String getSymbolicName()
  {
    ResourceLocator resourceLocator = getPluginResourceLocator();
    if ((resourceLocator instanceof InternalEclipsePlugin)) {
      return ((InternalEclipsePlugin)resourceLocator).getSymbolicName();
    }
    String result = getClass().getName();
    return result.substring(0, result.lastIndexOf('.'));
  }
  
  public void log(Object logEntry)
  {
    Logger logger = getPluginLogger();
    if (logger == null)
    {
      if ((logEntry instanceof Throwable)) {
        ((Throwable)logEntry).printStackTrace(System.err);
      } else {
        System.err.println(logEntry);
      }
    }
    else {
      logger.log(logEntry);
    }
  }
  
  public static abstract class EclipsePlugin
    extends Plugin
    implements ResourceLocator, Logger, EMFPlugin.InternalEclipsePlugin
  {
    protected EMFPlugin.InternalHelper helper;
    
    public EclipsePlugin()
    {
      helper = new EMFPlugin.InternalHelper(this);
    }
    
    @Deprecated
    public EclipsePlugin(IPluginDescriptor descriptor)
    {
      super();
      helper = new EMFPlugin.InternalHelper(this);
    }
    
    public String getSymbolicName()
    {
      return helper.getSymbolicName();
    }
    
    public URL getBaseURL()
    {
      return helper.getBaseURL();
    }
    
    public Object getImage(String key)
    {
      try
      {
        return doGetImage(key);
      }
      catch (MalformedURLException exception)
      {
        throw new WrappedException(exception);
      }
      catch (IOException exception)
      {
        throw 
          new MissingResourceException(
          CommonPlugin.INSTANCE.getString("_UI_StringResourceNotFound_exception", new Object[] { key }), 
          getClass().getName(), 
          key);
      }
    }
    
    protected Object doGetImage(String key)
      throws IOException
    {
      return helper.getImage(key);
    }
    
    public String getString(String key)
    {
      return helper.getString(key, true);
    }
    
    public String getString(String key, boolean translate)
    {
      return helper.getString(key, translate);
    }
    
    public String getString(String key, Object[] substitutions)
    {
      return helper.getString(key, substitutions, true);
    }
    
    public String getString(String key, Object[] substitutions, boolean translate)
    {
      return helper.getString(key, substitutions, translate);
    }
    
    public void log(Object logEntry)
    {
      helper.log(logEntry);
    }
  }
  
  public static abstract interface InternalEclipsePlugin
  {
    public abstract String getSymbolicName();
  }
  
  public static class InternalHelper
  {
    protected Plugin plugin;
    protected ResourceBundle resourceBundle;
    protected ResourceBundle untranslatedResourceBundle;
    
    public InternalHelper(Plugin plugin)
    {
      this.plugin = plugin;
    }
    
    protected Bundle getBundle()
    {
      return plugin.getBundle();
    }
    
    protected ILog getLog()
    {
      return plugin.getLog();
    }
    
    public String getSymbolicName()
    {
      return getBundle().getSymbolicName();
    }
    
    public URL getBaseURL()
    {
      return getBundle().getEntry("/");
    }
    
    public Object getImage(String key)
      throws IOException
    {
      URL url = new URL(getBaseURL() + "icons/" + key + EMFPlugin.extensionFor(key));
      InputStream inputStream = url.openStream();
      inputStream.close();
      return url;
    }
    
    public String getString(String key, boolean translate)
    {
      ResourceBundle bundle = translate ? resourceBundle : untranslatedResourceBundle;
      if (bundle == null) {
        if (translate)
        {
          bundle = resourceBundle = Platform.getResourceBundle(getBundle());
        }
        else
        {
          String resourceName = getBaseURL().toString() + "plugin.properties";
          try
          {
            InputStream inputStream = new URL(resourceName).openStream();
            bundle = untranslatedResourceBundle = new PropertyResourceBundle(inputStream);
            inputStream.close();
          }
          catch (IOException ioException)
          {
            throw new MissingResourceException("Missing properties: " + resourceName, getClass().getName(), "plugin.properties");
          }
        }
      }
      return bundle.getString(key);
    }
    
    public String getString(String key, Object[] substitutions, boolean translate)
    {
      return MessageFormat.format(getString(key, translate), substitutions);
    }
    
    public void log(Object logEntry)
    {
      if ((logEntry instanceof IStatus))
      {
        IStatus status = (IStatus)logEntry;
        getLog().log(status);
      }
      else
      {
        if (logEntry == null) {
          logEntry = new RuntimeException(getString("_UI_NullLogEntry_exception", true)).fillInStackTrace();
        }
        if ((logEntry instanceof Throwable))
        {
          Throwable throwable = (Throwable)logEntry;
          
          String message = throwable.getLocalizedMessage();
          if (message == null) {
            message = "";
          }
          getLog().log(new Status(2, getBundle().getSymbolicName(), 0, message, throwable));
        }
        else
        {
          getLog().log(new Status(2, getBundle().getSymbolicName(), 0, logEntry.toString(), null));
        }
      }
    }
  }
  
  public static void main(String[] args)
  {
    try
    {
      String[] relativePath = { "META-INF", "MANIFEST.MF" };
      Class<?> theClass = args.length > 0 ? Class.forName(args[0]) : EMFPlugin.class;
      
      String className = theClass.getName();
      int index = className.lastIndexOf(".");
      URL classURL = theClass.getResource((index == -1 ? className : className.substring(index + 1)) + ".class");
      URI uri = URI.createURI(classURL.toString());
      
      int count = 1;
      for (int i = 0; (i = className.indexOf('.', i)) != -1; i++) {
        count++;
      }
      uri = uri.trimSegments(count);
      
      URL manifestURL = null;
      if (URI.isArchiveScheme(uri.scheme())) {
        try
        {
          String manifestURI = uri.appendSegments(relativePath).toString();
          InputStream inputStream = new URL(manifestURI).openStream();
          inputStream.close();
          manifestURL = new URL(manifestURI);
        }
        catch (IOException exception)
        {
          uri = URI.createURI(uri.authority()).trimSegments(1);
        }
      }
      if (manifestURL == null)
      {
        String lastSegment = uri.lastSegment();
        if (("bin".equals(lastSegment)) || ("runtime".equals(lastSegment))) {
          uri = uri.trimSegments(1);
        }
        uri = uri.appendSegments(relativePath);
        manifestURL = new URL(uri.toString());
      }
      Manifest manifest = new Manifest(manifestURL.openStream());
      String symbolicName = manifest.getMainAttributes().getValue("Bundle-SymbolicName");
      if (symbolicName != null)
      {
        int end = symbolicName.indexOf(";");
        if (end != -1) {
          symbolicName = symbolicName.substring(0, end);
        }
        System.out.println("Bundle-SymbolicName=" + symbolicName + " Bundle-Version=" + manifest.getMainAttributes().getValue("Bundle-Version"));
        return;
      }
    }
    catch (Exception localException)
    {
      System.err.println("No Bundle information found");
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.EMFPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common.archive;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipFile;

class ArchiveURLConnection$1
  extends FilterInputStream
{
  ArchiveURLConnection$1(ArchiveURLConnection paramArchiveURLConnection, InputStream $anonymous0, ZipFile paramZipFile)
  {
    super($anonymous0);
  }
  
  public void close()
    throws IOException
  {
    super.close();
    val$zipFile.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.archive.ArchiveURLConnection.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common.archive;

import java.io.File;
import java.io.FilterOutputStream;
import java.io.OutputStream;

class ArchiveURLConnection$2
  extends FilterOutputStream
{
  protected boolean isClosed;
  
  ArchiveURLConnection$2(ArchiveURLConnection paramArchiveURLConnection, OutputStream $anonymous0, String paramString, boolean paramBoolean, File paramFile, byte[] paramArrayOfByte)
  {
    super($anonymous0);
  }
  
  /* Error */
  public void close()
    throws java.io.IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 101	org/eclipse/emf/common/archive/ArchiveURLConnection$2:isClosed	Z
    //   4: ifne +214 -> 218
    //   7: aload_0
    //   8: iconst_1
    //   9: putfield 101	org/eclipse/emf/common/archive/ArchiveURLConnection$2:isClosed	Z
    //   12: aload_0
    //   13: invokespecial 112	java/io/FilterOutputStream:close	()V
    //   16: aload_0
    //   17: getfield 105	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$nestedURL	Ljava/lang/String;
    //   20: ldc 2
    //   22: invokevirtual 120	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   25: istore_1
    //   26: iload_1
    //   27: ifeq +76 -> 103
    //   30: new 50	java/io/File
    //   33: dup
    //   34: aload_0
    //   35: getfield 105	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$nestedURL	Ljava/lang/String;
    //   38: iconst_5
    //   39: invokevirtual 119	java/lang/String:substring	(I)Ljava/lang/String;
    //   42: invokestatic 125	org/eclipse/emf/common/util/URI:decode	(Ljava/lang/String;)Ljava/lang/String;
    //   45: invokespecial 110	java/io/File:<init>	(Ljava/lang/String;)V
    //   48: astore_2
    //   49: aload_0
    //   50: getfield 102	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$deleteRequired	Z
    //   53: ifeq +37 -> 90
    //   56: aload_2
    //   57: invokevirtual 107	java/io/File:delete	()Z
    //   60: ifne +30 -> 90
    //   63: new 53	java/io/IOException
    //   66: dup
    //   67: new 57	java/lang/StringBuilder
    //   70: dup
    //   71: ldc 1
    //   73: invokespecial 122	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   76: aload_2
    //   77: invokevirtual 109	java/io/File:getPath	()Ljava/lang/String;
    //   80: invokevirtual 123	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   83: invokevirtual 121	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   86: invokespecial 114	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   89: athrow
    //   90: aload_0
    //   91: getfield 104	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$tempFile	Ljava/io/File;
    //   94: aload_2
    //   95: invokevirtual 108	java/io/File:renameTo	(Ljava/io/File;)Z
    //   98: ifne +5 -> 103
    //   101: iconst_0
    //   102: istore_1
    //   103: iload_1
    //   104: ifne +106 -> 210
    //   107: aconst_null
    //   108: astore_2
    //   109: aconst_null
    //   110: astore_3
    //   111: new 51	java/io/FileInputStream
    //   114: dup
    //   115: aload_0
    //   116: getfield 104	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$tempFile	Ljava/io/File;
    //   119: invokespecial 111	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   122: astore_2
    //   123: aload_0
    //   124: getfield 106	org/eclipse/emf/common/archive/ArchiveURLConnection$2:this$0	Lorg/eclipse/emf/common/archive/ArchiveURLConnection;
    //   127: aload_0
    //   128: getfield 105	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$nestedURL	Ljava/lang/String;
    //   131: invokevirtual 124	org/eclipse/emf/common/archive/ArchiveURLConnection:createOutputStream	(Ljava/lang/String;)Ljava/io/OutputStream;
    //   134: astore_3
    //   135: goto +14 -> 149
    //   138: aload_3
    //   139: aload_0
    //   140: getfield 103	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$bytes	[B
    //   143: iconst_0
    //   144: iload 4
    //   146: invokevirtual 118	java/io/OutputStream:write	([BII)V
    //   149: aload_2
    //   150: aload_0
    //   151: getfield 103	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$bytes	[B
    //   154: iconst_0
    //   155: aload_0
    //   156: getfield 103	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$bytes	[B
    //   159: arraylength
    //   160: invokevirtual 116	java/io/InputStream:read	([BII)I
    //   163: dup
    //   164: istore 4
    //   166: iconst_m1
    //   167: if_icmpgt -29 -> 138
    //   170: goto +24 -> 194
    //   173: astore 5
    //   175: aload_2
    //   176: ifnull +7 -> 183
    //   179: aload_2
    //   180: invokevirtual 115	java/io/InputStream:close	()V
    //   183: aload_3
    //   184: ifnull +7 -> 191
    //   187: aload_3
    //   188: invokevirtual 117	java/io/OutputStream:close	()V
    //   191: aload 5
    //   193: athrow
    //   194: aload_2
    //   195: ifnull +7 -> 202
    //   198: aload_2
    //   199: invokevirtual 115	java/io/InputStream:close	()V
    //   202: aload_3
    //   203: ifnull +7 -> 210
    //   206: aload_3
    //   207: invokevirtual 117	java/io/OutputStream:close	()V
    //   210: aload_0
    //   211: getfield 104	org/eclipse/emf/common/archive/ArchiveURLConnection$2:val$tempFile	Ljava/io/File;
    //   214: invokevirtual 107	java/io/File:delete	()Z
    //   217: pop
    //   218: return
    // Line number table:
    //   Java source line #511	-> byte code offset #0
    //   Java source line #513	-> byte code offset #7
    //   Java source line #517	-> byte code offset #12
    //   Java source line #519	-> byte code offset #16
    //   Java source line #524	-> byte code offset #26
    //   Java source line #526	-> byte code offset #30
    //   Java source line #527	-> byte code offset #49
    //   Java source line #529	-> byte code offset #63
    //   Java source line #531	-> byte code offset #90
    //   Java source line #533	-> byte code offset #101
    //   Java source line #536	-> byte code offset #103
    //   Java source line #541	-> byte code offset #107
    //   Java source line #542	-> byte code offset #109
    //   Java source line #545	-> byte code offset #111
    //   Java source line #546	-> byte code offset #123
    //   Java source line #547	-> byte code offset #135
    //   Java source line #549	-> byte code offset #138
    //   Java source line #547	-> byte code offset #149
    //   Java source line #553	-> byte code offset #173
    //   Java source line #556	-> byte code offset #175
    //   Java source line #558	-> byte code offset #179
    //   Java source line #560	-> byte code offset #183
    //   Java source line #562	-> byte code offset #187
    //   Java source line #564	-> byte code offset #191
    //   Java source line #556	-> byte code offset #194
    //   Java source line #558	-> byte code offset #198
    //   Java source line #560	-> byte code offset #202
    //   Java source line #562	-> byte code offset #206
    //   Java source line #568	-> byte code offset #210
    //   Java source line #570	-> byte code offset #218
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	219	0	this	2
    //   25	79	1	useRenameTo	boolean
    //   48	47	2	targetFile	File
    //   108	91	2	inputStream	java.io.InputStream
    //   110	97	3	outputStream	OutputStream
    //   138	7	4	size	int
    //   164	3	4	size	int
    //   173	19	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   111	173	173	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.common.archive.ArchiveURLConnection.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.common.archive;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FilterInputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.eclipse.emf.common.util.URI;

public class ArchiveURLConnection
  extends URLConnection
{
  protected String urlString;
  
  public ArchiveURLConnection(URL url)
  {
    super(url);
    urlString = url.toString();
  }
  
  protected ArchiveURLConnection(String url)
  {
    super(null);
    urlString = url;
  }
  
  protected boolean emulateArchiveScheme()
  {
    return false;
  }
  
  protected boolean useZipFile()
  {
    return false;
  }
  
  public void connect()
    throws IOException
  {
    connected = true;
  }
  
  protected String getNestedURL()
    throws IOException
  {
    int archiveSeparator = urlString.indexOf("!/");
    if (archiveSeparator < 0) {
      throw new MalformedURLException("missing archive separators " + urlString);
    }
    int start = urlString.indexOf(':') + 1;
    if ((start > urlString.length()) || (urlString.charAt(start) == '/')) {
      throw 
        new IllegalArgumentException(
        "archive protocol must be immediately followed by another URL protocol " + urlString);
    }
    int i = start;
    for (int end = urlString.indexOf("/") - 1; (i = urlString.indexOf(":", i)) < end;) {
      if (emulateArchiveScheme())
      {
        i++;start = i;
      }
      else
      {
        archiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
        if (archiveSeparator < 0) {
          throw new MalformedURLException("too few archive separators " + urlString);
        }
        i++;
      }
    }
    return urlString.substring(start, archiveSeparator);
  }
  
  public InputStream getInputStream()
    throws IOException
  {
    String nestedURL = getNestedURL();
    
    int archiveSeparator = urlString.indexOf(nestedURL) + nestedURL.length();
    int nextArchiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
    
    ZipEntry inputZipEntry = null;
    InputStream inputStream;
    InputStream inputStream;
    if ((!useZipFile()) || (!nestedURL.startsWith("file:")))
    {
      inputStream = createInputStream(nestedURL);
    }
    else
    {
      String entry = 
        URI.decode(nextArchiveSeparator < 0 ? 
        urlString.substring(archiveSeparator + 2) : 
        urlString.substring(archiveSeparator + 2, nextArchiveSeparator));
      
      archiveSeparator = nextArchiveSeparator;
      nextArchiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
      
      final ZipFile zipFile = new ZipFile(URI.decode(nestedURL.substring(5)));
      inputZipEntry = zipFile.getEntry(entry);
      InputStream zipEntryInputStream = inputZipEntry == null ? null : zipFile.getInputStream(inputZipEntry);
      if (zipEntryInputStream == null)
      {
        try
        {
          zipFile.close();
        }
        catch (Throwable localThrowable) {}
        throw new IOException("Archive entry not found " + urlString);
      }
      inputStream = 
        new FilterInputStream(zipEntryInputStream)
        {
          public void close()
            throws IOException
          {
            super.close();
            zipFile.close();
          }
        };
      }
      label356:
      while (archiveSeparator > 0)
      {
        inputZipEntry = null;
        
        String entry = 
          URI.decode(nextArchiveSeparator < 0 ? 
          urlString.substring(archiveSeparator + 2) : 
          urlString.substring(archiveSeparator + 2, nextArchiveSeparator));
        
        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
        while (zipInputStream.available() >= 0)
        {
          ZipEntry zipEntry = zipInputStream.getNextEntry();
          if (zipEntry == null) {
            break;
          }
          if (entry.equals(zipEntry.getName()))
          {
            inputZipEntry = zipEntry;
            inputStream = zipInputStream;
            
            archiveSeparator = nextArchiveSeparator;
            nextArchiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
            break label356;
          }
        }
        zipInputStream.close();
        throw new IOException("Archive entry not found " + urlString);
      }
      return yield(inputZipEntry, inputStream);
    }
    
    protected InputStream yield(ZipEntry zipEntry, InputStream inputStream)
      throws IOException
    {
      return inputStream;
    }
    
    protected InputStream createInputStream(String nestedURL)
      throws IOException
    {
      return new URL(nestedURL).openStream();
    }
    
    public OutputStream getOutputStream()
      throws IOException
    {
      return getOutputStream(false, -1L);
    }
    
    public void delete()
      throws IOException
    {
      getOutputStream(true, -1L).close();
    }
    
    public void setTimeStamp(long timeStamp)
      throws IOException
    {
      getOutputStream(false, timeStamp).close();
    }
    
    private OutputStream getOutputStream(boolean delete, long timeStamp)
      throws IOException
    {
      final String nestedURL = getNestedURL();
      
      final File tempFile = File.createTempFile("Archive", "zip");
      tempFile.deleteOnExit();
      
      InputStream sourceInputStream = null;
      OutputStream tempOutputStream = null;
      try
      {
        tempOutputStream = new FileOutputStream(tempFile);
        try
        {
          sourceInputStream = createInputStream(nestedURL);
        }
        catch (IOException localIOException) {}
        OutputStream outputStream = tempOutputStream;
        InputStream inputStream = sourceInputStream;
        
        int archiveSeparator = urlString.indexOf(nestedURL) + nestedURL.length();
        int nextArchiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
        
        final byte[] bytes = new byte['?'];
        
        boolean found = false;
        label311:
        do
        {
          String entry = 
            URI.decode(nextArchiveSeparator < 0 ? 
            urlString.substring(archiveSeparator + 2) : 
            urlString.substring(archiveSeparator + 2, nextArchiveSeparator));
          
          ZipOutputStream zipOutputStream = null;
          
          ZipInputStream zipInputStream = inputStream == null ? null : new ZipInputStream(inputStream);
          inputStream = zipInputStream;
          int size;
          for (; (zipInputStream != null) && (zipInputStream.available() >= 0); (size = zipInputStream.read(bytes, 0, bytes.length)) > -1)
          {
            ZipEntry zipEntry = zipInputStream.getNextEntry();
            if (zipEntry == null) {
              break;
            }
            boolean match = entry.equals(zipEntry.getName());
            if (!found) {
              found = (match) && (nextArchiveSeparator < 0);
            }
            if ((timeStamp == -1L) && (match)) {
              break label311;
            }
            if (zipOutputStream == null)
            {
              zipOutputStream = new ZipOutputStream(outputStream);
              outputStream = zipOutputStream;
            }
            if ((timeStamp != -1L) && (match) && (nextArchiveSeparator < 0)) {
              zipEntry.setTime(timeStamp);
            }
            zipOutputStream.putNextEntry(zipEntry);
            continue;
            int size;
            zipOutputStream.write(bytes, 0, size);
          }
          archiveSeparator = nextArchiveSeparator;
          nextArchiveSeparator = urlString.indexOf("!/", archiveSeparator + 2);
          if (((delete) || (timeStamp != -1L)) && (archiveSeparator < 0))
          {
            if (!found) {
              throw new IOException("Archive entry not found " + urlString);
            }
            ZipEntry outputZipEntry = null;
            break;
          }
          ZipEntry outputZipEntry = new ZipEntry(entry);
          if (zipOutputStream == null)
          {
            zipOutputStream = new ZipOutputStream(outputStream);
            outputStream = zipOutputStream;
          }
          zipOutputStream.putNextEntry(outputZipEntry);
        } while (archiveSeparator > 0);
        ZipEntry outputZipEntry;
        ZipOutputStream zipOutputStream;
        tempOutputStream = null;
        
        final boolean deleteRequired = sourceInputStream != null;
        FilterOutputStream result = 
          new FilterOutputStream(zipOutputStream == null ? outputStream : zipOutputStream)
          {
            protected boolean isClosed;
            
            /* Error */
            public void close()
              throws IOException
            {
              // Byte code:
              //   0: aload_0
              //   1: getfield 101	org/eclipse/emf/common/archive/ArchiveURLConnection$2:isClosed	Z
              //   4: ifne +214 -> 218
              //   7: aload_0
              //   8: iconst_1
              //   9: putfield 101	org/eclipse/emf/common/archive/ArchiveURLConnection$2:isClosed	Z
              //   12: aload_0
              //   13: invokespecial 112	java/io/
1 2 3 4 5 6 7 8 9 10 11 12

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-2017. Infinite Loop Ltd