org.eclipse.pde.api.tools_1.0.301.v20111129-2053

lass Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;

public abstract class ApiElement
  implements IApiElement
{
  private int fType = 0;
  private String fName = null;
  private IApiElement fParent = null;
  
  protected ApiElement(IApiElement parent, int type, String name)
  {
    fParent = parent;
    fType = type;
    fName = name;
  }
  
  public IApiElement getAncestor(int ancestorType)
  {
    IApiElement parent = fParent;
    while ((parent != null) && (parent.getType() != ancestorType)) {
      parent = parent.getParent();
    }
    return parent;
  }
  
  public String getName()
  {
    return fName;
  }
  
  public IApiElement getParent()
  {
    return fParent;
  }
  
  public int getType()
  {
    return fType;
  }
  
  protected void setName(String newname)
  {
    if (newname != null) {
      fName = newname;
    }
  }
  
  protected void abort(String message, Throwable e)
    throws CoreException
  {
    throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", message, e));
  }
  
  public IApiComponent getApiComponent()
  {
    return (IApiComponent)getAncestor(1);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiElement
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IFieldDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.util.Util;

public class ApiField
  extends ApiMember
  implements IApiField
{
  private Object fValue;
  private IFieldDescriptor fHandle;
  
  protected ApiField(IApiType enclosing, String name, String signature, String genericSig, int flags, Object value)
  {
    super(enclosing, name, signature, genericSig, 5, flags);
    fValue = value;
  }
  
  public boolean isEnumConstant()
  {
    return Flags.isEnum(getModifiers());
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof IApiField)) {
      return super.equals(obj);
    }
    return false;
  }
  
  public int hashCode()
  {
    return super.hashCode() + (fValue != null ? fValue.hashCode() : 0);
  }
  
  public Object getConstantValue()
  {
    return fValue;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer
      .append("Field : access(")
      .append(getModifiers())
      .append(") ")
      .append(getSignature())
      .append(' ')
      .append(getName())
      .append(" isEnum constant ")
      .append(isEnumConstant());
    if (getConstantValue() != null) {
      buffer.append(" = ").append(getConstantValue());
    }
    buffer.append(';').append(Util.LINE_DELIMITER);
    if (getGenericSignature() != null) {
      buffer.append(" Signature : ").append(getGenericSignature()).append(Util.LINE_DELIMITER);
    }
    return String.valueOf(buffer);
  }
  
  public IMemberDescriptor getHandle()
  {
    if (fHandle == null) {
      try
      {
        IApiType type = getEnclosingType();
        fHandle = ((IReferenceTypeDescriptor)type.getHandle()).getField(getName());
      }
      catch (CoreException localCoreException) {}
    }
    return fHandle;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiField
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;

public abstract class ApiMember
  extends ApiElement
  implements IApiMember
{
  private int fFlags = -1;
  private String fSignature;
  private String fGenericSignature;
  
  protected ApiMember(IApiElement parent, String name, String signature, String genericSig, int type, int flags)
  {
    super(parent, type, name);
    fFlags = flags;
    fSignature = signature;
    fGenericSignature = genericSig;
  }
  
  public String getSignature()
  {
    return fSignature;
  }
  
  public String getGenericSignature()
  {
    return fGenericSignature;
  }
  
  public int getModifiers()
  {
    return fFlags;
  }
  
  public IApiType getEnclosingType()
    throws CoreException
  {
    return (IApiType)getAncestor(2);
  }
  
  public IApiComponent getApiComponent()
  {
    return (IApiComponent)getAncestor(1);
  }
  
  public String getPackageName()
  {
    try
    {
      IApiType type = getEnclosingType();
      if (type != null) {
        return type.getPackageName();
      }
    }
    catch (CoreException localCoreException) {}
    return "";
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof IApiElement))
    {
      IApiElement element = (IApiElement)obj;
      if (element.getType() == getType()) {
        return (enclosingTypesEqual(this, element)) && (getName().equals(element.getName()));
      }
    }
    return false;
  }
  
  protected boolean enclosingTypesEqual(IApiElement e1, IApiElement e2)
  {
    IApiType t1 = (IApiType)e1.getAncestor(2);
    IApiType t2 = (IApiType)e2.getAncestor(2);
    if (t1 == null) {
      return t2 == null;
    }
    return t1.equals(t2);
  }
  
  public int hashCode()
  {
    IApiType enclosing = (IApiType)getAncestor(2);
    return getType() + getName().hashCode() + (enclosing == null ? 0 : enclosing.hashCode());
  }
  
  public void setModifiers(int access)
  {
    fFlags = access;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiMember
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMethodDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.util.Util;

public class ApiMethod
  extends ApiMember
  implements IApiMethod
{
  public static final int Polymorphic = 2097152;
  private static final String INIT = "<init>";
  private static final String CLINIT = "<clinit>";
  private String[] fExceptions;
  private String fDefaultValue;
  private IMethodDescriptor fHandle;
  
  protected ApiMethod(IApiType enclosing, String name, String signature, String genericSig, int flags, String[] exceptions)
  {
    super(enclosing, name, signature, genericSig, 6, flags);
    fExceptions = exceptions;
  }
  
  public boolean isConstructor()
  {
    return getName().equals("<init>");
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof IApiMethod)) {
      return (super.equals(obj)) && (((IApiMethod)obj).getSignature().equals(getSignature()));
    }
    return false;
  }
  
  public int hashCode()
  {
    return super.hashCode() + getSignature().hashCode();
  }
  
  public String[] getExceptionNames()
  {
    return fExceptions;
  }
  
  public boolean isClassInitializer()
  {
    return getName().equals("<clinit>");
  }
  
  public String getDefaultValue()
  {
    return fDefaultValue;
  }
  
  public void setDefaultValue(String value)
  {
    fDefaultValue = value;
  }
  
  public boolean isSynthetic()
  {
    return (getModifiers() & 0x1000) != 0;
  }
  
  public boolean isPolymorphic()
  {
    return (getModifiers() & 0x200000) != 0;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer
      .append("Method : access(")
      .append(getModifiers())
      .append(") ")
      .append(getSignature())
      .append(' ')
      .append(getName());
    if (getExceptionNames() != null)
    {
      buffer.append(" throws ");
      for (int i = 0; i < getExceptionNames().length; i++)
      {
        if (i > 0) {
          buffer.append(',');
        }
        buffer.append(getExceptionNames()[i]);
      }
    }
    buffer.append(';').append(Util.LINE_DELIMITER);
    if (getGenericSignature() != null) {
      buffer.append(" Generic signature : ").append(getGenericSignature()).append(Util.LINE_DELIMITER);
    }
    return String.valueOf(buffer);
  }
  
  public IMemberDescriptor getHandle()
  {
    if (fHandle == null) {
      try
      {
        IApiType type = getEnclosingType();
        fHandle = ((IReferenceTypeDescriptor)type.getHandle()).getMethod(getName(), getSignature());
      }
      catch (CoreException localCoreException) {}
    }
    return fHandle;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiMethod
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.util.Enumeration;
import org.eclipse.jdt.internal.core.OverflowingLRUCache;
import org.eclipse.jdt.internal.core.util.LRUCache;
import org.eclipse.jdt.internal.core.util.LRUCache.LRUCacheEntry;

class ApiModelCache$Cache
  extends OverflowingLRUCache
{
  final ApiModelCache this$0;
  
  public ApiModelCache$Cache(ApiModelCache paramApiModelCache, int size, int overflow)
  {
    super(size, overflow);
    this$0 = paramApiModelCache;
  }
  
  protected boolean close(LRUCache.LRUCacheEntry entry)
  {
    return true;
  }
  
  protected LRUCache newInstance(int size, int newOverflow)
  {
    return new Cache(this$0, size, newOverflow);
  }
  
  public boolean isEmpty()
  {
    return !keys().hasMoreElements();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiModelCache.Cache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.util.Enumeration;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.internal.core.OverflowingLRUCache;
import org.eclipse.jdt.internal.core.util.LRUCache;
import org.eclipse.jdt.internal.core.util.LRUCache.LRUCacheEntry;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;

public final class ApiModelCache
{
  static final int DEFAULT_CACHE_SIZE = 100;
  static final int DEFAULT_OVERFLOW = 10;
  
  class Cache
    extends OverflowingLRUCache
  {
    public Cache(int size, int overflow)
    {
      super(overflow);
    }
    
    protected boolean close(LRUCache.LRUCacheEntry entry)
    {
      return true;
    }
    
    protected LRUCache newInstance(int size, int newOverflow)
    {
      return new Cache(ApiModelCache.this, size, newOverflow);
    }
    
    public boolean isEmpty()
    {
      return !keys().hasMoreElements();
    }
  }
  
  static ApiModelCache fInstance = null;
  Cache fRootCache = null;
  Cache fMemberTypeCache = null;
  
  public static synchronized ApiModelCache getCache()
  {
    if (fInstance == null) {
      fInstance = new ApiModelCache();
    }
    return fInstance;
  }
  
  private String getCacheKey(String baseline, String component, String typename)
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append(baseline).append('.').append(component).append('.').append(typename);
    return buffer.toString();
  }
  
  public void cacheElementInfo(IApiElement element)
    throws CoreException
  {
    switch (element.getType())
    {
    case 2: 
      if (fRootCache == null) {
        fRootCache = new Cache(100, 10);
      }
      IApiComponent comp = element.getApiComponent();
      if (comp != null)
      {
        IApiBaseline baseline = comp.getBaseline();
        String id = comp.getSymbolicName();
        if (id == null) {
          return;
        }
        Cache compcache = (Cache)fRootCache.get(baseline.getName());
        if (compcache == null)
        {
          compcache = new Cache(100, 10);
          fRootCache.put(baseline.getName(), compcache);
        }
        Cache typecache = (Cache)compcache.get(id);
        if (typecache == null)
        {
          typecache = new Cache(100, 10);
          compcache.put(comp.getSymbolicName(), typecache);
        }
        ApiType type = (ApiType)element;
        if ((type.isMemberType()) || (isMemberType(type.getName())))
        {
          if (fMemberTypeCache == null) {
            fMemberTypeCache = new Cache(100, 10);
          }
          String key = getCacheKey(baseline.getName(), id, getRootName(type.getName()));
          Cache mcache = (Cache)fMemberTypeCache.get(key);
          if (mcache == null)
          {
            mcache = new Cache(100, 10);
            fMemberTypeCache.put(key, mcache);
          }
          mcache.put(type.getName(), type);
        }
        else
        {
          typecache.put(element.getName(), element);
        }
      }
      break;
    }
  }
  
  private String getRootName(String typename)
  {
    int idx = typename.indexOf('$');
    if (idx > -1) {
      return typename.substring(0, idx);
    }
    return typename;
  }
  
  private boolean isMemberType(String typename)
  {
    return typename.indexOf('$') > -1;
  }
  
  public IApiElement getElementInfo(String baselineid, String componentid, String identifier, int type)
  {
    if ((baselineid == null) || (componentid == null)) {
      return null;
    }
    switch (type)
    {
    case 2: 
      if (isMemberType(identifier))
      {
        if (fMemberTypeCache != null)
        {
          Cache mcache = (Cache)fMemberTypeCache.get(getCacheKey(baselineid, componentid, getRootName(identifier)));
          if (mcache != null) {
            return (IApiElement)mcache.get(identifier);
          }
        }
      }
      else if (fRootCache != null)
      {
        Cache compcache = (Cache)fRootCache.get(baselineid);
        if (compcache != null)
        {
          Cache typecache = (Cache)compcache.get(componentid);
          if ((typecache != null) && (identifier != null)) {
            return (IApiElement)typecache.get(identifier);
          }
        }
      }
      break;
    }
    return null;
  }
  
  public boolean removeElementInfo(String baselineid, String componentid, String identifier, int type)
  {
    if (baselineid == null) {
      return false;
    }
    switch (type)
    {
    case 2: 
      if ((componentid != null) && (identifier != null))
      {
        boolean removed = true;
        if (fMemberTypeCache != null) {
          if (isMemberType(identifier))
          {
            Cache mcache = (Cache)fMemberTypeCache.get(getCacheKey(baselineid, componentid, getRootName(identifier)));
            if (mcache != null) {
              return mcache.remove(identifier) != null;
            }
          }
          else
          {
            fMemberTypeCache.remove(getCacheKey(baselineid, componentid, getRootName(identifier)));
          }
        }
        if (fRootCache != null)
        {
          Cache compcache = (Cache)fRootCache.get(baselineid);
          if (compcache != null)
          {
            Cache typecache = (Cache)compcache.get(componentid);
            if (typecache != null)
            {
              removed &= typecache.remove(identifier) != null;
              if (typecache.isEmpty()) {
                removed &= compcache.remove(componentid) != null;
              }
              if (compcache.isEmpty()) {
                removed &= fRootCache.remove(baselineid) != null;
              }
              return removed;
            }
          }
        }
        else
        {
          return false;
        }
      }
      break;
    case 1: 
      flushMemberCache();
      if ((fRootCache != null) && (componentid != null))
      {
        Cache compcache = (Cache)fRootCache.get(baselineid);
        if (compcache != null)
        {
          boolean removed = compcache.remove(componentid) != null;
          if (compcache.isEmpty()) {
            removed &= fRootCache.remove(baselineid) != null;
          }
          return removed;
        }
      }
      break;
    case 4: 
      flushMemberCache();
      if (fRootCache != null) {
        return fRootCache.remove(baselineid) != null;
      }
      break;
    }
    return false;
  }
  
  public boolean removeElementInfo(IApiElement element)
  {
    if (element == null) {
      return false;
    }
    switch (element.getType())
    {
    case 1: 
    case 2: 
      if (fRootCache != null)
      {
        IApiComponent comp = element.getApiComponent();
        if (comp != null) {
          try
          {
            IApiBaseline baseline = comp.getBaseline();
            return removeElementInfo(baseline.getName(), comp.getSymbolicName(), element.getName(), element.getType());
          }
          catch (CoreException localCoreException) {}
        }
      }
      break;
    case 4: 
      flushMemberCache();
      if (fRootCache != null)
      {
        IApiBaseline baseline = (IApiBaseline)element;
        return fRootCache.remove(baseline.getName()) != null;
      }
      break;
    }
    return false;
  }
  
  public void flushCaches()
  {
    if (fRootCache != null) {
      fRootCache.flush();
    }
    flushMemberCache();
  }
  
  private void flushMemberCache()
  {
    if (fMemberTypeCache != null) {
      fMemberTypeCache.flush();
    }
  }
  
  public boolean isEmpty()
  {
    boolean empty = true;
    if (fRootCache != null) {
      empty &= fRootCache.isEmpty();
    }
    if (fMemberTypeCache != null) {
      empty &= fMemberTypeCache.isEmpty();
    }
    return empty;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiModelCache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.File;
import java.io.FilenameFilter;

class ApiModelFactory$CVSNameFilter
  implements FilenameFilter
{
  public boolean accept(File dir, String name)
  {
    return !name.equalsIgnoreCase("CVS");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiModelFactory.CVSNameFilter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;

public class ApiModelFactory
{
  private static final String CVS_FOLDER_NAME = "CVS";
  public static final IApiComponent[] NO_COMPONENTS = new IApiComponent[0];
  
  static class CVSNameFilter
    implements FilenameFilter
  {
    public boolean accept(File dir, String name)
    {
      return !name.equalsIgnoreCase("CVS");
    }
  }
  
  private static CVSNameFilter fgCvsFilter = new CVSNameFilter();
  private static long fNextId = 0L;
  
  private static long getBundleID()
  {
    return fNextId++;
  }
  
  public static IApiComponent newApiComponent(IApiBaseline baseline, String location)
    throws CoreException
  {
    BundleComponent component = new BundleComponent(baseline, location, getBundleID());
    if (component.isValidBundle()) {
      return component;
    }
    return null;
  }
  
  public static IApiComponent newApiComponent(IApiBaseline baseline, IPluginModelBase model)
    throws CoreException
  {
    BundleDescription bundleDescription = model.getBundleDescription();
    if (bundleDescription == null) {
      return null;
    }
    String location = bundleDescription.getLocation();
    if (location == null) {
      return null;
    }
    BundleComponent component = null;
    if (isBinaryProject(location)) {
      component = new BundleComponent(baseline, location, getBundleID());
    } else {
      component = new ProjectComponent(baseline, location, model, getBundleID());
    }
    if (component.isValidBundle()) {
      return component;
    }
    return null;
  }
  
  private static boolean isBinaryProject(String location)
    throws CoreException
  {
    IPath path = new Path(location);
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
    return (project != null) && ((!project.exists()) || (Util.isBinaryProject(project)));
  }
  
  public static IApiBaseline newApiBaseline(String name)
  {
    return new ApiBaseline(name);
  }
  
  public static IApiBaseline newApiBaseline(String name, File eeDescription)
    throws CoreException
  {
    return new ApiBaseline(name, eeDescription);
  }
  
  public static IApiBaseline newApiBaseline(String name, String location)
    throws CoreException
  {
    return new ApiBaseline(name, null, location);
  }
  
  public static IApiBaseline newApiBaseline(String name, File eeDescription, String location)
    throws CoreException
  {
    return new ApiBaseline(name, eeDescription, location);
  }
  
  public static IApiComponent[] addComponents(IApiBaseline baseline, String installLocation, IProgressMonitor monitor)
    throws CoreException
  {
    SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.configuring_baseline, 50);
    IApiComponent[] result = (IApiComponent[])null;
    try
    {
      ITargetPlatformService service = null;
      ApiPlugin plugin = ApiPlugin.getDefault();
      IApiComponent[] arrayOfIApiComponent1;
      if (plugin != null)
      {
        service = (ITargetPlatformService)ApiPlugin.getDefault().acquireService(ITargetPlatformService.class.getName());
        Util.updateMonitor(subMonitor, 1);
        IBundleContainer container = service.newProfileContainer(installLocation, null);
        ITargetDefinition definition = service.newTarget();
        subMonitor.subTask(Messages.resolving_target_definition);
        container.resolve(definition, subMonitor.newChild(30));
        Util.updateMonitor(subMonitor, 1);
        IResolvedBundle[] bundles = container.getBundles();
        List components = new ArrayList();
        if (bundles.length > 0)
        {
          subMonitor.setWorkRemaining(bundles.length);
          for (int i = 0; i < bundles.length; i++)
          {
            Util.updateMonitor(subMonitor, 1);
            if (!bundles[i].isSourceBundle())
            {
              IApiComponent component = newApiComponent(baseline, URIUtil.toFile(bundles[i].getBundleInfo().getLocation()).getAbsolutePath());
              if (component != null)
              {
                subMonitor.subTask(NLS.bind(Messages.adding_component__0, component.getSymbolicName()));
                components.add(component);
              }
            }
          }
        }
        result = (IApiComponent[])components.toArray(new IApiComponent[components.size()]);
      }
      else
      {
        File dir = new File(installLocation);
        if (dir.exists())
        {
          File[] files = dir.listFiles(fgCvsFilter);
          if (files == null) {
            return NO_COMPONENTS;
          }
          List components = new ArrayList();
          for (int i = 0; i < files.length; i++)
          {
            File bundle = files[i];
            IApiComponent component = newApiComponent(baseline, bundle.getAbsolutePath());
            if (component != null) {
              components.add(component);
            }
          }
          result = (IApiComponent[])components.toArray(new IApiComponent[components.size()]);
        }
      }
      if (result != null)
      {
        baseline.addApiComponents(result);
        return result;
      }
      return NO_COMPONENTS;
    }
    finally
    {
      subMonitor.done();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiModelFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import com.ibm.icu.text.MessageFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.pde.api.tools.internal.builder.ReferenceExtractor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiField;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMethod;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.objectweb.asm.ClassReader;

public class ApiType
  extends ApiMember
  implements IApiType
{
  private String fSuperclassName;
  private String[] fSuperInterfaceNames;
  private String fEnclosingTypeName;
  private String fSimpleName;
  private static final IApiMethod[] EMPTY_METHODS = new IApiMethod[0];
  private static final IApiField[] EMPTY_FIELDS = new IApiField[0];
  private static final IApiType[] EMPTY_TYPES = new IApiType[0];
  private static final String NO_ENCLOSING_METHOD = "";
  private Map fFields;
  private LinkedHashMap fMethods;
  private Map fMemberTypes;
  private IReferenceTypeDescriptor fHandle;
  private IApiType fSuperclass;
  private IApiType[] fSuperInterfaces;
  private IApiTypeRoot fStorage;
  private String fEnclosingMethodSignature = null;
  private String fEnclosingMethodName = null;
  private boolean fAnonymous = false;
  private boolean fLocal = false;
  private boolean fMemberType = false;
  private IApiType fEnclosingType = null;
  private IApiMethod fEnclosingMethod = null;
  
  public ApiType(IApiElement parent, String name, String signature, String genericSig, int flags, String enclosingName, IApiTypeRoot storage)
  {
    super(parent, name, signature, genericSig, 2, flags);
    fEnclosingTypeName = enclosingName;
    fStorage = storage;
  }
  
  public List extractReferences(int referenceMask, IProgressMonitor monitor)
    throws CoreException
  {
    HashSet references = new HashSet();
    ReferenceExtractor extractor = new ReferenceExtractor(this, references, referenceMask);
    ClassReader reader = new ClassReader(((AbstractApiTypeRoot)fStorage).getContents());
    reader.accept(extractor, 4);
    return new LinkedList(references);
  }
  
  public IApiField getField(String name)
  {
    if (fFields != null) {
      return (IApiField)fFields.get(name);
    }
    return null;
  }
  
  public IApiField[] getFields()
  {
    if (fFields != null) {
      return (IApiField[])fFields.values().toArray(new IApiField[fFields.size()]);
    }
    return EMPTY_FIELDS;
  }
  
  public String getPackageName()
  {
    return getName().substring(0, getName().lastIndexOf('.'));
  }
  
  public ApiMethod addMethod(String name, String signature, String genericSig, int modifiers, String[] exceptions)
  {
    if (fMethods == null) {
      fMethods = new LinkedHashMap();
    }
    ApiMethod method = new ApiMethod(this, name, signature, genericSig, modifiers, exceptions);
    fMethods.put(new MethodKey(getName(), name, signature, true), method);
    return method;
  }
  
  public ApiField addField(String name, String signature, String genericSig, int modifiers, Object value)
  {
    if (fFields == null) {
      fFields = new HashMap();
    }
    ApiField field = new ApiField(this, name, signature, genericSig, modifiers, value);
    fFields.put(name, field);
    return field;
  }
  
  public IApiMethod getMethod(String name, String signature)
  {
    if (fMethods != null) {
      return (IApiMethod)fMethods.get(new MethodKey(getName(), name, signature, true));
    }
    return null;
  }
  
  public IApiMethod[] getMethods()
  {
    if (fMethods != null) {
      return (IApiMethod[])fMethods.values().toArray(new IApiMethod[fMethods.size()]);
    }
    return EMPTY_METHODS;
  }
  
  public String[] getSuperInterfaceNames()
  {
    return fSuperInterfaceNames;
  }
  
  public void setSuperInterfaceNames(String[] names)
  {
    fSuperInterfaceNames = names;
  }
  
  public IApiType[] getSuperInterfaces()
    throws CoreException
  {
    String[] names = getSuperInterfaceNames();
    if (names == null) {
      return EMPTY_TYPES;
    }
    if (fSuperInterfaces == null)
    {
      IApiType[] interfaces = new IApiType[names.length];
      for (int i = 0; i < interfaces.length; i++)
      {
        interfaces[i] = resolveType(names[i]);
        if (interfaces[i] == null) {
          throw new CoreException(
            new Status(
            4, 
            "org.eclipse.pde.api.tools", 
            122, 
            MessageFormat.format(Messages.ApiType_0, new String[] { names[i], getName() }), 
            null));
        }
      }
      fSuperInterfaces = interfaces;
    }
    return fSuperInterfaces;
  }
  
  public IApiType getSuperclass()
    throws CoreException
  {
    String name = getSuperclassName();
    if (name == null) {
      return null;
    }
    if (fSuperclass == null)
    {
      fSuperclass = resolveType(name);
      if (fSuperclass == null) {
        throw new CoreException(new Status(
          4, 
          "org.eclipse.pde.api.tools", 
          122, 
          MessageFormat.format(Messages.ApiType_1, new String[] { name, getName() }), 
          null));
      }
    }
    return fSuperclass;
  }
  
  private IApiType resolveType(String qName)
    throws CoreException
  {
    if (getApiComponent() == null) {
      requiresApiComponent();
    }
    String packageName = Signatures.getPackageName(qName);
    IApiComponent[] components = getApiComponent().getBaseline()
      .resolvePackage(getApiComponent(), packageName);
    IApiTypeRoot result = Util.getClassFile(components, qName);
    if (result != null) {
      return result.getStructure();
    }
    return null;
  }
  
  private void requiresApiComponent()
    throws CoreException
  {
    throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", Messages.ApiType_2));
  }
  
  public String getSuperclassName()
  {
    return fSuperclassName;
  }
  
  public void setSuperclassName(String superName)
  {
    fSuperclassName = superName;
  }
  
  public void setSimpleName(String simpleName)
  {
    fSimpleName = simpleName;
  }
  
  public boolean isAnnotation()
  {
    return (getModifiers() & 0x2000) != 0;
  }
  
  public boolean isAnonymous()
  {
    return fAnonymous;
  }
  
  public boolean isLocal()
  {
    return fLocal;
  }
  
  public IApiTypeRoot getTypeRoot()
  {
    return fStorage;
  }
  
  public void setAnonymous()
  {
    fAnonymous = true;
  }
  
  public void setMemberType()
  {
    fMemberType = true;
  }
  
  public void setLocal()
  {
    fLocal = true;
  }
  
  public void setEnclosingMethodInfo(String name, String signature)
  {
    if (name != null) {
      fEnclosingMethodName = name;
    } else {
      fEnclosingMethodName = "";
    }
    if (signature != null) {
      fEnclosingMethodSignature = signature;
    } else {
      fEnclosingMethodSignature = "";
    }
  }
  
  public IApiMethod getEnclosingMethod()
  {
    if (fEnclosingMethod == null) {
      try
      {
        IApiType enclosingType = getEnclosingType();
        if (fEnclosingMethodName != null)
        {
          if (fEnclosingMethodName != "") {
            fEnclosingMethod = enclosingType.getMethod(fEnclosingMethodName, fEnclosingMethodSignature);
          }
        }
        else
        {
          TypeStructureBuilder.setEnclosingMethod(enclosingType, this);
          if (fEnclosingMethodName != null) {
            fEnclosingMethod = enclosingType.getMethod(fEnclosingMethodName, fEnclosingMethodSignature);
          } else {
            fEnclosingMethodName = "";
          }
        }
      }
      catch (CoreException localCoreException) {}
    }
    return fEnclosingMethod;
  }
  
  public boolean isClass()
  {
    return (getModifiers() & 0x6200) == 0;
  }
  
  public boolean isEnum()
  {
    return (getModifiers() & 0x4000) != 0;
  }
  
  public boolean isInterface()
  {
    return (getModifiers() & 0x200) != 0;
  }
  
  public boolean isMemberType()
  {
    return fMemberType;
  }
  
  public IMemberDescriptor getHandle()
  {
    if (fHandle == null) {
      fHandle = Util.getType(getName());
    }
    return fHandle;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof IApiType))
    {
      IApiType type = (IApiType)obj;
      if (getApiComponent() == null) {
        return (type.getApiComponent() == null) && (getName().equals(type.getName()));
      }
      return (getApiComponent().equals(type.getApiComponent())) && (getName().equals(type.getName()));
    }
    return false;
  }
  
  public int hashCode()
  {
    IApiComponent component = getApiComponent();
    if (component == null) {
      return getName().hashCode();
    }
    return component.hashCode() + getName().hashCode();
  }
  
  public void addMemberType(String name, int modifiers)
  {
    if (fMemberTypes == null) {
      fMemberTypes = new HashMap();
    }
    int index = name.lastIndexOf('$');
    String simpleName = name.substring(index + 1);
    fMemberTypes.put(simpleName, null);
  }
  
  public IApiType getMemberType(String simpleName)
    throws CoreException
  {
    if (fMemberTypes == null) {
      return null;
    }
    if (getApiComponent() == null) {
      requiresApiComponent();
    }
    if (fMemberTypes.containsKey(simpleName))
    {
      IApiTypeRoot file = (IApiTypeRoot)fMemberTypes.get(simpleName);
      if (file == null)
      {
        StringBuffer qName = new StringBuffer();
        qName.append(getName());
        qName.append('$');
        qName.append(simpleName);
        file = getApiComponent().findTypeRoot(qName.toString());
        if (file == null) {
          throw new CoreException(new Status(4, "org.eclipse.pde.api.tools", 
            MessageFormat.format(Messages.ApiType_3, 
            new String[] { simpleName, getName() })));
        }
        fMemberTypes.put(simpleName, file);
      }
      return file.getStructure();
    }
    return null;
  }
  
  public IApiType[] getMemberTypes()
    throws CoreException
  {
    if (fMemberTypes == null) {
      return EMPTY_TYPES;
    }
    IApiType[] members = new IApiType[fMemberTypes.size()];
    Iterator iterator = fMemberTypes.keySet().iterator();
    int index = 0;
    while (iterator.hasNext())
    {
      String name = (String)iterator.next();
      members[index] = getMemberType(name);
      index++;
    }
    return members;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer
      .append("Type : access(")
      .append(getModifiers())
      .append(") ")
      .append(getName());
    if (getSuperclassName() != null) {
      buffer.append(" superclass: ").append(getSuperclassName());
    }
    if (getSuperInterfaceNames() != null)
    {
      buffer.append(" interfaces : ");
      if (getSuperInterfaceNames().length > 0) {
        for (int i = 0; i < getSuperInterfaceNames().length; i++)
        {
          if (i > 0) {
            buffer.append(',');
          }
          buffer.append(getSuperInterfaceNames()[i]);
        }
      } else {
        buffer.append("none");
      }
    }
    buffer.append(';').append(Util.LINE_DELIMITER);
    if (getGenericSignature() != null) {
      buffer.append(" Signature : ").append(getGenericSignature()).append(Util.LINE_DELIMITER);
    }
    buffer.append(Util.LINE_DELIMITER).append("Methods : ").append(Util.LINE_DELIMITER);
    IApiMethod[] methods = getMethods();
    for (int i = 0; i < methods.length; i++) {
      buffer.append(methods[i]);
    }
    buffer.append(Util.LINE_DELIMITER).append("Fields : ").append(Util.LINE_DELIMITER);
    IApiField[] fields = getFields();
    for (int i = 0; i < fields.length; i++) {
      buffer.append(fields[i]);
    }
    return String.valueOf(buffer);
  }
  
  public String getSimpleName()
  {
    if (isAnonymous()) {
      return null;
    }
    if ((isLocal()) || (isMemberType())) {
      return fSimpleName;
    }
    String name = getName();
    int index = name.lastIndexOf('.');
    if (index != -1) {
      return name.substring(index + 1);
    }
    return name;
  }
  
  public IApiType getEnclosingType()
    throws CoreException
  {
    if (fEnclosingType != null) {
      return fEnclosingType;
    }
    if (fEnclosingTypeName != null)
    {
      IApiTypeRoot root = getApiComponent().findTypeRoot(processEnclosingTypeName());
      if (root != null) {
        fEnclosingType = root.getStructure();
      }
    }
    return fEnclosingType;
  }
  
  private String processEnclosingTypeName()
  {
    if ((isLocal()) || (isAnonymous()))
    {
      int idx = fEnclosingTypeName.lastIndexOf('$');
      if (Character.isDigit(fEnclosingTypeName.charAt(idx + 1))) {
        return fEnclosingTypeName.substring(0, idx);
      }
    }
    return fEnclosingTypeName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ApiType
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.util.Util;

class ArchiveApiTypeContainer$ArchiveApiTypeRoot
  extends AbstractApiTypeRoot
  implements Comparable
{
  private String fTypeName;
  
  public ArchiveApiType
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

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