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

ring
    //   357	65	20	name	StringBuffer
    //   400	40	21	file	File
    //   577	17	22	localObject	Object
    //   540	3	23	io	IOException
    //   567	3	23	io	IOException
    //   586	3	23	io	IOException
    //   603	3	23	io	IOException
    // Exception table:
    //   from	to	target	type
    //   7	27	30	javax/xml/parsers/ParserConfigurationException
    //   7	27	43	javax/xml/parsers/FactoryConfigurationError
    //   53	520	523	java/io/IOException
    //   533	537	540	java/io/IOException
    //   53	520	550	org/xml/sax/SAXException
    //   560	564	567	java/io/IOException
    //   53	533	577	finally
    //   550	560	577	finally
    //   579	583	586	java/io/IOException
    //   596	600	603	java/io/IOException
  }
  
  public void saving(ISaveContext context)
    throws CoreException
  {
    if (!fNeedsSaving) {
      return;
    }
    try
    {
      persistStateCache();
      cleanStateCache();
      fNeedsSaving = false;
    }
    catch (IOException e)
    {
      ApiPlugin.log(e);
    }
  }
  
  private void cleanStateCache()
  {
    if (baselinecache != null)
    {
      IApiBaseline baseline = null;
      for (Iterator iter = baselinecache.keySet().iterator(); iter.hasNext();)
      {
        baseline = (IApiBaseline)baselinecache.get(iter.next());
        if (!baseline.getName().equals(defaultbaseline))
        {
          baseline.dispose();
          hasinfos.remove(baseline.getName());
        }
      }
    }
  }
  
  public boolean isExistingProfileName(String name)
  {
    if (baselinecache == null) {
      return false;
    }
    return baselinecache.keySet().contains(name);
  }
  
  /* Error */
  public void stop()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 551	org/eclipse/pde/api/tools/internal/ApiBaselineManager:baselinecache	Ljava/util/HashMap;
    //   4: ifnull +51 -> 55
    //   7: aload_0
    //   8: getfield 551	org/eclipse/pde/api/tools/internal/ApiBaselineManager:baselinecache	Ljava/util/HashMap;
    //   11: invokevirtual 591	java/util/HashMap:values	()Ljava/util/Collection;
    //   14: invokeinterface 644 1 0
    //   19: astore_1
    //   20: goto +19 -> 39
    //   23: aload_1
    //   24: invokeinterface 647 1 0
    //   29: checkcast 324	org/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline
    //   32: astore_2
    //   33: aload_2
    //   34: invokeinterface 663 1 0
    //   39: aload_1
    //   40: invokeinterface 646 1 0
    //   45: ifne -22 -> 23
    //   48: aload_0
    //   49: getfield 551	org/eclipse/pde/api/tools/internal/ApiBaselineManager:baselinecache	Ljava/util/HashMap;
    //   52: invokevirtual 589	java/util/HashMap:clear	()V
    //   55: aload_0
    //   56: dup
    //   57: astore_1
    //   58: monitorenter
    //   59: aload_0
    //   60: getfield 556	org/eclipse/pde/api/tools/internal/ApiBaselineManager:workspacebaseline	Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;
    //   63: ifnull +12 -> 75
    //   66: aload_0
    //   67: getfield 556	org/eclipse/pde/api/tools/internal/ApiBaselineManager:workspacebaseline	Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;
    //   70: invokeinterface 663 1 0
    //   75: aload_1
    //   76: monitorexit
    //   77: goto +6 -> 83
    //   80: aload_1
    //   81: monitorexit
    //   82: athrow
    //   83: aload_0
    //   84: getfield 552	org/eclipse/pde/api/tools/internal/ApiBaselineManager:handlecache	Ljava/util/HashMap;
    //   87: ifnull +10 -> 97
    //   90: aload_0
    //   91: getfield 552	org/eclipse/pde/api/tools/internal/ApiBaselineManager:handlecache	Ljava/util/HashMap;
    //   94: invokevirtual 589	java/util/HashMap:clear	()V
    //   97: aload_0
    //   98: getfield 553	org/eclipse/pde/api/tools/internal/ApiBaselineManager:hasinfos	Ljava/util/HashSet;
    //   101: ifnull +10 -> 111
    //   104: aload_0
    //   105: getfield 553	org/eclipse/pde/api/tools/internal/ApiBaselineManager:hasinfos	Ljava/util/HashSet;
    //   108: invokevirtual 596	java/util/HashSet:clear	()V
    //   111: invokestatic 630	org/eclipse/pde/api/tools/internal/model/StubApiComponent:disposeAllCaches	()V
    //   114: goto +19 -> 133
    //   117: astore_3
    //   118: invokestatic 632	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:isRunningInFramework	()Z
    //   121: ifeq +10 -> 131
    //   124: invokestatic 637	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:getDefault	()Lorg/eclipse/pde/api/tools/internal/provisional/ApiPlugin;
    //   127: aload_0
    //   128: invokevirtual 635	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:removeSaveParticipant	(Lorg/eclipse/core/resources/ISaveParticipant;)V
    //   131: aload_3
    //   132: athrow
    //   133: invokestatic 632	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:isRunningInFramework	()Z
    //   136: ifeq +10 -> 146
    //   139: invokestatic 637	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:getDefault	()Lorg/eclipse/pde/api/tools/internal/provisional/ApiPlugin;
    //   142: aload_0
    //   143: invokevirtual 635	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:removeSaveParticipant	(Lorg/eclipse/core/resources/ISaveParticipant;)V
    //   146: return
    // Line number table:
    //   Java source line #554	-> byte code offset #0
    //   Java source line #556	-> byte code offset #7
    //   Java source line #557	-> byte code offset #23
    //   Java source line #558	-> byte code offset #33
    //   Java source line #556	-> byte code offset #39
    //   Java source line #560	-> byte code offset #48
    //   Java source line #562	-> byte code offset #55
    //   Java source line #563	-> byte code offset #59
    //   Java source line #564	-> byte code offset #66
    //   Java source line #562	-> byte code offset #75
    //   Java source line #567	-> byte code offset #83
    //   Java source line #568	-> byte code offset #90
    //   Java source line #570	-> byte code offset #97
    //   Java source line #571	-> byte code offset #104
    //   Java source line #573	-> byte code offset #111
    //   Java source line #575	-> byte code offset #117
    //   Java source line #576	-> byte code offset #118
    //   Java source line #577	-> byte code offset #124
    //   Java source line #579	-> byte code offset #131
    //   Java source line #576	-> byte code offset #133
    //   Java source line #577	-> byte code offset #139
    //   Java source line #580	-> byte code offset #146
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	147	0	this	ApiBaselineManager
    //   19	21	1	iterator	Iterator
    //   32	2	2	baseline	IApiBaseline
    //   117	15	3	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   59	77	80	finally
    //   80	82	80	finally
    //   0	117	117	finally
  }
  
  public void doneSaving(ISaveContext context) {}
  
  public void prepareToSave(ISaveContext context)
    throws CoreException
  {}
  
  public void rollback(ISaveContext context) {}
  
  public synchronized IApiBaseline getDefaultApiBaseline()
  {
    initializeStateCache();
    return (IApiBaseline)baselinecache.get(defaultbaseline);
  }
  
  public void setDefaultApiBaseline(String name)
  {
    fNeedsSaving = true;
    defaultbaseline = name;
  }
  
  public synchronized IApiBaseline getWorkspaceBaseline()
  {
    if (ApiPlugin.isRunningInFramework())
    {
      if (workspacebaseline == null) {
        try
        {
          workspacebaseline = createWorkspaceBaseline();
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
      }
      return workspacebaseline;
    }
    return null;
  }
  
  synchronized void disposeWorkspaceBaseline()
  {
    if (workspacebaseline != null)
    {
      if (DEBUG) {
        System.out.println("disposing workspace baseline");
      }
      workspacebaseline.dispose();
      StubApiComponent.disposeAllCaches();
      workspacebaseline = null;
    }
  }
  
  /* Error */
  private IApiBaseline createWorkspaceBaseline()
    throws CoreException
  {
    // Byte code:
    //   0: invokestatic 585	java/lang/System:currentTimeMillis	()J
    //   3: lstore_1
    //   4: aconst_null
    //   5: astore_3
    //   6: new 321	org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline
    //   9: dup
    //   10: invokespecial 631	org/eclipse/pde/api/tools/internal/model/WorkspaceBaseline:<init>	()V
    //   13: astore_3
    //   14: invokestatic 640	org/eclipse/pde/core/plugin/PluginRegistry:getWorkspaceModels	()[Lorg/eclipse/pde/core/plugin/IPluginModelBase;
    //   17: aconst_null
    //   18: invokestatic 642	org/eclipse/pde/internal/core/DependencyManager:getSelfandDependencies	([Lorg/eclipse/pde/core/plugin/IPluginModelBase;[Ljava/lang/String;)Ljava/util/Set;
    //   21: astore 4
    //   23: new 294	java/util/ArrayList
    //   26: dup
    //   27: aload 4
    //   29: invokeinterface 651 1 0
    //   34: invokespecial 587	java/util/ArrayList:<init>	(I)V
    //   37: astore 5
    //   39: aconst_null
    //   40: astore 6
    //   42: aconst_null
    //   43: astore 7
    //   45: aload 4
    //   47: invokeinterface 653 1 0
    //   52: astore 8
    //   54: goto +59 -> 113
    //   57: aload 8
    //   59: invokeinterface 647 1 0
    //   64: checkcast 291	java/lang/String
    //   67: invokestatic 641	org/eclipse/pde/core/plugin/PluginRegistry:findModel	(Ljava/lang/String;)Lorg/eclipse/pde/core/plugin/IPluginModelBase;
    //   70: astore 7
    //   72: aload 7
    //   74: ifnonnull +6 -> 80
    //   77: goto +36 -> 113
    //   80: aload_3
    //   81: aload 7
    //   83: invokestatic 629	org/eclipse/pde/api/tools/internal/model/ApiModelFactory:newApiComponent	(Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiBaseline;Lorg/eclipse/pde/core/plugin/IPluginModelBase;)Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;
    //   86: astore 6
    //   88: aload 6
    //   90: ifnull +23 -> 113
    //   93: aload 5
    //   95: aload 6
    //   97: invokeinterface 649 2 0
    //   102: pop
    //   103: goto +10 -> 113
    //   106: astore 9
    //   108: aload 9
    //   110: invokestatic 633	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   113: aload 8
    //   115: invokeinterface 646 1 0
    //   120: ifne -63 -> 57
    //   123: aload_3
    //   124: aload 5
    //   126: aload 5
    //   128: invokeinterface 648 1 0
    //   133: anewarray 325	org/eclipse/pde/api/tools/internal/provisional/model/IApiComponent
    //   136: invokeinterface 650 2 0
    //   141: checkcast 281	[Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;
    //   144: invokeinterface 668 2 0
    //   149: goto +47 -> 196
    //   152: astore 10
    //   154: getstatic 548	org/eclipse/pde/api/tools/internal/ApiBaselineManager:DEBUG	Z
    //   157: ifeq +36 -> 193
    //   160: getstatic 546	java/lang/System:out	Ljava/io/PrintStream;
    //   163: new 292	java/lang/StringBuffer
    //   166: dup
    //   167: ldc_w 265
    //   170: invokespecial 581	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   173: invokestatic 585	java/lang/System:currentTimeMillis	()J
    //   176: lload_1
    //   177: lsub
    //   178: invokevirtual 583	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   181: ldc_w 274
    //   184: invokevirtual 584	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   187: invokevirtual 580	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   190: invokevirtual 573	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   193: aload 10
    //   195: athrow
    //   196: getstatic 548	org/eclipse/pde/api/tools/internal/ApiBaselineManager:DEBUG	Z
    //   199: ifeq +36 -> 235
    //   202: getstatic 546	java/lang/System:out	Ljava/io/PrintStream;
    //   205: new 292	java/lang/StringBuffer
    //   208: dup
    //   209: ldc_w 265
    //   212: invokespecial 581	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   215: invokestatic 585	java/lang/System:currentTimeMillis	()J
    //   218: lload_1
    //   219: lsub
    //   220: invokevirtual 583	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   223: ldc_w 274
    //   226: invokevirtual 584	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   229: invokevirtual 580	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   232: invokevirtual 573	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   235: aload_3
    //   236: areturn
    // Line number table:
    //   Java source line #650	-> byte code offset #0
    //   Java source line #651	-> byte code offset #4
    //   Java source line #653	-> byte code offset #6
    //   Java source line #655	-> byte code offset #14
    //   Java source line #656	-> byte code offset #23
    //   Java source line #657	-> byte code offset #39
    //   Java source line #658	-> byte code offset #42
    //   Java source line #659	-> byte code offset #45
    //   Java source line #660	-> byte code offset #57
    //   Java source line #661	-> byte code offset #72
    //   Java source line #662	-> byte code offset #77
    //   Java source line #665	-> byte code offset #80
    //   Java source line #666	-> byte code offset #88
    //   Java source line #667	-> byte code offset #93
    //   Java source line #669	-> byte code offset #106
    //   Java source line #670	-> byte code offset #108
    //   Java source line #659	-> byte code offset #113
    //   Java source line #673	-> byte code offset #123
    //   Java source line #674	-> byte code offset #152
    //   Java source line #675	-> byte code offset #154
    //   Java source line #676	-> byte code offset #160
    //   Java source line #678	-> byte code offset #193
    //   Java source line #675	-> byte code offset #196
    //   Java source line #676	-> byte code offset #202
    //   Java source line #679	-> byte code offset #235
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	237	0	this	ApiBaselineManager
    //   3	216	1	time	long
    //   5	231	3	baseline	IApiBaseline
    //   21	25	4	ids	Set
    //   37	90	5	componentsList	java.util.List
    //   40	56	6	apiComponent	IApiComponent
    //   43	39	7	model	org.eclipse.pde.core.plugin.IPluginModelBase
    //   52	62	8	iter	Iterator
    //   106	3	9	e	CoreException
    //   152	42	10	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   80	103	106	org/eclipse/core/runtime/CoreException
    //   6	152	152	finally
  }
  
  public synchronized IApiComponent getWorkspaceComponent(String symbolicName)
  {
    IApiBaseline baseline = getWorkspaceBaseline();
    if (baseline != null) {
      return baseline.getApiComponent(symbolicName);
    }
    return null;
  }
}

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

import java.io.PrintStream;
import java.util.HashMap;
import org.eclipse.pde.api.tools.internal.descriptors.ElementDescriptorImpl;
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
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.IMethodDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

class ApiDescription$ManifestNode
  implements Comparable
{
  protected IElementDescriptor element;
  protected int visibility;
  protected int restrictions;
  protected ManifestNode parent;
  protected HashMap children;
  final ApiDescription this$0;
  
  public ApiDescription$ManifestNode(ApiDescription paramApiDescription, ManifestNode parent, IElementDescriptor element, int visibility, int restrictions)
  {
    this$0 = paramApiDescription;this.element = null;this.parent = null;children = new HashMap(1);
    this.element = element;
    this.visibility = visibility;
    this.restrictions = restrictions;
    this.parent = parent;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ManifestNode)) {
      return element.equals(element);
    }
    return false;
  }
  
  public int hashCode()
  {
    return element.hashCode();
  }
  
  public String toString()
  {
    String type = null;
    String name = null;
    switch (element.getElementType())
    {
    case 5: 
      type = "Field";
      name = ((IMemberDescriptor)element).getName();
      break;
    case 6: 
      type = "Method";
      name = ((IMemberDescriptor)element).getName();
      break;
    case 1: 
      type = "Package";
      name = ((IPackageDescriptor)element).getName();
      break;
    case 2: 
      type = "Type";
      name = ((IMemberDescriptor)element).getName();
    }
    StringBuffer buffer = new StringBuffer();
    buffer.append(type == null ? "Unknown" : type).append(" Node: ").append(name == null ? "Unknown Name" : name);
    buffer.append("\nVisibility: ").append(VisibilityModifiers.getVisibilityName(visibility));
    buffer.append("\nRestrictions: ").append(RestrictionModifiers.getRestrictionText(restrictions));
    if (parent != null)
    {
      String pname = parent.element.getElementType() == 1 ? 
        ((IPackageDescriptor)parent.element).getName() : ((IMemberDescriptor)parent.element).getName();
      buffer.append("\nParent: ").append(pname);
    }
    return buffer.toString();
  }
  
  public int compareTo(Object o)
  {
    if ((o instanceof ManifestNode))
    {
      ManifestNode node = (ManifestNode)o;
      return ((ElementDescriptorImpl)element).compareTo(element);
    }
    return -1;
  }
  
  protected boolean hasApiVisibility(ManifestNode node)
  {
    if (ApiDescription.DEBUG) {
      System.out.println("Checking node for API visibility:" + node);
    }
    if (node != null)
    {
      if (VisibilityModifiers.isAPI(visibility)) {
        return true;
      }
      if (visibility == 0) {
        return hasApiVisibility(parent);
      }
    }
    return false;
  }
  
  protected ManifestNode refresh()
  {
    if (ApiDescription.DEBUG) {
      System.out.println("Refreshing manifest node: " + this);
    }
    return this;
  }
  
  void persistXML(Document document, Element parent)
  {
    if (RestrictionModifiers.isUnrestricted(restrictions)) {
      return;
    }
    switch (element.getElementType())
    {
    case 6: 
      IMethodDescriptor md = (IMethodDescriptor)element;
      Element method = document.createElement("method");
      method.setAttribute("name", md.getName());
      method.setAttribute("signature", md.getSignature());
      persistAnnotations(method);
      parent.appendChild(method);
      break;
    case 5: 
      IFieldDescriptor fd = (IFieldDescriptor)element;
      Element field = document.createElement("field");
      field.setAttribute("name", fd.getName());
      persistAnnotations(field);
      parent.appendChild(field);
    }
  }
  
  void persistAnnotations(Element element)
  {
    element.setAttribute("visibility", Integer.toString(visibility));
    element.setAttribute("restrictions", Integer.toString(restrictions));
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.pde.api.tools.internal.descriptors.ElementDescriptorImpl;
import org.eclipse.pde.api.tools.internal.provisional.ApiDescriptionVisitor;
import org.eclipse.pde.api.tools.internal.provisional.IApiAccess;
import org.eclipse.pde.api.tools.internal.provisional.IApiAnnotations;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.RestrictionModifiers;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
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.IMethodDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class ApiDescription
  implements IApiDescription
{
  protected static final int VISIBILITY_INHERITED = 0;
  static boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  protected String fOwningComponentId = null;
  private boolean fModified = false;
  
  class ManifestNode
    implements Comparable
  {
    protected IElementDescriptor element = null;
    protected int visibility;
    protected int restrictions;
    protected ManifestNode parent = null;
    protected HashMap children = new HashMap(1);
    
    public ManifestNode(ManifestNode parent, IElementDescriptor element, int visibility, int restrictions)
    {
      this.element = element;
      this.visibility = visibility;
      this.restrictions = restrictions;
      this.parent = parent;
    }
    
    public boolean equals(Object obj)
    {
      if ((obj instanceof ManifestNode)) {
        return element.equals(element);
      }
      return false;
    }
    
    public int hashCode()
    {
      return element.hashCode();
    }
    
    public String toString()
    {
      String type = null;
      String name = null;
      switch (element.getElementType())
      {
      case 5: 
        type = "Field";
        name = ((IMemberDescriptor)element).getName();
        break;
      case 6: 
        type = "Method";
        name = ((IMemberDescriptor)element).getName();
        break;
      case 1: 
        type = "Package";
        name = ((IPackageDescriptor)element).getName();
        break;
      case 2: 
        type = "Type";
        name = ((IMemberDescriptor)element).getName();
      }
      StringBuffer buffer = new StringBuffer();
      buffer.append(type == null ? "Unknown" : type).append(" Node: ").append(name == null ? "Unknown Name" : name);
      buffer.append("\nVisibility: ").append(VisibilityModifiers.getVisibilityName(visibility));
      buffer.append("\nRestrictions: ").append(RestrictionModifiers.getRestrictionText(restrictions));
      if (parent != null)
      {
        String pname = parent.element.getElementType() == 1 ? 
          ((IPackageDescriptor)parent.element).getName() : ((IMemberDescriptor)parent.element).getName();
        buffer.append("\nParent: ").append(pname);
      }
      return buffer.toString();
    }
    
    public int compareTo(Object o)
    {
      if ((o instanceof ManifestNode))
      {
        ManifestNode node = (ManifestNode)o;
        return ((ElementDescriptorImpl)element).compareTo(element);
      }
      return -1;
    }
    
    protected boolean hasApiVisibility(ManifestNode node)
    {
      if (ApiDescription.DEBUG) {
        System.out.println("Checking node for API visibility:" + node);
      }
      if (node != null)
      {
        if (VisibilityModifiers.isAPI(visibility)) {
          return true;
        }
        if (visibility == 0) {
          return hasApiVisibility(parent);
        }
      }
      return false;
    }
    
    protected ManifestNode refresh()
    {
      if (ApiDescription.DEBUG) {
        System.out.println("Refreshing manifest node: " + this);
      }
      return this;
    }
    
    void persistXML(Document document, Element parent)
    {
      if (RestrictionModifiers.isUnrestricted(restrictions)) {
        return;
      }
      switch (element.getElementType())
      {
      case 6: 
        IMethodDescriptor md = (IMethodDescriptor)element;
        Element method = document.createElement("method");
        method.setAttribute("name", md.getName());
        method.setAttribute("signature", md.getSignature());
        persistAnnotations(method);
        parent.appendChild(method);
        break;
      case 5: 
        IFieldDescriptor fd = (IFieldDescriptor)element;
        Element field = document.createElement("field");
        field.setAttribute("name", fd.getName());
        persistAnnotations(field);
        parent.appendChild(field);
      }
    }
    
    void persistAnnotations(Element element)
    {
      element.setAttribute("visibility", Integer.toString(visibility));
      element.setAttribute("restrictions", Integer.toString(restrictions));
    }
  }
  
  protected HashMap fPackageMap = new HashMap();
  protected HashMap fAccessMap = new HashMap();
  private float fEmbeddedVersion = 0.0F;
  
  public ApiDescription(String owningComponentId)
  {
    fOwningComponentId = owningComponentId;
  }
  
  public void accept(ApiDescriptionVisitor visitor, IProgressMonitor monitor)
  {
    visitChildren(visitor, fPackageMap, monitor);
  }
  
  protected void visitChildren(ApiDescriptionVisitor visitor, Map childrenMap, IProgressMonitor monitor)
  {
    List elements = new ArrayList(childrenMap.keySet());
    Collections.sort(elements);
    Iterator iterator = elements.iterator();
    while (iterator.hasNext())
    {
      Util.updateMonitor(monitor);
      IElementDescriptor element = (IElementDescriptor)iterator.next();
      ManifestNode node = (ManifestNode)childrenMap.get(element);
      visitNode(visitor, node);
    }
  }
  
  public boolean accept(ApiDescriptionVisitor visitor, IElementDescriptor element, IProgressMonitor monitor)
  {
    ManifestNode node = findNode(element, false);
    if (node != null)
    {
      visitNode(visitor, node);
      return true;
    }
    return false;
  }
  
  public int compareEmbeddedVersionTo(String version)
  {
    float lversion = Float.parseFloat(version);
    if (fEmbeddedVersion < lversion) {
      return 1;
    }
    if (fEmbeddedVersion == lversion) {
      return 0;
    }
    return -1;
  }
  
  public void setEmbeddedVersion(String version)
  {
    try
    {
      fEmbeddedVersion = Float.parseFloat(version);
    }
    catch (NumberFormatException localNumberFormatException)
    {
      fEmbeddedVersion = Float.parseFloat("1.2");
    }
  }
  
  private void visitNode(ApiDescriptionVisitor visitor, ManifestNode node)
  {
    int vis = visibility;
    ManifestNode tmp = node;
    while (tmp != null)
    {
      vis = visibility;
      if (visibility == 0) {
        tmp = parent;
      } else {
        tmp = null;
      }
    }
    IApiAnnotations desc = new ApiAnnotations(vis, restrictions);
    boolean visitChildren = visitor.visitElement(element, desc);
    if ((visitChildren) && (!children.isEmpty())) {
      visitChildren(visitor, children, null);
    }
    visitor.endVisitElement(element, desc);
  }
  
  protected ManifestNode findNode(IElementDescriptor element, boolean write)
  {
    if (DEBUG)
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Looking up manifest node for element: ");
      buffer.append(element);
      System.out.println(buffer.toString());
    }
    IElementDescriptor[] path = element.getPath();
    Map map = fPackageMap;
    ManifestNode parentNode = null;
    ManifestNode node = null;
    for (int i = 0; i < path.length; i++)
    {
      IElementDescriptor current = path[i];
      parentNode = node;
      node = (ManifestNode)map.get(current);
      if (node == null) {
        if ((write) || (isInsertOnResolve(current)))
        {
          node = createNode(parentNode, current);
          if (node != null) {
            map.put(current, node);
          } else {
            return null;
          }
        }
        else
        {
          if (DEBUG)
          {
            StringBuffer buffer = new StringBuffer();
            buffer.append("Returning parent manifest node: ");
            buffer.append(parentNode);
            buffer.append(" when looking for element");
            buffer.append(element);
            System.out.println(buffer.toString());
          }
          return parentNode;
        }
      }
      node = node.refresh();
      if (node != null) {
        map = children;
      }
    }
    if (DEBUG)
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Manifest node found: ");
      buffer.append(node);
      buffer.append(" when looking for element");
      buffer.append(element);
      System.out.println(buffer.toString());
    }
    return node;
  }
  
  public IApiAnnotations resolveAnnotations(IElementDescriptor element)
  {
    ManifestNode node = findNode(element, false);
    if (node != null) {
      return resolveAnnotations(node, element);
    }
    if (DEBUG)
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Tried to resolve annotations for manifest node: ");
      buffer.append(node);
      buffer.append(" but the node could not be found.");
      System.out.println(buffer.toString());
    }
    return null;
  }
  
  protected int resolveVisibility(ManifestNode node)
  {
    ManifestNode visNode = node;
    int vis = visibility;
    while (vis == 0)
    {
      visNode = parent;
      vis = visibility;
    }
    return vis;
  }
  
  protected IApiAnnotations resolveAnnotations(ManifestNode node, IElementDescriptor element)
  {
    int vis = resolveVisibility(node);
    int res = 0;
    if (element.equals(element)) {
      res = restrictions;
    }
    if (DEBUG)
    {
      StringBuffer stringBuffer = new StringBuffer();
      stringBuffer.append("Resolved annotations for manifest node: ");
      stringBuffer.append(node);
      stringBuffer.append(" to be: ");
      stringBuffer.append(VisibilityModifiers.getVisibilityName(vis));
      stringBuffer.append(" ");
      stringBuffer.append(RestrictionModifiers.getRestrictionText(res));
      System.out.println(stringBuffer.toString());
    }
    return new ApiAnnotations(vis, res);
  }
  
  protected void clearPackages()
  {
    if (fPackageMap != null)
    {
      if (DEBUG) {
        System.out.println("Clearing package map");
      }
      fPackageMap.clear();
    }
  }
  
  protected ManifestNode createNode(ManifestNode parentNode, IElementDescriptor element)
  {
    int vis = 0;
    if (element.getElementType() == 1) {
      vis = 1;
    }
    if (DEBUG)
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Creating new manifest node for element: ");
      buffer.append(element);
      buffer.append(" and adding it to parent node: ");
      buffer.append(parentNode);
      System.out.println(buffer.toString());
    }
    return new ManifestNode(parentNode, element, vis, 0);
  }
  
  public IStatus setRestrictions(IElementDescriptor element, int restrictions)
  {
    ManifestNode node = findNode(element, true);
    if (node != null)
    {
      if (DEBUG)
      {
        StringBuffer buffer = new StringBuffer();
        buffer.append("Setting restrictions for manifest node: ");
        buffer.append(node);
        buffer.append(" to be ");
        buffer.append(RestrictionModifiers.getRestrictionText(restrictions));
        System.out.println(buffer.toString());
      }
      modified();
      restrictions = restrictions;
      return Status.OK_STATUS;
    }
    return new Status(4, "org.eclipse.pde.api.tools", 100, 
      MessageFormat.format("Failed to set API restriction: {0} not found in {1}", 
      new String[] { element.toString(), fOwningComponentId }), null);
  }
  
  public IStatus setVisibility(IElementDescriptor element, int visibility)
  {
    ManifestNode node = findNode(element, true);
    if (node != null)
    {
      if (DEBUG)
      {
        StringBuffer buffer = new StringBuffer();
        buffer.append("Setting visibility for manifest node: ");
        buffer.append(node);
        buffer.append(" to be ");
        buffer.append(VisibilityModifiers.getVisibilityName(visibility));
        System.out.println(buffer.toString());
      }
      modified();
      visibility = visibility;
      return Status.OK_STATUS;
    }
    return new Status(4, "org.eclipse.pde.api.tools", 100, 
      MessageFormat.format("Failed to set API visibility: {0} not found in {1}", 
      new String[] { element.toString(), fOwningComponentId }), null);
  }
  
  public IStatus setAddedProfile(IElementDescriptor element, int addedProfile)
  {
    return Status.OK_STATUS;
  }
  
  public IStatus setRemovedProfile(IElementDescriptor element, int removedProfile)
  {
    return Status.OK_STATUS;
  }
  
  public IStatus setSuperclass(IElementDescriptor element, String superclass)
  {
    return Status.OK_STATUS;
  }
  
  public IStatus setSuperinterfaces(IElementDescriptor element, String superinterfaces)
  {
    return Status.OK_STATUS;
  }
  
  public IStatus setInterface(IElementDescriptor element, boolean interfaceFlag)
  {
    return Status.OK_STATUS;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("API description for component: ").append(fOwningComponentId);
    return buffer.toString();
  }
  
  protected boolean isInsertOnResolve(IElementDescriptor elementDescriptor)
  {
    return false;
  }
  
  protected synchronized void modified()
  {
    fModified = true;
  }
  
  protected synchronized boolean isModified()
  {
    return fModified;
  }
  
  public IApiAccess resolveAccessLevel(IElementDescriptor element, IPackageDescriptor pelement)
  {
    if (fAccessMap != null)
    {
      HashMap map = (HashMap)fAccessMap.get(pelement);
      if (map != null) {
        return (IApiAccess)map.get(element);
      }
    }
    return null;
  }
  
  public void setAccessLevel(IElementDescriptor element, IPackageDescriptor pelement, int access)
  {
    if ((element != null) && (pelement != null) && (access != 0))
    {
      if (fAccessMap == null) {
        fAccessMap = new HashMap();
      }
      HashMap map = (HashMap)fAccessMap.get(pelement);
      if (map == null)
      {
        map = new HashMap();
        fAccessMap.put(pelement, map);
      }
      map.put(element, new ApiAccess(access));
    }
  }
}

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

import com.ibm.icu.text.MessageFormat;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.api.tools.internal.model.ApiModelCache;
import org.eclipse.pde.api.tools.internal.model.ProjectComponent;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.scanner.ScannerMessages;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public final class ApiDescriptionManager
  implements ISaveParticipant
{
  private static ApiDescriptionManager fgDefault;
  private Map fDescriptions = new HashMap();
  public static final IPath API_DESCRIPTIONS_CONTAINER_PATH = ApiPlugin.getDefault().getStateLocation();
  
  private ApiDescriptionManager()
  {
    ApiPlugin.getDefault().addSaveParticipant(this);
  }
  
  public static void shutdown()
  {
    if (fgDefault != null) {
      ApiPlugin.getDefault().removeSaveParticipant(fgDefault);
    }
  }
  
  public static synchronized ApiDescriptionManager getManager()
  {
    if (fgDefault == null) {
      fgDefault = new ApiDescriptionManager();
    }
    return fgDefault;
  }
  
  public synchronized IApiDescription getApiDescription(ProjectComponent component, BundleDescription bundle)
  {
    IJavaProject project = component.getJavaProject();
    ProjectApiDescription description = (ProjectApiDescription)fDescriptions.get(project);
    if (description == null)
    {
      if (Util.isApiProject(project)) {
        description = new ProjectApiDescription(project);
      } else {
        description = new NonApiProjectDescription(project);
      }
      try
      {
        restoreDescription(project, description);
      }
      catch (CoreException e)
      {
        ApiPlugin.log(e.getStatus());
        description = new ProjectApiDescription(project);
      }
      fDescriptions.put(project, description);
    }
    return description;
  }
  
  public synchronized void clean(IJavaProject project, boolean delete, boolean remove)
  {
    ProjectApiDescription desc = null;
    if (remove) {
      desc = (ProjectApiDescription)fDescriptions.remove(project);
    } else {
      desc = (ProjectApiDescription)fDescriptions.get(project);
    }
    if (desc != null) {
      desc.clean();
    }
    if (delete)
    {
      File file = API_DESCRIPTIONS_CONTAINER_PATH.append(project.getElementName())
        .append(".api_description").toFile();
      if (file.exists()) {
        file.delete();
      }
      file = API_DESCRIPTIONS_CONTAINER_PATH.append(project.getElementName()).toFile();
      if ((file.exists()) && (file.isDirectory())) {
        file.delete();
      }
    }
  }
  
  synchronized void projectChanged(IJavaProject project)
  {
    ProjectApiDescription desc = (ProjectApiDescription)fDescriptions.get(project);
    if (desc != null) {
      desc.projectChanged();
    }
  }
  
  synchronized void projectClasspathChanged(IJavaProject project)
  {
    ProjectApiDescription desc = (ProjectApiDescription)fDescriptions.get(project);
    if (desc != null) {
      desc.projectClasspathChanged();
    }
  }
  
  void flushElementCache(IJavaElement element)
  {
    switch (element.getElementType())
    {
    case 5: 
      ICompilationUnit unit = (ICompilationUnit)element;
      IType type = unit.findPrimaryType();
      if (type != null) {
        ApiModelCache.getCache().removeElementInfo(
          "workspace", 
          element.getJavaProject().getElementName(), 
          type.getFullyQualifiedName(), 
          2);
      }
      break;
    case 2: 
      ApiModelCache.getCache().removeElementInfo(
        "workspace", 
        element.getElementName(), 
        null, 
   
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-2017. Infinite Loop Ltd