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

ter(String location)
  {
    fLocation = location;
    try
    {
      parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      parser.setErrorHandler(new DefaultHandler());
    }
    catch (FactoryConfigurationError fce)
    {
      ApiPlugin.log(fce);
    }
    catch (ParserConfigurationException pce)
    {
      ApiPlugin.log(pce);
    }
  }
  
  /* Error */
  public void writeReferences(IReferenceDescriptor[] references)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 443	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fLocation	Ljava/lang/String;
    //   4: ifnull +108 -> 112
    //   7: new 244	java/io/File
    //   10: dup
    //   11: aload_0
    //   12: getfield 443	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fLocation	Ljava/lang/String;
    //   15: invokespecial 454	java/io/File:<init>	(Ljava/lang/String;)V
    //   18: astore_2
    //   19: aload_2
    //   20: invokevirtual 451	java/io/File:exists	()Z
    //   23: ifne +8 -> 31
    //   26: aload_2
    //   27: invokevirtual 453	java/io/File:mkdirs	()Z
    //   30: pop
    //   31: aload_0
    //   32: aload_1
    //   33: invokespecial 492	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:collateResults	([Lorg/eclipse/pde/api/tools/internal/search/IReferenceDescriptor;)V
    //   36: aload_0
    //   37: aload_2
    //   38: invokespecial 490	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:writeXML	(Ljava/io/File;)V
    //   41: goto +52 -> 93
    //   44: astore_2
    //   45: aload_2
    //   46: invokestatic 488	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   49: aload_0
    //   50: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   53: ifnull +59 -> 112
    //   56: aload_0
    //   57: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   60: invokevirtual 476	java/util/HashMap:clear	()V
    //   63: aload_0
    //   64: aconst_null
    //   65: putfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   68: goto +44 -> 112
    //   71: astore_3
    //   72: aload_0
    //   73: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   76: ifnull +15 -> 91
    //   79: aload_0
    //   80: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   83: invokevirtual 476	java/util/HashMap:clear	()V
    //   86: aload_0
    //   87: aconst_null
    //   88: putfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   91: aload_3
    //   92: athrow
    //   93: aload_0
    //   94: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   97: ifnull +15 -> 112
    //   100: aload_0
    //   101: getfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   104: invokevirtual 476	java/util/HashMap:clear	()V
    //   107: aload_0
    //   108: aconst_null
    //   109: putfield 444	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:fReferenceMap	Ljava/util/HashMap;
    //   112: return
    // Line number table:
    //   Java source line #101	-> byte code offset #0
    //   Java source line #103	-> byte code offset #7
    //   Java source line #104	-> byte code offset #19
    //   Java source line #105	-> byte code offset #26
    //   Java source line #107	-> byte code offset #31
    //   Java source line #108	-> byte code offset #36
    //   Java source line #110	-> byte code offset #44
    //   Java source line #111	-> byte code offset #45
    //   Java source line #114	-> byte code offset #49
    //   Java source line #115	-> byte code offset #56
    //   Java source line #116	-> byte code offset #63
    //   Java source line #113	-> byte code offset #71
    //   Java source line #114	-> byte code offset #72
    //   Java source line #115	-> byte code offset #79
    //   Java source line #116	-> byte code offset #86
    //   Java source line #118	-> byte code offset #91
    //   Java source line #114	-> byte code offset #93
    //   Java source line #115	-> byte code offset #100
    //   Java source line #116	-> byte code offset #107
    //   Java source line #120	-> byte code offset #112
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	113	0	this	XmlReferenceDescriptorWriter
    //   0	113	1	references	IReferenceDescriptor[]
    //   18	20	2	parent	File
    //   44	2	2	e	Exception
    //   71	21	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	41	44	java/lang/Exception
    //   7	49	71	finally
  }
  
  private void collateResults(IReferenceDescriptor[] references)
    throws CoreException
  {
    if (fReferenceMap == null) {
      fReferenceMap = new HashMap();
    }
    Integer type = null;
    Integer visibility = null;
    String id = null;
    String tname = null;
    HashMap rmap = null;
    HashMap mmap = null;
    HashMap vmap = null;
    HashMap tmap = null;
    HashSet reflist = null;
    IComponentDescriptor rcomponent = null;
    IComponentDescriptor mcomponent = null;
    for (int i = 0; i < references.length; i++)
    {
      rcomponent = references[i].getReferencedComponent();
      id = getId(rcomponent);
      rmap = (HashMap)fReferenceMap.get(id);
      if (rmap == null)
      {
        rmap = new HashMap();
        fReferenceMap.put(id, rmap);
      }
      mcomponent = references[i].getComponent();
      id = getId(mcomponent);
      mmap = (HashMap)rmap.get(id);
      if (mmap == null)
      {
        mmap = new HashMap();
        rmap.put(id, mmap);
      }
      if ((references[i].getReferenceFlags() & 0x1) > 0) {
        visibility = V_ILLEGAL;
      } else {
        visibility = new Integer(references[i].getVisibility());
      }
      vmap = (HashMap)mmap.get(visibility);
      if (vmap == null)
      {
        vmap = new HashMap();
        mmap.put(visibility, vmap);
      }
      type = new Integer(references[i].getReferenceType());
      tmap = (HashMap)vmap.get(type);
      if (tmap == null)
      {
        tmap = new HashMap();
        vmap.put(type, tmap);
      }
      tname = getText(references[i].getReferencedMember());
      reflist = (HashSet)tmap.get(tname);
      if (reflist == null)
      {
        reflist = new HashSet();
        tmap.put(tname, reflist);
      }
      reflist.add(references[i]);
    }
  }
  
  String getId(IComponentDescriptor component)
    throws CoreException
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append(component.getId()).append(" ").append('(').append(component.getVersion()).append(')');
    return buffer.toString();
  }
  
  private String getFormattedTypeName(String groupname)
  {
    if ("type_references".equals(groupname)) {
      return "Types";
    }
    if ("method_references".equals(groupname)) {
      return "Methods";
    }
    if ("field_references".equals(groupname)) {
      return "Fields";
    }
    return "unknown references";
  }
  
  private String getRefTypeName(int type)
  {
    switch (type)
    {
    case 1: 
      return "type_references";
    case 3: 
      return "method_references";
    case 2: 
      return "field_references";
    }
    return "unknown_reference_kinds";
  }
  
  private void writeXML(File parent)
    throws CoreException, FileNotFoundException, IOException
  {
    HashMap vismap = null;
    HashMap typemap = null;
    HashMap rmap = null;
    HashMap mmap = null;
    Integer type = null;
    Integer vis = null;
    String id = null;
    String referee = null;
    File root = null;
    File location = null;
    File base = null;
    Iterator iter2;
    for (Iterator iter = fReferenceMap.entrySet().iterator(); iter.hasNext(); iter2.hasNext())
    {
      Map.Entry entry = (Map.Entry)iter.next();
      id = (String)entry.getKey();
      referee = id;
      base = new File(parent, id);
      if (!base.exists()) {
        base.mkdir();
      }
      rmap = (HashMap)entry.getValue();
      iter2 = rmap.entrySet().iterator(); continue;
      Map.Entry entry2 = (Map.Entry)iter2.next();
      id = (String)entry2.getKey();
      root = new File(base, id);
      if (!root.exists()) {
        root.mkdir();
      }
      mmap = (HashMap)entry2.getValue();
      Iterator iter3;
      for (Iterator iter4 = mmap.entrySet().iterator(); iter4.hasNext(); iter3.hasNext())
      {
        Map.Entry entry3 = (Map.Entry)iter4.next();
        vis = (Integer)entry3.getKey();
        location = new File(root, VisibilityModifiers.getVisibilityName(vis.intValue()));
        if (!location.exists()) {
          location.mkdir();
        }
        vismap = (HashMap)entry3.getValue();
        iter3 = vismap.entrySet().iterator(); continue;
        Map.Entry entry4 = (Map.Entry)iter3.next();
        type = (Integer)entry4.getKey();
        typemap = (HashMap)entry4.getValue();
        writeGroup(id, referee, location, getRefTypeName(type.intValue()), typemap, vis.intValue());
      }
    }
  }
  
  /* Error */
  private void writeGroup(String origin, String referee, File parent, String name, HashMap map, int visibility)
    throws CoreException, FileNotFoundException, IOException
  {
    // Byte code:
    //   0: aload_3
    //   1: invokevirtual 451	java/io/File:exists	()Z
    //   4: ifeq +592 -> 596
    //   7: aconst_null
    //   8: astore 7
    //   10: aconst_null
    //   11: astore 8
    //   13: aconst_null
    //   14: astore 9
    //   16: iconst_0
    //   17: istore 10
    //   19: new 244	java/io/File
    //   22: dup
    //   23: aload_3
    //   24: new 254	java/lang/StringBuffer
    //   27: dup
    //   28: aload 4
    //   30: invokestatic 469	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   33: invokespecial 472	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   36: ldc_w 223
    //   39: invokevirtual 474	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   42: invokevirtual 471	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   45: invokespecial 455	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   48: astore 11
    //   50: aload 11
    //   52: invokevirtual 451	java/io/File:exists	()Z
    //   55: ifeq +133 -> 188
    //   58: aconst_null
    //   59: astore 12
    //   61: new 245	java/io/FileInputStream
    //   64: dup
    //   65: aload 11
    //   67: invokespecial 457	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   70: astore 12
    //   72: aload_0
    //   73: getfield 445	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:parser	Ljavax/xml/parsers/DocumentBuilder;
    //   76: aload 12
    //   78: invokevirtual 484	javax/xml/parsers/DocumentBuilder:parse	(Ljava/io/InputStream;)Lorg/w3c/dom/Document;
    //   81: astore 8
    //   83: goto +38 -> 121
    //   86: astore 13
    //   88: aload 13
    //   90: invokevirtual 459	java/io/IOException:printStackTrace	()V
    //   93: aload 12
    //   95: ifnull +36 -> 131
    //   98: aload 12
    //   100: invokevirtual 456	java/io/FileInputStream:close	()V
    //   103: goto +28 -> 131
    //   106: astore 14
    //   108: aload 12
    //   110: ifnull +8 -> 118
    //   113: aload 12
    //   115: invokevirtual 456	java/io/FileInputStream:close	()V
    //   118: aload 14
    //   120: athrow
    //   121: aload 12
    //   123: ifnull +8 -> 131
    //   126: aload 12
    //   128: invokevirtual 456	java/io/FileInputStream:close	()V
    //   131: aload 8
    //   133: ifnonnull +14 -> 147
    //   136: aload 7
    //   138: ifnull +8 -> 146
    //   141: aload 7
    //   143: invokevirtual 447	java/io/BufferedWriter:close	()V
    //   146: return
    //   147: aload 8
    //   149: invokeinterface 531 1 0
    //   154: astore 9
    //   156: aload 9
    //   158: ldc_w 235
    //   161: invokeinterface 534 2 0
    //   166: astore 13
    //   168: aload 13
    //   170: invokestatic 465	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   173: istore 10
    //   175: goto +118 -> 293
    //   178: astore 12
    //   180: aload 12
    //   182: invokevirtual 507	org/xml/sax/SAXException:printStackTrace	()V
    //   185: goto +108 -> 293
    //   188: invokestatic 505	org/eclipse/pde/api/tools/internal/util/Util:newDocument	()Lorg/w3c/dom/Document;
    //   191: astore 8
    //   193: aload 8
    //   195: ldc_w 239
    //   198: invokeinterface 532 2 0
    //   203: astore 9
    //   205: aload 8
    //   207: aload 9
    //   209: invokeinterface 533 2 0
    //   214: pop
    //   215: aload 9
    //   217: ldc_w 238
    //   220: iload 6
    //   222: invokestatic 464	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   225: invokeinterface 535 3 0
    //   230: aload 9
    //   232: ldc_w 232
    //   235: aload_1
    //   236: invokeinterface 535 3 0
    //   241: aload 9
    //   243: ldc_w 233
    //   246: aload_2
    //   247: invokeinterface 535 3 0
    //   252: aload 9
    //   254: ldc_w 231
    //   257: aload_0
    //   258: aload 4
    //   260: invokespecial 494	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:getFormattedTypeName	(Ljava/lang/String;)Ljava/lang/String;
    //   263: invokeinterface 535 3 0
    //   268: aload_0
    //   269: getfield 446	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:alternate	Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;
    //   272: ifnull +21 -> 293
    //   275: aload 9
    //   277: ldc_w 225
    //   280: aload_0
    //   281: aload_0
    //   282: getfield 446	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:alternate	Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;
    //   285: invokevirtual 495	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:getId	(Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IComponentDescriptor;)Ljava/lang/String;
    //   288: invokeinterface 535 3 0
    //   293: aload 8
    //   295: ifnonnull +14 -> 309
    //   298: aload 7
    //   300: ifnull +8 -> 308
    //   303: aload 7
    //   305: invokevirtual 447	java/io/BufferedWriter:close	()V
    //   308: return
    //   309: aconst_null
    //   310: astore 12
    //   312: aconst_null
    //   313: astore 13
    //   315: aconst_null
    //   316: astore 14
    //   318: aload 5
    //   320: invokevirtual 477	java/util/HashMap:entrySet	()Ljava/util/Set;
    //   323: invokeinterface 513 1 0
    //   328: astore 15
    //   330: goto +170 -> 500
    //   333: aload 15
    //   335: invokeinterface 510 1 0
    //   340: checkcast 259	java/util/Map$Entry
    //   343: astore 16
    //   345: aload 16
    //   347: invokeinterface 511 1 0
    //   352: checkcast 253	java/lang/String
    //   355: astore 12
    //   357: aload_0
    //   358: aload 9
    //   360: aload 12
    //   362: invokespecial 500	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:findTypeElement	(Lorg/w3c/dom/Element;Ljava/lang/String;)Lorg/w3c/dom/Element;
    //   365: astore 14
    //   367: aload 14
    //   369: ifnonnull +37 -> 406
    //   372: aload 8
    //   374: ldc_w 241
    //   377: invokeinterface 532 2 0
    //   382: astore 14
    //   384: aload 14
    //   386: ldc_w 231
    //   389: aload 12
    //   391: invokeinterface 535 3 0
    //   396: aload 9
    //   398: aload 14
    //   400: invokeinterface 536 2 0
    //   405: pop
    //   406: aload 16
    //   408: invokeinterface 512 1 0
    //   413: checkcast 256	java/util/HashSet
    //   416: astore 13
    //   418: aload 13
    //   420: ifnull +80 -> 500
    //   423: aload 13
    //   425: invokevirtual 482	java/util/HashSet:iterator	()Ljava/util/Iterator;
    //   428: astore 17
    //   430: goto +60 -> 490
    //   433: iinc 10 1
    //   436: aload 17
    //   438: invokeinterface 510 1 0
    //   443: checkcast 274	org/eclipse/pde/api/tools/internal/search/IReferenceDescriptor
    //   446: astore 18
    //   448: aload_0
    //   449: aload 8
    //   451: aload 14
    //   453: aload 18
    //   455: invokespecial 498	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:writeReference	(Lorg/w3c/dom/Document;Lorg/w3c/dom/Element;Lorg/eclipse/pde/api/tools/internal/search/IReferenceDescriptor;)V
    //   458: aload 17
    //   460: invokeinterface 509 1 0
    //   465: ifne +25 -> 490
    //   468: aload 18
    //   470: invokeinterface 530 1 0
    //   475: astore 19
    //   477: aload 19
    //   479: ifnull +11 -> 490
    //   482: aload_0
    //   483: aload 14
    //   485: aload 19
    //   487: invokespecial 497	org/eclipse/pde/api/tools/internal/search/XmlReferenceDescriptorWriter:addMemberDetails	(Lorg/w3c/dom/Element;Lorg/eclipse/pde/api/tools/internal/provisional/descriptors/IMemberDescriptor;)V
    //   490: aload 17
    //   492: invokeinterface 509 1 0
    //   497: ifne -64 -> 433
    //   500: aload 15
    //   502: invokeinterface 509 1 0
    //   507: ifne -174 -> 333
    //   510: aload 9
    //   512: ldc_w 235
    //   515: iload 10
    //   517: invokestatic 464	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   520: invokeinterface 535 3 0
    //   525: new 243	java/io/BufferedWriter
    //   528: dup
    //   529: new 249	java/io/OutputStreamWriter
    //   532: dup
    //   533: new 247	java/io/FileOutputStream
    //   536: dup
    //   537: aload 11
    //   539: invokespecial 458	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   542: ldc_w 224
    //   545: invokespecial 460	java/io/OutputStreamWriter:<init>	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   548: invokespecial 449	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   551: astore 7
    //   553: aload 7
    //   555: aload 8
    //   557: invokestatic 506	org/eclipse/pde/api/tools/internal/util/Util:serializeDocument	(Lorg/w3c/dom/Document;)Ljava/lang/String;
    //   560: invokevirtual 450	java/io/BufferedWriter:write	(Ljava/lang/String;)V
    //   563: aload 7
    //   565: invokevirtual 448	java/io/BufferedWriter:flush	()V
    //   568: goto +18 -> 586
    //   571: astore 20
    //   573: aload 7
    //   575: ifnull +8 -> 583
    //   578: aload 7
    //   580: invokevirtual 447	java/io/BufferedWriter:close	()V
    //   583: aload 20
    //   585: athrow
    //   586: aload 7
    //   588: ifnull +8 -> 596
    //   591: aload 7
    //   593: invokevirtual 447	java/io/BufferedWriter:close	()V
    //   596: return
    // Line number table:
    //   Java source line #302	-> byte code offset #0
    //   Java source line #303	-> byte code offset #7
    //   Java source line #305	-> byte code offset #10
    //   Java source line #306	-> byte code offset #13
    //   Java source line #307	-> byte code offset #16
    //   Java source line #308	-> byte code offset #19
    //   Java source line #309	-> byte code offset #50
    //   Java source line #311	-> byte code offset #58
    //   Java source line #313	-> byte code offset #61
    //   Java source line #314	-> byte code offset #72
    //   Java source line #315	-> byte code offset #86
    //   Java source line #316	-> byte code offset #88
    //   Java source line #318	-> byte code offset #93
    //   Java source line #319	-> byte code offset #98
    //   Java source line #317	-> byte code offset #106
    //   Java source line #318	-> byte code offset #108
    //   Java source line #319	-> byte code offset #113
    //   Java source line #321	-> byte code offset #118
    //   Java source line #318	-> byte code offset #121
    //   Java source line #319	-> byte code offset #126
    //   Java source line #322	-> byte code offset #131
    //   Java source line #382	-> byte code offset #136
    //   Java source line #383	-> byte code offset #141
    //   Java source line #323	-> byte code offset #146
    //   Java source line #325	-> byte code offset #147
    //   Java source line #326	-> byte code offset #156
    //   Java source line #327	-> byte code offset #168
    //   Java source line #329	-> byte code offset #178
    //   Java source line #330	-> byte code offset #180
    //   Java source line #334	-> byte code offset #188
    //   Java source line #335	-> byte code offset #193
    //   Java source line #336	-> byte code offset #205
    //   Java source line #337	-> byte code offset #215
    //   Java source line #338	-> byte code offset #230
    //   Java source line #339	-> byte code offset #241
    //   Java source line #340	-> byte code offset #252
    //   Java source line #341	-> byte code offset #268
    //   Java source line #342	-> byte code offset #275
    //   Java source line #345	-> byte code offset #293
    //   Java source line #382	-> byte code offset #298
    //   Java source line #383	-> byte code offset #303
    //   Java source line #346	-> byte code offset #308
    //   Java source line #348	-> byte code offset #309
    //   Java source line #349	-> byte code offset #312
    //   Java source line #350	-> byte code offset #315
    //   Java source line #351	-> byte code offset #318
    //   Java source line #352	-> byte code offset #333
    //   Java source line #353	-> byte code offset #345
    //   Java source line #354	-> byte code offset #357
    //   Java source line #355	-> byte code offset #367
    //   Java source line #356	-> byte code offset #372
    //   Java source line #357	-> byte code offset #384
    //   Java source line #358	-> byte code offset #396
    //   Java source line #360	-> byte code offset #406
    //   Java source line #361	-> byte code offset #418
    //   Java source line #362	-> byte code offset #423
    //   Java source line #363	-> byte code offset #433
    //   Java source line #364	-> byte code offset #436
    //   Java source line #365	-> byte code offset #448
    //   Java source line #366	-> byte code offset #458
    //   Java source line #368	-> byte code offset #468
    //   Java source line #369	-> byte code offset #477
    //   Java source line #370	-> byte code offset #482
    //   Java source line #362	-> byte code offset #490
    //   Java source line #351	-> byte code offset #500
    //   Java source line #376	-> byte code offset #510
    //   Java source line #377	-> byte code offset #525
    //   Java source line #378	-> byte code offset #553
    //   Java source line #379	-> byte code offset #563
    //   Java source line #381	-> byte code offset #571
    //   Java source line #382	-> byte code offset #573
    //   Java source line #383	-> byte code offset #578
    //   Java source line #385	-> byte code offset #583
    //   Java source line #382	-> byte code offset #586
    //   Java source line #383	-> byte code offset #591
    //   Java source line #387	-> byte code offset #596
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	597	0	this	XmlReferenceDescriptorWriter
    //   0	597	1	origin	String
    //   0	597	2	referee	String
    //   0	597	3	parent	File
    //   0	597	4	name	String
    //   0	597	5	map	HashMap
    //   0	597	6	visibility	int
    //   8	584	7	writer	java.io.BufferedWriter
    //   11	121	8	doc	Document
    //   147	147	8	doc	Document
    //   309	247	8	doc	Document
    //   14	3	9	root	Element
    //   147	129	9	root	Element
    //   309	202	9	root	Element
    //   17	3	10	count	int
    //   147	27	10	count	int
    //   309	207	10	count	int
    //   48	18	11	out	File
    //   147	1	11	out	File
    //   309	229	11	out	File
    //   59	68	12	inputStream	java.io.FileInputStream
    //   147	1	12	inputStream	java.io.FileInputStream
    //   178	3	12	se	org.xml.sax.SAXException
    //   310	80	12	tname	String
    //   86	3	13	e	IOException
    //   166	3	13	value	String
    //   313	111	13	refs	HashSet
    //   106	13	14	localObject1	Object
    //   316	168	14	telement	Element
    //   328	173	15	iter	Iterator
    //   343	64	16	entry	Map.Entry
    //   428	63	17	iter2	Iterator
    //   446	23	18	ref	IReferenceDescriptor
    //   475	11	19	resolved	IMemberDescriptor
    //   571	13	20	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   61	83	86	java/io/IOException
    //   61	93	106	finally
    //   58	136	178	org/xml/sax/SAXException
    //   147	175	178	org/xml/sax/SAXException
    //   10	136	571	finally
    //   147	298	571	finally
    //   309	571	571	finally
  }
  
  private void addMemberDetails(Element element, IMemberDescriptor member)
  {
    switch (member.getElementType())
    {
    case 2: 
      element.setAttribute("type", ((IReferenceTypeDescriptor)member).getQualifiedName());
      break;
    case 5: 
      IReferenceTypeDescriptor encl = member.getEnclosingType();
      element.setAttribute("type", encl.getQualifiedName());
      element.setAttribute("member", member.getName());
      break;
    case 6: 
      IReferenceTypeDescriptor encl = member.getEnclosingType();
      element.setAttribute("type", encl.getQualifiedName());
      element.setAttribute("member", member.getName());
      element.setAttribute("signature", ((IMethodDescriptor)member).getSignature());
    }
  }
  
  private Element findTypeElement(Element root, String tname)
  {
    if (tname == null) {
      return null;
    }
    Element kelement = null;
    NodeList nodes = root.getElementsByTagName("target");
    for (int i = 0; i < nodes.getLength(); i++)
    {
      kelement = (Element)nodes.item(i);
      if (tname.equals(kelement.getAttribute("name"))) {
        return kelement;
      }
    }
    return null;
  }
  
  private Element findKindElement(Element root, Integer kind)
  {
    Element kelement = null;
    NodeList nodes = root.getElementsByTagName("reference_kind");
    for (int i = 0; i < nodes.getLength(); i++)
    {
      kelement = (Element)nodes.item(i);
      if (kind.toString().equals(kelement.getAttribute("kind"))) {
        return kelement;
      }
    }
    return null;
  }
  
  private void writeReference(Document document, Element parent, IReferenceDescriptor reference)
    throws CoreException
  {
    Element kelement = null;
    Integer kind = new Integer(reference.getReferenceKind());
    kelement = findKindElement(parent, kind);
    if (kelement == null)
    {
      kelement = document.createElement("reference_kind");
      kelement.setAttribute("reference_kind_name", Reference.getReferenceText(kind.intValue()));
      kelement.setAttribute("kind", kind.toString());
      kelement.setAttribute("flags", Integer.toString(reference.getReferenceFlags()));
      parent.appendChild(kelement);
    }
    Element relement = document.createElement("reference");
    IMemberDescriptor member = reference.getMember();
    relement.setAttribute("origin", getText(member));
    String[] messages = reference.getProblemMessages();
    if (messages != null) {
      relement.setAttribute("message_arguments", getText(messages));
    }
    addMemberDetails(relement, member);
    member = reference.getReferencedMember();
    if (member != null)
    {
      relement.setAttribute("linenumber", Integer.toString(reference.getLineNumber()));
      kelement.appendChild(relement);
    }
  }
  
  String getText(Object[] array)
  {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < array.length; i++)
    {
      buffer.append(array[i].toString());
      if (i < array.length - 1) {
        buffer.append(",");
      }
    }
    return buffer.toString();
  }
  
  private String getText(IMemberDescriptor member)
    throws CoreException
  {
    switch (member.getElementType())
    {
    case 2: 
      return Signatures.getQualifiedTypeSignature((IReferenceTypeDescriptor)member);
    case 6: 
      return Signatures.getQualifiedMethodSignature((IMethodDescriptor)member);
    case 5: 
      return Signatures.getQualifiedFieldSignature((IFieldDescriptor)member);
    }
    return null;
  }
  
  public void setAlternate(IComponentDescriptor other)
  {
    alternate = other;
  }
}

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

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.CoreException;
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.builder.IReference;
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.search.IApiSearchReporter;
import org.eclipse.pde.api.tools.internal.provisional.search.IMetadata;
import org.xml.sax.helpers.DefaultHandler;

public class XmlSearchReporter
  implements IApiSearchReporter
{
  private String fLocation = null;
  private DocumentBuilder parser = null;
  private boolean debug = false;
  private int referenceCount = 0;
  private int illegalCount = 0;
  private int internalCount = 0;
  
  public XmlSearchReporter(String location, boolean debug)
  {
    fLocation = location;
    this.debug = debug;
    try
    {
      parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      parser.setErrorHandler(new DefaultHandler());
    }
    catch (FactoryConfigurationError fce)
    {
      ApiPlugin.log(fce);
    }
    catch (ParserConfigurationException pce)
    {
      ApiPlugin.log(pce);
    }
  }
  
  public void reportResults(IApiElement element, IReference[] references)
  {
    if (references.length == 0) {
      return;
    }
    HashSet writtenReferences = new HashSet();
    XmlReferenceDescriptorWriter writer = new XmlReferenceDescriptorWriter(fLocation);
    List descriptors = new ArrayList(references.length + 1);
    for (int i = 0; i < references.length; i++)
    {
      Reference reference = (Reference)references[i];
      try
      {
        IReferenceDescriptor descriptor = reference.getReferenceDescriptor();
        descriptors.add(descriptor);
        if (!writtenReferences.contains(descriptor))
        {
          referenceCount += 1;
          if ((references[i].getReferenceFlags() & 0x1) > 0) {
            illegalCount += 1;
          }
          if (descriptor.getVisibility() == 2) {
            internalCount += 1;
          }
          writtenReferences.add(descriptor);
        }
      }
      catch (CoreException e)
      {
        ApiPlugin.log(e.getStatus());
      }
    }
    writer.writeReferences((IReferenceDescriptor[])descriptors.toArray(new IReferenceDescriptor[descriptors.size()]));
  }
  
  String getId(IApiComponent component)
    throws CoreException
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append(component.getSymbolicName()).append(" ").append('(').append(component.getVersion()).append(')');
    return buffer.toString();
  }
  
  /* Error */
  public void reportNotSearched(IApiElement[] elements)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +4 -> 5
    //   4: return
    //   5: aconst_null
    //   6: astore_2
    //   7: aload_0
    //   8: getfield 283	org/eclipse/pde/api/tools/internal/search/XmlSearchReporter:debug	Z
    //   11: ifeq +11 -> 22
    //   14: getstatic 279	java/lang/System:out	Ljava/io/PrintStream;
    //   17: ldc 2
    //   19: invokevirtual 297	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   22: new 146	java/io/File
    //   25: dup
    //   26: aload_0
    //   27: getfield 284	org/eclipse/pde/api/tools/internal/search/XmlSearchReporter:fLocation	Ljava/lang/String;
    //   30: invokespecial 293	java/io/File:<init>	(Ljava/lang/String;)V
    //   33: astore_3
    //   34: aload_3
    //   35: invokevirtual 291	java/io/File:exists	()Z
    //   38: ifne +8 -> 46
    //   41: aload_3
    //   42: invokevirtual 292	java/io/File:mkdirs	()Z
    //   45: pop
    //   46: new 146	java/io/File
    //   49: dup
    //   50: aload_3
    //   51: ldc 7
    //   53: invokespecial 294	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   56: astore 4
    //   58: aload 4
    //   60: invokevirtual 291	java/io/File:exists	()Z
    //   63: ifne +9 -> 72
    //   66: aload 4
    //   68: invokevirtual 290	java/io/File:createNewFile	()Z
    //   71: pop
    //   72: invokestatic 320	org/eclipse/pde/api/tools/internal/util/Util:newDocument	()Lorg/w3c/dom/Document;
    //   75: astore 5
    //   77: aload 5
    //   79: ldc 4
    //   81: invokeinterface 331 2 0
    //   86: astore 6
    //   88: aload 5
    //   90: aload 6
    //   92: invokeinterface 332 2 0
    //   97: pop
    //   98: aconst_null
    //   99: astore 7
    //   101: aconst_null
    //   102: astore 8
    //   104: iconst_0
    //   105: istore 9
    //   107: goto +78 -> 185
    //   110: aload_1
    //   111: iload 9
    //   113: aaload
    //   114: checkcast 171	org/eclipse/pde/api/tools/internal/search/SkippedComponent
    //   117: astore 8
    //   119: aload 5
    //   121: ldc 3
    //   123: invokeinterface 331 2 0
    //   128: astore 7
    //   130: aload 7
    //   132: ldc 6
    //   134: aload 8
    //   136: invokevirtual 315	org/eclipse/pde/api/tools/internal/search/SkippedComponent:getComponentId	()Ljava/lang/String;
    //   139: invokeinterface 333 3 0
    //   144: aload 7
    //   146: ldc 8
    //   148: aload 8
    //   150: invokevirtual 317	org/eclipse/pde/api/tools/internal/search/SkippedComponent:getVersion	()Ljava/lang/String;
    //   153: invokeinterface 333 3 0
    //   158: aload 7
    //   160: ldc 5
    //   162: aload 8
    //   164: invokevirtual 316	org/eclipse/pde/api/tools/internal/search/SkippedComponent:getErrorDetails	()Ljava/lang/String;
    //   167: invokeinterface 333 3 0
    //   172: aload 6
    //   174: aload 7
    //   176: invokeinterface 334 2 0
    //   181: pop
    //   182: iinc 9 1
    //   185: iload 9
    //   187: aload_1
    //   188: arraylength
    //   189: if_icmplt -79 -> 110
    //   192: new 145	java/io/BufferedWriter
    //   195: dup
    //   196: new 150	java/io/OutputStreamWriter
    //   199: dup
    //   200: new 148	java/io/FileOutputStream
    //   203: dup
    //   204: aload 4
    //   206: invokespecial 295	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   209: ldc_w 136
    //   212: invokespecial 296	java/io/OutputStreamWriter:<init>	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   215: invokespecial 288	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   218: astore_2
    //   219: aload_2
    //   220: aload 5
    //   222: invokestatic 321	org/eclipse/pde/api/tools/internal/util/Util:serializeDocument	(Lorg/w3c/dom/Document;)Ljava/lang/String;
    //   225: invokevirtual 289	java/io/BufferedWriter:write	(Ljava/lang/String;)V
    //   228: aload_2
    //   229: invokevirtual 287	java/io/BufferedWriter:flush	()V
    //   232: goto +68 -> 300
    //   235: pop
    //   236: aload_2
    //   237: ifnull +75 -> 312
    //   240: aload_2
    //   241: invokevirtual 286	java/io/BufferedWriter:close	()V
    //   244: goto +68 -> 312
    //   247: pop
    //   248: goto +64 -> 312
    //   251: pop
    //   252: aload_2
    //   253: ifnull +59 -> 312
    //   256: aload_2
    //   257: invokevirtual 286	java/io/BufferedWriter:close	()V
    //   260: goto +52 -> 312
    //   263: pop
    //   264: goto +48 -> 312
    //   267: pop
    //   268: aload_2
    //   269: ifnull +43 -> 312
    //   272: aload_2
    //   273: invokevirtual 286	java/io/BufferedWriter:close	()V
    //   276: goto +36 -> 312
    //   279: pop
    //   280: goto +32 -> 312
    //   283: astore 10
    //   285: aload_2
    //   286: ifnull +11 -> 297
    //   289: aload_2
    //   290: invokevirtual 286	java/io/BufferedWriter:close	()V
    //   293: goto +4 -> 297
    //   296: pop
    //   297: aload 10
    //   299: athrow
    //   300: aload_2
    //   301: ifnull +11 -> 312
    //   304: aload_2
    //   305: invokevirtual 286	java/io/BufferedWriter:close	()V
    //   308: goto +4 -> 312
    //   311: pop
    //   312: return
    // Line number table:
    //   Java source line #134	-> byte code offset #0
    //   Java source line #135	-> byte code offset #4
    //   Java source line #137	-> byte code offset #5
    //   Java source line #139	-> byte code offset #7
    //   Java source line #140	-> byte code offset #14
    //   Java source line #142	-> byte code offset #22
    //   Java source line #143	-> byte code offset #34
    //   Java source line #144	-> byte code offset #41
    //   Java source line #146	-> byte code offset #46
    //   Java source line #147	-> byte code offset #58
    //   Java source line #148	-> byte code offset #66
    //   Java source line #150	-> byte code offset #72
    //   Java source line #151	-> byte code offset #77
    //   Java source line #152	-> byte code offset #88
    //   Java source line #153	-> byte code offset #98
    //   Java source line #154	-> byte code offset #101
    //   Java source line #155	-> byte code offset #104
    //   Java source line #156	-> byte code offset #110
    //   Java source line #157	-> byte code offset #119
    //   Java source line #158	-> byte code offset #130
    //   Java source line #159	-> byte code offset #144
    //   Java source line #160	-> byte code offset #158
    //   Java source line #161	-> byte code offset #172
    //   Java source line #155	-> byte code offset #182
    //   Java source line #163	-> byte code offset #192
    //   Java source line #164	-> byte code offset #219
    //   Java source line #165	-> byte code offset #228
    //   Java source line #167	-> byte code offset #235
    //   Java source line #171	-> byte code offset #236
    //   Java source line #173	-> byte code offset #240
    //   Java source line #174	-> byte code offset #247
    //   Java source line #168	-> byte code offset #251
    //   Java source line #171	-> byte code offset #252
    //   Java source line #173	-> byte code offset #256
    //   Java source line #174	-> byte code offset #263
    //   Java source line #169	-> byte code offset #267
    //   Java source line #171	-> byte code offset #268
    //   Java source line #173	-> byte code offset #272
    //   Java source line #174	-> byte code offset #279
    //   Java source line #170	-> byte code offset #283
    //   Java source line #171	-> byte code offset #285
    //   Java source line #173	-> byte code offset #289
    //   Java source line #174	-> byte code offset #296
    //   Java source line #176	-> byte code offset #297
    //   Java source line #171	-> byte code offset #300
    //   Java source line #173	-> byte code offset #304
    //   Java source line #174	-> byte code offset #311
    //   Java source line #177	-> byte code offset #312
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	313	0	this	XmlSearchReporter
    //   0	313	1	elements	IApiElement[]
    //   6	299	2	writer	java.io.BufferedWriter
    //   33	18	3	rootfile	File
    //   56	149	4	file	File
    //   75	146	5	doc	org.w3c.dom.Document
    //   86	87	6	root	org.w3c.dom.Element
    //   99	76	7	comp	org.w3c.dom.Element
    //   102	6
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