org.eclipse.osgi_3.8.2.v20130124-134944

  }
  
  protected void setContainingState(State value)
  {
    synchronized (monitor)
    {
      containingState = ((StateImpl)value);
      if ((containingState != null) && (containingState.getReader() != null))
      {
        if (containingState.getReader().isLazyLoaded()) {
          stateBits |= 0x10;
        } else {
          stateBits &= 0xFFFFFFEF;
        }
      }
      else {
        stateBits &= 0xFFFFFFEF;
      }
    }
  }
  
  protected void setHost(HostSpecification host)
  {
    synchronized (monitor)
    {
      this.host = host;
      if (host != null) {
        ((VersionConstraintImpl)host).setBundle(this);
      }
    }
  }
  
  protected void setLazyLoaded(boolean lazyLoad)
  {
    loadLazyData();
    synchronized (monitor)
    {
      if (lazyLoad) {
        stateBits |= 0x10;
      } else {
        stateBits &= 0xFFFFFFEF;
      }
    }
  }
  
  protected void setSelectedExports(ExportPackageDescription[] selectedExports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.selectedExports = selectedExports;
      if (selectedExports != null) {
        for (int i = 0; i < selectedExports.length; i++) {
          ((ExportPackageDescriptionImpl)selectedExports[i]).setExporter(this);
        }
      }
    }
  }
  
  protected void setSelectedCapabilities(GenericDescription[] selectedCapabilities)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.selectedCapabilities = selectedCapabilities;
      if (selectedCapabilities != null)
      {
        GenericDescription[] arrayOfGenericDescription;
        int j = (arrayOfGenericDescription = selectedCapabilities).length;
        for (int i = 0; i < j; i++)
        {
          GenericDescription capability = arrayOfGenericDescription[i];
          ((GenericDescriptionImpl)capability).setSupplier(this);
        }
      }
    }
  }
  
  protected void setSubstitutedExports(ExportPackageDescription[] substitutedExports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.substitutedExports = substitutedExports;
    }
  }
  
  protected void setResolvedImports(ExportPackageDescription[] resolvedImports)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedImports = resolvedImports;
    }
  }
  
  protected void setResolvedRequires(BundleDescription[] resolvedRequires)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedRequires = resolvedRequires;
    }
  }
  
  protected void setResolvedCapabilities(GenericDescription[] resolvedCapabilities)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.resolvedCapabilities = resolvedCapabilities;
    }
  }
  
  protected void setStateWires(Map<String, List<StateWire>> stateWires)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.stateWires = stateWires;
    }
  }
  
  void clearAddedDynamicImportPackages()
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.addedDynamicImports = null;
    }
  }
  
  public String toString()
  {
    if (getSymbolicName() == null) {
      return "[" + getBundleId() + "]";
    }
    return getSymbolicName() + "_" + getVersion();
  }
  
  public Object getKey()
  {
    return new Long(bundleId);
  }
  
  public boolean compare(KeyedElement other)
  {
    if (!(other instanceof BundleDescriptionImpl)) {
      return false;
    }
    BundleDescriptionImpl otherBundleDescription = (BundleDescriptionImpl)other;
    return bundleId == bundleId;
  }
  
  public int getKeyHashCode()
  {
    return (int)(bundleId ^ bundleId >>> 32);
  }
  
  protected void removeDependencies()
  {
    synchronized (monitor)
    {
      if (dependencies == null) {
        return;
      }
      Iterator<BundleDescription> iter = dependencies.iterator();
      while (iter.hasNext()) {
        ((BundleDescriptionImpl)iter.next()).removeDependent(this);
      }
      dependencies = null;
    }
  }
  
  protected void addDependencies(BaseDescription[] newDependencies, boolean checkDups)
  {
    synchronized (monitor)
    {
      if (newDependencies == null) {
        return;
      }
      if ((!checkDups) && (dependencies == null)) {
        dependencies = new ArrayList(newDependencies.length);
      }
      for (int i = 0; i < newDependencies.length; i++) {
        addDependency((BaseDescriptionImpl)newDependencies[i], checkDups);
      }
    }
  }
  
  protected void addDependency(BaseDescriptionImpl dependency, boolean checkDups)
  {
    synchronized (monitor)
    {
      BundleDescriptionImpl bundle = (BundleDescriptionImpl)dependency.getSupplier();
      if (bundle == this) {
        return;
      }
      if (dependencies == null) {
        dependencies = new ArrayList(10);
      }
      if ((!checkDups) || (!dependencies.contains(bundle)))
      {
        bundle.addDependent(this);
        dependencies.add(bundle);
      }
    }
  }
  
  List<BundleDescription> getBundleDependencies()
  {
    synchronized (monitor)
    {
      if (dependencies == null) {
        return new ArrayList(0);
      }
      ArrayList<BundleDescription> required = new ArrayList(dependencies.size());
      for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();)
      {
        BundleDescription dep = (BundleDescription)iter.next();
        if ((dep != this) && (dep.getHost() == null)) {
          required.add(dep);
        }
      }
      return required;
    }
  }
  
  protected void addDependent(BundleDescription dependent)
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        dependents = new ArrayList(10);
      }
      dependents.add(dependent);
    }
  }
  
  protected void removeDependent(BundleDescription dependent)
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        return;
      }
      dependents.remove(dependent);
    }
  }
  
  public BundleDescription[] getDependents()
  {
    synchronized (monitor)
    {
      if (dependents == null) {
        return EMPTY_BUNDLEDESCS;
      }
      return (BundleDescription[])dependents.toArray(new BundleDescription[dependents.size()]);
    }
  }
  
  boolean hasDependents()
  {
    synchronized (monitor)
    {
      return dependents != null;
    }
  }
  
  void setFullyLoaded(boolean fullyLoaded)
  {
    synchronized (monitor)
    {
      if (fullyLoaded) {
        stateBits |= 0x8;
      } else {
        stateBits &= 0xFFFFFFF7;
      }
    }
  }
  
  boolean isFullyLoaded()
  {
    return (stateBits & 0x8) != 0;
  }
  
  void setLazyDataOffset(int lazyDataOffset)
  {
    this.lazyDataOffset = lazyDataOffset;
  }
  
  int getLazyDataOffset()
  {
    return lazyDataOffset;
  }
  
  void setLazyDataSize(int lazyDataSize)
  {
    this.lazyDataSize = lazyDataSize;
  }
  
  int getLazyDataSize()
  {
    return lazyDataSize;
  }
  
  private LazyData loadLazyData()
  {
    if ((stateBits & 0x10) == 0) {
      return lazyData;
    }
    StateImpl currentState = (StateImpl)getContainingState();
    StateReader reader = currentState == null ? null : currentState.getReader();
    if (reader == null) {
      throw new IllegalStateException("No valid reader for the bundle description");
    }
    synchronized (monitor)
    {
      if (isFullyLoaded())
      {
        reader.setAccessedFlag(true);
        return lazyData;
      }
      try
      {
        reader.fullyLoad(this);
        return lazyData;
      }
      catch (IOException e)
      {
        throw new RuntimeException(e.getMessage(), e);
      }
    }
  }
  
  void addDynamicResolvedImport(ExportPackageDescriptionImpl result)
  {
    synchronized (monitor)
    {
      addDependency(result, true);
      
      checkLazyData();
      if (lazyData.resolvedImports == null)
      {
        lazyData.resolvedImports = new ExportPackageDescription[] { result };
        return;
      }
      ExportPackageDescription[] newImports = new ExportPackageDescription[lazyData.resolvedImports.length + 1];
      System.arraycopy(lazyData.resolvedImports, 0, newImports, 0, lazyData.resolvedImports.length);
      newImports[(newImports.length - 1)] = result;
      lazyData.resolvedImports = newImports;
    }
  }
  
  void addDynamicImportPackages(ImportPackageSpecification[] dynamicImport)
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      if (addedDynamicImports == null) {
        addedDynamicImports = new ArrayList();
      }
      ImportPackageSpecification[] arrayOfImportPackageSpecification;
      int j = (arrayOfImportPackageSpecification = dynamicImport).length;
      for (int i = 0; i < j; i++)
      {
        ImportPackageSpecification addImport = arrayOfImportPackageSpecification[i];
        if (!"dynamic".equals(addImport.getDirective("resolution"))) {
          throw new IllegalArgumentException("Import must be a dynamic import.");
        }
      }
      j = (arrayOfImportPackageSpecification = dynamicImport).length;
      for (i = 0; i < j; i++)
      {
        ImportPackageSpecification addImport = arrayOfImportPackageSpecification[i];
        for (Iterator localIterator = addedDynamicImports.iterator(); localIterator.hasNext();)
        {
          ImportPackageSpecification currentImport = (ImportPackageSpecification)localIterator.next();
          if (equalImports(addImport, currentImport)) {
            break;
          }
        }
        ((ImportPackageSpecificationImpl)addImport).setBundle(this);
        addedDynamicImports.add(addImport);
      }
    }
  }
  
  private boolean equalImports(ImportPackageSpecification addImport, ImportPackageSpecification currentImport)
  {
    if (!isEqual(addImport.getName(), currentImport.getName())) {
      return false;
    }
    if (!isEqual(addImport.getVersionRange(), currentImport.getVersionRange())) {
      return false;
    }
    if (!isEqual(addImport.getBundleSymbolicName(), currentImport.getBundleSymbolicName())) {
      return false;
    }
    if (!isEqual(addImport.getBundleVersionRange(), currentImport.getBundleVersionRange())) {
      return false;
    }
    return isEqual(addImport.getAttributes(), currentImport.getAttributes());
  }
  
  private boolean isEqual(Object o1, Object o2)
  {
    return o1 == null ? false : o2 == null ? true : o1.equals(o2);
  }
  
  void unload()
  {
    StateImpl currentState = (StateImpl)getContainingState();
    StateReader reader = currentState == null ? null : currentState.getReader();
    if (reader == null) {
      throw new IllegalStateException("BundleDescription does not belong to a reader.");
    }
    synchronized (monitor)
    {
      if ((stateBits & 0x10) == 0) {
        return;
      }
      if (!isFullyLoaded()) {
        return;
      }
      synchronized (monitor)
      {
        setFullyLoaded(false);
        lazyData = null;
      }
    }
  }
  
  void setDynamicStamps(Map<String, Long> dynamicStamps)
  {
    synchronized (monitor)
    {
      checkLazyData();
      lazyData.dynamicStamps = dynamicStamps;
    }
  }
  
  void setDynamicStamp(String requestedPackage, Long timestamp)
  {
    synchronized (monitor)
    {
      checkLazyData();
      if (lazyData.dynamicStamps == null)
      {
        if (timestamp == null) {
          return;
        }
        lazyData.dynamicStamps = new HashMap();
      }
      if (timestamp == null) {
        lazyData.dynamicStamps.remove(requestedPackage);
      } else {
        lazyData.dynamicStamps.put(requestedPackage, timestamp);
      }
    }
  }
  
  long getDynamicStamp(String requestedPackage)
  {
    LazyData currentData = loadLazyData();
    synchronized (monitor)
    {
      Long stamp = dynamicStamps == null ? null : (Long)dynamicStamps.get(requestedPackage);
      return stamp == null ? 0L : stamp.longValue();
    }
  }
  
  /* Error */
  Map<String, Long> getDynamicStamps()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 727	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:loadLazyData	()Lorg/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData;
    //   4: astore_1
    //   5: aload_0
    //   6: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   9: dup
    //   10: astore_2
    //   11: monitorenter
    //   12: aload_1
    //   13: getfield 672	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl$LazyData:dynamicStamps	Ljava/util/Map;
    //   16: aload_2
    //   17: monitorexit
    //   18: areturn
    //   19: aload_2
    //   20: monitorexit
    //   21: athrow
    // Line number table:
    //   Java source line #771	-> byte code offset #0
    //   Java source line #772	-> byte code offset #5
    //   Java source line #773	-> byte code offset #12
    //   Java source line #772	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	22	0	this	BundleDescriptionImpl
    //   4	9	1	currentData	LazyData
    //   10	10	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   12	18	19	finally
    //   19	21	19	finally
  }
  
  public void setEquinoxEE(int equinox_ee)
  {
    this.equinox_ee = equinox_ee;
  }
  
  public int getEquinoxEE()
  {
    return equinox_ee;
  }
  
  private void checkLazyData()
  {
    if (lazyData == null) {
      lazyData = new LazyData();
    }
  }
  
  /* Error */
  public Map<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 657	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:attributes	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #816	-> byte code offset #0
    //   Java source line #817	-> byte code offset #7
    //   Java source line #816	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleDescriptionImpl
    //   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;
    }
  }
  
  Object getDirective(String key)
  {
    synchronized (monitor)
    {
      if ("mandatory".equals(key)) {
        return mandatory;
      }
      if ("singleton".equals(key)) {
        return isSingleton() ? Boolean.TRUE : Boolean.FALSE;
      }
      if ("fragment-attachment".equals(key))
      {
        if (!attachFragments()) {
          return "never";
        }
        if (dynamicFragments()) {
          return "always";
        }
        return "resolve-time";
      }
    }
    return null;
  }
  
  void setDirective(String key, Object value)
  {
    if ("mandatory".equals(key)) {
      mandatory = ((String[])value);
    }
  }
  
  void setArbitraryDirectives(Map<String, ?> directives)
  {
    synchronized (monitor)
    {
      arbitraryDirectives = directives;
    }
  }
  
  /* Error */
  Map<String, String> getArbitraryDirectives()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 650	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 656	org/eclipse/osgi/internal/resolver/BundleDescriptionImpl:arbitraryDirectives	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #859	-> byte code offset #0
    //   Java source line #860	-> byte code offset #7
    //   Java source line #859	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleDescriptionImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  public Map<String, String> getDeclaredDirectives()
  {
    Map<String, String> result = new HashMap(2);
    Map<String, String> arbitrary = getArbitraryDirectives();
    if (arbitrary != null) {
      result.putAll(arbitrary);
    }
    if (!attachFragments()) {
      result.put("fragment-attachment", "never");
    } else if (dynamicFragments()) {
      result.put("fragment-attachment", "always");
    } else {
      result.put("fragment-attachment", "resolve-time");
    }
    if (isSingleton()) {
      result.put("singleton", Boolean.TRUE.toString());
    }
    String[] mandatoryDirective = (String[])getDirective("mandatory");
    if (mandatoryDirective != null) {
      result.put("mandatory", ExportPackageDescriptionImpl.toString(mandatoryDirective));
    }
    return Collections.unmodifiableMap(result);
  }
  
  public Map<String, Object> getDeclaredAttributes()
  {
    Map<String, Object> result = new HashMap(1);
    synchronized (monitor)
    {
      if (attributes != null) {
        result.putAll(attributes);
      }
    }
    result.put("osgi.wiring.bundle", getName());
    result.put("bundle-version", getVersion());
    return Collections.unmodifiableMap(result);
  }
  
  public List<BundleRequirement> getDeclaredRequirements(String namespace)
  {
    List<BundleRequirement> result = new ArrayList();
    Object localObject;
    if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace)))
    {
      BundleSpecification[] requires = getRequiredBundles();
      j = (localObject = requires).length;
      for (i = 0; i < j; i++)
      {
        BundleSpecification require = localObject[i];
        result.add(require.getRequirement());
      }
    }
    if ((host != null) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
      result.add(host.getRequirement());
    }
    if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
    {
      ImportPackageSpecification[] imports = getImportPackages();
      j = (localObject = imports).length;
      for (i = 0; i < j; i++)
      {
        ImportPackageSpecification importPkg = localObject[i];
        result.add(importPkg.getRequirement());
      }
    }
    GenericSpecification[] genericSpecifications = getGenericRequires();
    int j = (localObject = genericSpecifications).length;
    for (int i = 0; i < j; i++)
    {
      GenericSpecification requirement = localObject[i];
      if ((namespace == null) || (namespace.equals(requirement.getType()))) {
        result.add(requirement.getRequirement());
      }
    }
    return Collections.unmodifiableList(result);
  }
  
  public List<BundleCapability> getDeclaredCapabilities(String namespace)
  {
    List<BundleCapability> result = new ArrayList();
    if ((host == null) && 
      (getSymbolicName() != null))
    {
      if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace))) {
        result.add(getCapability());
      }
      if ((attachFragments()) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
        result.add(getCapability("osgi.wiring.host"));
      }
    }
    Object localObject;
    if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
    {
      ExportPackageDescription[] exports = getExportPackages();
      j = (localObject = exports).length;
      for (i = 0; i < j; i++)
      {
        ExportPackageDescription exportPkg = localObject[i];
        result.add(exportPkg.getCapability());
      }
    }
    GenericDescription[] genericCapabilities = getGenericCapabilities();
    int j = (localObject = genericCapabilities).length;
    for (int i = 0; i < j; i++)
    {
      GenericDescription capabilitiy = localObject[i];
      if ((namespace == null) || (namespace.equals(capabilitiy.getType()))) {
        result.add(capabilitiy.getCapability());
      }
    }
    return Collections.unmodifiableList(result);
  }
  
  public int getTypes()
  {
    return getHost() != null ? 1 : 0;
  }
  
  public Bundle getBundle()
  {
    Object ref = getUserObject();
    if ((ref instanceof BundleReference)) {
      return ((BundleReference)ref).getBundle();
    }
    return null;
  }
  
  String getInternalNameSpace()
  {
    return "osgi.wiring.bundle";
  }
  
  public BundleWiring getWiring()
  {
    synchronized (monitor)
    {
      if ((bundleWiring != null) || (!isResolved())) {
        return bundleWiring;
      }
      return bundleWiring = new DescriptionWiring();
    }
  }
  
  static class BundleWireImpl
    implements BundleWire
  {
    private final BundleCapability capability;
    private final BundleWiring provider;
    private final BundleRequirement requirement;
    private final BundleWiring requirer;
    
    public BundleWireImpl(StateWire wire)
    {
      VersionConstraint declaredRequirement = wire.getDeclaredRequirement();
      if ((declaredRequirement instanceof HostSpecification)) {
        capability = ((BaseDescriptionImpl)wire.getDeclaredCapability()).getCapability("osgi.wiring.host");
      } else {
        capability = wire.getDeclaredCapability().getCapability();
      }
      provider = wire.getCapabilityHost().getWiring();
      requirement = declaredRequirement.getRequirement();
      requirer = wire.getRequirementHost().getWiring();
    }
    
    public BundleCapability getCapability()
    {
      return capability;
    }
    
    public BundleRequirement getRequirement()
    {
      return requirement;
    }
    
    public BundleWiring getProviderWiring()
    {
      return provider;
    }
    
    public BundleWiring getRequirerWiring()
    {
      return requirer;
    }
    
    public int hashCode()
    {
      int hashcode = 31 + capability.hashCode();
      hashcode = hashcode * 31 + requirement.hashCode();
      hashcode = hashcode * 31 + provider.hashCode();
      hashcode = hashcode * 31 + requirer.hashCode();
      return hashcode;
    }
    
    public boolean equals(Object obj)
    {
      if (!(obj instanceof BundleWireImpl)) {
        return false;
      }
      BundleWireImpl other = (BundleWireImpl)obj;
      return (capability.equals(other.getCapability())) && (requirement.equals(other.getRequirement())) && (provider.equals(other.getProviderWiring())) && (requirer.equals(other.getRequirerWiring()));
    }
    
    public String toString()
    {
      return getRequirement() + " -> " + getCapability();
    }
    
    public BundleRevision getProvider()
    {
      return provider.getRevision();
    }
    
    public BundleRevision getRequirer()
    {
      return requirer.getRevision();
    }
  }
  
  static List<Wire> asListWire(List<? extends Wire> l)
  {
    return l;
  }
  
  static List<Capability> asListCapability(List<? extends Capability> l)
  {
    return l;
  }
  
  static List<Requirement> asListRequirement(List<? extends Requirement> l)
  {
    return l;
  }
  
  class DescriptionWiring
    implements BundleWiring
  {
    private volatile boolean valid = true;
    
    DescriptionWiring() {}
    
    public Bundle getBundle()
    {
      return BundleDescriptionImpl.this.getBundle();
    }
    
    public boolean isInUse()
    {
      return (valid) && ((isCurrent()) || (hasDependents()));
    }
    
    void invalidate()
    {
      valid = false;
    }
    
    public boolean isCurrent()
    {
      return (valid) && (!isRemovalPending());
    }
    
    public List<BundleCapability> getCapabilities(String namespace)
    {
      if (!isInUse()) {
        return null;
      }
      List<BundleCapability> result = new ArrayList();
      GenericDescription[] genericCapabilities = getSelectedGenericCapabilities();
      GenericDescription[] arrayOfGenericDescription1;
      int j = (arrayOfGenericDescription1 = genericCapabilities).length;
      for (int i = 0; i < j; i++)
      {
        GenericDescription capabilitiy = arrayOfGenericDescription1[i];
        if ((namespace == null) || (namespace.equals(capabilitiy.getType()))) {
          result.add(capabilitiy.getCapability());
        }
      }
      if (host != null) {
        return result;
      }
      if (getSymbolicName() != null)
      {
        if ((namespace == null) || ("osgi.wiring.bundle".equals(namespace))) {
          result.add(getCapability());
        }
        if ((attachFragments()) && ((namespace == null) || ("osgi.wiring.host".equals(namespace)))) {
          result.add(getCapability("osgi.wiring.host"));
        }
      }
      if ((namespace == null) || ("osgi.wiring.package".equals(namespace)))
      {
        ExportPackageDescription[] exports = getSelectedExports();
        ExportPackageDescription[] arrayOfExportPackageDescription1;
        int k = (arrayOfExportPackageDescription1 = exports).length;
        for (j = 0; j < k; j++)
        {
          ExportPackageDescription exportPkg = arrayOfExportPackageDescription1[j];
          result.add(exportPkg.getCapability());
        }
      }
      return result;
    }
    
    public List<Capability> getResourceCapabilities(String namespace)
    {
      return BundleDescriptionImpl.asListCapability(getCapabilities(namespace));
    }
    
    public List<BundleRequirement> getRequirements(String namespace)
    {
      List<BundleWire> requiredWires = getRequiredWires(namespace);
      if (requiredWires == null) {
        return null;
      }
      List<BundleRequirement> requirements = new ArrayList(requiredWires.size());
      for (Iterator localIterator = requiredWires.iterator(); localIterator.hasNext();)
      {
        BundleWire wire = (BundleWire)localIterator.next();
        if (!requirements.contains(wire.getRequirement())) {
          requirements.add(wire.getRequirement());
        }
      }
      if ((getHost() == null) && ((namespace == null) || ("osgi.wiring.package".equals(namespace))))
      {
        ImportPackageSpecification[] arrayOfImportPackageSpecification1;
        if (hasDynamicImports())
        {
          ImportPackageSpecification[] imports = getImportPackages();
          j = (arrayOfImportPackageSpecification1 = imports).length;
          for (i = 0; i < j; i++)
          {
            ImportPackageSpecification impPackage = arrayOfImportPackageSpecification1[i];
            if ("dynamic".equals(impPackage.getDirective("resolution")))
            {
              BundleRequirement req = impPackage.getRequirement();
              if (!requirements.contains(req)) {
                requirements.add(req);
              }
            }
          }
        }
        ImportPackageSpecification[] addedDynamic = getAddedDynamicImportPackages();
        int j = (arrayOfImportPackageSpecification1 = addedDynamic).length;
        for (int i = 0; i < j; i++)
        {
          ImportPackageSpecification dynamicImport = arrayOfImportPackageSpecification1[i];
          BundleRequirement req = dynamicImport.getRequirement();
          if (!requirements.contains(req)) {
            requirements.add(req);
          }
        }
      }
      return requirements;
    }
    
    public List<Requirement> getResourceRequirements(String namespace)
    {
      return BundleDescriptionImpl.asListRequirement(getRequirements(namespace));
    }
    
    public List<BundleWire> getProvidedWires(String namespace)
    {
      if (!isInUse()) {
        return null;
      }
      BundleDescription[] dependentBundles = getDependents();
      List<BundleWire> unorderedResult = new ArrayList();
      int j = (localObject1 = dependentBundles).length;
      for (int i = 0; i < j; i++)
      {
        BundleDescription dependent = localObject1[i];
        List<BundleWire> dependentWires = dependent.getWiring().getRequiredWires(namespace);
        if (dependentWires != null) {
          for (Iterator localIterator = dependentWires.iterator(); localIterator.hasNext();)
          {
            BundleWire bundleWire = (BundleWire)localIterator.next();
            if (bundleWire.getProviderWiring() == this) {
              unorderedResult.add(bundleWire);
            }
          }
        }
      }
      List<BundleWire> orderedResult = new ArrayList(unorderedResult.size());
      Object capabilities = getCapabilities(namespace);
      Iterator<BundleWire> wires;
      for (Object localObject1 = ((List)capabilities).iterator(); ((Iterator)localObject1).hasNext(); wires.hasNext())
      {
        BundleCapability capability = (BundleCapability)((Iterator)localObject1).next();
        wires = unorderedResult.iterator(); continue;
        BundleWire wire = (BundleWire)wires.next();
        if (wire.getCapability().equals(capability))
        {
          wires.remove();
          orderedResult.add(wire);
        }
      }
      return orderedResult;
    }
    
    public List<Wire> getProvidedResourceWires(String namespace)
    {
      return BundleDescriptionImpl.asListWire(getProvidedWires(namespace));
    }
    
    public List<BundleWire> getRequiredWires(String namespace)
    {
      if (!isInUse()) {
        return null;
      }
      List<BundleWire> result = Collections.EMPTY_LIST;
      Map<String, List<StateWire>> wireMap = getWires();
      if (namespace == null)
      {
        result = new ArrayList();
        Iterator localIterator2;
        for (Iterator localIterator1 = wireMap.values().iterator(); localIterator1.hasNext(); localIterator2.hasNext())
        {
          List<StateWire> wires = (List)localIterator1.next();
          localIterator2 = wires.iterator(); continue;wire = (StateWire)localIterator2.next();
          result.add(new BundleDescriptionImpl.BundleWireImpl(wire));
        }
        return result;
      }
      List<StateWire> wires = (List)wireMap.get(namespace);
      if (wires == null) {
        return result;
      }
      result = new ArrayList(wires.size());
      for (StateWire wire = wires.iterator(); wire.hasNext();)
      {
        StateWire wire = (StateWire)wire.next();
        result.add(new BundleDescriptionImpl.BundleWireImpl(wire));
      }
      return result;
    }
    
    public List<Wire> getRequiredResourceWires(String namespace)
    {
      return BundleDescriptionImpl.asListWire(getRequiredWires(namespace));
    }
    
    public BundleRevision getRevision()
    {
      return BundleDescriptionImpl.this;
    }
    
    public BundleRevision getResource()
    {
      return getRevision();
    }
    
    public ClassLoader getClassLoader()
    {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null) {
        sm.checkPermission(BundleDescriptionImpl.GET_CLASSLOADER_PERM);
      }
      if (!isInUse()) {
        return null;
      }
      return (ClassLoader)getBundleClassLoader();
    }
    
    private BundleClassLoader getBundleClassLoader()
    {
      Object o = getUserObject();
      if (!(o instanceof BundleLoaderProxy))
      {
        if ((o instanceof BundleReference)) {
          o = ((BundleReference)o).getBundle();
        }
        if ((o instanceof BundleHost)) {
          o = ((BundleHost)o).getLoaderProxy();
        }
      }
      if ((o instanceof BundleLoaderProxy)) {
        return ((BundleLoaderProxy)o).getBundleLoader().createClassLoader();
      }
      return null;
    }
    
    private boolean hasResourcePermission()
    {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null) {
        try
        {
          sm.checkPermission(new AdminPermission(getBundle(), "resource"));
        }
        catch (SecurityException localSecurityException)
        {
          return false;
        }
      }
      return true;
    }
    
    public List<URL> findEntries(String path, String filePattern, int options)
    {
      if ((!hasResourcePermission()) || (!isInUse())) {
        return null;
      }
      List<URL> result = Collections.EMPTY_LIST;
      BundleClassLoader bcl = getBundleClassLoader();
      if (bcl != null) {
        result = bcl.findEntries(path, filePattern, options);
      }
      return Collections.unmodifiableList(result);
    }
    
    public Collection<String> listResources(String path, String filePattern, int options)
    {
      if ((!hasResourcePermission()) || (!isInUse())) {
        return null;
      }
      Collection<String> result = Collections.EMPTY_LIST;
      BundleClassLoader bcl = getBundleClassLoader();
      if (bcl != null) {
        result = bcl.listResources(path, filePattern, options);
      }
      return Collections.unmodifiableCollection(result);
    }
    
    public String toString()
    {
      return BundleDescriptionImpl.this.toString();
    }
  }
  
  public List<Capability> getCapabilities(String namespace)
  {
    return asListCapability(getDeclaredCapabilities(namespace));
  }
  
  public List<Requirement> getRequirements(String namespace)
  {
    return asListRequirement(getDeclaredRequirements(namespace));
  }
  
  final class LazyData
  {
    String location;
    String platformFilter;
    BundleSpecification[] requiredBundles;
    ExportPackageDescription[] exportPackages;
    ImportPackageSpecification[] importPackages;
    GenericDescription[] genericCapabilities;
    GenericSpecification[] genericRequires;
    NativeCodeSpecification nativeCode;
    ExportPackageDescription[] selectedExports;
    GenericDescription[] selectedCapabilities;
    BundleDescription[] resolvedRequires;
    ExportPackageDescription[] resolvedImports;
    GenericDescription[] resolvedCapabilities;
    ExportPackageDescription[] substitutedExports;
    String[] executionEnvironments;
    Map<String, Long> dynamicStamps;
    Map<String, List<StateWire>> stateWires;
    List<ImportPackageSpecification> addedDynamicImports;
    
    LazyData() {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.BundleDescriptionImpl
 * 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.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.service.resolver.BaseDescription;
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.service.resolver.VersionRange;

public class BundleSpecificationImpl
  extends VersionConstraintImpl
  implements BundleSpecification
{
  private boolean exported;
  private boolean optional;
  private Map<String, Object> attributes;
  private Map<String, String> arbitraryDirectives;
  
  protected void setExported(boolean exported)
  {
    synchronized (monitor)
    {
      this.exported = exported;
    }
  }
  
  protected void setOptional(boolean optional)
  {
    synchronized (monitor)
    {
      this.optional = optional;
    }
  }
  
  /* Error */
  public boolean isExported()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 182	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 180	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:exported	Z
    //   11: aload_1
    //   12: monitorexit
    //   13: ireturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #38	-> byte code offset #0
    //   Java source line #39	-> byte code offset #7
    //   Java source line #38	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  public boolean isOptional()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 182	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 181	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:optional	Z
    //   11: aload_1
    //   12: monitorexit
    //   13: ireturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #44	-> byte code offset #0
    //   Java source line #45	-> byte code offset #7
    //   Java source line #44	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleSpecificationImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  Map<String, Object> getAttributes()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 182	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 184	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:attributes	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #50	-> byte code offset #0
    //   Java source line #51	-> byte code offset #7
    //   Java source line #50	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleSpecificationImpl
    //   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 182	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 183	org/eclipse/osgi/internal/resolver/BundleSpecificationImpl:arbitraryDirectives	Ljava/util/Map;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #63	-> byte code offset #0
    //   Java source line #64	-> byte code offset #7
    //   Java source line #63	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	BundleSpecificationImpl
    //   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;
    }
  }
  
  public boolean isSatisfiedBy(BaseDescription supplier)
  {
    if (!(supplier instanceof BundleDescriptionImpl)) {
      return false;
    }
    BundleDescriptionImpl candidate = (BundleDescriptionImpl)supplier;
    if (candidate.getHost() != null) {
      return false;
    }
    Map<String, ?> requiredAttrs = getAttributes();
    if (requiredAttrs != null)
    {
      Map<String, ?> prividerAttrs = candidate.getAttributes();
      if (prividerAttrs == null) {
        return false;
      }
      for (Iterator localIterator = requiredAttrs.keySet().iterator(); localIterator.hasNext();)
      {
        String key = (String)localIterator.next();
        Object requiredValue = requiredAttrs.get(key);
        Object prividedValue = prividerAttrs.get(key);
        if ((prividedValue == null) || (!requiredValue.equals(prividedValue))) {
          return false;
        }
      }
    }
    String[] mandatory 
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-2017. Infinite Loop Ltd