org.eclipse.equinox.registry_3.5.200.v20120522-1841

16:44:43.357 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.registry_3.5.200.v20120522-1841.jar
package org.eclipse.core.internal.adapter;

import java.util.ArrayList;
import org.eclipse.core.internal.registry.Handle;
import org.eclipse.core.internal.registry.RegistryMessages;
import org.eclipse.core.internal.registry.osgi.EquinoxUtils;
import org.eclipse.core.internal.runtime.IAdapterFactoryExt;
import org.eclipse.core.internal.runtime.RuntimeLog;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;

class AdapterFactoryProxy
  implements IAdapterFactory, IAdapterFactoryExt
{
  private IConfigurationElement element;
  private IAdapterFactory factory;
  private boolean factoryLoaded = false;
  private String ownerId;
  private int internalOwnerID = -1;
  
  public static AdapterFactoryProxy createProxy(IConfigurationElement element)
  {
    AdapterFactoryProxy result = new AdapterFactoryProxy();
    element = element;
    IExtension extension = element.getDeclaringExtension();
    ownerId = extension.getUniqueIdentifier();
    if ((extension instanceof Handle)) {
      internalOwnerID = ((Handle)extension).getId();
    }
    if ("factory".equals(element.getName())) {
      return result;
    }
    result.logError();
    return null;
  }
  
  public boolean originatesFrom(IExtension extension)
  {
    String id = extension.getUniqueIdentifier();
    if (id != null) {
      return id.equals(ownerId);
    }
    if (!(extension instanceof Handle)) {
      return false;
    }
    return internalOwnerID == ((Handle)extension).getId();
  }
  
  String getAdaptableType()
  {
    String result = element.getAttribute("adaptableType");
    if (result != null) {
      return result;
    }
    logError();
    return "";
  }
  
  public Object getAdapter(Object adaptableObject, Class adapterType)
  {
    if (!factoryLoaded) {
      loadFactory(false);
    }
    return factory == null ? null : factory.getAdapter(adaptableObject, adapterType);
  }
  
  public Class[] getAdapterList()
  {
    if (!factoryLoaded) {
      loadFactory(false);
    }
    return factory == null ? null : factory.getAdapterList();
  }
  
  public String[] getAdapterNames()
  {
    IConfigurationElement[] children = element.getChildren();
    ArrayList adapters = new ArrayList(children.length);
    for (int i = 0; i < children.length; i++) {
      if ("adapter".equals(children[i].getName()))
      {
        String type = children[i].getAttribute("type");
        if (type != null) {
          adapters.add(type);
        }
      }
    }
    if (adapters.isEmpty()) {
      logError();
    }
    return (String[])adapters.toArray(new String[adapters.size()]);
  }
  
  IExtension getExtension()
  {
    return element.getDeclaringExtension();
  }
  
  public synchronized IAdapterFactory loadFactory(boolean force)
  {
    if ((factory != null) || (factoryLoaded)) {
      return factory;
    }
    String contributorName = element.getContributor().getName();
    boolean isActive;
    try
    {
      isActive = EquinoxUtils.isActive(contributorName);
    }
    catch (NoClassDefFoundError localNoClassDefFoundError)
    {
      boolean isActive;
      isActive = true;
    }
    if ((!force) && (!isActive)) {
      return null;
    }
    factoryLoaded = true;
    try
    {
      factory = ((IAdapterFactory)element.createExecutableExtension("class"));
    }
    catch (CoreException e)
    {
      String msg = NLS.bind(RegistryMessages.adapters_cantInstansiate, getAdaptableType(), element.getContributor().getName());
      RuntimeLog.log(new Status(4, "org.eclipse.equinox.registry", 0, msg, e));
    }
    return factory;
  }
  
  private void logError()
  {
    String msg = NLS.bind(RegistryMessages.adapters_badAdapterFactory, element.getContributor().getName());
    RuntimeLog.log(new Status(4, "org.eclipse.equinox.registry", 0, msg, null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.adapter.AdapterFactoryProxy
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.adapter;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.internal.runtime.AdapterManager;
import org.eclipse.core.internal.runtime.IAdapterManagerProvider;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IRegistryEventListener;
import org.eclipse.core.runtime.RegistryFactory;

public final class AdapterManagerListener
  implements IRegistryEventListener, IAdapterManagerProvider
{
  public static final String ADAPTER_POINT_ID = "org.eclipse.core.runtime.adapters";
  private AdapterManager theAdapterManager;
  
  public AdapterManagerListener()
  {
    theAdapterManager = AdapterManager.getDefault();
    theAdapterManager.registerLazyFactoryProvider(this);
  }
  
  public boolean addFactories(AdapterManager adapterManager)
  {
    IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint("org.eclipse.core.runtime.adapters");
    if (point == null) {
      return false;
    }
    boolean factoriesAdded = false;
    IExtension[] extensions = point.getExtensions();
    for (int i = 0; i < extensions.length; i++)
    {
      IConfigurationElement[] elements = extensions[i].getConfigurationElements();
      for (int j = 0; j < elements.length; j++)
      {
        AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(elements[j]);
        if (proxy != null)
        {
          adapterManager.registerFactory(proxy, proxy.getAdaptableType());
          factoriesAdded = true;
        }
      }
    }
    RegistryFactory.getRegistry().addListener(this, "org.eclipse.core.runtime.adapters");
    return factoriesAdded;
  }
  
  private void registerExtension(IExtension extension)
  {
    IConfigurationElement[] elements = extension.getConfigurationElements();
    for (int j = 0; j < elements.length; j++)
    {
      AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(elements[j]);
      if (proxy != null) {
        theAdapterManager.registerFactory(proxy, proxy.getAdaptableType());
      }
    }
  }
  
  public synchronized void added(IExtension[] extensions)
  {
    for (int i = 0; i < extensions.length; i++) {
      registerExtension(extensions[i]);
    }
    theAdapterManager.flushLookup();
  }
  
  public synchronized void removed(IExtension[] extensions)
  {
    theAdapterManager.flushLookup();
    for (int i = 0; i < extensions.length; i++)
    {
      Iterator it2;
      for (Iterator it = theAdapterManager.getFactories().values().iterator(); it.hasNext(); it2.hasNext())
      {
        it2 = ((List)it.next()).iterator(); continue;
        IAdapterFactory factory = (IAdapterFactory)it2.next();
        if ((factory instanceof AdapterFactoryProxy)) {
          if (((AdapterFactoryProxy)factory).originatesFrom(extensions[i])) {
            it2.remove();
          }
        }
      }
    }
  }
  
  public synchronized void added(IExtensionPoint[] extensionPoints) {}
  
  public synchronized void removed(IExtensionPoint[] extensionPoints) {}
  
  public synchronized void stop()
  {
    RegistryFactory.getRegistry().removeListener(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.adapter.AdapterManagerListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.InvalidRegistryObjectException;

public class BaseExtensionHandle
  extends Handle
  implements IExtension
{
  public BaseExtensionHandle(IObjectManager objectManager, int id)
  {
    super(objectManager, id);
  }
  
  protected Extension getExtension()
  {
    return (Extension)objectManager.getObject(getId(), (byte)2);
  }
  
  protected boolean shouldPersist()
  {
    return getExtension().shouldPersist();
  }
  
  public String getNamespace()
  {
    return getContributor().getName();
  }
  
  public String getNamespaceIdentifier()
  {
    return getExtension().getNamespaceIdentifier();
  }
  
  public IContributor getContributor()
  {
    return getExtension().getContributor();
  }
  
  String getContributorId()
  {
    return getExtension().getContributorId();
  }
  
  public String getExtensionPointUniqueIdentifier()
  {
    return getExtension().getExtensionPointIdentifier();
  }
  
  public String getLabel()
  {
    return getExtension().getLabel();
  }
  
  public String getLabelAsIs()
  {
    return getExtension().getLabelAsIs();
  }
  
  public String getLabel(String locale)
  {
    return getExtension().getLabel(locale);
  }
  
  public String getSimpleIdentifier()
  {
    return getExtension().getSimpleIdentifier();
  }
  
  public String getUniqueIdentifier()
  {
    return getExtension().getUniqueIdentifier();
  }
  
  public IConfigurationElement[] getConfigurationElements()
  {
    return (IConfigurationElement[])objectManager.getHandles(getExtension().getRawChildren(), (byte)1);
  }
  
  RegistryObject getObject()
  {
    return getExtension();
  }
  
  public boolean isValid()
  {
    try
    {
      getExtension();
    }
    catch (InvalidRegistryObjectException localInvalidRegistryObjectException)
    {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.BaseExtensionHandle
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.InvalidRegistryObjectException;

public class BaseExtensionPointHandle
  extends Handle
  implements IExtensionPoint
{
  public BaseExtensionPointHandle(IObjectManager objectManager, int id)
  {
    super(objectManager, id);
  }
  
  public IExtension[] getExtensions()
  {
    return (IExtension[])objectManager.getHandles(getExtensionPoint().getRawChildren(), (byte)2);
  }
  
  public String getNamespace()
  {
    return getContributor().getName();
  }
  
  public String getNamespaceIdentifier()
  {
    return getExtensionPoint().getNamespace();
  }
  
  public IContributor getContributor()
  {
    return getExtensionPoint().getContributor();
  }
  
  protected boolean shouldPersist()
  {
    return getExtensionPoint().shouldPersist();
  }
  
  public IExtension getExtension(String extensionId)
  {
    if (extensionId == null) {
      return null;
    }
    int[] children = getExtensionPoint().getRawChildren();
    for (int i = 0; i < children.length; i++) {
      if (extensionId.equals(((Extension)objectManager.getObject(children[i], (byte)2)).getUniqueIdentifier())) {
        return (ExtensionHandle)objectManager.getHandle(children[i], (byte)2);
      }
    }
    return null;
  }
  
  public IConfigurationElement[] getConfigurationElements()
  {
    Extension[] tmpExtensions = (Extension[])objectManager.getObjects(getExtensionPoint().getRawChildren(), (byte)2);
    if (tmpExtensions.length == 0) {
      return ConfigurationElementHandle.EMPTY_ARRAY;
    }
    ArrayList result = new ArrayList();
    for (int i = 0; i < tmpExtensions.length; i++) {
      result.addAll(Arrays.asList(objectManager.getHandles(tmpExtensions[i].getRawChildren(), (byte)1)));
    }
    return (IConfigurationElement[])result.toArray(new IConfigurationElement[result.size()]);
  }
  
  public String getLabelAsIs()
  {
    return getExtensionPoint().getLabelAsIs();
  }
  
  public String getLabel()
  {
    return getExtensionPoint().getLabel();
  }
  
  public String getLabel(String locale)
  {
    return getExtensionPoint().getLabel(locale);
  }
  
  public String getSchemaReference()
  {
    return getExtensionPoint().getSchemaReference();
  }
  
  public String getSimpleIdentifier()
  {
    return getExtensionPoint().getSimpleIdentifier();
  }
  
  public String getUniqueIdentifier()
  {
    return getExtensionPoint().getUniqueIdentifier();
  }
  
  RegistryObject getObject()
  {
    return getExtensionPoint();
  }
  
  protected ExtensionPoint getExtensionPoint()
  {
    return (ExtensionPoint)objectManager.getObject(getId(), (byte)3);
  }
  
  public boolean isValid()
  {
    try
    {
      getExtensionPoint();
    }
    catch (InvalidRegistryObjectException localInvalidRegistryObjectException)
    {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.BaseExtensionPointHandle
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;

public class BufferedRandomInputStream
  extends InputStream
{
  private RandomAccessFile inputFile;
  private String filePath;
  private int buffer_size;
  private int buffer_pos;
  private long buffer_start = 0L;
  private long file_pointer;
  private byte[] buffer;
  
  public BufferedRandomInputStream(File file)
    throws IOException
  {
    this(file, 2048);
  }
  
  public BufferedRandomInputStream(File file, int bufferSize)
    throws IOException
  {
    filePath = file.getCanonicalPath();
    inputFile = new RandomAccessFile(file, "r");
    buffer = new byte[bufferSize];
    file_pointer = 0L;
    resetBuffer();
  }
  
  private void resetBuffer()
  {
    buffer_pos = 0;
    buffer_size = 0;
    buffer_start = 0L;
  }
  
  private int fillBuffer()
    throws IOException
  {
    buffer_pos = 0;
    buffer_start = file_pointer;
    buffer_size = inputFile.read(buffer, 0, buffer.length);
    file_pointer += buffer_size;
    return buffer_size;
  }
  
  public int read()
    throws IOException
  {
    if ((buffer_pos >= buffer_size) && 
      (fillBuffer() <= 0)) {
      return -1;
    }
    return buffer[(buffer_pos++)] & 0xFF;
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    int available = buffer_size - buffer_pos;
    if (available < 0) {
      return -1;
    }
    if (len <= available)
    {
      System.arraycopy(buffer, buffer_pos, b, off, len);
      buffer_pos += len;
      return len;
    }
    System.arraycopy(buffer, buffer_pos, b, off, available);
    if (fillBuffer() <= 0) {
      return available;
    }
    return available + read(b, off + available, len - available);
  }
  
  public long skip(long n)
    throws IOException
  {
    if (n <= 0L) {
      return 0L;
    }
    int available = buffer_size - buffer_pos;
    if (n <= available)
    {
      buffer_pos = ((int)(buffer_pos + n));
      return n;
    }
    resetBuffer();
    int skipped = inputFile.skipBytes((int)(n - available));
    file_pointer += skipped;
    return available + skipped;
  }
  
  public int available()
    throws IOException
  {
    return buffer_size - buffer_pos;
  }
  
  public void close()
    throws IOException
  {
    inputFile.close();
    inputFile = null;
    buffer = null;
  }
  
  public String toString()
  {
    return filePath;
  }
  
  public void seek(long pos)
    throws IOException
  {
    if ((pos >= buffer_start) && (pos < buffer_start + buffer_size))
    {
      buffer_pos = ((int)(pos - buffer_start));
    }
    else
    {
      inputFile.seek(pos);
      file_pointer = pos;
      resetBuffer();
    }
  }
  
  public long length()
    throws IOException
  {
    return inputFile.length();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.BufferedRandomInputStream
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;

public class CombinedEventDelta
{
  private final boolean addition;
  private IObjectManager objectManager;
  private static final int arrayGrowthSpace = 5;
  private Map extensionsByID = null;
  private Map extPointsByID = null;
  private ArrayList allExtensions = null;
  private ArrayList allExtensionPoints = null;
  
  private CombinedEventDelta(boolean addition)
  {
    this.addition = addition;
  }
  
  public static CombinedEventDelta recordAddition()
  {
    return new CombinedEventDelta(true);
  }
  
  public static CombinedEventDelta recordRemoval()
  {
    return new CombinedEventDelta(false);
  }
  
  public boolean isAddition()
  {
    return addition;
  }
  
  public boolean isRemoval()
  {
    return !addition;
  }
  
  public void setObjectManager(IObjectManager manager)
  {
    objectManager = manager;
  }
  
  public IObjectManager getObjectManager()
  {
    return objectManager;
  }
  
  private List getExtensionsBucket(String id)
  {
    if (extensionsByID == null) {
      extensionsByID = new HashMap();
    }
    List extensions = (List)extensionsByID.get(id);
    if (extensions == null)
    {
      extensions = new ArrayList(5);
      extensionsByID.put(id, extensions);
    }
    return extensions;
  }
  
  private List getExtPointsBucket(String id)
  {
    if (extPointsByID == null) {
      extPointsByID = new HashMap();
    }
    List extensionPoints = (List)extPointsByID.get(id);
    if (extensionPoints == null)
    {
      extensionPoints = new ArrayList(5);
      extPointsByID.put(id, extensionPoints);
    }
    return extensionPoints;
  }
  
  private List getExtPointsGlobal()
  {
    if (allExtensionPoints == null) {
      allExtensionPoints = new ArrayList();
    }
    return allExtensionPoints;
  }
  
  private List getExtensionsGlobal()
  {
    if (allExtensions == null) {
      allExtensions = new ArrayList();
    }
    return allExtensions;
  }
  
  public void rememberExtensionPoint(ExtensionPoint extensionPoint)
  {
    String bucketId = extensionPoint.getUniqueIdentifier();
    Object extPt = new Integer(extensionPoint.getObjectId());
    getExtPointsBucket(bucketId).add(extPt);
    getExtPointsGlobal().add(extPt);
  }
  
  public void rememberExtension(ExtensionPoint extensionPoint, int ext)
  {
    String bucketId = extensionPoint.getUniqueIdentifier();
    Object extension = new Integer(ext);
    
    getExtensionsBucket(bucketId).add(extension);
    getExtensionsGlobal().add(extension);
  }
  
  public void rememberExtensions(ExtensionPoint extensionPoint, int[] exts)
  {
    if (exts == null) {
      return;
    }
    if (exts.length == 0) {
      return;
    }
    for (int i = 0; i < exts.length; i++) {
      rememberExtension(extensionPoint, exts[i]);
    }
  }
  
  public IExtensionPoint[] getExtensionPoints(String id)
  {
    List extensionPoints = null;
    if ((id != null) && (extPointsByID != null)) {
      extensionPoints = (List)extPointsByID.get(id);
    } else if (id == null) {
      extensionPoints = allExtensionPoints;
    }
    if (extensionPoints == null) {
      return null;
    }
    int size = extensionPoints.size();
    ArrayList result = new ArrayList(size);
    for (int i = 0; i < size; i++)
    {
      Integer extPt = (Integer)extensionPoints.get(i);
      IExtensionPoint extensionPoint = new ExtensionPointHandle(objectManager, extPt.intValue());
      result.add(extensionPoint);
    }
    if (result.size() == 0) {
      return null;
    }
    return (IExtensionPoint[])result.toArray(new IExtensionPoint[result.size()]);
  }
  
  public IExtension[] getExtensions(String id)
  {
    List extensions = null;
    if ((id != null) && (extensionsByID != null)) {
      extensions = (List)extensionsByID.get(id);
    } else if (id == null) {
      extensions = allExtensions;
    }
    if (extensions == null) {
      return null;
    }
    int size = extensions.size();
    ArrayList result = new ArrayList(size);
    for (int i = 0; i < size; i++)
    {
      Integer ext = (Integer)extensions.get(i);
      IExtension extension = new ExtensionHandle(objectManager, ext.intValue());
      result.add(extension);
    }
    return (IExtension[])result.toArray(new IExtension[result.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.CombinedEventDelta
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import java.util.Hashtable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IExecutableExtensionFactory;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.spi.RegistryContributor;
import org.eclipse.osgi.util.NLS;

public class ConfigurationElement
  extends RegistryObject
{
  static final ConfigurationElement[] EMPTY_ARRAY = new ConfigurationElement[0];
  int parentId;
  byte parentType;
  protected String[] propertiesAndValue;
  private String name;
  private String contributorId;
  
  protected ConfigurationElement(ExtensionRegistry registry, boolean persist)
  {
    super(registry, persist);
  }
  
  protected ConfigurationElement(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean persist)
  {
    super(registry, persist);
    
    setObjectId(self);
    this.contributorId = contributorId;
    this.name = name;
    this.propertiesAndValue = propertiesAndValue;
    setRawChildren(children);
    setExtraDataOffset(extraDataOffset);
    parentId = parent;
    this.parentType = parentType;
  }
  
  void throwException(String message, Throwable exception)
    throws CoreException
  {
    throw new CoreException(new Status(4, "org.eclipse.equinox.registry", 1, message, exception));
  }
  
  protected String getValue()
  {
    return getValueAsIs();
  }
  
  String getValueAsIs()
  {
    if ((propertiesAndValue.length != 0) && (propertiesAndValue.length % 2 == 1)) {
      return propertiesAndValue[(propertiesAndValue.length - 1)];
    }
    return null;
  }
  
  public String getAttribute(String attrName)
  {
    return getAttributeAsIs(attrName);
  }
  
  String getAttributeAsIs(String attrName)
  {
    if (propertiesAndValue.length <= 1) {
      return null;
    }
    int size = propertiesAndValue.length - propertiesAndValue.length % 2;
    for (int i = 0; i < size; i += 2) {
      if (propertiesAndValue[i].equals(attrName)) {
        return propertiesAndValue[(i + 1)];
      }
    }
    return null;
  }
  
  protected String[] getAttributeNames()
  {
    if (propertiesAndValue.length <= 1) {
      return RegistryObjectManager.EMPTY_STRING_ARRAY;
    }
    int size = propertiesAndValue.length / 2;
    String[] result = new String[size];
    for (int i = 0; i < size; i++) {
      result[i] = propertiesAndValue[(i * 2)];
    }
    return result;
  }
  
  void setProperties(String[] value)
  {
    propertiesAndValue = value;
  }
  
  protected String[] getPropertiesAndValue()
  {
    return propertiesAndValue;
  }
  
  void setValue(String value)
  {
    if (propertiesAndValue.length == 0)
    {
      propertiesAndValue = new String[] { value };
      return;
    }
    if (propertiesAndValue.length % 2 == 1)
    {
      propertiesAndValue[(propertiesAndValue.length - 1)] = value;
      return;
    }
    String[] newPropertiesAndValue = new String[propertiesAndValue.length + 1];
    System.arraycopy(propertiesAndValue, 0, newPropertiesAndValue, 0, propertiesAndValue.length);
    newPropertiesAndValue[propertiesAndValue.length] = value;
    propertiesAndValue = newPropertiesAndValue;
  }
  
  void setContributorId(String id)
  {
    contributorId = id;
  }
  
  protected String getContributorId()
  {
    return contributorId;
  }
  
  public ConfigurationElement[] getChildren(String childrenName)
  {
    if (getRawChildren().length == 0) {
      return EMPTY_ARRAY;
    }
    ConfigurationElement[] result = new ConfigurationElement[1];
    int idx = 0;
    RegistryObjectManager objectManager = registry.getObjectManager();
    for (int i = 0; i < children.length; i++)
    {
      ConfigurationElement toTest = (ConfigurationElement)objectManager.getObject(children[i], (byte)(noExtraData() ? 1 : 4));
      if (name.equals(childrenName))
      {
        if (idx != 0)
        {
          ConfigurationElement[] copy = new ConfigurationElement[result.length + 1];
          System.arraycopy(result, 0, copy, 0, result.length);
          result = copy;
        }
        result[(idx++)] = toTest;
      }
    }
    if (idx == 0) {
      result = EMPTY_ARRAY;
    }
    return result;
  }
  
  void setParentId(int objectId)
  {
    parentId = objectId;
  }
  
  protected String getName()
  {
    return name;
  }
  
  void setName(String name)
  {
    this.name = name;
  }
  
  void setParentType(byte type)
  {
    parentType = type;
  }
  
  public IContributor getContributor()
  {
    return registry.getObjectManager().getContributor(contributorId);
  }
  
  protected Object createExecutableExtension(String attributeName)
    throws CoreException
  {
    String prop = null;
    
    String contributorName = null;
    String className = null;
    Object initData = null;
    if (attributeName != null)
    {
      prop = getAttribute(attributeName);
    }
    else
    {
      prop = getValue();
      if (prop != null)
      {
        prop = prop.trim();
        if (prop.equals("")) {
          prop = null;
        }
      }
    }
    if (prop == null)
    {
      ConfigurationElement[] exec = getChildren(attributeName);
      if (exec.length != 0)
      {
        ConfigurationElement element = exec[0];
        contributorName = element.getAttribute("plugin");
        className = element.getAttribute("class");
        ConfigurationElement[] parms = element.getChildren("parameter");
        if (parms.length != 0)
        {
          Hashtable initParms = new Hashtable(parms.length + 1);
          for (int i = 0; i < parms.length; i++)
          {
            String pname = parms[i].getAttribute("name");
            if (pname != null) {
              initParms.put(pname, parms[i].getAttribute("value"));
            }
          }
          if (!initParms.isEmpty()) {
            initData = initParms;
          }
        }
      }
      else
      {
        throwException(NLS.bind(RegistryMessages.exExt_extDefNotFound, attributeName), null);
      }
    }
    else
    {
      int i = prop.indexOf(':');
      String executable;
      if (i != -1)
      {
        String executable = prop.substring(0, i).trim();
        initData = prop.substring(i + 1).trim();
      }
      else
      {
        executable = prop;
      }
      i = executable.indexOf('/');
      if (i != -1)
      {
        contributorName = executable.substring(0, i).trim();
        className = executable.substring(i + 1).trim();
      }
      else
      {
        className = executable;
      }
    }
    RegistryContributor defaultContributor = registry.getObjectManager().getContributor(contributorId);
    Object result = registry.createExecutableExtension(defaultContributor, className, contributorName);
    try
    {
      ConfigurationElementHandle confElementHandle = new ConfigurationElementHandle(registry.getObjectManager(), getObjectId());
      if ((result instanceof IExecutableExtension)) {
        ((IExecutableExtension)result).setInitializationData(confElementHandle, attributeName, initData);
      }
    }
    catch (CoreException ce)
    {
      throw ce;
    }
    catch (Exception te)
    {
      throwException(NLS.bind(RegistryMessages.plugin_initObjectError, getContributor().getName(), className), te);
    }
    if ((result instanceof IExecutableExtensionFactory)) {
      result = ((IExecutableExtensionFactory)result).create();
    }
    return result;
  }
  
  String getAttribute(String attrName, String locale)
  {
    registry.logMultiLangError();
    return getAttribute(attrName);
  }
  
  String getValue(String locale)
  {
    registry.logMultiLangError();
    return getValue();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.ConfigurationElement
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.Status;

public class ConfigurationElementHandle
  extends Handle
  implements IConfigurationElement
{
  static final ConfigurationElementHandle[] EMPTY_ARRAY = new ConfigurationElementHandle[0];
  
  public ConfigurationElementHandle(IObjectManager objectManager, int id)
  {
    super(objectManager, id);
  }
  
  protected ConfigurationElement getConfigurationElement()
  {
    return (ConfigurationElement)objectManager.getObject(getId(), (byte)1);
  }
  
  protected boolean shouldPersist()
  {
    return getConfigurationElement().shouldPersist();
  }
  
  public String getAttribute(String propertyName)
  {
    return getConfigurationElement().getAttribute(propertyName);
  }
  
  public String getAttribute(String attrName, String locale)
  {
    return getConfigurationElement().getAttribute(attrName, locale);
  }
  
  public String[] getAttributeNames()
  {
    return getConfigurationElement().getAttributeNames();
  }
  
  public IConfigurationElement[] getChildren()
  {
    ConfigurationElement actualCe = getConfigurationElement();
    if (actualCe.noExtraData()) {
      return (IConfigurationElement[])objectManager.getHandles(actualCe.getRawChildren(), (byte)1);
    }
    return (IConfigurationElement[])objectManager.getHandles(actualCe.getRawChildren(), (byte)4);
  }
  
  public Object createExecutableExtension(String propertyName)
    throws CoreException
  {
    try
    {
      return getConfigurationElement().createExecutableExtension(propertyName);
    }
    catch (InvalidRegistryObjectException e)
    {
      Status status = new Status(4, "org.eclipse.equinox.registry", 1, "Invalid registry object", e);
      if ((objectManager instanceof RegistryObjectManager)) {
        ((RegistryObjectManager)objectManager).getRegistry().log(status);
      }
      throw new CoreException(status);
    }
  }
  
  public String getAttributeAsIs(String name)
  {
    return getConfigurationElement().getAttributeAsIs(name);
  }
  
  public IConfigurationElement[] getChildren(String name)
  {
    ConfigurationElement actualCE = getConfigurationElement();
    ConfigurationElement[] children = (ConfigurationElement[])objectManager.getObjects(actualCE.getRawChildren(), (byte)(actualCE.noExtraData() ? 1 : 4));
    if (children.length == 0) {
      return EMPTY_ARRAY;
    }
    IConfigurationElement[] result = new IConfigurationElement[1];
    int idx = 0;
    for (int i = 0; i < children.length; i++) {
      if (children[i].getName().equals(name))
      {
        if (idx != 0)
        {
          IConfigurationElement[] copy = new IConfigurationElement[result.length + 1];
          System.arraycopy(result, 0, copy, 0, result.length);
          result = copy;
        }
        result[(idx++)] = ((IConfigurationElement)objectManager.getHandle(children[i].getObjectId(), actualCE.noExtraData() ? 1 : 4));
      }
    }
    if (idx == 0) {
      return EMPTY_ARRAY;
    }
    return result;
  }
  
  public IExtension getDeclaringExtension()
  {
    Object result = this;
    while (!((result = ((ConfigurationElementHandle)result).getParent()) instanceof ExtensionHandle)) {}
    return (IExtension)result;
  }
  
  public String getName()
  {
    return getConfigurationElement().getName();
  }
  
  public Object getParent()
  {
    ConfigurationElement actualCe = getConfigurationElement();
    return objectManager.getHandle(parentId, parentType);
  }
  
  public String getValue()
  {
    return getConfigurationElement().getValue();
  }
  
  public String getValue(String locale)
  {
    return getConfigurationElement().getValue(locale);
  }
  
  public String getValueAsIs()
  {
    return getConfigurationElement().getValueAsIs();
  }
  
  RegistryObject getObject()
  {
    return getConfigurationElement();
  }
  
  public String getNamespace()
  {
    return getContributor().getName();
  }
  
  public String getNamespaceIdentifier()
  {
    return getDeclaringExtension().getNamespaceIdentifier();
  }
  
  public IContributor getContributor()
  {
    return getConfigurationElement().getContributor();
  }
  
  public boolean isValid()
  {
    try
    {
      getConfigurationElement();
    }
    catch (InvalidRegistryObjectException localInvalidRegistryObjectException)
    {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.ConfigurationElementHandle
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

public class ConfigurationElementMulti
  extends ConfigurationElement
{
  private DirectMap translatedProperties = new DirectMap(10, 0.5F);
  
  protected ConfigurationElementMulti(ExtensionRegistry registry, boolean persist)
  {
    super(registry, persist);
  }
  
  protected ConfigurationElementMulti(int self, String contributorId, String name, String[] propertiesAndValue, int[] children, int extraDataOffset, int parent, byte parentType, ExtensionRegistry registry, boolean persist)
  {
    super(self, contributorId, name, propertiesAndValue, children, extraDataOffset, parent, parentType, registry, persist);
  }
  
  String getAttribute(String attrName, String locale)
  {
    if (propertiesAndValue.length <= 1) {
      return null;
    }
    int size = propertiesAndValue.length - propertiesAndValue.length % 2;
    int index = -1;
    int i = 0;
    for (int j = 0; i < size; j++)
    {
      if (propertiesAndValue[i].equals(attrName))
      {
        index = j;
        break;
      }
      i += 2;
    }
    if (index == -1) {
      return null;
    }
    String result = getTranslatedAtIndex(index, locale);
    if (result != null) {
      return result;
    }
    return propertiesAndValue[(index * 2 + 1)];
  }
  
  String getValue(String locale)
  {
    if ((propertiesAndValue.length == 0) || (propertiesAndValue.length % 2 == 0)) {
      return null;
    }
    int index = propertiesAndValue.length - 1;
    return getTranslatedAtIndex(index, locale);
  }
  
  private synchronized String getTranslatedAtIndex(int index, String locale)
  {
    String[] translated = null;
    if (!translatedProperties.containsKey(locale))
    {
      String[] propertiesNonTranslated = getNonTranslated();
      translated = registry.translate(propertiesNonTranslated, getContributor(), locale);
      translatedProperties.put(locale, translated);
      registry.getObjectManager().markDirty();
    }
    else
    {
      translated = translatedProperties.get(locale);
    }
    if (translated != null) {
      return translated[index];
    }
    return null;
  }
  
  private String[] getNonTranslated()
  {
    int size = propertiesAndValue.length / 2;
    boolean hasValue = propertiesAndValue.length % 2 == 1;
    if (hasValue) {
      size++;
    }
    String[] propertiesNonTranslated = new String[size];
    int pos = 0;
    for (int i = 1; i < propertiesAndValue.length; i += 2)
    {
      propertiesNonTranslated[pos] = propertiesAndValue[i];
      pos++;
    }
    if (hasValue) {
      propertiesNonTranslated[pos] = propertiesAndValue[(propertiesAndValue.length - 1)];
    }
    return propertiesNonTranslated;
  }
  
  synchronized int getNumCachedLocales()
  {
    return translatedProperties.getSzie();
  }
  
  synchronized String[] getCachedLocales()
  {
    return translatedProperties.getKeys();
  }
  
  synchronized String[][] getCachedTranslations()
  {
    return translatedProperties.getValues();
  }
  
  synchronized void setTranslatedProperties(DirectMap translated)
  {
    translatedProperties = translated;
  }
  
  public String getAttribute(String attrName)
  {
    return getAttribute(attrName, getLocale());
  }
  
  public String getValue()
  {
    return getValue(getLocale());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.internal.registry.ConfigurationElementMulti
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.internal.registry;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.spi.RegistryContributor;

public class Contribution
  implements KeyedElement
{
  static final int[] EMPTY_CHILDREN = new int[2];
  protected ExtensionRegistry registry;
  protected final String contributorId;
  private String defaultNamespace = null;
  protected boolean persist;
  private int[] children = EMPTY_CHILDREN;
  public static final byte EXTENSION_POINT = 0;
  public static final byte EXTENSION = 1;
  
  protected Contribution(String contributorId, ExtensionRegistry registry, boolean persist)
  {
    this.contributorId = contributorId;
    this.registry = registry;
    this.persist = persist;
  }
  
  void mergeContribution(Contribution addContribution)
  {
    Assert.isTrue(contributorId.equals(contributorId));
    Assert.isTrue(registry == registry);
    if (shouldPersist() != addContribution.shouldPersist()) {
      persist = true;
    }
    int[] existing = getRawChildren();
    int[] addition = addContribution.getRawChildren();
    
    int extensionPoints = existing[0] + addition[0];
    int extensions = existing[1] + addition[1];
    int[] allChildren = new int[2 + extensionPoints + extensions];
    
    allChildren[0] = extensionPoints;
    System.arraycopy(existing, 2, allChildren, 2, existing[0]);
    System.arraycopy(addition, 2, allChildren, 2 + existing[0], addition[0]);
    allChildren[1] = extensions;
    System.arraycopy(existing, 2 + existing[0], allChildren, 2 + extensionPoints, existing[1]);
    System.arraycopy(addition, 2 + addition[0], allChildren, 2 + extensionPoints + existing[1], addition[1]);
    
    children = allChildren;
  }
  
  void setRawChildren(int[] children)
  {
    this.children = children;
  }
  
  protected String getContributorId()
  {
    return contributorId;
  }
  
  protected int[] getRawChildren()
  {
    return children;
  }
  
  protected int[] getExtensions()
  {
    int[] results = new int[children[1]];
    System.arraycopy(children, 2 + children[0], results, 0, children[1]);
    return results;
  }
  
  protected int[] getExtensionPoints()
  {
    int[] results = new int[children[0]];
    System.arraycopy(children, 2, results, 0, children[0]);
    return results;
  }
  
  public String getDefaultNamespace()
  {
    if (defaultNamespace == null) {
      defaultNamespace = registry.getObjectManager().getContributor(contributorId).getName();
    }
    return defaultNamespace;
  }
  
  public String toString()
  {
    return "Contribution: " + contributorId + " in namespace" + getDefaultNamespace();
  }
  
  public int getKeyHashCode()
  {
    return getKey().hashCode();
  }
  
  public Object getKey()
  {
    return contributorId;
  }
  
  public boolean compare(KeyedElement other)
  {
    return contributorId.equals(contributorId);
  }
  
  p
1 2 3 4 5 6 7 8 9

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