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

 
  public int getTotalApiRefCount()
  {
    return total_api_field_count + total_api_method_count + total_api_type_count;
  }
  
  public int getTotalInternalRefCount()
  {
    return total_private_field_count + total_private_method_count + total_private_type_count;
  }
  
  public int getTotalPermissableRefCount()
  {
    return total_permissable_field_count + total_permissable_method_count + total_permissable_type_count;
  }
  
  public int getTotalFragmentPermissibleRefCount()
  {
    return total_fragment_permissible_field_count + total_fragment_permissible_method_count + total_fragment_permissible_type_count;
  }
  
  public int getTotalIllegalRefCount()
  {
    return total_illegal_field_count + total_illegal_method_count + total_illegal_type_count;
  }
}

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

import java.util.TreeMap;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;

class UseReportConverter$Member
{
  IElementDescriptor descriptor = null;
  TreeMap children = new TreeMap(UseReportConverter.compare);
  UseReportConverter.CountGroup counts = new UseReportConverter.CountGroup();
  
  public UseReportConverter$Member(IElementDescriptor desc)
  {
    descriptor = desc;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

final class UseReportConverter$MissingHandler
  extends DefaultHandler
{
  List missing = new ArrayList();
  static String pattern = "Require-Bundle:";
  
  public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
  {
    if ("component".equals(qName))
    {
      String value = attributes.getValue("details");
      StringTokenizer tokenizer = new StringTokenizer(value, "<>");
      int index = -1;
      while (tokenizer.hasMoreTokens())
      {
        value = tokenizer.nextToken();
        index = value.indexOf(pattern);
        if (index > -1) {
          missing.add(value.replaceAll(pattern, ""));
        }
      }
    }
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;

class UseReportConverter$Reference
{
  IElementDescriptor desc = null;
  int line = -1;
  int vis = -1;
  String message = null;
  
  public UseReportConverter$Reference(IElementDescriptor desc, int line, int vis, String message)
  {
    this.desc = desc;
    this.line = line;
    this.vis = vis;
    this.message = message;
  }
}

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

import java.util.TreeMap;

class UseReportConverter$Report
{
  String name = null;
  TreeMap children = new TreeMap(UseReportConverter.compare);
  UseReportConverter.CountGroup counts = new UseReportConverter.CountGroup();
}

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

import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor;

class UseReportConverter$Type
{
  IElementDescriptor desc = null;
  UseReportConverter.CountGroup counts = new UseReportConverter.CountGroup();
  
  public UseReportConverter$Type(IElementDescriptor desc)
  {
    this.desc = desc;
  }
}

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

import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IMemberDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IReferenceTypeDescriptor;

class UseReportConverter$Visitor
  extends UseScanVisitor
{
  ArrayList reports;
  UseReportConverter.Report currentreport;
  UseReportConverter.Type currenttype;
  UseReportConverter.Type currentreferee;
  UseReportConverter.Member currentmember;
  HashMap keys;
  ArrayList referees;
  final UseReportConverter this$0;
  
  UseReportConverter$Visitor(UseReportConverter paramUseReportConverter)
  {
    this$0 = paramUseReportConverter;
    
    reports = new ArrayList();
    currentreport = null;
    currenttype = null;currentreferee = null;
    currentmember = null;
    keys = new HashMap();
    referees = new ArrayList();
  }
  
  private boolean acceptReference(IMemberDescriptor desc, Pattern[] patterns)
  {
    if (patterns != null) {
      for (int i = 0; i < patterns.length; i++) {
        if (patterns[i].matcher(desc.getPackage().getName()).find()) {
          return false;
        }
      }
    }
    return true;
  }
  
  IReferenceTypeDescriptor getEnclosingDescriptor(IMemberDescriptor member)
  {
    switch (member.getElementType())
    {
    case 2: 
      return (IReferenceTypeDescriptor)member;
    case 5: 
    case 6: 
      return member.getEnclosingType();
    }
    return null;
  }
  
  public boolean visitComponent(IComponentDescriptor target)
  {
    currentreport = new UseReportConverter.Report();
    currentreport.name = this$0.composeName(target.getId(), target.getVersion());
    reports.add(currentreport);
    return true;
  }
  
  /* Error */
  public void endVisitComponent(IComponentDescriptor target)
  {
    // Byte code:
    //   0: lconst_0
    //   1: lstore_2
    //   2: getstatic 275	org/eclipse/pde/api/tools/internal/search/UseReportConverter:DEBUG	Z
    //   5: ifeq +34 -> 39
    //   8: getstatic 274	java/lang/System:out	Ljava/io/PrintStream;
    //   11: new 136	java/lang/StringBuffer
    //   14: dup
    //   15: ldc 3
    //   17: invokespecial 311	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   20: aload_1
    //   21: invokeinterface 345 1 0
    //   26: invokevirtual 313	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   29: invokevirtual 310	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   32: invokevirtual 308	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   35: invokestatic 314	java/lang/System:currentTimeMillis	()J
    //   38: lstore_2
    //   39: aload_0
    //   40: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   43: getfield 298	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:counts	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$CountGroup;
    //   46: invokevirtual 336	org/eclipse/pde/api/tools/internal/search/UseReportConverter$CountGroup:getTotalRefCount	()I
    //   49: ifle +21 -> 70
    //   52: aload_0
    //   53: getfield 303	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:this$0	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter;
    //   56: aload_0
    //   57: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   60: aload_0
    //   61: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
    //   64: invokevirtual 334	org/eclipse/pde/api/tools/internal/search/UseReportConverter:writeReferencedMemberPage	(Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;Ljava/util/List;)V
    //   67: goto +15 -> 82
    //   70: aload_0
    //   71: getfield 301	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:reports	Ljava/util/ArrayList;
    //   74: aload_0
    //   75: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   78: invokevirtual 318	java/util/ArrayList:remove	(Ljava/lang/Object;)Z
    //   81: pop
    //   82: getstatic 275	org/eclipse/pde/api/tools/internal/search/UseReportConverter:DEBUG	Z
    //   85: ifeq +98 -> 183
    //   88: getstatic 274	java/lang/System:out	Ljava/io/PrintStream;
    //   91: new 136	java/lang/StringBuffer
    //   94: dup
    //   95: ldc 4
    //   97: invokespecial 311	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   100: invokestatic 314	java/lang/System:currentTimeMillis	()J
    //   103: lload_2
    //   104: lsub
    //   105: invokevirtual 312	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   108: ldc 2
    //   110: invokevirtual 313	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   113: invokevirtual 310	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   116: invokevirtual 308	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   119: goto +64 -> 183
    //   122: astore_2
    //   123: aload_2
    //   124: invokestatic 333	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   127: aload_0
    //   128: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   131: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
    //   134: invokevirtual 325	java/util/TreeMap:clear	()V
    //   137: aload_0
    //   138: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
    //   141: invokevirtual 320	java/util/HashMap:clear	()V
    //   144: aload_0
    //   145: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
    //   148: invokevirtual 316	java/util/ArrayList:clear	()V
    //   151: goto +56 -> 207
    //   154: astore 4
    //   156: aload_0
    //   157: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   160: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
    //   163: invokevirtual 325	java/util/TreeMap:clear	()V
    //   166: aload_0
    //   167: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
    //   170: invokevirtual 320	java/util/HashMap:clear	()V
    //   173: aload_0
    //   174: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
    //   177: invokevirtual 316	java/util/ArrayList:clear	()V
    //   180: aload 4
    //   182: athrow
    //   183: aload_0
    //   184: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
    //   187: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
    //   190: invokevirtual 325	java/util/TreeMap:clear	()V
    //   193: aload_0
    //   194: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
    //   197: invokevirtual 320	java/util/HashMap:clear	()V
    //   200: aload_0
    //   201: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
    //   204: invokevirtual 316	java/util/ArrayList:clear	()V
    //   207: return
    // Line number table:
    //   Java source line #143	-> byte code offset #0
    //   Java source line #144	-> byte code offset #2
    //   Java source line #145	-> byte code offset #8
    //   Java source line #146	-> byte code offset #35
    //   Java source line #148	-> byte code offset #39
    //   Java source line #149	-> byte code offset #52
    //   Java source line #152	-> byte code offset #70
    //   Java source line #154	-> byte code offset #82
    //   Java source line #155	-> byte code offset #88
    //   Java source line #158	-> byte code offset #122
    //   Java source line #159	-> byte code offset #123
    //   Java source line #163	-> byte code offset #127
    //   Java source line #164	-> byte code offset #137
    //   Java source line #165	-> byte code offset #144
    //   Java source line #161	-> byte code offset #154
    //   Java source line #163	-> byte code offset #156
    //   Java source line #164	-> byte code offset #166
    //   Java source line #165	-> byte code offset #173
    //   Java source line #166	-> byte code offset #180
    //   Java source line #163	-> byte code offset #183
    //   Java source line #164	-> byte code offset #193
    //   Java source line #165	-> byte code offset #200
    //   Java source line #167	-> byte code offset #207
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	208	0	this	Visitor
    //   0	208	1	target	IComponentDescriptor
    //   1	103	2	start	long
    //   122	2	2	e	Exception
    //   154	27	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	119	122	java/lang/Exception
    //   0	127	154	finally
  }
  
  public boolean visitReferencingComponent(IComponentDescriptor component)
  {
    currentreferee = new UseReportConverter.Type(component);
    return true;
  }
  
  public void endVisitReferencingComponent(IComponentDescriptor component)
  {
    if (currentreferee.counts.getTotalRefCount() > 0) {
      referees.add(currentreferee);
    }
  }
  
  public boolean visitMember(IMemberDescriptor referencedMember)
  {
    IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
    if (desc == null) {
      return false;
    }
    currenttype = ((UseReportConverter.Type)keys.get(desc));
    if (currenttype == null)
    {
      currenttype = new UseReportConverter.Type(desc);
      keys.put(desc, currenttype);
    }
    TreeMap map = (TreeMap)currentreport.children.get(currenttype);
    if (map == null)
    {
      map = new TreeMap(UseReportConverter.compare);
      currentreport.children.put(currenttype, map);
    }
    currentmember = ((UseReportConverter.Member)map.get(referencedMember));
    if (currentmember == null)
    {
      currentmember = new UseReportConverter.Member(referencedMember);
      map.put(referencedMember, currentmember);
    }
    return true;
  }
  
  public void endVisitMember(IMemberDescriptor referencedMember)
  {
    if (currentmember.children.size() == 0)
    {
      TreeMap map = (TreeMap)currentreport.children.get(currenttype);
      map.remove(referencedMember);
    }
    if (currenttype.counts.getTotalRefCount() == 0)
    {
      IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
      if (desc != null)
      {
        keys.remove(desc);
        currentreport.children.remove(currenttype);
      }
    }
  }
  
  String formatMessages(String[] messages)
  {
    if (messages != null)
    {
      StringBuffer buffer = new StringBuffer();
      for (int i = 0; i < messages.length; i++)
      {
        buffer.append(messages[i]);
        if (i < messages.length - 1) {
          buffer.append("\n");
        }
      }
      return buffer.toString();
    }
    return null;
  }
  
  public void visitReference(IReferenceDescriptor reference)
  {
    IMemberDescriptor fromMember = reference.getMember();
    if ((!acceptReference(reference.getReferencedMember(), this$0.topatterns)) || 
      (!acceptReference(fromMember, this$0.frompatterns))) {
      return;
    }
    int lineNumber = reference.getLineNumber();
    int refKind = reference.getReferenceKind();
    int visibility = reference.getVisibility();
    String refname = Reference.getReferenceText(refKind);
    ArrayList refs = (ArrayList)currentmember.children.get(refname);
    if (refs == null)
    {
      refs = new ArrayList();
      currentmember.children.put(refname, refs);
    }
    refs.add(new UseReportConverter.Reference(fromMember, lineNumber, visibility, formatMessages(reference.getProblemMessages())));
    switch (fromMember.getElementType())
    {
    case 2: 
      switch (visibility)
      {
      case 1: 
        currentmember.counts.total_api_type_count += 1;
        currenttype.counts.total_api_type_count += 1;
        currentreferee.counts.total_api_type_count += 1;
        currentreport.counts.total_api_type_count += 1;
        break;
      case 2: 
        currentmember.counts.total_private_type_count += 1;
        currenttype.counts.total_private_type_count += 1;
        currentreferee.counts.total_private_type_count += 1;
        currentreport.counts.total_private_type_count += 1;
        break;
      case 8: 
        currentmember.counts.total_permissable_type_count += 1;
        currenttype.counts.total_permissable_type_count += 1;
        currentreferee.counts.total_permissable_type_count += 1;
        currentreport.counts.total_permissable_type_count += 1;
        break;
      case 5: 
        currentmember.counts.total_fragment_permissible_type_count += 1;
        currenttype.counts.total_fragment_permissible_type_count += 1;
        currentreferee.counts.total_fragment_permissible_type_count += 1;
        currentreport.counts.total_fragment_permissible_type_count += 1;
        break;
      case 22: 
        currentmember.counts.total_illegal_type_count += 1;
        currenttype.counts.total_illegal_type_count += 1;
        currentreferee.counts.total_illegal_type_count += 1;
        currentreport.counts.total_illegal_type_count += 1;
      }
      break;
    case 6: 
      switch (visibility)
      {
      case 1: 
        currentmember.counts.total_api_method_count += 1;
        currenttype.counts.total_api_method_count += 1;
        currentreferee.counts.total_api_method_count += 1;
        currentreport.counts.total_api_method_count += 1;
        break;
      case 2: 
        currentmember.counts.total_private_method_count += 1;
        currenttype.counts.total_private_method_count += 1;
        currentreferee.counts.total_private_method_count += 1;
        currentreport.counts.total_private_method_count += 1;
        break;
      case 8: 
        currentmember.counts.total_permissable_method_count += 1;
        currenttype.counts.total_permissable_method_count += 1;
        currentreferee.counts.total_permissable_method_count += 1;
        currentreport.counts.total_permissable_method_count += 1;
        break;
      case 5: 
        currentmember.counts.total_fragment_permissible_method_count += 1;
        currenttype.counts.total_fragment_permissible_method_count += 1;
        currentreferee.counts.total_fragment_permissible_method_count += 1;
        currentreport.counts.total_fragment_permissible_method_count += 1;
        break;
      case 22: 
        currentmember.counts.total_illegal_method_count += 1;
        currenttype.counts.total_illegal_method_count += 1;
        currentreferee.counts.total_illegal_method_count += 1;
        currentreport.counts.total_illegal_method_count += 1;
      }
      break;
    case 5: 
      switch (visibility)
      {
      case 1: 
        currentmember.counts.total_api_field_count += 1;
        currenttype.counts.total_api_field_count += 1;
        currentreferee.counts.total_api_field_count += 1;
        currentreport.counts.total_api_field_count += 1;
        break;
      case 2: 
        currentmember.counts.total_private_field_count += 1;
        currenttype.counts.total_private_field_count += 1;
        currentreferee.counts.total_private_field_count += 1;
        currentreport.counts.total_private_field_count += 1;
        break;
      case 8: 
        currentmember.counts.total_permissable_field_count += 1;
        currenttype.counts.total_permissable_field_count += 1;
        currentreferee.counts.total_permissable_field_count += 1;
        currentreport.counts.total_permissable_field_count += 1;
        break;
      case 5: 
        currentmember.counts.total_fragment_permissible_field_count += 1;
        currenttype.counts.total_fragment_permissible_field_count += 1;
        currentreferee.counts.total_fragment_permissible_field_count += 1;
        currentreport.counts.total_fragment_permissible_field_count += 1;
        break;
      case 22: 
        currentmember.counts.total_illegal_field_count += 1;
        currenttype.counts.total_illegal_field_count += 1;
        currentreferee.counts.total_illegal_field_count += 1;
        currentreport.counts.total_illegal_field_count += 1;
      }
      break;
    }
  }
}

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

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
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.jdt.core.Signature;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.builder.Reference;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.VisibilityModifiers;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IComponentDescriptor;
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.provisional.descriptors.IReferenceTypeDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.search.IMetadata;
import org.eclipse.pde.api.tools.internal.util.Signatures;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.osgi.framework.Version;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class UseReportConverter
  extends HTMLConvertor
{
  class Visitor
    extends UseScanVisitor
  {
    ArrayList reports = new ArrayList();
    UseReportConverter.Report currentreport = null;
    UseReportConverter.Type currenttype = null;
    UseReportConverter.Type currentreferee = null;
    UseReportConverter.Member currentmember = null;
    HashMap keys = new HashMap();
    ArrayList referees = new ArrayList();
    
    Visitor() {}
    
    private boolean acceptReference(IMemberDescriptor desc, Pattern[] patterns)
    {
      if (patterns != null) {
        for (int i = 0; i < patterns.length; i++) {
          if (patterns[i].matcher(desc.getPackage().getName()).find()) {
            return false;
          }
        }
      }
      return true;
    }
    
    IReferenceTypeDescriptor getEnclosingDescriptor(IMemberDescriptor member)
    {
      switch (member.getElementType())
      {
      case 2: 
        return (IReferenceTypeDescriptor)member;
      case 5: 
      case 6: 
        return member.getEnclosingType();
      }
      return null;
    }
    
    public boolean visitComponent(IComponentDescriptor target)
    {
      currentreport = new UseReportConverter.Report();
      currentreport.name = composeName(target.getId(), target.getVersion());
      reports.add(currentreport);
      return true;
    }
    
    /* Error */
    public void endVisitComponent(IComponentDescriptor target)
    {
      // Byte code:
      //   0: lconst_0
      //   1: lstore_2
      //   2: getstatic 275	org/eclipse/pde/api/tools/internal/search/UseReportConverter:DEBUG	Z
      //   5: ifeq +34 -> 39
      //   8: getstatic 274	java/lang/System:out	Ljava/io/PrintStream;
      //   11: new 136	java/lang/StringBuffer
      //   14: dup
      //   15: ldc 3
      //   17: invokespecial 311	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
      //   20: aload_1
      //   21: invokeinterface 345 1 0
      //   26: invokevirtual 313	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
      //   29: invokevirtual 310	java/lang/StringBuffer:toString	()Ljava/lang/String;
      //   32: invokevirtual 308	java/io/PrintStream:println	(Ljava/lang/String;)V
      //   35: invokestatic 314	java/lang/System:currentTimeMillis	()J
      //   38: lstore_2
      //   39: aload_0
      //   40: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   43: getfield 298	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:counts	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$CountGroup;
      //   46: invokevirtual 336	org/eclipse/pde/api/tools/internal/search/UseReportConverter$CountGroup:getTotalRefCount	()I
      //   49: ifle +21 -> 70
      //   52: aload_0
      //   53: getfield 303	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:this$0	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter;
      //   56: aload_0
      //   57: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   60: aload_0
      //   61: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
      //   64: invokevirtual 334	org/eclipse/pde/api/tools/internal/search/UseReportConverter:writeReferencedMemberPage	(Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;Ljava/util/List;)V
      //   67: goto +15 -> 82
      //   70: aload_0
      //   71: getfield 301	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:reports	Ljava/util/ArrayList;
      //   74: aload_0
      //   75: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   78: invokevirtual 318	java/util/ArrayList:remove	(Ljava/lang/Object;)Z
      //   81: pop
      //   82: getstatic 275	org/eclipse/pde/api/tools/internal/search/UseReportConverter:DEBUG	Z
      //   85: ifeq +98 -> 183
      //   88: getstatic 274	java/lang/System:out	Ljava/io/PrintStream;
      //   91: new 136	java/lang/StringBuffer
      //   94: dup
      //   95: ldc 4
      //   97: invokespecial 311	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
      //   100: invokestatic 314	java/lang/System:currentTimeMillis	()J
      //   103: lload_2
      //   104: lsub
      //   105: invokevirtual 312	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
      //   108: ldc 2
      //   110: invokevirtual 313	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
      //   113: invokevirtual 310	java/lang/StringBuffer:toString	()Ljava/lang/String;
      //   116: invokevirtual 308	java/io/PrintStream:println	(Ljava/lang/String;)V
      //   119: goto +64 -> 183
      //   122: astore_2
      //   123: aload_2
      //   124: invokestatic 333	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
      //   127: aload_0
      //   128: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   131: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
      //   134: invokevirtual 325	java/util/TreeMap:clear	()V
      //   137: aload_0
      //   138: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
      //   141: invokevirtual 320	java/util/HashMap:clear	()V
      //   144: aload_0
      //   145: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
      //   148: invokevirtual 316	java/util/ArrayList:clear	()V
      //   151: goto +56 -> 207
      //   154: astore 4
      //   156: aload_0
      //   157: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   160: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
      //   163: invokevirtual 325	java/util/TreeMap:clear	()V
      //   166: aload_0
      //   167: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
      //   170: invokevirtual 320	java/util/HashMap:clear	()V
      //   173: aload_0
      //   174: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
      //   177: invokevirtual 316	java/util/ArrayList:clear	()V
      //   180: aload 4
      //   182: athrow
      //   183: aload_0
      //   184: getfield 305	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:currentreport	Lorg/eclipse/pde/api/tools/internal/search/UseReportConverter$Report;
      //   187: getfield 297	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Report:children	Ljava/util/TreeMap;
      //   190: invokevirtual 325	java/util/TreeMap:clear	()V
      //   193: aload_0
      //   194: getfield 302	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:keys	Ljava/util/HashMap;
      //   197: invokevirtual 320	java/util/HashMap:clear	()V
      //   200: aload_0
      //   201: getfield 300	org/eclipse/pde/api/tools/internal/search/UseReportConverter$Visitor:referees	Ljava/util/ArrayList;
      //   204: invokevirtual 316	java/util/ArrayList:clear	()V
      //   207: return
      // Line number table:
      //   Java source line #143	-> byte code offset #0
      //   Java source line #144	-> byte code offset #2
      //   Java source line #145	-> byte code offset #8
      //   Java source line #146	-> byte code offset #35
      //   Java source line #148	-> byte code offset #39
      //   Java source line #149	-> byte code offset #52
      //   Java source line #152	-> byte code offset #70
      //   Java source line #154	-> byte code offset #82
      //   Java source line #155	-> byte code offset #88
      //   Java source line #158	-> byte code offset #122
      //   Java source line #159	-> byte code offset #123
      //   Java source line #163	-> byte code offset #127
      //   Java source line #164	-> byte code offset #137
      //   Java source line #165	-> byte code offset #144
      //   Java source line #161	-> byte code offset #154
      //   Java source line #163	-> byte code offset #156
      //   Java source line #164	-> byte code offset #166
      //   Java source line #165	-> byte code offset #173
      //   Java source line #166	-> byte code offset #180
      //   Java source line #163	-> byte code offset #183
      //   Java source line #164	-> byte code offset #193
      //   Java source line #165	-> byte code offset #200
      //   Java source line #167	-> byte code offset #207
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	208	0	this	Visitor
      //   0	208	1	target	IComponentDescriptor
      //   1	103	2	start	long
      //   122	2	2	e	Exception
      //   154	27	4	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   0	119	122	java/lang/Exception
      //   0	127	154	finally
    }
    
    public boolean visitReferencingComponent(IComponentDescriptor component)
    {
      currentreferee = new UseReportConverter.Type(component);
      return true;
    }
    
    public void endVisitReferencingComponent(IComponentDescriptor component)
    {
      if (currentreferee.counts.getTotalRefCount() > 0) {
        referees.add(currentreferee);
      }
    }
    
    public boolean visitMember(IMemberDescriptor referencedMember)
    {
      IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
      if (desc == null) {
        return false;
      }
      currenttype = ((UseReportConverter.Type)keys.get(desc));
      if (currenttype == null)
      {
        currenttype = new UseReportConverter.Type(desc);
        keys.put(desc, currenttype);
      }
      TreeMap map = (TreeMap)currentreport.children.get(currenttype);
      if (map == null)
      {
        map = new TreeMap(UseReportConverter.compare);
        currentreport.children.put(currenttype, map);
      }
      currentmember = ((UseReportConverter.Member)map.get(referencedMember));
      if (currentmember == null)
      {
        currentmember = new UseReportConverter.Member(referencedMember);
        map.put(referencedMember, currentmember);
      }
      return true;
    }
    
    public void endVisitMember(IMemberDescriptor referencedMember)
    {
      if (currentmember.children.size() == 0)
      {
        TreeMap map = (TreeMap)currentreport.children.get(currenttype);
        map.remove(referencedMember);
      }
      if (currenttype.counts.getTotalRefCount() == 0)
      {
        IReferenceTypeDescriptor desc = getEnclosingDescriptor(referencedMember);
        if (desc != null)
        {
          keys.remove(desc);
          currentreport.children.remove(currenttype);
        }
      }
    }
    
    String formatMessages(String[] messages)
    {
      if (messages != null)
      {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < messages.length; i++)
        {
          buffer.append(messages[i]);
          if (i < messages.length - 1) {
            buffer.append("\n");
          }
        }
        return buffer.toString();
      }
      return null;
    }
    
    public void visitReference(IReferenceDescriptor reference)
    {
      IMemberDescriptor fromMember = reference.getMember();
      if ((!acceptReference(reference.getReferencedMember(), topatterns)) || 
        (!acceptReference(fromMember, frompatterns))) {
        return;
      }
      int lineNumber = reference.getLineNumber();
      int refKind = reference.getReferenceKind();
      int visibility = reference.getVisibility();
      String refname = Reference.getReferenceText(refKind);
      ArrayList refs = (ArrayList)currentmember.children.get(refname);
      if (refs == null)
      {
        refs = new ArrayList();
        currentmember.children.put(refname, refs);
      }
      refs.add(new UseReportConverter.Reference(fromMember, lineNumber, visibility, formatMessages(reference.getProblemMessages())));
      switch (fromMember.getElementType())
      {
      case 2: 
        switch (visibility)
        {
        case 1: 
          currentmember.counts.total_api_type_count += 1;
          currenttype.counts.total_api_type_count += 1;
          currentreferee.counts.total_api_type_count += 1;
          currentreport.counts.total_api_type_count += 1;
          break;
        case 2: 
          currentmember.counts.total_private_type_count += 1;
          currenttype.counts.total_private_type_count += 1;
          currentreferee.counts.total_private_type_count += 1;
          currentreport.counts.total_private_type_count += 1;
          break;
        case 8: 
          currentmember.counts.total_permissable_type_count += 1;
          currenttype.counts.total_permissable_type_count += 1;
          currentreferee.counts.total_permissable_type_count += 1;
          currentreport.counts.total_permissable_type_count += 1;
          break;
        case 5: 
          currentmember.counts.total_fragment_permissible_type_count += 1;
          currenttype.counts.total_fragment_permissible_type_count += 1;
          currentreferee.counts.total_fragment_permissible_type_count += 1;
          currentreport.counts.total_fragment_permissible_type_count += 1;
          break;
        case 22: 
          currentmember.counts.total_illegal_type_count += 1;
          currenttype.counts.total_illegal_type_count += 1;
          currentreferee.counts.total_illegal_type_count += 1;
          currentreport.counts.total_illegal_type_count += 1;
        }
        break;
      case 6: 
        switch (visibility)
        {
        case 1: 
          currentmember.counts.total_api_method_count += 1;
          currenttype.counts.total_api_method_count += 1;
          currentreferee.counts.total_api_method_count += 1;
          currentreport.counts.total_api_method_count += 1;
          break;
        case 2: 
          currentmember.counts.total_private_method_count += 1;
          currenttype.counts.total_private_method_count += 1;
          currentreferee.counts.total_private_method_count += 1;
          currentreport.counts.total_private_method_count += 1;
          break;
        case 8: 
          currentmember.counts.total_permissable_method_count += 1;
          currenttype.counts.total_permissable_method_count += 1;
          currentreferee.counts.total_permissable_method_count += 1;
          currentreport.counts.total_permissable_method_count += 1;
          break;
        case 5: 
          currentmember.counts.total_fragment_permissible_method_count += 1;
          currenttype.counts.total_fragment_permissible_method_count += 1;
          currentreferee.counts.total_fragment_permissible_method_count += 1;
          currentreport.counts.total_fragment_permissible_method_count += 1;
          break;
        case 22: 
          currentmember.counts.total_illegal_method_count += 1;
          currenttype.counts.total_illegal_method_count += 1;
          currentreferee.counts.total_illegal_method_count += 1;
          current
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