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

ileProperties.get("org.eclipse.jdt.core.compiler.codegen.targetPlatform");
        version = targetVersion != null ? Version.parseVersion(targetVersion) : null;
      }
      catch (IllegalArgumentException localIllegalArgumentException2) {}
    }
    if (version == null) {
      version = DEFAULT_JRE_VERSION;
    }
    iu.setVersion(version);
    
    profileName = profileName.replace('-', '.');
    profileName = profileName.replace('/', '.');
    profileName = profileName.replace('_', '.');
    iu.setId("a.jre." + profileName.toLowerCase());
    
    IProvidedCapability[] capabilities = generateJRECapability(iu.getId(), iu.getVersion());
    iu.setCapabilities(capabilities);
  }
  
  private void initialize(IPublisherInfo publisherInfo)
  {
    info = publisherInfo;
    if (jreLocation != null)
    {
      File javaProfile = null;
      if (jreLocation.isDirectory())
      {
        File[] profiles = jreLocation.listFiles(new FileFilter()
        {
          public boolean accept(File pathname)
          {
            return pathname.getAbsolutePath().endsWith(".profile");
          }
        });
        if ((profiles != null) && (profiles.length > 0)) {
          javaProfile = profiles[0];
        }
      }
      else if (jreLocation.isFile())
      {
        javaProfile = jreLocation;
      }
      else
      {
        throw new IllegalArgumentException(NLS.bind(Messages.exception_nonExistingJreLocationFile, jreLocation.getAbsolutePath()));
      }
      profileProperties = loadProfile(javaProfile);
    }
    if (profileProperties == null)
    {
      String entry = environment != null ? "/profiles/" + environment.replace('/', '_') + ".profile" : "/profiles/JavaSE-1.6.profile";
      URL profileURL = Activator.getContext().getBundle().getEntry(entry);
      profileProperties = loadProfile(profileURL);
    }
  }
  
  private Map<String, String> loadProfile(File profileFile)
  {
    if ((profileFile == null) || (!profileFile.exists())) {
      return null;
    }
    try
    {
      InputStream stream = new BufferedInputStream(new FileInputStream(profileFile));
      Map<String, String> properties = loadProfile(stream);
      if (properties != null) {
        properties.put("jre.action.profile.location", profileFile.getAbsolutePath());
      }
      return properties;
    }
    catch (FileNotFoundException localFileNotFoundException) {}
    return null;
  }
  
  private Map<String, String> loadProfile(URL profileURL)
  {
    if (profileURL == null) {
      return null;
    }
    try
    {
      InputStream stream = profileURL.openStream();
      return loadProfile(stream);
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private Map<String, String> loadProfile(InputStream stream)
  {
    if (stream != null) {
      try
      {
        return CollectionUtils.loadProperties(stream);
      }
      catch (IOException localIOException2)
      {
        return null;
      }
      finally
      {
        try
        {
          stream.close();
        }
        catch (IOException localIOException4) {}
      }
    }
    return null;
  }
}

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

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.PublisherResult;

public class MergeResultsAction
  extends AbstractPublisherAction
{
  private IPublisherAction[] actions;
  private int mode;
  
  public MergeResultsAction(IPublisherAction[] actions, int mode)
  {
    this.actions = actions;
    this.mode = mode;
  }
  
  public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor)
  {
    MultiStatus finalStatus = new MultiStatus(MergeResultsAction.class.getName(), 0, "publishing result", null);
    for (int i = 0; i < actions.length; i++)
    {
      if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
      }
      IPublisherAction action = actions[i];
      IPublisherResult result = new PublisherResult();
      finalStatus.merge(action.perform(publisherInfo, result, monitor));
      results.merge(result, mode);
    }
    if (!finalStatus.isOK()) {
      return finalStatus;
    }
    return Status.OK_STATUS;
  }
}

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

import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;

public class QueryableFilterAdvice
  implements IFilterAdvice
{
  private IQueryable<IInstallableUnit> queryable;
  
  public QueryableFilterAdvice(IQueryable<IInstallableUnit> queryable)
  {
    this.queryable = queryable;
  }
  
  public IMatchExpression<IInstallableUnit> getFilter(String id, Version version, boolean exact)
  {
    IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, version);
    IQueryResult<IInstallableUnit> result = queryable.query(query, null);
    if (!result.isEmpty()) {
      return ((IInstallableUnit)result.iterator().next()).getFilter();
    }
    if (exact) {
      return null;
    }
    query = QueryUtil.createIUQuery(id);
    result = queryable.query(query, null);
    if (!result.isEmpty()) {
      return ((IInstallableUnit)result.iterator().next()).getFilter();
    }
    return null;
  }
  
  public boolean isApplicable(String configSpec, boolean includeDefault, String id, Version version)
  {
    return true;
  }
}

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

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
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.IVersionedId;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.PublisherResult;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;

public class RootFilesAction
  extends AbstractPublisherAction
{
  private String idBase;
  private Version version;
  private String flavor;
  private boolean createParent = true;
  
  public static String computeIUId(String id, String flavor)
  {
    return flavor + id + ".rootfiles";
  }
  
  public RootFilesAction(IPublisherInfo info, String idBase, Version version, String flavor)
  {
    this.idBase = (idBase == null ? "org.eclipse" : idBase);
    this.version = version;
    this.flavor = flavor;
  }
  
  public void setCreateParent(boolean createParent)
  {
    this.createParent = createParent;
  }
  
  public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor)
  {
    setPublisherInfo(publisherInfo);
    IPublisherResult innerResult = new PublisherResult();
    
    String[] configSpecs = publisherInfo.getConfigurations();
    for (int i = 0; i < configSpecs.length; i++)
    {
      if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
      }
      generateRootFileIUs(configSpecs[i], innerResult);
    }
    results.merge(innerResult, 2);
    if (createParent) {
      publishTopLevelRootFilesIU(innerResult.getIUs(null, "root"), results);
    }
    if (monitor.isCanceled()) {
      return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
  }
  
  private void publishTopLevelRootFilesIU(Collection<? extends IVersionedId> children, IPublisherResult result)
  {
    MetadataFactory.InstallableUnitDescription descriptor = createParentIU(children, computeIUId(idBase, flavor), version);
    descriptor.setSingleton(true);
    IInstallableUnit rootIU = MetadataFactory.createInstallableUnit(descriptor);
    if (rootIU == null) {
      return;
    }
    result.addIU(rootIU, "root");
  }
  
  private void generateRootFileIUs(String configSpec, IPublisherResult result)
  {
    MetadataFactory.InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
    iu.setSingleton(true);
    String idPrefix = idBase + ".rootfiles";
    String iuId = idPrefix + '.' + createIdString(configSpec);
    iu.setId(iuId);
    iu.setVersion(version);
    IMatchExpression<IInstallableUnit> filter = createFilterSpec(configSpec);
    iu.setFilter(filter);
    IArtifactKey key = PublisherHelper.createBinaryArtifactKey(iuId, version);
    iu.setArtifacts(new IArtifactKey[] { key });
    iu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
    IProvidedCapability launcherCapability = MetadataFactory.createProvidedCapability(flavor + idBase, idPrefix, version);
    iu.setCapabilities(new IProvidedCapability[] { PublisherHelper.createSelfCapability(iuId, version), launcherCapability });
    result.addIU(MetadataFactory.createInstallableUnit(iu), "root");
    
    MetadataFactory.InstallableUnitFragmentDescription cu = new MetadataFactory.InstallableUnitFragmentDescription();
    String configUnitId = flavor + iuId;
    cu.setId(configUnitId);
    cu.setVersion(version);
    cu.setFilter(filter);
    cu.setHost(new IRequirement[] { MetadataFactory.createRequirement("org.eclipse.equinox.p2.iu", iuId, new VersionRange(version, true, version, true), null, false, false) });
    cu.setProperty("org.eclipse.equinox.p2.type.fragment", Boolean.TRUE.toString());
    
    cu.setCapabilities(new IProvidedCapability[] { PublisherHelper.createSelfCapability(configUnitId, version) });
    
    cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
    Map<String, String> touchpointData = new HashMap();
    String configurationData = "unzip(source:@artifact, target:${installFolder});";
    touchpointData.put("install", configurationData);
    String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});";
    touchpointData.put("uninstall", unConfigurationData);
    processTouchpointAdvice(cu, touchpointData, info, configSpec);
    IInstallableUnit unit = MetadataFactory.createInstallableUnit(cu);
    result.addIU(unit, "root");
    if ((info.getArtifactOptions() & 0x3) > 0)
    {
      IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(info, key, null);
      IRootFilesAdvice advice = getAdvice(configSpec);
      publishArtifact(descriptor, advice.getIncludedFiles(), advice.getExcludedFiles(), info, createPrefixComputer(advice.getRoot()));
    }
  }
  
  private FileUtils.IPathComputer createPrefixComputer(File root)
  {
    if (root == null) {
      return createParentPrefixComputer(1);
    }
    return createRootPrefixComputer(root);
  }
  
  private IRootFilesAdvice getAdvice(String configSpec)
  {
    Collection<IRootFilesAdvice> advice = info.getAdvice(configSpec, true, null, null, IRootFilesAdvice.class);
    ArrayList<File> inclusions = new ArrayList();
    ArrayList<File> exclusions = new ArrayList();
    File root = null;
    for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
    {
      IRootFilesAdvice entry = (IRootFilesAdvice)localIterator.next();
      if (root == null) {
        root = entry.getRoot();
      }
      File[] list = entry.getIncludedFiles();
      if (list != null) {
        inclusions.addAll(Arrays.asList(list));
      }
      list = entry.getExcludedFiles();
      if (list != null) {
        exclusions.addAll(Arrays.asList(list));
      }
    }
    File[] includeList = (File[])inclusions.toArray(new File[inclusions.size()]);
    File[] excludeList = (File[])exclusions.toArray(new File[exclusions.size()]);
    return new RootFilesAdvice(root, includeList, excludeList, configSpec);
  }
}

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

import java.io.File;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;

public class RootFilesAdvice
  extends AbstractAdvice
  implements IRootFilesAdvice
{
  private File root;
  private File[] excludedFiles;
  private File[] includedFiles;
  private String configSpec;
  
  public RootFilesAdvice(File root, File[] includedFiles, File[] excludedFiles, String configSpec)
  {
    this.root = root;
    this.excludedFiles = excludedFiles;
    this.includedFiles = includedFiles;
    this.configSpec = configSpec;
  }
  
  public File getRoot()
  {
    return root;
  }
  
  protected String getConfigSpec()
  {
    return configSpec;
  }
  
  public File[] getExcludedFiles()
  {
    return excludedFiles;
  }
  
  public File[] getIncludedFiles()
  {
    return includedFiles;
  }
}

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

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.publisher.Activator;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.ILicense;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
import org.eclipse.equinox.p2.publisher.IPublisherInfo;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.NLS;

public class RootIUAction
  extends AbstractPublisherAction
{
  private Version version;
  private String id;
  private String name;
  private Collection<IVersionAdvice> versionAdvice;
  
  public RootIUAction(String id, Version version, String name)
  {
    this.id = id;
    this.version = version;
    this.name = name;
  }
  
  public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor)
  {
    info = publisherInfo;
    return generateRootIU(results);
  }
  
  protected IStatus generateRootIU(IPublisherResult result)
  {
    Collection<? extends IVersionedId> children = getChildren(result);
    MetadataFactory.InstallableUnitDescription descriptor = createTopLevelIUDescription(children, null, false);
    processUpdateDescriptorAdvice(descriptor, info);
    processCapabilityAdvice(descriptor, info);
    processTouchpointAdvice(descriptor, null, info);
    processInstallableUnitPropertiesAdvice(descriptor, info);
    processLicense(descriptor, info);
    IInstallableUnit rootIU = MetadataFactory.createInstallableUnit(descriptor);
    if (rootIU == null) {
      return new Status(4, Activator.ID, NLS.bind(Messages.error_rootIU_generation, new Object[] { name, id, version }));
    }
    result.addIU(rootIU, "non_root");
    
    MetadataFactory.InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(rootIU, info);
    for (int iuIndex = 0; (others != null) && (iuIndex < others.length); iuIndex++) {
      result.addIU(MetadataFactory.createInstallableUnit(others[iuIndex]), "root");
    }
    return Status.OK_STATUS;
  }
  
  protected static void processLicense(MetadataFactory.InstallableUnitDescription iu, IPublisherInfo info)
  {
    Collection<ILicenseAdvice> advice = info.getAdvice(null, true, iu.getId(), iu.getVersion(), ILicenseAdvice.class);
    if (advice.size() > 0)
    {
      ILicenseAdvice entry = (ILicenseAdvice)advice.iterator().next();
      String licenseText = entry.getLicenseText() == null ? "" : entry.getLicenseText();
      String licenseUrl = entry.getLicenseURL() == null ? "" : entry.getLicenseURL();
      if ((licenseText.length() > 0) || (licenseUrl.length() > 0)) {
        iu.setLicenses(new ILicense[] { MetadataFactory.createLicense(toURIOrNull(licenseUrl), licenseText) });
      }
    }
  }
  
  private static URI toURIOrNull(String url)
  {
    if (url == null) {
      return null;
    }
    try
    {
      return URIUtil.fromString(url);
    }
    catch (URISyntaxException localURISyntaxException) {}
    return null;
  }
  
  private Collection<? extends IVersionedId> getChildren(IPublisherResult result)
  {
    HashSet<IVersionedId> children = new HashSet();
    Collection<IRootIUAdvice> rootAdvice = info.getAdvice(null, true, null, null, IRootIUAdvice.class);
    if (rootAdvice == null) {
      return children;
    }
    for (Iterator localIterator1 = rootAdvice.iterator(); localIterator1.hasNext();)
    {
      IRootIUAdvice advice = (IRootIUAdvice)localIterator1.next();
      Collection<? extends Object> list = advice.getChildren(result);
      if (list != null) {
        for (Iterator localIterator2 = list.iterator(); localIterator2.hasNext();)
        {
          Object object = localIterator2.next();
          if ((object instanceof String))
          {
            String childId = (String)object;
            IInstallableUnit iu = queryForIU(result, childId, getVersionAdvice(childId));
            if (iu != null) {
              children.add(iu);
            }
          }
          else if ((object instanceof IVersionedId))
          {
            children.add((IVersionedId)object);
          }
        }
      }
    }
    return children;
  }
  
  private MetadataFactory.InstallableUnitDescription createTopLevelIUDescription(Collection<? extends IVersionedId> children, Collection<IRequirement> requires, boolean configureLauncherData)
  {
    MetadataFactory.InstallableUnitDescription root = new MetadataFactory.InstallableUnitDescription();
    root.setSingleton(true);
    root.setId(id);
    root.setVersion(version);
    root.setProperty("org.eclipse.equinox.p2.name", name);
    
    Collection<IRequirement> requiredCapabilities = createIURequirements(children);
    if (requires != null) {
      requiredCapabilities.addAll(requires);
    }
    root.setRequirements((IRequirement[])requiredCapabilities.toArray(new IRequirement[requiredCapabilities.size()]));
    root.setArtifacts(new IArtifactKey[0]);
    
    root.setProperty("lineUp", "true");
    root.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(id, VersionRange.emptyRange, 0, null));
    root.setProperty("org.eclipse.equinox.p2.type.group", Boolean.TRUE.toString());
    root.setCapabilities(new IProvidedCapability[] { createSelfCapability(id, version) });
    
    root.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
    return root;
  }
  
  private Version getVersionAdvice(String iuID)
  {
    if (versionAdvice == null)
    {
      versionAdvice = info.getAdvice(null, true, null, null, IVersionAdvice.class);
      if (versionAdvice == null) {
        return null;
      }
    }
    for (Iterator localIterator = versionAdvice.iterator(); localIterator.hasNext();)
    {
      IVersionAdvice advice = (IVersionAdvice)localIterator.next();
      
      Version result = advice.getVersion("org.eclipse.equinox.p2.iu", iuID);
      if (result == null) {
        result = advice.getVersion("bundle", iuID);
      }
      if (result == null) {
        result = advice.getVersion("feature", iuID);
      }
      if (result != null) {
        return result;
      }
    }
    return null;
  }
}

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

import java.util.Collection;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherResult;

public class RootIUAdvice
  extends AbstractAdvice
  implements IRootIUAdvice
{
  private Collection<? extends Object> children;
  
  public RootIUAdvice(Collection<? extends Object> children)
  {
    this.children = children;
  }
  
  public Collection<? extends Object> getChildren(IPublisherResult result)
  {
    return children;
  }
}

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

import java.util.Arrays;
import java.util.Collection;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;

public class RootIUResultFilterAdvice
  extends AbstractAdvice
  implements IRootIUAdvice
{
  private IQuery<IInstallableUnit> query;
  
  public RootIUResultFilterAdvice(IQuery<IInstallableUnit> query)
  {
    this.query = query;
  }
  
  public Collection<IInstallableUnit> getChildren(IPublisherResult result)
  {
    Collection<IInstallableUnit> value = result.getIUs(null, "root");
    if (query == null) {
      return value;
    }
    return Arrays.asList((IInstallableUnit[])query.perform(value.iterator()).toArray(IInstallableUnit.class));
  }
}

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

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherAdvice;

public class VersionAdvice
  extends AbstractAdvice
  implements IVersionAdvice
{
  Map<String, Map<String, Version>> versions = new HashMap(11);
  
  public void load(String namespace, String location)
  {
    load(namespace, location, null);
  }
  
  /* Error */
  public void load(String namespace, String location, String idSuffix)
  {
    // Byte code:
    //   0: new 63	java/io/File
    //   3: dup
    //   4: aload_2
    //   5: invokespecial 140	java/io/File:<init>	(Ljava/lang/String;)V
    //   8: astore 4
    //   10: aload_1
    //   11: ifnonnull +6 -> 17
    //   14: ldc 1
    //   16: astore_1
    //   17: aconst_null
    //   18: astore 6
    //   20: new 62	java/io/BufferedInputStream
    //   23: dup
    //   24: new 64	java/io/FileInputStream
    //   27: dup
    //   28: aload 4
    //   30: invokespecial 141	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   33: invokespecial 139	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   36: astore 6
    //   38: aload 6
    //   40: invokestatic 150	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:loadProperties	(Ljava/io/InputStream;)Ljava/util/Map;
    //   43: astore 5
    //   45: goto +38 -> 83
    //   48: pop
    //   49: aload 6
    //   51: ifnull +12 -> 63
    //   54: aload 6
    //   56: invokevirtual 142	java/io/InputStream:close	()V
    //   59: goto +4 -> 63
    //   62: pop
    //   63: return
    //   64: astore 7
    //   66: aload 6
    //   68: ifnull +12 -> 80
    //   71: aload 6
    //   73: invokevirtual 142	java/io/InputStream:close	()V
    //   76: goto +4 -> 80
    //   79: pop
    //   80: aload 7
    //   82: athrow
    //   83: aload 6
    //   85: ifnull +12 -> 97
    //   88: aload 6
    //   90: invokevirtual 142	java/io/InputStream:close	()V
    //   93: goto +4 -> 97
    //   96: pop
    //   97: aload 5
    //   99: invokeinterface 158 1 0
    //   104: invokeinterface 165 1 0
    //   109: astore 8
    //   111: goto +72 -> 183
    //   114: aload 8
    //   116: invokeinterface 157 1 0
    //   121: checkcast 72	java/util/Map$Entry
    //   124: astore 7
    //   126: aload 7
    //   128: invokeinterface 163 1 0
    //   133: checkcast 67	java/lang/String
    //   136: astore 9
    //   138: aload_3
    //   139: ifnull +24 -> 163
    //   142: new 68	java/lang/StringBuffer
    //   145: dup
    //   146: aload 9
    //   148: invokestatic 143	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   151: invokespecial 145	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   154: aload_3
    //   155: invokevirtual 146	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   158: invokevirtual 144	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   161: astore 9
    //   163: aload_0
    //   164: aload_1
    //   165: aload 9
    //   167: aload 7
    //   169: invokeinterface 164 1 0
    //   174: checkcast 67	java/lang/String
    //   177: invokestatic 151	org/eclipse/equinox/p2/metadata/Version:parseVersion	(Ljava/lang/String;)Lorg/eclipse/equinox/p2/metadata/Version;
    //   180: invokevirtual 155	org/eclipse/equinox/p2/publisher/actions/VersionAdvice:setVersion	(Ljava/lang/String;Ljava/lang/String;Lorg/eclipse/equinox/p2/metadata/Version;)V
    //   183: aload 8
    //   185: invokeinterface 156 1 0
    //   190: ifne -76 -> 114
    //   193: return
    // Line number table:
    //   Java source line #39	-> byte code offset #0
    //   Java source line #40	-> byte code offset #10
    //   Java source line #41	-> byte code offset #14
    //   Java source line #44	-> byte code offset #17
    //   Java source line #46	-> byte code offset #20
    //   Java source line #47	-> byte code offset #38
    //   Java source line #48	-> byte code offset #48
    //   Java source line #51	-> byte code offset #49
    //   Java source line #53	-> byte code offset #54
    //   Java source line #54	-> byte code offset #62
    //   Java source line #49	-> byte code offset #63
    //   Java source line #50	-> byte code offset #64
    //   Java source line #51	-> byte code offset #66
    //   Java source line #53	-> byte code offset #71
    //   Java source line #54	-> byte code offset #79
    //   Java source line #57	-> byte code offset #80
    //   Java source line #51	-> byte code offset #83
    //   Java source line #53	-> byte code offset #88
    //   Java source line #54	-> byte code offset #96
    //   Java source line #58	-> byte code offset #97
    //   Java source line #59	-> byte code offset #126
    //   Java source line #60	-> byte code offset #138
    //   Java source line #61	-> byte code offset #142
    //   Java source line #62	-> byte code offset #163
    //   Java source line #58	-> byte code offset #183
    //   Java source line #64	-> byte code offset #193
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	194	0	this	VersionAdvice
    //   0	194	1	namespace	String
    //   0	194	2	location	String
    //   0	194	3	idSuffix	String
    //   8	21	4	file	java.io.File
    //   43	3	5	properties	Map<String, String>
    //   83	1	5	properties	Map<String, String>
    //   97	1	5	properties	Map<String, String>
    //   18	71	6	stream	java.io.InputStream
    //   64	17	7	localObject1	Object
    //   124	44	7	entry	Object
    //   109	75	8	localIterator	Iterator
    //   136	30	9	key	String
    //   48	1	13	localIOException1	java.io.IOException
    //   62	1	14	localIOException2	java.io.IOException
    //   79	1	15	localIOException3	java.io.IOException
    //   96	1	16	localIOException4	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   20	45	48	java/io/IOException
    //   54	59	62	java/io/IOException
    //   20	49	64	finally
    //   71	76	79	java/io/IOException
    //   88	93	96	java/io/IOException
  }
  
  public Version getVersion(String namespace, String id)
  {
    Map<String, Version> values = (Map)versions.get(namespace);
    if (values != null)
    {
      Version result = (Version)values.get(id);
      if (result != null) {
        return result;
      }
    }
    values = (Map)versions.get("null");
    if (values == null) {
      return null;
    }
    return (Version)values.get(id);
  }
  
  public void setVersion(String namespace, String id, Version version)
  {
    Map<String, Version> values = (Map)versions.get(namespace);
    if (values == null)
    {
      if (version == null) {
        return;
      }
      values = new HashMap();
      versions.put(namespace, values);
    }
    if (version == null) {
      values.remove(id);
    } else {
      values.put(id, version);
    }
  }
  
  public IPublisherAdvice merge(IPublisherAdvice advice)
  {
    if (!(advice instanceof VersionAdvice)) {
      return this;
    }
    VersionAdvice source = (VersionAdvice)advice;
    for (Iterator localIterator = versions.keySet().iterator(); localIterator.hasNext();)
    {
      String namespace = (String)localIterator.next();
      Map<String, Version> myValues = (Map)versions.get(namespace);
      Map<String, Version> sourceValues = (Map)versions.get(namespace);
      if (myValues == null) {
        versions.put(namespace, sourceValues);
      } else if (sourceValues != null) {
        versions.put(namespace, merge(myValues, sourceValues));
      }
    }
    return this;
  }
  
  private Map<String, Version> merge(Map<String, Version> myValues, Map<String, Version> sourceValues)
  {
    Map<String, Version> result = new HashMap(myValues);
    for (Iterator localIterator = sourceValues.keySet().iterator(); localIterator.hasNext();)
    {
      String key = (String)localIterator.next();
      if (result.get(key) == null) {
        result.put(key, (Version)sourceValues.get(key));
      }
    }
    return result;
  }
}

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

import java.io.File;

class LocalizationHelper$1
  extends LocalizationHelper.FileFilter
{
  LocalizationHelper$1(LocalizationHelper paramLocalizationHelper, String paramString)
  {
    super(paramLocalizationHelper);
  }
  
  public boolean accept(File directory, String filename)
  {
    return LocalizationHelper.getLocaleString(filename, val$filenamePrefix) != null;
  }
}

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

import java.io.File;
import java.io.FilenameFilter;

abstract class LocalizationHelper$FileFilter
  implements FilenameFilter
{
  final LocalizationHelper this$0;
  
  public LocalizationHelper$FileFilter(LocalizationHelper paramLocalizationHelper) {}
  
  public abstract boolean accept(File paramFile, String paramString);
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;

public final class LocalizationHelper
{
  private static final String PROPERTIES_FILE_EXTENSION = ".properties";
  private static final Locale DEFAULT_LOCALE = new Locale("df", "LT");
  private static LocalizationHelper instance = new LocalizationHelper();
  
  public static String getLocaleString(String filename, String prefix)
  {
    String localeString = null;
    if ((filename.startsWith(prefix)) && (filename.endsWith(".properties"))) {
      if (filename.length() > prefix.length() + ".properties".length()) {
        localeString = filename.substring(prefix.length() + 1, filename.length() - ".properties".length());
      } else {
        localeString = "";
      }
    }
    return localeString;
  }
  
  public static Locale getLocale(String localeString)
  {
    Locale locale = DEFAULT_LOCALE;
    if ((localeString.length() == 5) && (localeString.indexOf('_') == 2)) {
      locale = new Locale(localeString.substring(0, 2), localeString.substring(3, 5));
    } else if (localeString.length() == 2) {
      locale = new Locale(localeString.substring(0, 2));
    }
    return locale;
  }
  
  public static Map<Locale, Map<String, String>> getDirPropertyLocalizations(File root, String localizationPath, Locale defaultLocale, String[] propertyKeys)
  {
    File fullPath = new File(root, localizationPath);
    File localizationDir = fullPath.getParentFile();
    String localizationFile = fullPath.getName();
    String[] localizationFiles = getLocalizationFiles(localizationDir, localizationFile);
    
    HashMap<Locale, Map<String, String>> localizations = null;
    if ((localizationFiles != null) && (localizationFiles.length > 0))
    {
      localizations = new HashMap(localizationFiles.length);
      for (int i = 0; i < localizationFiles.length; i++)
      {
        String nextFile = localizationFiles[i];
        Locale nextLocale = getLocale(getLocaleString(nextFile, localizationFile));
        try
        {
          Map<String, String> properties = loadProperties(localizationDir, nextFile);
          Map<String, String> localizedStrings = getLocalizedProperties(propertyKeys, properties);
          if (localizedStrings.size() > 0)
          {
            localizations.put(nextLocale, localizedStrings);
            if ((DEFAULT_LOCALE.equals(nextLocale)) && (defaultLocale != null)) {
              localizations.put(nextLocale, localizedStrings);
            }
          }
        }
        catch (IOException ioe)
        {
          ioe.printStackTrace();
        }
      }
    }
    return localizations;
  }
  
  /* Error */
  public static Map<Locale, Map<String, String>> getJarPropertyLocalizations(File root, String localizationPath, Locale defaultLocale, String[] propertyKeys)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: new 122	java/util/HashMap
    //   6: dup
    //   7: iconst_4
    //   8: invokespecial 251	java/util/HashMap:<init>	(I)V
    //   11: astore 5
    //   13: new 126	java/util/zip/ZipFile
    //   16: dup
    //   17: aload_0
    //   18: iconst_1
    //   19: invokespecial 259	java/util/zip/ZipFile:<init>	(Ljava/io/File;I)V
    //   22: astore 4
    //   24: aload 4
    //   26: invokevirtual 260	java/util/zip/ZipFile:entries	()Ljava/util/Enumeration;
    //   29: astore 6
    //   31: goto +154 -> 185
    //   34: aload 6
    //   36: invokeinterface 272 1 0
    //   41: checkcast 125	java/util/zip/ZipEntry
    //   44: astore 7
    //   46: aload 7
    //   48: invokevirtual 257	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   51: astore 8
    //   53: aload 8
    //   55: aload_1
    //   56: invokestatic 267	org/eclipse/equinox/spi/p2/publisher/LocalizationHelper:getLocaleString	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   59: astore 9
    //   61: aload 7
    //   63: invokevirtual 256	java/util/zip/ZipEntry:isDirectory	()Z
    //   66: ifne +119 -> 185
    //   69: aload 9
    //   71: ifnull +114 -> 185
    //   74: aload 9
    //   76: invokestatic 265	org/eclipse/equinox/spi/p2/publisher/LocalizationHelper:getLocale	(Ljava/lang/String;)Ljava/util/Locale;
    //   79: astore 10
    //   81: aconst_null
    //   82: astore 11
    //   84: aload 4
    //   86: aload 7
    //   88: invokevirtual 261	java/util/zip/ZipFile:getInputStream	(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;
    //   91: astore 11
    //   93: aload 11
    //   95: invokestatic 263	org/eclipse/equinox/internal/p2/core/helpers/CollectionUtils:loadProperties	(Ljava/io/InputStream;)Ljava/util/Map;
    //   98: astore 12
    //   100: aload_3
    //   101: aload 12
    //   103: invokestatic 269	org/eclipse/equinox/spi/p2/publisher/LocalizationHelper:getLocalizedProperties	([Ljava/lang/String;Ljava/util/Map;)Ljava/util/Map;
    //   106: astore 13
    //   108: aload 13
    //   110: invokeinterface 273 1 0
    //   115: ifle +60 -> 175
    //   118: aload 5
    //   120: aload 10
    //   122: aload 13
    //   124: invokeinterface 275 3 0
    //   129: pop
    //   130: getstatic 224	org/eclipse/equinox/spi/p2/publisher/LocalizationHelper:DEFAULT_LOCALE	Ljava/util/Locale;
    //   133: aload 10
    //   135: invokevirtual 253	java/util/Locale:equals	(Ljava/lang/Object;)Z
    //   138: ifeq +37 -> 175
    //   141: aload_2
    //   142: ifnull +33 -> 175
    //   145: aload 5
    //   147: aload 10
    //   149: aload 13
    //   151: invokeinterface 275 3 0
    //   156: pop
    //   157: goto +18 -> 175
    //   160: astore 14
    //   162: aload 11
    //   164: ifnull +8 -> 172
    //   167: aload 11
    //   169: invokevirtual 234	java/io/InputStream:close	()V
    //   172: aload 14
    //   174: athrow
    //   175: aload 11
    //   177: ifnull +8 -> 185
    //   180: aload 11
    //   182: invokevirtual 234	java/io/InputStream:close	()V
    //   185: aload 6
    //   187: invokeinterface 271 1 0
    //   192: ifne -158 -> 34
    //   195: goto +46 -> 241
    //   198: astore 6
    //   200: aload 6
    //   202: invokevirtual 233	java/io/IOException:printStackTrace	()V
    //   205: aload 4
    //   207: ifnull +48 -> 255
    //   210: aload 4
    //   212: invokevirtual 258	java/util/zip/ZipFile:close	()V
    //   215: goto +40 -> 255
    //   218: pop
    //   219: goto +36 -> 255
    //   222: astore 15
    //   224: aload 4
    //   226: ifnull +12 -> 238
    //   229: aload 4
    //   231: invokevirtual 258	java/util/zip/ZipFile:close	()V
    //   234: goto +4 -> 238
    //   237: pop
    //   238: aload 15
    //   240: athrow
    //   241: aload 4
    //   243: ifnull +12 -> 255
    //   246: aload 4
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