org.eclipse.equinox.p2.publisher_1.2.0.v20121002-080415

    //   248: invokevirtual 258	java/util/zip/ZipFile:close	()V
    //   251: goto +4 -> 255
    //   254: pop
    //   255: aload 5
    //   257: areturn
    // Line number table:
    //   Java source line #93	-> byte code offset #0
    //   Java source line #94	-> byte code offset #3
    //   Java source line #96	-> byte code offset #13
    //   Java source line #97	-> byte code offset #24
    //   Java source line #98	-> byte code offset #34
    //   Java source line #99	-> byte code offset #46
    //   Java source line #100	-> byte code offset #53
    //   Java source line #102	-> byte code offset #61
    //   Java source line #103	-> byte code offset #74
    //   Java source line #104	-> byte code offset #81
    //   Java source line #106	-> byte code offset #84
    //   Java source line #107	-> byte code offset #93
    //   Java source line #108	-> byte code offset #100
    //   Java source line #109	-> byte code offset #108
    //   Java source line #110	-> byte code offset #118
    //   Java source line #111	-> byte code offset #130
    //   Java source line #112	-> byte code offset #145
    //   Java source line #115	-> byte code offset #160
    //   Java source line #116	-> byte code offset #162
    //   Java source line #117	-> byte code offset #167
    //   Java source line #118	-> byte code offset #172
    //   Java source line #116	-> byte code offset #175
    //   Java source line #117	-> byte code offset #180
    //   Java source line #97	-> byte code offset #185
    //   Java source line #121	-> byte code offset #198
    //   Java source line #122	-> byte code offset #200
    //   Java source line #124	-> byte code offset #205
    //   Java source line #126	-> byte code offset #210
    //   Java source line #127	-> byte code offset #218
    //   Java source line #123	-> byte code offset #222
    //   Java source line #124	-> byte code offset #224
    //   Java source line #126	-> byte code offset #229
    //   Java source line #127	-> byte code offset #237
    //   Java source line #131	-> byte code offset #238
    //   Java source line #124	-> byte code offset #241
    //   Java source line #126	-> byte code offset #246
    //   Java source line #127	-> byte code offset #254
    //   Java source line #133	-> byte code offset #255
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	258	0	root	File
    //   0	258	1	localizationPath	String
    //   0	258	2	defaultLocale	Locale
    //   0	258	3	propertyKeys	String[]
    //   1	246	4	jarFile	java.util.zip.ZipFile
    //   11	245	5	localizations	Map<Locale, Map<String, String>>
    //   29	157	6	entries	java.util.Enumeration<? extends java.util.zip.ZipEntry>
    //   198	3	6	ioe	IOException
    //   44	43	7	nextEntry	java.util.zip.ZipEntry
    //   51	3	8	nextName	String
    //   59	16	9	localeString	String
    //   79	69	10	nextLocale	Locale
    //   82	99	11	stream	InputStream
    //   98	4	12	properties	Map<String, String>
    //   106	44	13	localizedStrings	Map<String, String>
    //   160	13	14	localObject1	Object
    //   222	17	15	localObject2	Object
    //   218	1	17	localIOException1	IOException
    //   237	1	18	localIOException2	IOException
    //   254	1	19	localIOException3	IOException
    // Exception table:
    //   from	to	target	type
    //   84	160	160	finally
    //   13	195	198	java/io/IOException
    //   210	215	218	java/io/IOException
    //   13	205	222	finally
    //   229	234	237	java/io/IOException
    //   246	251	254	java/io/IOException
  }
  
  private static Map<String, String> loadProperties(File root, String propertyFilename)
    throws IOException
  {
    InputStream propertyStream = null;
    try
    {
      Map localMap;
      try
      {
        if (root.isDirectory())
        {
          propertyStream = new FileInputStream(new File(root, propertyFilename));
        }
        else
        {
          URLConnection connection = new URL("jar:" + root.toURL().toExternalForm() + "!/" + propertyFilename).openConnection();
          connection.setUseCaches(false);
          propertyStream = connection.getInputStream();
        }
      }
      catch (FileNotFoundException localFileNotFoundException)
      {
        return CollectionUtils.emptyMap();
      }
      return CollectionUtils.loadProperties(propertyStream);
    }
    finally
    {
      if (propertyStream != null) {
        propertyStream.close();
      }
    }
  }
  
  public static Map<String, String> getLocalizedProperties(String[] propertyKeys, Map<String, String> properties)
  {
    Map<String, String> localizedProperties = new HashMap();
    for (int i = 0; i < propertyKeys.length; i++)
    {
      String key = propertyKeys[i];
      if (key != null)
      {
        String localizedValue = (String)properties.get(key);
        if (localizedValue != null) {
          localizedProperties.put(key, localizedValue);
        }
      }
    }
    return localizedProperties;
  }
  
  public static String[] getLocalizationFiles(File localizationDir, final String filenamePrefix)
  {
    LocalizationHelper tmp8_5 = instance;tmp8_5.getClass();localizationDir.list(new FileFilter(tmp8_5)
    {
      public boolean accept(File directory, String filename)
      {
        return LocalizationHelper.getLocaleString(filename, filenamePrefix) != null;
      }
    });
  }
  
  private abstract class FileFilter
    implements FilenameFilter
  {
    public FileFilter() {}
    
    public abstract boolean accept(File paramFile, String paramString);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.spi.p2.publisher.LocalizationHelper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.spi.p2.publisher;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.metadata.BasicVersion;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.ITouchpointType;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;

public class PublisherHelper
{
  public static final String NAMESPACE_ECLIPSE_TYPE = "org.eclipse.equinox.p2.eclipse.type";
  public static final String NAMESPACE_FLAVOR = "org.eclipse.equinox.p2.flavor";
  public static final String TYPE_ECLIPSE_FEATURE = "feature";
  public static final String TYPE_ECLIPSE_SOURCE = "source";
  public static final String NAMESPACE_IU_LOCALIZATION = "org.eclipse.equinox.p2.localization";
  public static final String[] BUNDLE_LOCALIZED_PROPERTIES = { "Bundle-Name", "Bundle-Description", "Bundle-Vendor", "Bundle-ContactAddress", "Bundle-DocURL", "Bundle-UpdateLocation", "Bundle-Localization" };
  public static final String CAPABILITY_NS_JAVA_PACKAGE = "java.package";
  public static final String CAPABILITY_NS_UPDATE_FEATURE = "org.eclipse.update.feature";
  public static final String ECLIPSE_FEATURE_CLASSIFIER = "org.eclipse.update.feature";
  public static final String OSGI_BUNDLE_CLASSIFIER = "osgi.bundle";
  public static final String BINARY_ARTIFACT_CLASSIFIER = "binary";
  public static final String INSTALL_FEATURES_FILTER = "(org.eclipse.update.install.features=true)";
  public static final String IU_NAMESPACE = "org.eclipse.equinox.p2.iu";
  public static final String ECLIPSE_INSTALL_HANDLER_PROP = "org.eclipse.update.installHandler";
  public static final ITouchpointType TOUCHPOINT_NATIVE = MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.native", org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0));
  public static final ITouchpointType TOUCHPOINT_OSGI = MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0));
  public static final IProvidedCapability FEATURE_CAPABILITY = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.eclipse.type", "feature", org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0));
  
  public static IArtifactDescriptor createArtifactDescriptor(IArtifactKey key, File pathOnDisk)
  {
    return createArtifactDescriptor(null, null, key, pathOnDisk);
  }
  
  public static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactKey key, File pathOnDisk)
  {
    return createArtifactDescriptor(info, info.getArtifactRepository(), key, pathOnDisk);
  }
  
  private static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk)
  {
    IArtifactDescriptor result = artifactRepo != null ? artifactRepo.createArtifactDescriptor(key) : new ArtifactDescriptor(key);
    if ((result instanceof ArtifactDescriptor))
    {
      ArtifactDescriptor descriptor = (ArtifactDescriptor)result;
      if (pathOnDisk != null)
      {
        descriptor.setProperty("artifact.size", Long.toString(pathOnDisk.length()));
        descriptor.setProperty("download.size", Long.toString(pathOnDisk.length()));
      }
      if ((info == null) || ((info.getArtifactOptions() & 0x8) == 0))
      {
        String md5 = computeMD5(pathOnDisk);
        if (md5 != null) {
          descriptor.setProperty("download.md5", md5);
        }
      }
    }
    return result;
  }
  
  private static String computeMD5(File file)
  {
    if ((file == null) || (file.isDirectory()) || (!file.exists())) {
      return null;
    }
    try
    {
      md5Checker = MessageDigest.getInstance("MD5");
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      MessageDigest md5Checker;
      return null;
    }
    MessageDigest md5Checker;
    InputStream fis = null;
    try
    {
      fis = new BufferedInputStream(new FileInputStream(file));
      int read = -1;
      while ((read = fis.read()) != -1) {
        md5Checker.update((byte)read);
      }
      byte[] digest = md5Checker.digest();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < digest.length; i++)
      {
        if ((digest[i] & 0xFF) < 16) {
          buf.append('0');
        }
        buf.append(Integer.toHexString(digest[i] & 0xFF));
      }
      return buf.toString();
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      return null;
    }
    catch (IOException localIOException3)
    {
      return null;
    }
    finally
    {
      if (fis != null) {
        try
        {
          fis.close();
        }
        catch (IOException localIOException5) {}
      }
    }
  }
  
  public static IProvidedCapability makeTranslationCapability(String hostId, Locale locale)
  {
    return MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", locale.toString(), org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0));
  }
  
  public static String createDefaultConfigUnitId(String classifier, String configurationFlavor)
  {
    return configurationFlavor + "." + classifier + ".default";
  }
  
  public static IInstallableUnit createDefaultFeatureConfigurationUnit(String configurationFlavor)
  {
    MetadataFactory.InstallableUnitFragmentDescription cu = new MetadataFactory.InstallableUnitFragmentDescription();
    String configUnitId = createDefaultConfigUnitId("org.eclipse.update.feature", configurationFlavor);
    cu.setId(configUnitId);
    org.eclipse.equinox.p2.metadata.Version configUnitVersion = org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0);
    cu.setVersion(configUnitVersion);
    
    cu.setProperty("org.eclipse.equinox.p2.type.fragment", Boolean.TRUE.toString());
    cu.setCapabilities(new IProvidedCapability[] { createSelfCapability(configUnitId, configUnitVersion), MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.flavor", configurationFlavor, org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0)) });
    
    IRequirement[] reqs = { MetadataFactory.createRequirement("org.eclipse.equinox.p2.eclipse.type", "feature", org.eclipse.equinox.p2.metadata.VersionRange.emptyRange, null, true, true, false) };
    cu.setHost(reqs);
    
    cu.setFilter("(org.eclipse.update.install.features=true)");
    Map<String, String> touchpointData = new HashMap();
    touchpointData.put("install", "installFeature(feature:${artifact},featureId:default,featureVersion:default)");
    touchpointData.put("uninstall", "uninstallFeature(feature:${artifact},featureId:default,featureVersion:default)");
    cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
    
    return MetadataFactory.createInstallableUnit(cu);
  }
  
  public static IInstallableUnit createDefaultConfigurationUnitForSourceBundles(String configurationFlavor)
  {
    MetadataFactory.InstallableUnitFragmentDescription cu = new MetadataFactory.InstallableUnitFragmentDescription();
    String configUnitId = createDefaultConfigUnitId("source", configurationFlavor);
    cu.setId(configUnitId);
    org.eclipse.equinox.p2.metadata.Version configUnitVersion = org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0);
    cu.setVersion(configUnitVersion);
    
    cu.setProperty("org.eclipse.equinox.p2.type.fragment", Boolean.TRUE.toString());
    cu.setCapabilities(new IProvidedCapability[] { createSelfCapability(configUnitId, configUnitVersion), MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.flavor", configurationFlavor, org.eclipse.equinox.p2.metadata.Version.createOSGi(1, 0, 0)) });
    
    IRequirement[] reqs = { MetadataFactory.createRequirement("org.eclipse.equinox.p2.eclipse.type", "source", org.eclipse.equinox.p2.metadata.VersionRange.emptyRange, null, true, true, false) };
    cu.setHost(reqs);
    Map<String, String> touchpointData = new HashMap();
    
    touchpointData.put("install", "addSourceBundle(bundle:${artifact})");
    touchpointData.put("uninstall", "removeSourceBundle(bundle:${artifact})");
    cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
    return MetadataFactory.createInstallableUnit(cu);
  }
  
  public static ArtifactKey createBinaryArtifactKey(String id, org.eclipse.equinox.p2.metadata.Version version)
  {
    return new ArtifactKey("binary", id, version);
  }
  
  public static IProvidedCapability createSelfCapability(String installableUnitId, org.eclipse.equinox.p2.metadata.Version installableUnitVersion)
  {
    return MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.iu", installableUnitId, installableUnitVersion);
  }
  
  public static org.osgi.framework.Version toOSGiVersion(org.eclipse.equinox.p2.metadata.Version version)
  {
    if (version == null) {
      return null;
    }
    if (version == org.eclipse.equinox.p2.metadata.Version.emptyVersion) {
      return org.osgi.framework.Version.emptyVersion;
    }
    if (version == org.eclipse.equinox.p2.metadata.Version.MAX_VERSION) {
      return new org.osgi.framework.Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    }
    BasicVersion bv = (BasicVersion)version;
    return new org.osgi.framework.Version(bv.getMajor(), bv.getMinor(), bv.getMicro(), bv.getQualifier());
  }
  
  public static org.eclipse.equinox.p2.metadata.Version fromOSGiVersion(org.osgi.framework.Version version)
  {
    if (version == null) {
      return null;
    }
    if ((version.getMajor() == Integer.MAX_VALUE) && (version.getMicro() == Integer.MAX_VALUE) && (version.getMicro() == Integer.MAX_VALUE)) {
      return org.eclipse.equinox.p2.metadata.Version.MAX_VERSION;
    }
    return org.eclipse.equinox.p2.metadata.Version.createOSGi(version.getMajor(), version.getMinor(), version.getMicro(), version.getQualifier());
  }
  
  public static org.eclipse.osgi.service.resolver.VersionRange toOSGiVersionRange(org.eclipse.equinox.p2.metadata.VersionRange range)
  {
    if (range.equals(org.eclipse.equinox.p2.metadata.VersionRange.emptyRange)) {
      return org.eclipse.osgi.service.resolver.VersionRange.emptyRange;
    }
    return new org.eclipse.osgi.service.resolver.VersionRange(toOSGiVersion(range.getMinimum()), range.getIncludeMinimum(), toOSGiVersion(range.getMaximum()), range.getIncludeMinimum());
  }
  
  public static org.eclipse.equinox.p2.metadata.VersionRange fromOSGiVersionRange(org.eclipse.osgi.service.resolver.VersionRange range)
  {
    if (range.equals(org.eclipse.osgi.service.resolver.VersionRange.emptyRange)) {
      return org.eclipse.equinox.p2.metadata.VersionRange.emptyRange;
    }
    return new org.eclipse.equinox.p2.metadata.VersionRange(fromOSGiVersion(range.getMinimum()), range.getIncludeMinimum(), fromOSGiVersion(range.getMaximum()), range.getIncludeMaximum());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.spi.p2.publisher.PublisherHelper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5

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