org.eclipse.osgi_3.8.2.v20130124-134944

= (String[])candidate.getDirective("mandatory");
    if (!hasMandatoryAttributes(mandatory)) {
      return false;
    }
    if ((getName() != null) && (getName().equals(candidate.getSymbolicName())) && ((getVersionRange() == null) || (getVersionRange().isIncluded(candidate.getVersion())))) {
      return true;
    }
    return false;
  }
  
  protected boolean hasMandatoryAttributes(String[] mandatory)
  {
    if (mandatory != null)
    {
      Map<String, ?> requiredAttrs = getAttributes();
      String[] arrayOfString;
      int j = (arrayOfString = mandatory).length;
      for (int i = 0; i < j; i++)
      {
        String key = arrayOfString[i];
        if (!"bundle-version".equals(key)) {
          if ((requiredAttrs == null) || (requiredAttrs.get(key) == null)) {
            return false;
          }
        }
      }
    }
    return true;
  }
  
  public String toString()
  {
    return "Require-Bundle: " + getName() + "; bundle-version=\"" + getVersionRange() + "\"";
  }
  
  protected Map<String, String> getInternalDirectives()
  {
    Map<String, String> result = new HashMap(2);
    synchronized (monitor)
    {
      if (arbitraryDirectives != null) {
        result.putAll(arbitraryDirectives);
      }
      if (exported) {
        result.put("visibility", "reexport");
      }
      if (optional) {
        result.put("resolution", "optional");
      }
      result.put("filter", createFilterDirective());
      return result;
    }
  }
  
  private String createFilterDirective()
  {
    StringBuffer filter = new StringBuffer();
    filter.append("(&");
    synchronized (monitor)
    {
      addFilterAttribute(filter, "osgi.wiring.bundle", getName());
      VersionRange range = getVersionRange();
      if ((range != null) && (range != VersionRange.emptyRange)) {
        addFilterAttribute(filter, "bundle-version", range);
      }
      if (attributes != null) {
        addFilterAttributes(filter, attributes);
      }
    }
    filter.append(')');
    return filter.toString();
  }
  
  protected Map<String, Object> getInteralAttributes()
  {
    return Collections.EMPTY_MAP;
  }
  
  protected String getInternalNameSpace()
  {
    return "osgi.wiring.bundle";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.BundleSpecificationImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.ArrayList;
import java.util.List;

public class ComputeNodeOrder$Digraph$Vertex
{
  public static final String WHITE = "white";
  public static final String GREY = "grey";
  public static final String BLACK = "black";
  public String color = "white";
  public Vertex predecessor = null;
  public int finishTime;
  public Object id;
  public List<Vertex> adjacent = new ArrayList(3);
  
  public ComputeNodeOrder$Digraph$Vertex(Object id)
  {
    this.id = id;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.ComputeNodeOrder.Digraph.Vertex
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

class ComputeNodeOrder$Digraph
{
  public static class Vertex
  {
    public static final String WHITE = "white";
    public static final String GREY = "grey";
    public static final String BLACK = "black";
    public String color = "white";
    public Vertex predecessor = null;
    public int finishTime;
    public Object id;
    public List<Vertex> adjacent = new ArrayList(3);
    
    public Vertex(Object id)
    {
      this.id = id;
    }
  }
  
  private List<Vertex> vertexList = new ArrayList(100);
  private Map<Object, Vertex> vertexMap = new HashMap(100);
  private int time;
  private boolean initialized = false;
  private boolean cycles = false;
  
  public void freeze()
  {
    if (!initialized)
    {
      initialized = true;
      
      DFS();
    }
  }
  
  public void addVertex(Object id)
    throws IllegalArgumentException
  {
    if (initialized) {
      throw new IllegalArgumentException();
    }
    Vertex vertex = new Vertex(id);
    Object existing = vertexMap.put(id, vertex);
    if (existing != null) {
      throw new IllegalArgumentException();
    }
    vertexList.add(vertex);
  }
  
  public void addEdge(Object fromId, Object toId)
    throws IllegalArgumentException
  {
    if (initialized) {
      throw new IllegalArgumentException();
    }
    Vertex fromVertex = (Vertex)vertexMap.get(fromId);
    Vertex toVertex = (Vertex)vertexMap.get(toId);
    if ((fromVertex == null) || (toVertex == null)) {
      return;
    }
    adjacent.add(toVertex);
  }
  
  public List<Object> idsByDFSFinishTime(boolean increasing)
  {
    if (!initialized) {
      throw new IllegalArgumentException();
    }
    int len = vertexList.size();
    Object[] r = new Object[len];
    for (Iterator<Vertex> allV = vertexList.iterator(); allV.hasNext();)
    {
      Vertex vertex = (Vertex)allV.next();
      int f = finishTime;
      if (increasing) {
        r[(f - 1)] = id;
      } else {
        r[(len - f)] = id;
      }
    }
    return Arrays.asList(r);
  }
  
  public boolean containsCycles()
  {
    if (!initialized) {
      throw new IllegalArgumentException();
    }
    return cycles;
  }
  
  public List<Object[]> nonTrivialComponents()
  {
    if (!initialized) {
      throw new IllegalArgumentException();
    }
    Map<Vertex, List<Object>> components = new HashMap();
    for (Iterator<Vertex> it = vertexList.iterator(); it.hasNext();)
    {
      Vertex vertex = (Vertex)it.next();
      if (predecessor != null)
      {
        Vertex root = vertex;
        while (predecessor != null) {
          root = predecessor;
        }
        List<Object> component = (List)components.get(root);
        if (component == null)
        {
          component = new ArrayList(2);
          component.add(id);
          components.put(root, component);
        }
        component.add(id);
      }
    }
    List<Object[]> result = new ArrayList(components.size());
    for (Iterator<List<Object>> it = components.values().iterator(); it.hasNext();)
    {
      List<Object> component = (List)it.next();
      if (component.size() > 1) {
        result.add(component.toArray());
      }
    }
    return result;
  }
  
  private void DFS()
  {
    Integer NEXT_VERTEX_OBJECT = new Integer(1);
    Integer AFTER_NEXTED_DFS_VISIT_OBJECT = new Integer(4);
    
    time = 0;
    
    List<Object> stack = new ArrayList(Math.max(1, vertexList.size()));
    Iterator<Vertex> allAdjacent = null;
    Vertex vertex = null;
    Iterator<Vertex> allV = vertexList.iterator();
    int state = 1;
    for (;;)
    {
      switch (state)
      {
      case 1: 
        if (!allV.hasNext()) {
          return;
        }
        Vertex nextVertex = (Vertex)allV.next();
        if (color == "white")
        {
          stack.add(NEXT_VERTEX_OBJECT);
          vertex = nextVertex;
          state = 2;
        }
        else
        {
          state = 1;
        }
        break;
      case 2: 
        color = "grey";
        allAdjacent = adjacent.iterator();
        state = 3;
        break;
      case 3: 
        if (allAdjacent.hasNext())
        {
          Vertex adjVertex = (Vertex)allAdjacent.next();
          if (color == "white")
          {
            predecessor = vertex;
            stack.add(allAdjacent);
            stack.add(vertex);
            stack.add(AFTER_NEXTED_DFS_VISIT_OBJECT);
            vertex = adjVertex;
            state = 2;
          }
          else
          {
            if (color == "grey") {
              cycles = true;
            }
            state = 3;
          }
        }
        else
        {
          color = "black";
          time += 1;
          finishTime = time;
          state = ((Integer)stack.remove(stack.size() - 1)).intValue();
        }
        break;
      case 4: 
        vertex = (Vertex)stack.remove(stack.size() - 1);
        
        Iterator<Vertex> unchecked = (Iterator)stack.remove(stack.size() - 1);
        allAdjacent = unchecked;
        state = 3;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.ComputeNodeOrder.Digraph
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class ComputeNodeOrder
{
  private static class Digraph
  {
    public static class Vertex
    {
      public static final String WHITE = "white";
      public static final String GREY = "grey";
      public static final String BLACK = "black";
      public String color = "white";
      public Vertex predecessor = null;
      public int finishTime;
      public Object id;
      public List<Vertex> adjacent = new ArrayList(3);
      
      public Vertex(Object id)
      {
        this.id = id;
      }
    }
    
    private List<Vertex> vertexList = new ArrayList(100);
    private Map<Object, Vertex> vertexMap = new HashMap(100);
    private int time;
    private boolean initialized = false;
    private boolean cycles = false;
    
    public void freeze()
    {
      if (!initialized)
      {
        initialized = true;
        
        DFS();
      }
    }
    
    public void addVertex(Object id)
      throws IllegalArgumentException
    {
      if (initialized) {
        throw new IllegalArgumentException();
      }
      Vertex vertex = new Vertex(id);
      Object existing = vertexMap.put(id, vertex);
      if (existing != null) {
        throw new IllegalArgumentException();
      }
      vertexList.add(vertex);
    }
    
    public void addEdge(Object fromId, Object toId)
      throws IllegalArgumentException
    {
      if (initialized) {
        throw new IllegalArgumentException();
      }
      Vertex fromVertex = (Vertex)vertexMap.get(fromId);
      Vertex toVertex = (Vertex)vertexMap.get(toId);
      if ((fromVertex == null) || (toVertex == null)) {
        return;
      }
      adjacent.add(toVertex);
    }
    
    public List<Object> idsByDFSFinishTime(boolean increasing)
    {
      if (!initialized) {
        throw new IllegalArgumentException();
      }
      int len = vertexList.size();
      Object[] r = new Object[len];
      for (Iterator<Vertex> allV = vertexList.iterator(); allV.hasNext();)
      {
        Vertex vertex = (Vertex)allV.next();
        int f = finishTime;
        if (increasing) {
          r[(f - 1)] = id;
        } else {
          r[(len - f)] = id;
        }
      }
      return Arrays.asList(r);
    }
    
    public boolean containsCycles()
    {
      if (!initialized) {
        throw new IllegalArgumentException();
      }
      return cycles;
    }
    
    public List<Object[]> nonTrivialComponents()
    {
      if (!initialized) {
        throw new IllegalArgumentException();
      }
      Map<Vertex, List<Object>> components = new HashMap();
      for (Iterator<Vertex> it = vertexList.iterator(); it.hasNext();)
      {
        Vertex vertex = (Vertex)it.next();
        if (predecessor != null)
        {
          Vertex root = vertex;
          while (predecessor != null) {
            root = predecessor;
          }
          List<Object> component = (List)components.get(root);
          if (component == null)
          {
            component = new ArrayList(2);
            component.add(id);
            components.put(root, component);
          }
          component.add(id);
        }
      }
      List<Object[]> result = new ArrayList(components.size());
      for (Iterator<List<Object>> it = components.values().iterator(); it.hasNext();)
      {
        List<Object> component = (List)it.next();
        if (component.size() > 1) {
          result.add(component.toArray());
        }
      }
      return result;
    }
    
    private void DFS()
    {
      Integer NEXT_VERTEX_OBJECT = new Integer(1);
      Integer AFTER_NEXTED_DFS_VISIT_OBJECT = new Integer(4);
      
      time = 0;
      
      List<Object> stack = new ArrayList(Math.max(1, vertexList.size()));
      Iterator<Vertex> allAdjacent = null;
      Vertex vertex = null;
      Iterator<Vertex> allV = vertexList.iterator();
      int state = 1;
      for (;;)
      {
        switch (state)
        {
        case 1: 
          if (!allV.hasNext()) {
            return;
          }
          Vertex nextVertex = (Vertex)allV.next();
          if (color == "white")
          {
            stack.add(NEXT_VERTEX_OBJECT);
            vertex = nextVertex;
            state = 2;
          }
          else
          {
            state = 1;
          }
          break;
        case 2: 
          color = "grey";
          allAdjacent = adjacent.iterator();
          state = 3;
          break;
        case 3: 
          if (allAdjacent.hasNext())
          {
            Vertex adjVertex = (Vertex)allAdjacent.next();
            if (color == "white")
            {
              predecessor = vertex;
              stack.add(allAdjacent);
              stack.add(vertex);
              stack.add(AFTER_NEXTED_DFS_VISIT_OBJECT);
              vertex = adjVertex;
              state = 2;
            }
            else
            {
              if (color == "grey") {
                cycles = true;
              }
              state = 3;
            }
          }
          else
          {
            color = "black";
            time += 1;
            finishTime = time;
            state = ((Integer)stack.remove(stack.size() - 1)).intValue();
          }
          break;
        case 4: 
          vertex = (Vertex)stack.remove(stack.size() - 1);
          
          Iterator<Vertex> unchecked = (Iterator)stack.remove(stack.size() - 1);
          allAdjacent = unchecked;
          state = 3;
        }
      }
    }
  }
  
  public static Object[][] computeNodeOrder(Object[] objects, Object[][] references)
  {
    Digraph g1 = new Digraph();
    for (int i = 0; i < objects.length; i++) {
      g1.addVertex(objects[i]);
    }
    for (int i = 0; i < references.length; i++) {
      g1.addEdge(references[i][1], references[i][0]);
    }
    g1.freeze();
    
    Digraph g2 = new Digraph();
    
    List<Object> resortedVertexes = g1.idsByDFSFinishTime(false);
    for (Iterator<Object> it = resortedVertexes.iterator(); it.hasNext();) {
      g2.addVertex(it.next());
    }
    for (int i = 0; i < references.length; i++) {
      g2.addEdge(references[i][0], references[i][1]);
    }
    g2.freeze();
    
    List<Object> sortedProjectList = g2.idsByDFSFinishTime(true);
    Object[] orderedNodes = new Object[sortedProjectList.size()];
    sortedProjectList.toArray(orderedNodes);
    
    boolean hasCycles = g2.containsCycles();
    Object[][] knots;
    Object[][] knots;
    if (hasCycles)
    {
      List<Object[]> knotList = g2.nonTrivialComponents();
      knots = (Object[][])knotList.toArray(new Object[knotList.size()][]);
    }
    else
    {
      knots = new Object[0][];
    }
    for (int i = 0; i < orderedNodes.length; i++) {
      objects[i] = orderedNodes[i];
    }
    return knots;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.ComputeNodeOrder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osgi.framework.internal.core.Constants;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.osgi.framework.Version;

public class ExportPackageDescriptionImpl
  extends BaseDescriptionImpl
  implements ExportPackageDescription
{
  public static final String EQUINOX_EE = "x-equinox-ee";
  private static final Integer EQUINOX_EE_DEFAULT = new Integer(-1);
  private String[] uses;
  private Map<String, Object> attributes;
  private Map<String, String> arbitraryDirectives;
  private volatile BundleDescription exporter;
  private String exclude;
  private String include;
  private String[] friends;
  private String[] mandatory;
  private Boolean internal = Boolean.FALSE;
  private int equinox_ee = -1;
  private ExportPackageDescription fragmentDeclaration = null;
  
  public ExportPackageDescriptionImpl() {}
  
  public ExportPackageDescriptionImpl(BundleDescription host, ExportPackageDescription fragmentDeclaration)
  {
    setName(fragmentDeclaration.getName());
    setVersion(fragmentDeclaration.getVersion());
    setDirectives(fragmentDeclaration.getDirectives());
    setArbitraryDirectives(((ExportPackageDescriptionImpl)fragmentDeclaration).getArbitraryDirectives());
    setAttributes(fragmentDeclaration.getAttributes());
    setExporter(host);
    this.fragmentDeclaration = fragmentDeclaration;
  }
  
  public Map<String, Object> getDirectives()
  {
    synchronized (monitor)
    {
      Map<String, Object> result = new HashMap(7);
      if (uses != null) {
        result.put("uses", uses);
      }
      if (exclude != null) {
        result.put("exclude", exclude);
      }
      if (include != null) {
        result.put("include", include);
      }
      if (mandatory != null) {
        result.put("mandatory", mandatory);
      }
      if (friends != null) {
        result.put("x-friends", friends);
      }
      result.put("x-internal", internal);
      result.put("x-equinox-ee", equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer(equinox_ee));
      return result;
    }
  }
  
  public Map<String, String> getDeclaredDirectives()
  {
    Map<String, String> result = new HashMap(6);
    synchronized (monitor)
    {
      Map<String, String> arbitrary = getArbitraryDirectives();
      if (arbitrary != null) {
        result.putAll(arbitrary);
      }
      if (uses != null) {
        result.put("uses", toString(uses));
      }
      if (exclude != null) {
        result.put("exclude", exclude);
      }
      if (include != null) {
        result.put("include", include);
      }
      if (mandatory != null) {
        result.put("mandatory", toString(mandatory));
      }
      if (friends != null) {
        result.put("x-friends", toString(friends));
      }
      if (internal != null) {
        result.put("x-internal", internal.toString());
      }
      return Collections.unmodifiableMap(result);
    }
  }
  
  public Map<String, Object> getDeclaredAttributes()
  {
    Map<String, Object> result = new HashMap(2);
    synchronized (monitor)
    {
      if (attributes != null) {
        result.putAll(attributes);
      }
      result.put("osgi.wiring.package", getName());
      result.put("version", getVersion());
      Version bundleVersion = getSupplier().getVersion();
      if (bundleVersion != null) {
        result.put("bundle-version", bundleVersion);
      }
      String symbolicName = getSupplier().getSymbolicName();
      if (symbolicName != null) {
        if (symbolicName.equals(Constants.getInternalSymbolicName())) {
          result.put("bundle-symbolic-name", Arrays.asList(new String[] { "system.bundle", symbolicName }));
        } else {
          result.put("bundle-symbolic-name", symbolicName);
        }
      }
      return Collections.unmodifiableMap(result);
    }
  }
  
  static String toString(String[] list)
  {
    StringBuffer buffer = new StringBuffer();
    String[] arrayOfString = list;int j = list.length;
    for (int i = 0; i < j; i++)
    {
      String string = arrayOfString[i];
      buffer.append(string).append(',');
    }
    if (buffer.length() > 0) {
      buffer.setLength(buffer.length() - 1);
    }
    return buffer.toString();
  }
  
  public Object getDirective(String key)
  {
    synchronized (monitor)
    {
      if (key.equals("uses")) {
        return uses;
      }
      if (key.equals("exclude")) {
        return exclude;
      }
      if (key.equals("include")) {
        return include;
      }
      if (key.equals("mandatory")) {
        return mandatory;
      }
      if (key.equals("x-friends")) {
        return friends;
      }
      if (key.equals("x-internal")) {
        return internal;
      }
      if (key.equals("x-equinox-ee")) {
        return equinox_ee == -1 ? EQUINOX_EE_DEFAULT : new Integer(equinox_ee);
      }
      return null;
    }
  }
  
  public Object setDirective(String key, Object value)
  {
    synchronized (monitor)
    {
      if (key.equals("uses")) {
        return uses = (String[])value;
      }
      if (key.equals("exclude")) {
        return exclude = (String)value;
      }
      if (key.equals("include")) {
        return include = (String)value;
      }
      if (key.equals("mandatory")) {
        return mandatory = (String[])value;
      }
      if (key.equals("x-friends")) {
        return friends = (String[])value;
      }
      if (key.equals("x-internal")) {
        return internal = (Boolean)value;
      }
      if (key.equals("x-equinox-ee"))
      {
        equinox_ee = ((Integer)value).intValue();
        return value;
      }
      return null;
    }
  }
  
  public void setDirectives(Map<String, ?> directives)
  {
    synchronized (monitor)
    {
      if (directives == null) {
        return;
      }
      uses = ((String[])directives.get("uses"));
      exclude = ((String)directives.get("exclude"));
      include = ((String)directives.get("include"));
      mandatory = ((String[])directives.get("mandatory"));
      friends = ((String[])directives.get("x-friends"));
      internal = ((Boolean)directives.get("x-internal"));
      equinox_ee = ((Integer)directives.get("x-equinox-ee")).intValue();
    }
  }
  
  void setArbitraryDirectives(Map<String, ?> directives)
  {
    synchronized (monitor)
    {
      arbitraryDirectives = directives;
    }
  }
  
  /* Error */
  Map<String, String> getArbitraryDirectives()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 211	org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 217	org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl:arbitraryDirectives	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #185	-> byte code offset #0
    //   Java source line #186	-> byte code offset #7
    //   Java source line #185	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	ExportPackageDescriptionImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  public Map<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 211	org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 218	org/eclipse/osgi/internal/resolver/ExportPackageDescriptionImpl:attributes	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #191	-> byte code offset #0
    //   Java source line #192	-> byte code offset #7
    //   Java source line #191	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	ExportPackageDescriptionImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public BundleDescription getSupplier()
  {
    return getExporter();
  }
  
  public BundleDescription getExporter()
  {
    return exporter;
  }
  
  /**
   * @deprecated
   */
  public boolean isRoot()
  {
    return true;
  }
  
  protected void setAttributes(Map<String, ?> attributes)
  {
    synchronized (monitor)
    {
      this.attributes = attributes;
    }
  }
  
  protected void setExporter(BundleDescription exporter)
  {
    this.exporter = exporter;
  }
  
  public BaseDescription getFragmentDeclaration()
  {
    return fragmentDeclaration;
  }
  
  void setFragmentDeclaration(ExportPackageDescription fragmentDeclaration)
  {
    this.fragmentDeclaration = fragmentDeclaration;
  }
  
  public String toString()
  {
    return "Export-Package: " + getName() + "; version=\"" + getVersion() + "\"";
  }
  
  String getInternalNameSpace()
  {
    return "osgi.wiring.package";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.ExportPackageDescriptionImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.GenericDescription;
import org.osgi.framework.Version;

public class GenericDescriptionImpl
  extends BaseDescriptionImpl
  implements GenericDescription
{
  private Dictionary<String, Object> attributes;
  private volatile BundleDescription supplier;
  private volatile String type = "generic";
  private Map<String, String> directives;
  private GenericDescription fragmentDeclaration;
  
  public GenericDescriptionImpl() {}
  
  public GenericDescriptionImpl(BundleDescription host, GenericDescription fragmentDeclaration)
  {
    setType(fragmentDeclaration.getType());
    Dictionary<String, Object> origAttrs = fragmentDeclaration.getAttributes();
    if (origAttrs != null)
    {
      Hashtable<String, Object> copyAttrs = new Hashtable();
      for (Enumeration<String> keys = origAttrs.keys(); keys.hasMoreElements();)
      {
        String key = (String)keys.nextElement();
        copyAttrs.put(key, origAttrs.get(key));
      }
      setAttributes(copyAttrs);
    }
    Map<String, String> origDirectives = fragmentDeclaration.getDeclaredDirectives();
    Map<String, String> copyDirectives = new HashMap(origDirectives);
    setDirectives(copyDirectives);
    setSupplier(host);
    this.fragmentDeclaration = fragmentDeclaration;
  }
  
  /* Error */
  public Dictionary<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 154	org/eclipse/osgi/internal/resolver/GenericDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 156	org/eclipse/osgi/internal/resolver/GenericDescriptionImpl:attributes	Ljava/util/Dictionary;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #49	-> byte code offset #0
    //   Java source line #50	-> byte code offset #7
    //   Java source line #49	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericDescriptionImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public BundleDescription getSupplier()
  {
    return supplier;
  }
  
  void setAttributes(Dictionary<String, Object> attributes)
  {
    synchronized (monitor)
    {
      this.attributes = attributes;
    }
  }
  
  void setDirectives(Map<String, String> directives)
  {
    synchronized (monitor)
    {
      this.directives = directives;
    }
  }
  
  void setSupplier(BundleDescription supplier)
  {
    this.supplier = supplier;
  }
  
  public String toString()
  {
    StringBuffer sb = new StringBuffer();
    sb.append("Provide-Capability").append(": ").append(getType());
    Map<String, Object> attrs = getDeclaredAttributes();
    sb.append(toString(attrs, false));
    return sb.toString();
  }
  
  /**
   * @deprecated
   */
  public String getName()
  {
    synchronized (monitor)
    {
      Object name = attributes != null ? attributes.get(getType()) : null;
      return (name instanceof String) ? (String)name : null;
    }
  }
  
  public String getType()
  {
    return type;
  }
  
  void setType(String type)
  {
    if ((type == null) || (type.equals("generic"))) {
      this.type = "generic";
    } else {
      this.type = type;
    }
  }
  
  /**
   * @deprecated
   */
  public Version getVersion()
  {
    Object version = attributes != null ? attributes.get("version") : null;
    return (version instanceof Version) ? (Version)version : super.getVersion();
  }
  
  public Map<String, String> getDeclaredDirectives()
  {
    synchronized (monitor)
    {
      if (directives == null) {
        return Collections.EMPTY_MAP;
      }
      return Collections.unmodifiableMap(directives);
    }
  }
  
  public Map<String, Object> getDeclaredAttributes()
  {
    synchronized (monitor)
    {
      Map<String, Object> result = new HashMap(5);
      if (attributes != null) {
        for (Enumeration<String> keys = attributes.keys(); keys.hasMoreElements();)
        {
          String key = (String)keys.nextElement();
          Object value = attributes.get(key);
          if ((value instanceof List)) {
            value = Collections.unmodifiableList((List)value);
          }
          result.put(key, value);
        }
      }
      return Collections.unmodifiableMap(result);
    }
  }
  
  String getInternalNameSpace()
  {
    return getType();
  }
  
  public BaseDescription getFragmentDeclaration()
  {
    return fragmentDeclaration;
  }
  
  void setFragmentDeclaration(GenericDescription fragmentDeclaration)
  {
    this.fragmentDeclaration = fragmentDeclaration;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.GenericDescriptionImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.internal.resolver;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osgi.framework.internal.core.FilterImpl;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.GenericDescription;
import org.eclipse.osgi.service.resolver.GenericSpecification;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;

public class GenericSpecificationImpl
  extends VersionConstraintImpl
  implements GenericSpecification
{
  private Filter matchingFilter;
  private String type = "generic";
  private int resolution = 0;
  private GenericDescription[] suppliers;
  private Map<String, Object> attributes;
  private Map<String, String> arbitraryDirectives;
  public static final int RESOLUTION_FROM_BREE = 4;
  
  public String getMatchingFilter()
  {
    synchronized (monitor)
    {
      return matchingFilter == null ? null : matchingFilter.toString();
    }
  }
  
  void setMatchingFilter(String matchingFilter, boolean matchName)
    throws InvalidSyntaxException
  {
    synchronized (monitor)
    {
      String name = getName();
      if ((matchName) && (name != null) && (!"*".equals(name)))
      {
        String nameFilter = "(" + getType() + "=" + getName() + ")";
        matchingFilter = "(&" + nameFilter + matchingFilter + ")";
      }
      this.matchingFilter = (matchingFilter == null ? null : FilterImpl.newInstance(matchingFilter));
    }
  }
  
  void setMatchingFilter(Filter matchingFilter)
  {
    synchronized (monitor)
    {
      this.matchingFilter = matchingFilter;
    }
  }
  
  public boolean isSatisfiedBy(BaseDescription supplier)
  {
    if (!(supplier instanceof GenericDescription)) {
      return false;
    }
    GenericDescription candidate = (GenericDescription)supplier;
    if (!getType().equals(candidate.getType())) {
      return false;
    }
    return (matchingFilter == null) || (matchingFilter.match(candidate.getAttributes()));
  }
  
  protected boolean hasMandatoryAttributes(String[] mandatory)
  {
    return true;
  }
  
  public String toString()
  {
    StringBuffer sb = new StringBuffer();
    sb.append("Require-Capability").append(": ").append(getType());
    if (matchingFilter != null) {
      sb.append("; filter=\"").append(getMatchingFilter()).append('"');
    }
    return sb.toString();
  }
  
  /* Error */
  public String getType()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 175	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 176	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:type	Ljava/lang/String;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #79	-> byte code offset #0
    //   Java source line #80	-> byte code offset #7
    //   Java source line #79	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  void setType(String type)
  {
    synchronized (monitor)
    {
      if ((type == null) || (type.equals("generic"))) {
        this.type = "generic";
      } else {
        this.type = type;
      }
    }
  }
  
  /* Error */
  public int getResolution()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 175	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 174	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:resolution	I
    //   11: aload_1
    //   12: monitorexit
    //   13: ireturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #94	-> byte code offset #0
    //   Java source line #95	-> byte code offset #7
    //   Java source line #94	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public boolean isResolved()
  {
    synchronized (monitor)
    {
      return (suppliers != null) && (suppliers.length > 0);
    }
  }
  
  void setResolution(int resolution)
  {
    synchronized (monitor)
    {
      this.resolution = resolution;
    }
  }
  
  public BaseDescription getSupplier()
  {
    synchronized (monitor)
    {
      return (suppliers == null) || (suppliers.length == 0) ? null : suppliers[0];
    }
  }
  
  protected void setSupplier(BaseDescription supplier)
  {
    synchronized (monitor)
    {
      if (supplier == null)
      {
        suppliers = null;
        return;
      }
      int len = suppliers == null ? 0 : suppliers.length;
      GenericDescription[] temp = new GenericDescription[len + 1];
      if (suppliers != null) {
        System.arraycopy(suppliers, 0, temp, 0, len);
      }
      temp[len] = ((GenericDescription)supplier);
      suppliers = temp;
    }
  }
  
  /* Error */
  public GenericDescription[] getSuppliers()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 175	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 179	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:suppliers	[Lorg/eclipse/osgi/service/resolver/GenericDescription;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #133	-> byte code offset #0
    //   Java source line #134	-> byte code offset #7
    //   Java source line #133	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  void setSupplers(GenericDescription[] suppliers)
  {
    synchronized (monitor)
    {
      this.suppliers = suppliers;
    }
  }
  
  /* Error */
  Map<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 175	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 178	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:attributes	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #145	-> byte code offset #0
    //   Java source line #146	-> byte code offset #7
    //   Java source line #145	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  void setAttributes(Map<String, ?> attributes)
  {
    synchronized (monitor)
    {
      this.attributes = attributes;
    }
  }
  
  /* Error */
  Map<String, String> getArbitraryDirectives()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 175	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 177	org/eclipse/osgi/internal/resolver/GenericSpecificationImpl:arbitraryDirectives	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #158	-> byte code offset #0
    //   Java source line #159	-> byte code offset #7
    //   Java source line #158	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	GenericSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  void setArbitraryDirectives(Map<String, ?> directives)
  {
    synchronized (monitor)
    {
      arbitraryDirectives = directives;
    }
  }
  
  protected Map<String, String> getInternalDirectives()
  {
    Map<String, String> result = new HashMap(2);
    synchronized (monitor)
    {
      if (arbitraryDirectives != null) {
        result.putAll(arbitraryDirectives);
      }
      if ((resolution & 0x1) != 0) {
        result.put("resolution", "optional");
      }
      if ((resolution & 0x2) != 0) {
        result.put("cardinality", "multiple");
      }
      if (matchingFilter != null) {
        result.put("filter", matching
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

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