org.eclipse.osgi_3.8.2.v20130124-134944

      if ((obj instanceof String))
      {
        out.writeInt(1);
        writeStringOrNull((String)obj, out);
      }
      else
      {
        String[] props = (String[])obj;
        out.writeInt(props.length);
        for (int i = 0; i < props.length; i++) {
          writeStringOrNull(props[i], out);
        }
      }
    }
  }
  
  private void writeBundleDescription(BundleDescription bundle, DataOutputStream out, boolean force)
    throws IOException
  {
    if ((force) && (!forcedWrite.contains(bundle)))
    {
      int index = addToObjectTable(bundle);
      out.writeByte(1);
      out.writeInt(index);
      forcedWrite.add(bundle);
    }
    else if (writePrefix(bundle, out))
    {
      return;
    }
    out.writeLong(bundle.getBundleId());
    writeBaseDescription(bundle, out);
    out.writeInt(((BundleDescriptionImpl)bundle).getLazyDataOffset());
    out.writeInt(((BundleDescriptionImpl)bundle).getLazyDataSize());
    out.writeBoolean(bundle.isResolved());
    out.writeBoolean(bundle.isSingleton());
    out.writeBoolean(bundle.hasDynamicImports());
    out.writeBoolean(bundle.attachFragments());
    out.writeBoolean(bundle.dynamicFragments());
    writeList(out, (String[])((BundleDescriptionImpl)bundle).getDirective("mandatory"));
    writeMap(out, bundle.getAttributes());
    writeMap(out, ((BundleDescriptionImpl)bundle).getArbitraryDirectives());
    writeHostSpec((HostSpecificationImpl)bundle.getHost(), out, force);
    
    List<BundleDescription> dependencies = ((BundleDescriptionImpl)bundle).getBundleDependencies();
    out.writeInt(dependencies.size());
    for (Iterator<BundleDescription> iter = dependencies.iterator(); iter.hasNext();) {
      writeBundleDescription((BundleDescription)iter.next(), out, force);
    }
  }
  
  private void writeBundleDescriptionLazyData(BundleDescription bundle, DataOutputStream out)
    throws IOException
  {
    int dataStart = out.size();
    int index = getFromObjectTable(bundle);
    ((BundleDescriptionImpl)bundle).setLazyDataOffset(out.size());
    out.writeInt(index);
    
    writeStringOrNull(bundle.getLocation(), out);
    writeStringOrNull(bundle.getPlatformFilter(), out);
    
    ExportPackageDescription[] exports = bundle.getExportPackages();
    out.writeInt(exports.length);
    for (int i = 0; i < exports.length; i++) {
      writeExportPackageDesc((ExportPackageDescriptionImpl)exports[i], out);
    }
    ImportPackageSpecification[] imports = bundle.getImportPackages();
    out.writeInt(imports.length);
    for (int i = 0; i < imports.length; i++) {
      writeImportPackageSpec((ImportPackageSpecificationImpl)imports[i], out);
    }
    BundleSpecification[] requiredBundles = bundle.getRequiredBundles();
    out.writeInt(requiredBundles.length);
    for (int i = 0; i < requiredBundles.length; i++) {
      writeBundleSpec((BundleSpecificationImpl)requiredBundles[i], out);
    }
    ExportPackageDescription[] selectedExports = bundle.getSelectedExports();
    if (selectedExports == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(selectedExports.length);
      for (int i = 0; i < selectedExports.length; i++) {
        writeExportPackageDesc((ExportPackageDescriptionImpl)selectedExports[i], out);
      }
    }
    ExportPackageDescription[] substitutedExports = bundle.getSubstitutedExports();
    if (substitutedExports == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(substitutedExports.length);
      for (int i = 0; i < substitutedExports.length; i++) {
        writeExportPackageDesc((ExportPackageDescriptionImpl)substitutedExports[i], out);
      }
    }
    ExportPackageDescription[] resolvedImports = bundle.getResolvedImports();
    if (resolvedImports == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(resolvedImports.length);
      for (int i = 0; i < resolvedImports.length; i++) {
        writeExportPackageDesc((ExportPackageDescriptionImpl)resolvedImports[i], out);
      }
    }
    BundleDescription[] resolvedRequires = bundle.getResolvedRequires();
    if (resolvedRequires == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(resolvedRequires.length);
      for (int i = 0; i < resolvedRequires.length; i++) {
        writeBundleDescription(resolvedRequires[i], out, false);
      }
    }
    String[] ees = bundle.getExecutionEnvironments();
    out.writeInt(ees.length);
    for (int i = 0; i < ees.length; i++) {
      writeStringOrNull(ees[i], out);
    }
    Map<String, Long> dynamicStamps = ((BundleDescriptionImpl)bundle).getDynamicStamps();
    if (dynamicStamps == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(dynamicStamps.size());
      for (Iterator<String> pkgs = dynamicStamps.keySet().iterator(); pkgs.hasNext();)
      {
        String pkg = (String)pkgs.next();
        writeStringOrNull(pkg, out);
        out.writeLong(((Long)dynamicStamps.get(pkg)).longValue());
      }
    }
    GenericDescription[] genericCapabilities = bundle.getGenericCapabilities();
    if (genericCapabilities == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(genericCapabilities.length);
      for (int i = 0; i < genericCapabilities.length; i++) {
        writeGenericDescription(genericCapabilities[i], out);
      }
    }
    GenericSpecification[] genericRequires = bundle.getGenericRequires();
    if (genericRequires == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(genericRequires.length);
      for (int i = 0; i < genericRequires.length; i++) {
        writeGenericSpecification((GenericSpecificationImpl)genericRequires[i], out);
      }
    }
    GenericDescription[] selectedCapabilities = bundle.getSelectedGenericCapabilities();
    if (selectedCapabilities == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(selectedCapabilities.length);
      for (int i = 0; i < selectedCapabilities.length; i++) {
        writeGenericDescription(selectedCapabilities[i], out);
      }
    }
    GenericDescription[] resolvedCapabilities = bundle.getResolvedGenericRequires();
    if (resolvedCapabilities == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(resolvedCapabilities.length);
      for (int i = 0; i < resolvedCapabilities.length; i++) {
        writeGenericDescription(resolvedCapabilities[i], out);
      }
    }
    writeNativeCode(bundle.getNativeCodeSpecification(), out);
    
    writeMap(out, ((BundleDescriptionImpl)bundle).getWiresInternal());
    
    ((BundleDescriptionImpl)bundle).setLazyDataSize(out.size() - dataStart);
  }
  
  private void writeDisabledInfo(DisabledInfo disabledInfo, DataOutputStream out)
    throws IOException
  {
    writeStringOrNull(disabledInfo.getPolicyName(), out);
    writeStringOrNull(disabledInfo.getMessage(), out);
    writeBundleDescription(disabledInfo.getBundle(), out, false);
  }
  
  private void writeBundleSpec(BundleSpecificationImpl bundle, DataOutputStream out)
    throws IOException
  {
    if (writePrefix(bundle, out)) {
      return;
    }
    writeVersionConstraint(bundle, out);
    writeBundleDescription((BundleDescription)bundle.getSupplier(), out, false);
    out.writeBoolean(bundle.isExported());
    out.writeBoolean(bundle.isOptional());
    writeMap(out, bundle.getAttributes());
    writeMap(out, bundle.getArbitraryDirectives());
  }
  
  private void writeExportPackageDesc(ExportPackageDescriptionImpl exportPackageDesc, DataOutputStream out)
    throws IOException
  {
    if (writePrefix(exportPackageDesc, out)) {
      return;
    }
    writeBaseDescription(exportPackageDesc, out);
    writeBundleDescription(exportPackageDesc.getExporter(), out, false);
    writeMap(out, exportPackageDesc.getAttributes());
    writeMap(out, exportPackageDesc.getDirectives());
    writeMap(out, exportPackageDesc.getArbitraryDirectives());
    writeExportPackageDesc((ExportPackageDescriptionImpl)exportPackageDesc.getFragmentDeclaration(), out);
  }
  
  private void writeGenericDescription(GenericDescription description, DataOutputStream out)
    throws IOException
  {
    if (writePrefix(description, out)) {
      return;
    }
    writeBaseDescription(description, out);
    writeBundleDescription(description.getSupplier(), out, false);
    writeStringOrNull(description.getType() == "generic" ? null : description.getType(), out);
    Dictionary<String, Object> attrs = description.getAttributes();
    Map<String, Object> mapAttrs = new HashMap(attrs.size());
    for (Enumeration<String> keys = attrs.keys(); keys.hasMoreElements();)
    {
      String key = (String)keys.nextElement();
      mapAttrs.put(key, attrs.get(key));
    }
    writeMap(out, mapAttrs);
    Map<String, String> directives = description.getDeclaredDirectives();
    writeMap(out, directives);
    writeGenericDescription((GenericDescription)((BaseDescriptionImpl)description).getFragmentDeclaration(), out);
  }
  
  private void writeGenericSpecification(GenericSpecificationImpl specification, DataOutputStream out)
    throws IOException
  {
    if (writePrefix(specification, out)) {
      return;
    }
    writeVersionConstraint(specification, out);
    writeStringOrNull(specification.getType() == "generic" ? null : specification.getType(), out);
    GenericDescription[] suppliers = specification.getSuppliers();
    out.writeInt(suppliers == null ? 0 : suppliers.length);
    if (suppliers != null) {
      for (int i = 0; i < suppliers.length; i++) {
        writeGenericDescription(suppliers[i], out);
      }
    }
    out.writeInt(specification.getResolution());
    writeStringOrNull(specification.getMatchingFilter(), out);
    writeMap(out, specification.getAttributes());
    writeMap(out, specification.getArbitraryDirectives());
  }
  
  private void writeNativeCode(NativeCodeSpecification nativeCodeSpecification, DataOutputStream out)
    throws IOException
  {
    if (nativeCodeSpecification == null)
    {
      out.writeBoolean(false);
      return;
    }
    out.writeBoolean(true);
    out.writeBoolean(nativeCodeSpecification.isOptional());
    NativeCodeDescription[] nativeDescs = nativeCodeSpecification.getPossibleSuppliers();
    int numDescs = nativeDescs == null ? 0 : nativeDescs.length;
    out.writeInt(numDescs);
    int supplierIndex = -1;
    for (int i = 0; i < numDescs; i++)
    {
      if (nativeDescs[i] == nativeCodeSpecification.getSupplier()) {
        supplierIndex = i;
      }
      writeNativeCodeDescription(nativeDescs[i], out);
    }
    out.writeInt(supplierIndex);
  }
  
  private void writeNativeCodeDescription(NativeCodeDescription nativeCodeDescription, DataOutputStream out)
    throws IOException
  {
    writeBaseDescription(nativeCodeDescription, out);
    writeBundleDescription(nativeCodeDescription.getSupplier(), out, false);
    Filter filter = nativeCodeDescription.getFilter();
    writeStringOrNull(filter == null ? null : filter.toString(), out);
    writeStringArray(nativeCodeDescription.getLanguages(), out);
    writeStringArray(nativeCodeDescription.getNativePaths(), out);
    writeStringArray(nativeCodeDescription.getOSNames(), out);
    writeVersionRanges(nativeCodeDescription.getOSVersions(), out);
    writeStringArray(nativeCodeDescription.getProcessors(), out);
    out.writeBoolean(nativeCodeDescription.hasInvalidNativePaths());
  }
  
  private void writeVersionRanges(VersionRange[] ranges, DataOutputStream out)
    throws IOException
  {
    out.writeInt(ranges == null ? 0 : ranges.length);
    if (ranges == null) {
      return;
    }
    for (int i = 0; i < ranges.length; i++) {
      writeVersionRange(ranges[i], out);
    }
  }
  
  private void writeStringArray(String[] strings, DataOutputStream out)
    throws IOException
  {
    out.writeInt(strings == null ? 0 : strings.length);
    if (strings == null) {
      return;
    }
    for (int i = 0; i < strings.length; i++) {
      writeStringOrNull(strings[i], out);
    }
  }
  
  private void writeMap(DataOutputStream out, Map<String, ?> source)
    throws IOException
  {
    if (source == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(source.size());
      Iterator<String> iter = source.keySet().iterator();
      while (iter.hasNext())
      {
        String key = (String)iter.next();
        Object value = source.get(key);
        writeStringOrNull(key, out);
        if ((value instanceof String))
        {
          out.writeByte(0);
          writeStringOrNull((String)value, out);
        }
        else if ((value instanceof String[]))
        {
          out.writeByte(1);
          writeList(out, (String[])value);
        }
        else if ((value instanceof Boolean))
        {
          out.writeByte(2);
          out.writeBoolean(((Boolean)value).booleanValue());
        }
        else if ((value instanceof Integer))
        {
          out.writeByte(3);
          out.writeInt(((Integer)value).intValue());
        }
        else if ((value instanceof Long))
        {
          out.writeByte(4);
          out.writeLong(((Long)value).longValue());
        }
        else if ((value instanceof Double))
        {
          out.writeByte(5);
          out.writeDouble(((Double)value).doubleValue());
        }
        else if ((value instanceof Version))
        {
          out.writeByte(6);
          writeVersion((Version)value, out);
        }
        else if ("java.net.URI".equals(value.getClass().getName()))
        {
          out.writeByte(7);
          writeStringOrNull(value.toString(), out);
        }
        else if ((value instanceof List))
        {
          writeList(out, (List)value);
        }
      }
    }
  }
  
  private void writeList(DataOutputStream out, List<?> list)
    throws IOException
  {
    byte type = getListType(list);
    if (type == -2) {
      return;
    }
    out.writeByte(8);
    out.writeByte(type);
    out.writeInt(list.size());
    for (Iterator localIterator = list.iterator(); localIterator.hasNext();)
    {
      Object value = localIterator.next();
      switch (type)
      {
      case 0: 
        writeStringOrNull((String)value, out);
        break;
      case 3: 
        out.writeInt(((Integer)value).intValue());
        break;
      case 4: 
        out.writeLong(((Long)value).longValue());
        break;
      case 5: 
        out.writeDouble(((Double)value).doubleValue());
        break;
      case 6: 
        writeVersion((Version)value, out);
        break;
      case 7: 
        writeStateWire((StateWire)value, out);
      }
    }
  }
  
  private void writeStateWire(StateWire wire, DataOutputStream out)
    throws IOException
  {
    VersionConstraint requirement = wire.getDeclaredRequirement();
    if ((requirement instanceof ImportPackageSpecificationImpl))
    {
      out.writeByte(0);
      writeImportPackageSpec((ImportPackageSpecificationImpl)requirement, out);
    }
    else if ((requirement instanceof BundleSpecificationImpl))
    {
      out.writeByte(1);
      writeBundleSpec((BundleSpecificationImpl)requirement, out);
    }
    else if ((requirement instanceof HostSpecificationImpl))
    {
      out.writeByte(2);
      writeHostSpec((HostSpecificationImpl)requirement, out, false);
    }
    else if ((requirement instanceof GenericSpecificationImpl))
    {
      out.writeByte(3);
      writeGenericSpecification((GenericSpecificationImpl)requirement, out);
    }
    else
    {
      throw new IllegalArgumentException("Unknown requiement type: " + requirement.getClass());
    }
    BaseDescription capability = wire.getDeclaredCapability();
    if ((capability instanceof BundleDescription)) {
      writeBundleDescription((BundleDescription)capability, out, false);
    } else if ((capability instanceof ExportPackageDescriptionImpl)) {
      writeExportPackageDesc((ExportPackageDescriptionImpl)capability, out);
    } else if ((capability instanceof GenericDescription)) {
      writeGenericDescription((GenericDescription)capability, out);
    } else {
      throw new IllegalArgumentException("Unknown capability type: " + requirement.getClass());
    }
    writeBundleDescription(wire.getRequirementHost(), out, false);
    writeBundleDescription(wire.getCapabilityHost(), out, false);
  }
  
  private byte getListType(List<?> list)
  {
    if (list.size() == 0) {
      return -1;
    }
    Object type = list.get(0);
    if ((type instanceof String)) {
      return 0;
    }
    if ((type instanceof Integer)) {
      return 3;
    }
    if ((type instanceof Long)) {
      return 4;
    }
    if ((type instanceof Double)) {
      return 5;
    }
    if ((type instanceof Version)) {
      return 6;
    }
    if ((type instanceof StateWire)) {
      return 7;
    }
    return -2;
  }
  
  private void writeList(DataOutputStream out, String[] list)
    throws IOException
  {
    if (list == null)
    {
      out.writeInt(0);
    }
    else
    {
      out.writeInt(list.length);
      for (int i = 0; i < list.length; i++) {
        writeStringOrNull(list[i], out);
      }
    }
  }
  
  private void writeBaseDescription(BaseDescription rootDesc, DataOutputStream out)
    throws IOException
  {
    writeStringOrNull(rootDesc.getName(), out);
    writeVersion(rootDesc.getVersion(), out);
  }
  
  private void writeImportPackageSpec(ImportPackageSpecificationImpl importPackageSpec, DataOutputStream out)
    throws IOException
  {
    if (writePrefix(importPackageSpec, out)) {
      return;
    }
    writeVersionConstraint(importPackageSpec, out);
    if (importPackageSpec.getBundle().isResolved()) {
      writeExportPackageDesc((ExportPackageDescriptionImpl)importPackageSpec.getSupplier(), out);
    } else {
      out.writeByte(0);
    }
    writeStringOrNull(importPackageSpec.getBundleSymbolicName(), out);
    writeVersionRange(importPackageSpec.getBundleVersionRange(), out);
    writeMap(out, importPackageSpec.getAttributes());
    writeMap(out, importPackageSpec.getDirectives());
    writeMap(out, importPackageSpec.getArbitraryDirectives());
  }
  
  private void writeHostSpec(HostSpecificationImpl host, DataOutputStream out, boolean force)
    throws IOException
  {
    if ((host != null) && (force) && (!forcedWrite.contains(host)))
    {
      int index = addToObjectTable(host);
      out.writeByte(1);
      out.writeInt(index);
      forcedWrite.add(host);
    }
    else if (writePrefix(host, out))
    {
      return;
    }
    writeVersionConstraint(host, out);
    BundleDescription[] hosts = host.getHosts();
    if (hosts == null)
    {
      out.writeInt(0);
      return;
    }
    out.writeInt(hosts.length);
    for (int i = 0; i < hosts.length; i++) {
      writeBundleDescription(hosts[i], out, force);
    }
    writeMap(out, host.getAttributes());
    writeMap(out, host.getArbitraryDirectives());
  }
  
  private void writeVersionConstraint(VersionConstraint constraint, DataOutputStream out)
    throws IOException
  {
    writeStringOrNull(constraint.getName(), out);
    writeVersionRange(constraint.getVersionRange(), out);
  }
  
  private void writeVersion(Version version, DataOutputStream out)
    throws IOException
  {
    if ((version == null) || (version.equals(Version.emptyVersion)))
    {
      out.writeByte(0);
      return;
    }
    out.writeByte(1);
    out.writeInt(version.getMajor());
    out.writeInt(version.getMinor());
    out.writeInt(version.getMicro());
    writeQualifier(version.getQualifier(), out);
  }
  
  private void writeVersionRange(VersionRange versionRange, DataOutputStream out)
    throws IOException
  {
    if ((versionRange == null) || (versionRange.equals(VersionRange.emptyRange)))
    {
      out.writeByte(0);
      return;
    }
    out.writeByte(1);
    writeVersion(versionRange.getMinimum(), out);
    out.writeBoolean(versionRange.getIncludeMinimum());
    writeVersion(versionRange.getMaximum(), out);
    out.writeBoolean(versionRange.getIncludeMaximum());
  }
  
  private boolean writeIndex(Object object, DataOutputStream out)
    throws IOException
  {
    if (object == null)
    {
      out.writeByte(0);
      return true;
    }
    int index = getFromObjectTable(object);
    if (index == -1) {
      return false;
    }
    out.writeByte(2);
    out.writeInt(index);
    return true;
  }
  
  /* Error */
  public void saveStateDeprecated(StateImpl state, DataOutputStream output)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: aload_2
    //   3: invokespecial 722	org/eclipse/osgi/internal/resolver/StateWriter:writeStateDeprecated	(Lorg/eclipse/osgi/internal/resolver/StateImpl;Ljava/io/DataOutputStream;)V
    //   6: goto +10 -> 16
    //   9: astore_3
    //   10: aload_2
    //   11: invokevirtual 629	java/io/DataOutputStream:close	()V
    //   14: aload_3
    //   15: athrow
    //   16: aload_2
    //   17: invokevirtual 629	java/io/DataOutputStream:close	()V
    //   20: return
    // Line number table:
    //   Java source line #683	-> byte code offset #0
    //   Java source line #684	-> byte code offset #6
    //   Java source line #685	-> byte code offset #10
    //   Java source line #686	-> byte code offset #14
    //   Java source line #685	-> byte code offset #16
    //   Java source line #687	-> byte code offset #20
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	21	0	this	StateWriter
    //   0	21	1	state	StateImpl
    //   0	21	2	output	DataOutputStream
    //   9	6	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	9	9	finally
  }
  
  private void writeStringOrNull(String string, DataOutputStream out)
    throws IOException
  {
    if (string == null)
    {
      out.writeByte(0);
    }
    else
    {
      byte[] data = string.getBytes("UTF-8");
      if (data.length > 65535)
      {
        out.writeByte(3);
        out.writeInt(data.length);
        out.write(data);
      }
      else
      {
        out.writeByte(1);
        out.writeUTF(string);
      }
    }
  }
  
  private void writeQualifier(String string, DataOutputStream out)
    throws IOException
  {
    if ((string != null) && (string.length() == 0)) {
      string = null;
    }
    writeStringOrNull(string, out);
  }
}

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

import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.BundleContextImpl;
import org.eclipse.osgi.framework.internal.core.Framework;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateDelta;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

public class SystemState
  extends StateImpl
{
  private final Framework framework;
  
  public SystemState(BundleContext context)
  {
    framework = (context == null ? null : ((BundleContextImpl)context).getFramework());
  }
  
  boolean basicAddBundle(BundleDescription description)
  {
    if ((framework != null) && (description.getUserObject() == null))
    {
      AbstractBundle bundle = framework.getBundle(description.getBundleId());
      description.setUserObject(bundle != null ? bundle.getBundleData() : null);
    }
    return super.basicAddBundle(description);
  }
  
  public StateDelta compare(State state)
    throws BundleException
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.SystemState
 * 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.HashSet;
import java.util.Set;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateDelta;
import org.osgi.framework.BundleException;

public class UserState
  extends StateImpl
{
  private final Set<String> updated = Collections.synchronizedSet(new HashSet());
  
  public boolean removeBundle(BundleDescription description)
  {
    if (description.getLocation() != null) {
      updated.remove(description.getLocation());
    }
    if (!super.removeBundle(description)) {
      return false;
    }
    return true;
  }
  
  public boolean updateBundle(BundleDescription newDescription)
  {
    if (!super.updateBundle(newDescription)) {
      return false;
    }
    updated.add(newDescription.getLocation());
    return true;
  }
  
  public StateDelta compare(State baseState)
    throws BundleException
  {
    BundleDescription[] current = getBundles();
    StateDeltaImpl delta = new StateDeltaImpl(this);
    for (int i = 0; i < current.length; i++)
    {
      BundleDescription existing = baseState.getBundleByLocation(current[i].getLocation());
      if (existing == null) {
        delta.recordBundleAdded((BundleDescriptionImpl)current[i]);
      } else if (updated.contains(current[i].getLocation())) {
        delta.recordBundleUpdated((BundleDescriptionImpl)current[i]);
      }
    }
    BundleDescription[] existing = baseState.getBundles();
    for (int i = 0; i < existing.length; i++)
    {
      BundleDescription local = getBundleByLocation(existing[i].getLocation());
      if (local == null) {
        delta.recordBundleRemoved((BundleDescriptionImpl)existing[i]);
      }
    }
    return delta;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.UserState
 * 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.Map;
import org.eclipse.osgi.service.resolver.VersionConstraint;
import org.eclipse.osgi.service.resolver.extras.SpecificationReference;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.resource.Capability;

class VersionConstraintImpl$BundleRequirementImpl
  implements BundleRequirement, SpecificationReference
{
  private final String namespace;
  final VersionConstraintImpl this$0;
  
  public VersionConstraintImpl$BundleRequirementImpl(VersionConstraintImpl paramVersionConstraintImpl, String namespace)
  {
    this.namespace = namespace;
  }
  
  public String getNamespace()
  {
    return namespace;
  }
  
  public Map<String, String> getDirectives()
  {
    return Collections.unmodifiableMap(this$0.getInternalDirectives());
  }
  
  public Map<String, Object> getAttributes()
  {
    return Collections.unmodifiableMap(this$0.getInteralAttributes());
  }
  
  public BundleRevision getRevision()
  {
    return this$0.getBundle();
  }
  
  public boolean matches(BundleCapability capability)
  {
    return this$0.isSatisfiedBy(((BaseDescriptionImpl.BaseCapability)capability).getBaseDescription());
  }
  
  public int hashCode()
  {
    return System.identityHashCode(this$0);
  }
  
  private VersionConstraintImpl getVersionConstraint()
  {
    return this$0;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof BundleRequirementImpl)) {
      return false;
    }
    return ((BundleRequirementImpl)obj).getVersionConstraint() == this$0;
  }
  
  public String toString()
  {
    return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
  }
  
  public boolean matches(Capability capability)
  {
    if ((capability instanceof BundleCapability)) {
      return matches((BundleCapability)capability);
    }
    if (!namespace.equals(capability.getNamespace())) {
      return false;
    }
    String filterSpec = (String)getDirectives().get("filter");
    try
    {
      if ((filterSpec != null) && (!FrameworkUtil.createFilter(filterSpec).matches(capability.getAttributes()))) {
        return false;
      }
    }
    catch (InvalidSyntaxException localInvalidSyntaxException)
    {
      return false;
    }
    return this$0.hasMandatoryAttributes(ManifestElement.getArrayFromList((String)capability.getDirectives().get("mandatory")));
  }
  
  public BundleRevision getResource()
  {
    return getRevision();
  }
  
  public VersionConstraint getSpecification()
  {
    return this$0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.internal.resolver.VersionConstraintImpl.BundleRequirementImpl
 * 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.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
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.VersionConstraint;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.service.resolver.extras.SpecificationReference;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.resource.Capability;

abstract class VersionConstraintImpl
  implements VersionConstraint
{
  protected final Object monitor = new Object();
  private String name;
  private VersionRange versionRange;
  private BundleDescription bundle;
  private BaseDescription supplier;
  private volatile Object userObject;
  
  public String getName()
  {
    synchronized (monitor)
    {
      if ("system.bundle".equals(name))
      {
        StateImpl state = (StateImpl)getBundle().getContainingState();
        return state == null ? Constants.getInternalSymbolicName() : state.getSystemBundle();
      }
      return name;
    }
  }
  
  public VersionRange getVersionRange()
  {
    synchronized (monitor)
    {
      if (versionRange == null) {
        return VersionRange.emptyRange;
      }
      return versionRange;
    }
  }
  
  /* Error */
  public BundleDescription getBundle()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 174	org/eclipse/osgi/internal/resolver/VersionConstraintImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 178	org/eclipse/osgi/internal/resolver/VersionConstraintImpl:bundle	Lorg/eclipse/osgi/service/resolver/BundleDescription;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #58	-> byte code offset #0
    //   Java source line #59	-> byte code offset #7
    //   Java source line #58	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	VersionConstraintImpl
    //   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 supplier != null;
    }
  }
  
  /* Error */
  public BaseDescription getSupplier()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 174	org/eclipse/osgi/internal/resolver/VersionConstraintImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 177	org/eclipse/osgi/internal/resolver/VersionConstraintImpl:supplier	Lorg/eclipse/osgi/service/resolver/BaseDescription;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: aload_1
    //   15: monitorexit
    //   16: athrow
    // Line number table:
    //   Java source line #70	-> byte code offset #0
    //   Java source line #71	-> byte code offset #7
    //   Java source line #70	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	17	0	this	VersionConstraintImpl
    //   5	10	1	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	16	14	finally
  }
  
  /* Error */
  public boolean isSatisfiedBy(BaseDescription candidate)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 174	org/eclipse/osgi/internal/resolver/VersionConstraintImpl:monitor	Ljava/lang/Object;
    //   4: dup
    //   5: astore_2
    //   6: monitorenter
    //   7: aload_2
    //   8: monitorexit
    //   9: iconst_0
    //   10: ireturn
    //   11: aload_2
    //   12: monitorexit
    //   13: athrow
    // Line number table:
    //   Java source line #76	-> byte code offset #0
    //   Java source line #77	-> byte code offset #7
    //   Java source line #76	-> byte code offset #11
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	14	0	this	VersionConstraintImpl
    //   0	14	1	candidate	BaseDescription
    //   5	7	2	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   7	9	11	finally
    //   11	13	11	finally
  }
  
  protected void setName(String name)
  {
    synchronized (monitor)
    {
      this.name = name;
    }
  }
  
  protected void setVersionRange(VersionRange versionRange)
  {
    synchronized (monitor)
    {
      this.versionRange = versionRange;
    }
  }
  
  protected void setBundle(BundleDescription bundle)
  {
    synchronized (monitor)
    {
      this.bundle = bundle;
    }
  }
  
  protected void setSupplier(BaseDescription supplier)
  {
    synchronized (monitor)
    {
      this.supplier = supplier;
    }
  }
  
  protected abstract String getInternalNameSpace();
  
  protected abstract Map<String, String> getInternalDirectives();
  
  protected abstract Map<String, Object> getInteralAttributes();
  
  protected abstract boolean hasMandatoryAttributes(String[] paramArrayOfString);
  
  public BundleRequirement getRequirement()
  {
    String namespace = getInternalNameSpace();
    if (namespace == null) {
      return null;
    }
    return new BundleRequirementImpl(namespace);
  }
  
  public Object getUserObject()
  {
    return userObject;
  }
  
  public void setUserObject(Object userObject)
  {
    this.userObject = userObject;
  }
  
  class BundleRequirementImpl
    implements BundleRequirement, SpecificationReference
  {
    private final String namespace;
    
    public BundleRequirementImpl(String namespace)
    {
      this.namespace = namespace;
    }
    
    public String getNamespace()
    {
      return namespace;
    }
    
    public Map<String, String> getDirectives()
    {
      return Collections.unmodifiableMap(getInternalDirectives());
    }
    
    public Map<String, Object> getAttributes()
    {
      return Collections.unmodifiableMap(getInteralAttributes());
    }
    
    public BundleRevision getRevision()
    {
      return getBundle();
    }
    
    public boolean matches(BundleCapability capability)
    {
      return isSatisfiedBy(((BaseDescriptionImpl.BaseCapability)capability).getBaseDescription());
    }
    
    public int hashCode()
    {
      return System.identityHashCode(VersionConstraintImpl.this);
    }
    
    private VersionConstraintImpl getVersionConstraint()
    {
      return VersionConstraintImpl.this;
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (!(obj instanceof BundleRequirementImpl)) {
        return false;
      }
      return ((BundleRequirementImpl)obj).getVersionConstraint() == VersionConstraintImpl.this;
    }
    
    public String toString()
    {
      return getNamespace() + BaseDescriptionImpl.toString(getAttributes(), false) + BaseDescriptionImpl.toString(getDirectives(), true);
    }
    
    public boolean matches(Capability capability)
    {
      if ((capability instanceof BundleCapability)) {
        return matches((BundleCapability)capability);
      }
      if (!namespace.equals(capability.getNamespace())) {
        return false;
      }
      String filterSpec = (String)getDirectives().get("filter");
      try
      {
        if ((filterSpec != null) && (!FrameworkUtil.createFilter(filterSpec).matches(capability.getAttributes()))) {
          return false;
        }
      }
      catch (InvalidSyntaxException localInvalidSyntaxException)
      {
        return false;
      }
      return hasMandatoryAttributes(ManifestElement.getArrayFromList((String)capability.getDirectives().get("mandatory")));
    }
    
    public BundleRevision getResource()
    {
      return getRevision();
    }
    
    public VersionConstraint getSpecification()
    {
      return VersionConstraintImpl.this;
    }
  }
  
  static StringBuffer addFilterAttributes(StringBuffer filter, Map<String, ?> attributes)
  {
    for (Iterator localIterator = attributes.entrySet().iterator(); localIterator.hasNext();)
    {
      Map.Entry<String, ?> entry = (Map.Entry)localIterator.next();
      addFilterAttribute(filter, (String)entry.getKey(), entry.getValue());
    }
    return filter;
  }
  
  static StringBuffer addFilterAttribute(StringBuffer filter, String attr, Object value)
  {
    return addFilterAttribute(filter, attr, value, true);
  }
  
  static StringBuffer addFilterAttribute(StringBuffer filter, String attr, Object value, boolean escapeWildCard)
  {
    if ((value instanceof VersionRange))
    {
      VersionRange range = (VersionRange)value;
      filter.append(range.toFilterString(attr));
    }
    else
    {
      filter.append('(').append(attr).append('=').append(escapeValue(value, escapeWildCard)).append(')');
    }
    return filter;
  }
  
  private static String escapeValue(Object o, boolean escapeWildCard)
  {
    String value = o.toString();
    boolean escaped = false;
    int inlen = value.length();
    int outlen = inlen << 1;
    
    char[] output = new char[outlen];
    value.getChars(0, inlen, output, inlen);
    
    int cursor = 0;
    for (int i = inlen; i < outlen; i++)
    {
      char c = output[i];
      switch (c)
      {
      case '*': 
        if (!escapeWildCard) {
          break;
        }
      case '(': 
      case ')': 
      case '\\': 
        output[cursor] = '\\';
        cursor++;
        escaped = true;
      }
      output[cursor] = c;
      cursor++;
    }
    return escaped ? new String(output, 0, cursor) : value;
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.util.Properties;
import org.eclipse.core.runtime.adaptor.LocationManager;
import org.eclipse.osgi.baseadaptor.BaseData;
import org.eclipse.osgi.framework.internal.core.AbstractBundle;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.internal.baseadaptor.DevClassPathHelper;
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine;
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEvent;
import org.eclipse.osgi.internal.signedcontent.SignedBundleHook;
import org.eclipse.osgi.internal.signedcontent.SignedStorageHook;
import org.eclipse.osgi.service.resolver.BundleDescription;
im
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