org.eclipse.equinox.p2.metadata_2.1.0.v20120430-2001

16:44:17.261 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.metadata_2.1.0.v20120430-2001.jar
package org.eclipse.equinox.internal.p2.metadata;

import java.util.ArrayList;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.expression.IMemberProvider;

public class ArtifactKey
  implements IArtifactKey, IMemberProvider
{
  private static final String SEPARATOR = ",";
  public static final String MEMBER_ID = "id";
  public static final String MEMBER_CLASSIFIER = "classifier";
  public static final String MEMBER_VERSION = "version";
  private final String id;
  private final String classifier;
  private final Version version;
  
  private static String[] getArrayFromList(String stringList, String separator)
  {
    if ((stringList == null) || (stringList.trim().length() == 0)) {
      return new String[0];
    }
    ArrayList<String> list = new ArrayList();
    boolean separatorSeen = true;
    StringTokenizer tokens = new StringTokenizer(stringList, separator, true);
    while (tokens.hasMoreTokens())
    {
      String token = tokens.nextToken().trim();
      if (token.equals(separator))
      {
        if (separatorSeen) {
          list.add("");
        }
        separatorSeen = true;
      }
      else
      {
        separatorSeen = false;
        if (token.length() != 0) {
          list.add(token);
        }
      }
    }
    if (separatorSeen) {
      list.add("");
    }
    return (String[])list.toArray(new String[list.size()]);
  }
  
  public static IArtifactKey parse(String specification)
  {
    String[] parts = getArrayFromList(specification, ",");
    if ((parts.length < 2) || (parts.length > 3)) {
      throw new IllegalArgumentException("Unexpected number of parts in artifact key: " + specification);
    }
    Version version = Version.emptyVersion;
    if ((parts.length == 3) && (parts[2].trim().length() > 0)) {
      version = Version.parseVersion(parts[2]);
    }
    try
    {
      return new ArtifactKey(parts[0], parts[1], version);
    }
    catch (IllegalArgumentException e)
    {
      throw ((IllegalArgumentException)new IllegalArgumentException("Wrong version syntax in artifact key: " + specification).initCause(e));
    }
  }
  
  public ArtifactKey(String classifier, String id, Version version)
  {
    Assert.isNotNull(classifier);
    Assert.isNotNull(id);
    Assert.isNotNull(version);
    if (classifier.indexOf(",") != -1) {
      throw new IllegalArgumentException("comma not allowed in classifier");
    }
    if (id.indexOf(",") != -1) {
      throw new IllegalArgumentException("comma not allowed in id");
    }
    this.classifier = classifier;
    this.id = id;
    this.version = version;
  }
  
  public ArtifactKey(IArtifactKey artifactKey)
  {
    classifier = artifactKey.getClassifier();
    id = artifactKey.getId();
    version = artifactKey.getVersion();
  }
  
  public String getClassifier()
  {
    return classifier;
  }
  
  public Version getVersion()
  {
    return version;
  }
  
  public int hashCode()
  {
    int hash = id.hashCode();
    hash = 17 * hash + getVersion().hashCode();
    hash = 17 * hash + classifier.hashCode();
    return hash;
  }
  
  public String toString()
  {
    return classifier + "," + id + "," + getVersion();
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof IArtifactKey)) {
      return false;
    }
    IArtifactKey ak = (IArtifactKey)obj;
    return (ak.getId().equals(id)) && (ak.getVersion().equals(getVersion())) && (ak.getClassifier().equals(classifier));
  }
  
  public String getId()
  {
    return id;
  }
  
  public String toExternalForm()
  {
    StringBuffer data = new StringBuffer(classifier).append(",");
    data.append(id).append(",");
    data.append(version.toString());
    return data.toString();
  }
  
  public Object getMember(String memberName)
  {
    if ("id" == memberName) {
      return id;
    }
    if ("version" == memberName) {
      return version;
    }
    if ("classifier" == memberName) {
      return classifier;
    }
    throw new IllegalArgumentException("No such member: " + memberName);
  }
}

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

import org.eclipse.equinox.p2.metadata.Version;

public abstract class BasicVersion
  extends Version
{
  private static final long serialVersionUID = -2983093417537485027L;
  
  public abstract int getMajor();
  
  public abstract int getMicro();
  
  public abstract int getMinor();
  
  public abstract String getQualifier();
  
  public abstract void originalToString(StringBuffer paramStringBuffer, boolean paramBoolean);
  
  public abstract void rawToString(StringBuffer paramStringBuffer, boolean paramBoolean);
  
  abstract Comparable<?>[] getVector();
}

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

import java.net.URI;
import org.eclipse.equinox.p2.metadata.ICopyright;

public class Copyright
  implements ICopyright
{
  private final String body;
  private URI location;
  
  public Copyright(URI location, String body)
  {
    if (body == null) {
      throw new IllegalArgumentException("body cannot be null");
    }
    this.location = location;
    this.body = body;
  }
  
  public URI getLocation()
  {
    return location;
  }
  
  public String getBody()
  {
    return body;
  }
}

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

import java.io.Serializable;

class EnumDefinition$EnumSegment
  implements Comparable<EnumSegment>, Serializable
{
  private static final long serialVersionUID = 4737907767214436543L;
  private final int ordinal;
  private final EnumDefinition definition;
  
  EnumDefinition$EnumSegment(int ordinal, EnumDefinition definition)
  {
    this.ordinal = ordinal;
    this.definition = definition;
  }
  
  public int compareTo(EnumSegment other)
  {
    if (other == this) {
      return 0;
    }
    if (definition == definition) {
      return ordinal - ordinal;
    }
    String thisId = definition.getIdentifier(ordinal);
    String otherId = definition.getIdentifier(ordinal);
    if (thisId.equals(otherId)) {
      return 0;
    }
    int thisOrdinalInOther = definition.getOrdinal(thisId);
    int otherOrdinalInThis = definition.getOrdinal(otherId);
    if (thisOrdinalInOther >= 0)
    {
      if (otherOrdinalInThis >= 0)
      {
        int thisOrder = ordinal - otherOrdinalInThis;
        int otherOrder = thisOrdinalInOther - ordinal;
        if ((thisOrder > 0) && (otherOrder > 0)) {
          return 1;
        }
        if ((thisOrder < 0) && (otherOrder < 0)) {
          return -1;
        }
      }
      else
      {
        return thisOrdinalInOther - ordinal;
      }
    }
    else if (otherOrdinalInThis >= 0) {
      return ordinal - otherOrdinalInThis;
    }
    return definition.compareTo(definition);
  }
  
  public boolean equals(Object other)
  {
    return (other == this) || (((other instanceof EnumSegment)) && (compareTo((EnumSegment)other) == 0));
  }
  
  public int hashCode()
  {
    return (1 + ordinal) * 31 + definition.getIdentifier(ordinal).hashCode();
  }
  
  int getOrdinal()
  {
    return ordinal;
  }
  
  String getIdentifier()
  {
    return definition.getIdentifier(ordinal);
  }
  
  void toString(StringBuffer sb)
  {
    definition.toString(sb, ordinal);
  }
  
  private Object readResolve()
  {
    return definition.getSegment(ordinal);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.metadata.EnumDefinition.EnumSegment
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.metadata;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

class EnumDefinition
  implements Comparable<EnumDefinition>, Serializable
{
  private static final long serialVersionUID = 7237775466362654473L;
  
  static class EnumSegment
    implements Comparable<EnumSegment>, Serializable
  {
    private static final long serialVersionUID = 4737907767214436543L;
    private final int ordinal;
    private final EnumDefinition definition;
    
    EnumSegment(int ordinal, EnumDefinition definition)
    {
      this.ordinal = ordinal;
      this.definition = definition;
    }
    
    public int compareTo(EnumSegment other)
    {
      if (other == this) {
        return 0;
      }
      if (definition == definition) {
        return ordinal - ordinal;
      }
      String thisId = definition.getIdentifier(ordinal);
      String otherId = definition.getIdentifier(ordinal);
      if (thisId.equals(otherId)) {
        return 0;
      }
      int thisOrdinalInOther = definition.getOrdinal(thisId);
      int otherOrdinalInThis = definition.getOrdinal(otherId);
      if (thisOrdinalInOther >= 0)
      {
        if (otherOrdinalInThis >= 0)
        {
          int thisOrder = ordinal - otherOrdinalInThis;
          int otherOrder = thisOrdinalInOther - ordinal;
          if ((thisOrder > 0) && (otherOrder > 0)) {
            return 1;
          }
          if ((thisOrder < 0) && (otherOrder < 0)) {
            return -1;
          }
        }
        else
        {
          return thisOrdinalInOther - ordinal;
        }
      }
      else if (otherOrdinalInThis >= 0) {
        return ordinal - otherOrdinalInThis;
      }
      return definition.compareTo(definition);
    }
    
    public boolean equals(Object other)
    {
      return (other == this) || (((other instanceof EnumSegment)) && (compareTo((EnumSegment)other) == 0));
    }
    
    public int hashCode()
    {
      return (1 + ordinal) * 31 + definition.getIdentifier(ordinal).hashCode();
    }
    
    int getOrdinal()
    {
      return ordinal;
    }
    
    String getIdentifier()
    {
      return definition.getIdentifier(ordinal);
    }
    
    void toString(StringBuffer sb)
    {
      definition.toString(sb, ordinal);
    }
    
    private Object readResolve()
    {
      return definition.getSegment(ordinal);
    }
  }
  
  private static final Map<EnumDefinition, EnumSegment[]> enumDefinitionCache = new HashMap();
  private final String[][] identifiers;
  private final int longestLength;
  private final int shortestLength;
  
  private static EnumSegment[] getEnumSegments(EnumDefinition ed)
  {
    EnumSegment[] values = (EnumSegment[])enumDefinitionCache.get(ed);
    if (values == null)
    {
      int ordinal = identifiers.length;
      values = new EnumSegment[ordinal];
      do
      {
        values[ordinal] = new EnumSegment(ordinal, ed);ordinal--;
      } while (ordinal >= 0);
      enumDefinitionCache.put(ed, values);
    }
    return values;
  }
  
  static EnumDefinition getEnumDefinition(List<List<String>> identifiers)
  {
    for (Iterator localIterator = enumDefinitionCache.keySet().iterator(); localIterator.hasNext();)
    {
      EnumDefinition ed = (EnumDefinition)localIterator.next();
      String[][] defs = identifiers;
      int ordinal = defs.length;
      if (ordinal != identifiers.size()) {}
      do
      {
        String[] def = defs[ordinal];
        List<String> ldef = (List)identifiers.get(ordinal);
        int idx = def.length;
        if (ldef.size() != idx) {
          break;
        }
        do
        {
          if (!def[idx].equals(ldef.get(idx))) {
            break;
          }
          idx--;
        } while (idx >= 0);
        ordinal--;
      } while (ordinal >= 0);
      return ed;
    }
    EnumDefinition ed = new EnumDefinition(identifiers);
    getEnumSegments(ed);
    return ed;
  }
  
  private EnumDefinition(List<List<String>> identifiers)
  {
    int ordinal = identifiers.size();
    String[][] defs = new String[ordinal][];
    int minLen = Integer.MAX_VALUE;
    int maxLen = 0;
    do
    {
      List<String> idents = (List)identifiers.get(ordinal);
      int idx = idents.size();
      String[] def = (String[])idents.toArray(new String[idx]);
      defs[ordinal] = def;
      do
      {
        int idLen = def[idx].length();
        if (idLen < minLen) {
          minLen = idLen;
        }
        if (idLen > maxLen) {
          maxLen = idLen;
        }
        idx--;
      } while (idx >= 0);
      ordinal--;
    } while (ordinal >= 0);
    shortestLength = minLen;
    longestLength = maxLen;
    this.identifiers = defs;
  }
  
  static EnumSegment getSegment(List<List<String>> identifiers, int ordinal)
  {
    return new EnumDefinition(identifiers).getSegment(ordinal);
  }
  
  EnumSegment getSegment(int ordinal)
  {
    return getEnumSegments(this)[ordinal];
  }
  
  int getOrdinal(String identifier)
  {
    if (identifier != null)
    {
      int ordinal = identifiers.length;
      do
      {
        String[] idents = identifiers[ordinal];
        int idx = idents.length;
        do
        {
          if (idents[idx].equals(identifier)) {
            return ordinal;
          }
          idx--;
        } while (idx >= 0);
        ordinal--;
      } while (ordinal >= 0);
    }
    return -1;
  }
  
  String getIdentifier(int ordinal)
  {
    return (ordinal >= 0) && (ordinal < identifiers.length) ? identifiers[ordinal][0] : null;
  }
  
  public int hashCode()
  {
    int result = 1;
    int ordinal = identifiers.length;
    do
    {
      String[] idents = identifiers[ordinal];
      int idx = idents.length;
      do
      {
        result = 31 * result + idents[idx].hashCode();idx--;
      } while (idx >= 0);
      ordinal--;
    } while (ordinal > 0);
    return result;
  }
  
  public boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if (!(o instanceof EnumDefinition)) {
      return false;
    }
    String[][] otherIds = identifiers;
    int ordinal = identifiers.length;
    if (ordinal != otherIds.length) {
      return false;
    }
    do
    {
      if (!Arrays.equals(identifiers[ordinal], otherIds[ordinal])) {
        return false;
      }
      ordinal--;
    } while (ordinal >= 0);
    return true;
  }
  
  public int compareTo(EnumDefinition o)
  {
    if (o == this) {
      return 0;
    }
    int top = identifiers.length;
    int cmp = top - identifiers.length;
    if (cmp != 0) {
      return cmp;
    }
    for (int idx = 0; idx < top; idx++)
    {
      cmp = identifiers[idx][0].compareTo(identifiers[idx][0]);
      if (cmp != 0) {
        return cmp;
      }
    }
    return 0;
  }
  
  public String toString()
  {
    StringBuffer bld = new StringBuffer();
    toString(bld);
    return bld.toString();
  }
  
  public void toString(StringBuffer bld)
  {
    bld.append('{');
    int top = identifiers.length;
    int ordinal = 0;
    for (;;)
    {
      String[] idents = identifiers[ordinal];
      int identsTop = idents.length;
      bld.append(idents[0]);
      for (int idx = 1; idx < identsTop; idx++)
      {
        bld.append('=');
        bld.append(idents[idx]);
      }
      ordinal++;
      if (ordinal == top) {
        break;
      }
      bld.append(',');
    }
    bld.append('}');
  }
  
  void toString(StringBuffer bld, int selectedOrdinal)
  {
    bld.append('{');
    int top = identifiers.length;
    int ordinal = 0;
    for (;;)
    {
      if (ordinal == selectedOrdinal) {
        bld.append('^');
      }
      bld.append(identifiers[ordinal][0]);
      ordinal++;
      if (ordinal == top) {
        break;
      }
      bld.append(',');
    }
    bld.append('}');
  }
  
  int getLongestLength()
  {
    return longestLength;
  }
  
  int getShortestLength()
  {
    return shortestLength;
  }
}

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

import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.VersionRange;

public abstract interface IRequiredCapability
  extends IRequirement
{
  public abstract String getName();
  
  public abstract String getNamespace();
  
  public abstract VersionRange getRange();
}

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

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;

public class IUMap$MapIterator
  implements Iterator<IInstallableUnit>
{
  private final Iterator<Object> unitIterator;
  private IInstallableUnit[] currentBucket;
  private int bucketIndex = 0;
  private IInstallableUnit nextElement = null;
  final IUMap this$0;
  
  IUMap$MapIterator(IUMap paramIUMap)
  {
    unitIterator = units.values().iterator();
  }
  
  public boolean hasNext()
  {
    return positionNext();
  }
  
  public IInstallableUnit next()
  {
    if (!positionNext()) {
      throw new NoSuchElementException();
    }
    IInstallableUnit nxt = nextElement;
    nextElement = null;
    return nxt;
  }
  
  public void remove()
  {
    throw new UnsupportedOperationException();
  }
  
  private boolean positionNext()
  {
    if (nextElement != null) {
      return true;
    }
    if (currentBucket != null)
    {
      nextElement = currentBucket[bucketIndex];
      if (++bucketIndex == currentBucket.length)
      {
        currentBucket = null;
        bucketIndex = -1;
      }
      return true;
    }
    if (!unitIterator.hasNext()) {
      return false;
    }
    Object val = unitIterator.next();
    if ((val instanceof IInstallableUnit))
    {
      nextElement = ((IInstallableUnit)val);
    }
    else
    {
      currentBucket = ((IInstallableUnit[])val);
      nextElement = currentBucket[0];
      bucketIndex = 1;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.metadata.IUMap.MapIterator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.metadata;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.p2.core.IPool;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.CollectionResult;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;

public class IUMap
  implements Cloneable
{
  public IUMap() {}
  
  public class MapIterator
    implements Iterator<IInstallableUnit>
  {
    private final Iterator<Object> unitIterator;
    private IInstallableUnit[] currentBucket;
    private int bucketIndex = 0;
    private IInstallableUnit nextElement = null;
    
    MapIterator()
    {
      unitIterator = units.values().iterator();
    }
    
    public boolean hasNext()
    {
      return positionNext();
    }
    
    public IInstallableUnit next()
    {
      if (!positionNext()) {
        throw new NoSuchElementException();
      }
      IInstallableUnit nxt = nextElement;
      nextElement = null;
      return nxt;
    }
    
    public void remove()
    {
      throw new UnsupportedOperationException();
    }
    
    private boolean positionNext()
    {
      if (nextElement != null) {
        return true;
      }
      if (currentBucket != null)
      {
        nextElement = currentBucket[bucketIndex];
        if (++bucketIndex == currentBucket.length)
        {
          currentBucket = null;
          bucketIndex = -1;
        }
        return true;
      }
      if (!unitIterator.hasNext()) {
        return false;
      }
      Object val = unitIterator.next();
      if ((val instanceof IInstallableUnit))
      {
        nextElement = ((IInstallableUnit)val);
      }
      else
      {
        currentBucket = ((IInstallableUnit[])val);
        nextElement = currentBucket[0];
        bucketIndex = 1;
      }
      return true;
    }
  }
  
  final Map<String, Object> units = new HashMap();
  
  private IUMap(IUMap cloneSource)
  {
    units.putAll(units);
  }
  
  public void add(IInstallableUnit unit)
  {
    String key = unit.getId();
    Object matching = units.get(key);
    if (matching == null)
    {
      units.put(key, unit);
      return;
    }
    if (matching.getClass().isArray())
    {
      IInstallableUnit[] iuArr = (IInstallableUnit[])matching;
      int idx = iuArr.length;
      do
      {
        if (iuArr[idx].equals(unit)) {
          return;
        }
        idx--;
      } while (idx >= 0);
      IInstallableUnit[] iuArrPlus = new IInstallableUnit[iuArr.length + 1];
      System.arraycopy(iuArr, 0, iuArrPlus, 0, iuArr.length);
      iuArrPlus[iuArr.length] = unit;
      units.put(unit.getId(), iuArrPlus);
    }
    else
    {
      IInstallableUnit old = (IInstallableUnit)matching;
      if (!old.equals(unit)) {
        units.put(key, new IInstallableUnit[] { old, unit });
      }
    }
  }
  
  public void addAll(IInstallableUnit[] toAdd)
  {
    for (int i = 0; i < toAdd.length; i++) {
      add(toAdd[i]);
    }
  }
  
  public void addAll(Collection<IInstallableUnit> toAdd)
  {
    for (Iterator localIterator = toAdd.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit unit = (IInstallableUnit)localIterator.next();
      add(unit);
    }
  }
  
  public void clear()
  {
    units.clear();
  }
  
  public IUMap clone()
  {
    return new IUMap(this);
  }
  
  public Iterator<IInstallableUnit> iterator()
  {
    return new MapIterator();
  }
  
  public boolean contains(IInstallableUnit unit)
  {
    return !internalGet(unit.getId(), unit.getVersion()).isEmpty();
  }
  
  public Collection<IInstallableUnit> getUnits(String id)
  {
    Object bucket = units.get(id);
    if (bucket == null) {
      return CollectionUtils.emptyList();
    }
    return bucket.getClass().isArray() ? CollectionUtils.unmodifiableList((IInstallableUnit[])bucket) : Collections.singletonList((IInstallableUnit)bucket);
  }
  
  public IQueryResult<IInstallableUnit> get(String id)
  {
    return internalGet(id, null);
  }
  
  private IQueryResult<IInstallableUnit> internalGet(String id, Version version)
  {
    if (id == null)
    {
      IQuery<IInstallableUnit> query = version == null ? QueryUtil.createIUAnyQuery() : QueryUtil.createIUQuery(null, version);
      return query.perform(iterator());
    }
    Collection<IInstallableUnit> idUnits = getUnits(id);
    if (idUnits.isEmpty()) {
      return Collector.emptyCollector();
    }
    return version == null ? new CollectionResult(idUnits) : QueryUtil.createIUQuery(id, version).perform(idUnits.iterator());
  }
  
  public IInstallableUnit get(String id, Version version)
  {
    IQueryResult<IInstallableUnit> result = internalGet(id, version);
    return result.isEmpty() ? null : (IInstallableUnit)result.iterator().next();
  }
  
  public void remove(IInstallableUnit unit)
  {
    String key = unit.getId();
    Object matching = units.get(key);
    if (matching == null) {
      return;
    }
    if ((matching instanceof IInstallableUnit))
    {
      if (matching.equals(unit)) {
        units.remove(key);
      }
      return;
    }
    IInstallableUnit[] array = (IInstallableUnit[])matching;
    int idx = array.length;
    do
    {
      if (unit.equals(array[idx]))
      {
        if (array.length == 2)
        {
          units.put(key, idx == 0 ? array[1] : array[0]);
          break;
        }
        IInstallableUnit[] newArray = new IInstallableUnit[array.length - 1];
        if (idx > 0) {
          System.arraycopy(array, 0, newArray, 0, idx);
        }
        if (idx + 1 < array.length) {
          System.arraycopy(array, idx + 1, newArray, idx, array.length - (idx + 1));
        }
        units.put(key, newArray);
        break;
      }
      idx--;
    } while (idx >= 0);
  }
  
  public void removeAll(Collection<IInstallableUnit> toRemove)
  {
    for (Iterator localIterator = toRemove.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit iu = (IInstallableUnit)localIterator.next();
      remove(iu);
    }
  }
  
  public void compress(IPool<IInstallableUnit> iuPool)
  {
    if (iuPool == null) {
      return;
    }
    Iterator<Map.Entry<String, Object>> entries = units.entrySet().iterator();
    while (entries.hasNext())
    {
      Map.Entry<String, Object> entry = (Map.Entry)entries.next();
      Object value = entry.getValue();
      if (value.getClass().isArray())
      {
        IInstallableUnit[] array = (IInstallableUnit[])value;
        for (int i = 0; i < array.length; i++) {
          array[i] = ((IInstallableUnit)iuPool.add(array[i]));
        }
      }
      else
      {
        entry.setValue(iuPool.add((IInstallableUnit)value));
      }
    }
  }
}

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

import java.util.LinkedHashMap;
import java.util.Map.Entry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.expression.IFilterExpression;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;

class InstallableUnit$1
  extends LinkedHashMap<IFilterExpression, IMatchExpression<IInstallableUnit>>
{
  public boolean removeEldestEntry(Map.Entry<IFilterExpression, IMatchExpression<IInstallableUnit>> expr)
  {
    return size() > 64;
  }
}

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

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.ICopyright;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
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.ITouchpointData;
import org.eclipse.equinox.p2.metadata.ITouchpointType;
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.expression.IExpression;
import org.eclipse.equinox.p2.metadata.expression.IExpressionFactory;
import org.eclipse.equinox.p2.metadata.expression.IFilterExpression;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.metadata.expression.IMemberProvider;

public class InstallableUnit
  implements IInstallableUnit, IMemberProvider
{
  private static final Map<IFilterExpression, IMatchExpression<IInstallableUnit>> filterCache = new LinkedHashMap()
  {
    public boolean removeEldestEntry(Map.Entry<IFilterExpression, IMatchExpression<IInstallableUnit>> expr)
    {
      return size() > 64;
    }
  };
  private static final OrderedProperties NO_PROPERTIES = new OrderedProperties();
  private static final IProvidedCapability[] NO_PROVIDES = new IProvidedCapability[0];
  private static final IRequirement[] NO_REQUIRES = new IRequirement[0];
  private static final IArtifactKey[] NO_ARTIFACTS = new IArtifactKey[0];
  private static final ITouchpointData[] NO_TOUCHPOINT_DATA = new ITouchpointData[0];
  private static final ILicense[] NO_LICENSE = new ILicense[0];
  private static final IExpression filterWrap;
  public static final String MEMBER_PROVIDED_CAPABILITIES = "providedCapabilities";
  public static final String MEMBER_ID = "id";
  public static final String MEMBER_VERSION = "version";
  public static final String MEMBER_PROPERTIES = "properties";
  public static final String MEMBER_FILTER = "filter";
  public static final String MEMBER_ARTIFACTS = "artifacts";
  public static final String MEMBER_REQUIREMENTS = "requirements";
  public static final String MEMBER_LICENSES = "licenses";
  public static final String MEMBER_COPYRIGHT = "copyright";
  public static final String MEMBER_TOUCHPOINT_DATA = "touchpointData";
  public static final String MEMBER_TOUCHPOINT_TYPE = "touchpointType";
  public static final String MEMBER_UPDATE_DESCRIPTOR = "updateDescriptor";
  public static final String MEMBER_SINGLETON = "singleton";
  
  static
  {
    IExpressionFactory factory = ExpressionUtil.getFactory();
    filterWrap = factory.matches(factory.member(factory.thisVariable(), "properties"), factory.indexedParameter(0));
  }
  
  private IArtifactKey[] artifacts = NO_ARTIFACTS;
  private IMatchExpression<IInstallableUnit> filter;
  private String id;
  private OrderedProperties properties;
  private OrderedProperties localizedProperties;
  IProvidedCapability[] providedCapabilities = NO_PROVIDES;
  private IRequirement[] requires = NO_REQUIRES;
  private IRequirement[] metaRequires = NO_REQUIRES;
  private boolean singleton;
  private ITouchpointData[] touchpointData = NO_TOUCHPOINT_DATA;
  private ITouchpointType touchpointType;
  private Version version = Version.emptyVersion;
  private IUpdateDescriptor updateInfo;
  private ILicense[] licenses = NO_LICENSE;
  private ICopyright copyright;
  public static final String MEMBER_TRANSLATED_PROPERTIES = "translatedProperties";
  public static final String MEMBER_PROFILE_PROPERTIES = "profileProperties";
  
  public void addTouchpointData(ITouchpointData newData)
  {
    int tl = touchpointData.length;
    if (tl == 0)
    {
      touchpointData = new ITouchpointData[] { newData };
    }
    else
    {
      ITouchpointData[] newDatas = new ITouchpointData[tl + 1];
      System.arraycopy(touchpointData, 0, newDatas, 0, tl);
      newDatas[tl] = newData;
      touchpointData = newDatas;
    }
  }
  
  public int compareTo(IInstallableUnit other)
  {
    int cmp = getId().compareTo(other.getId());
    if (cmp == 0) {
      cmp = getVersion().compareTo(other.getVersion());
    }
    return cmp;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof IInstallableUnit)) {
      return false;
    }
    IInstallableUnit other = (IInstallableUnit)obj;
    if (id == null)
    {
      if (other.getId() != null) {
        return false;
      }
    }
    else if (!id.equals(other.getId())) {
      return false;
    }
    if (getVersion() == null)
    {
      if (other.getVersion() != null) {
        return false;
      }
    }
    else if (!getVersion().equals(other.getVersion())) {
      return false;
    }
    return true;
  }
  
  public Collection<IArtifactKey> getArtifacts()
  {
    return CollectionUtils.unmodifiableList(artifacts);
  }
  
  public IMatchExpression<IInstallableUnit> getFilter()
  {
    return filter;
  }
  
  public Collection<IInstallableUnitFragment> getFragments()
  {
    return CollectionUtils.emptyList();
  }
  
  public String getId()
  {
    return id;
  }
  
  public Map<String, String> getProperties()
  {
    return OrderedProperties.unmodifiableProperties(properties());
  }
  
  public String getLocalizedProperty(String key)
  {
    String result = null;
    if (localizedProperties != null) {
      result = localizedProperties.getProperty(key);
    }
    return result;
  }
  
  public String getProperty(String key)
  {
    return properties().getProperty(key);
  }
  
  public Collection<IProvidedCapability> getProvidedCapabilities()
  {
    return CollectionUtils.unmodifiableList(providedCapabilities);
  }
  
  public String getProperty(String key, String locale)
  {
    return TranslationSupport.getInstance().getIUProperty(this, key, locale);
  }
  
  public List<IRequirement> getRequirements()
  {
    return CollectionUtils.unmodifiableList(requires);
  }
  
  public Collection<ITouchpointData> getTouchpointData()
  {
    return CollectionUtils.unmodifiableList(touchpointData);
  }
  
  public ITouchpointType getTouchpointType()
  {
    return touchpointType != null ? touchpointType : ITouchpointType.NONE;
  }
  
  public Version getVersion()
  {
    return version;
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (id == null ? 0 : id.hashCode());
    result = 31 * result + (getVersion() == null ? 0 : getVersion().hashCode());
    return result;
  }
  
  public boolean isResolved()
  {
    return false;
  }
  
  public boolean isSingleton()
  {
    return singleton;
  }
  
  private OrderedProperties properties()
  {
    return properties != null ? properties : NO_PROPERTIES;
  }
  
  public void setArtifacts(IArtifactKey[] value)
  {
    if ((value == null) || (value.length == 0)) {
      artifacts = NO_ARTIFACTS;
    } else {
      artifacts = value;
    }
  }
  
  public void setCapabilities(IProvidedCapability[] newCapabilities)
  {
    if ((newCapabilities == null) || (newCapabilities.length == 0)) {
      providedCapabilities = NO_PROVIDES;
    } else {
      providedCapabilities = newCapabilities;
    }
  }
  
  public void setFilter(IMatchExpression<IInstallableUnit> filter)
  {
    this.filter = filter;
  }
  
  public void setFilter(String filter)
  {
    setFilter(parseFilter(filter));
  }
  
  public void setId(String id)
  {
    this.id = id;
  }
  
  public static IMatchExpression<IInstallableUnit> parseFilter(String filterStr)
  {
    IFilterExpression filter = ExpressionUtil.parseLDAP(filterStr);
    if (filter == null) {
      return null;
    }
    synchronized (filterCache)
    {
      IMatchExpression<IInstallableUnit> matchExpr = (IMatchExpression)filterCache.get(filter);
      if (matchExpr != null) {
        return matchExpr;
      }
      matchExpr = ExpressionUtil.getFactory().matchExpression(filterWrap, new Object[] { filter });
      filterCache.put(filter, matchExpr);
      return matchExpr;
    }
  }
  
  public String setLocalizedProperty(String key, String value)
  {
    if (localizedProperties == null) {
      localizedProperties = new OrderedProperties();
    }
    return localizedProperties.put(key, value);
  }
  
  public String setProperty(String key, String value)
  {
    if (value == null) {
      return properties != null ? properties.remove(key) : null;
    }
    if (properties == null) {
      properties = new OrderedProperties();
    }
    return (String)properties.setProperty(key, value);
  }
  
  public void setRequiredCapabilities(IRequirement[] capabilities)
  {
    if (capabilities.length == 0) {
      requires = NO_REQUIRES;
    } else {
      requires = ((IRequirement[])capabilities.clone());
    }
  }
  
  public void setSingleton(boolean singleton)
  {
    this.singleton = singleton;
  }
  
  public void setTouchpointType(ITouchpointType type)
  {
    touchpointType = (type != ITouchpointType.NONE ? type : null);
  }
  
  public void setVersion(Version newVersion)
  {
    version = (newVersion != null ? newVersion : Version.emptyVersion);
  }
  
  public String toString()
  {
    return id + ' ' + getVersion();
  }
  
  public IInstallableUnit unresolved()
  {
    return this;
  }
  
  public IUpdateDescriptor getUpdateDescriptor()
  {
    return updateInfo;
  }
  
  public void setUpdateDescriptor(IUpdateDescriptor updateInfo)
  {
    this.updateInfo = updateInfo;
  }
  
  public void setLicenses(ILicense[] license)
  {
    licenses = (license == null ? NO_LICENSE : license);
  }
  
  public Collection<ILicense> getLicenses()
  {
    return CollectionUtils.unmodifiableList(licenses);
  }
  
  public Collection<ILicense> getLicenses(String locale)
  {
    return CollectionUtils.unmodifiableList(TranslationSupport.getInstance().getLicenses(this, locale));
  }
  
  public void setCopyright(ICopyright copyright)
  {
    this.copyright = copyright;
  }
  
  public ICopyright getCopyright()
  {
    return copyright;
  }
  
  public ICopyright getCopyright(String locale)
  {
    return TranslationSupport.getInstance().getCopyright(this, locale);
  }
  
  public boolean satisfies(IRequirement candidate)
  {
    return candidate.isMatch(this);
  }
  
  public Collection<IRequirement> getMetaRequirements()
  {
    return CollectionUtils.unmodifiableList(metaRequires);
  }
  
  public void setMetaRequiredCapabilities(IRequirement[] metaReqs)
  {
    if (metaReqs.length == 0) {
      metaRequires = NO_REQUIRES;
    } else {
      metaRequires = ((IRequirement[])metaReqs.clone());
    }
  }
  
  public Object getMember(String memberName)
  {
    if ("providedCapabilities" == memberName) {
      return providedCapabilities;
    }
    if ("id" == memberName) {
      return id;
    }
    if ("version" == memberName) {
      return version;
    }
    if ("properties" == memberName) {
      return properties;
    }
    if ("filter" == memberName) {
      return filter;
    }
    if ("artifacts" == memberName) {
      return artifacts;
    }
    if ("requirements" == memberName) {
      return requires;
    }
    if ("licenses" == memberName) {
      return licenses;
    }
    if ("copyright" == memberName) {
      return copyright;
    }
    if ("touchpointData" == memberName) {
      return touchpointData;
    }
    if ("touchpointType" == memberName) {
      return touchpointType;
    }
    if ("updateDescriptor" == memberName) {
      return updateInfo;
    }
    if ("singleton" == memberName) {
      return Boolean.valueOf(singleton);
    }
    throw new IllegalArgumentException("No such member: " + memberName);
  }
  
  public static IInstallableUnit contextIU(String ws, String os, String arch)
  {
    InstallableUnit ctxIU = new InstallableUnit();
    ctxIU.setId("org.eclipse.equinox.p2.context.iu");
    ctxIU.setProperty("osgi.ws", ws);
    ctxIU.setProperty("osgi.os", os);
    ctxIU.setProperty("osgi.arch", arch);
    return ctxIU;
  }
  
  public static IInstallableUnit contextIU(Map<String, String> environment)
  {
    InstallableUnit ctxIU = new InstallableUnit();
    ctxIU.setId("org.eclipse.equinox.p2.context.iu");
    for (Iterator localIterator = environment.entrySet().iterator(); localIterator.hasNext();)
    {
      Map.Entry<String, String> entry = (Map.Entry)localIterator.next();
      ctxIU.setProperty((String)entry.getKey(), (String)entry.getValue());
    }
    return ctxIU;
  }
}

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

import java.util.Collection;
import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
import org.eclipse.equinox.p2.metadata.IRequirement;

public class InstallableUnitFragment
  extends InstallableUnit
  implements IInstallableUnitFragment
{
  private Collection<IRequireme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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