1 package org.incava.javadoc; 2 3 import java.awt.Point ; 4 import java.io.*; 5 import java.util.*; 6 import org.incava.text.LineMapping; 7 import org.incava.text.Location; 8 9 10 13 public class JavadocNode 14 { 15 private JavadocDescriptionNode description = null; 16 17 private JavadocTaggedNode[] tagged = new JavadocTaggedNode[0]; 18 19 private int startLine; 20 21 private int startColumn; 22 23 private int endLine; 24 25 private int endColumn; 26 27 30 public static JavadocNode parse(String text, int startLine, int startColumn) 31 { 32 JavadocParser parser = new JavadocParser(); 33 List subs = parser.parse(text, startLine, startColumn); 34 35 if (subs == null) { 36 return null; 37 } 38 else { 39 42 LineMapping lines = new LineMapping(text, startLine, startColumn); 43 JavadocNode jd = new JavadocNode(); 44 45 jd.startLine = startLine; 46 jd.startColumn = startColumn; 47 48 Location end = lines.getLocation(text.length() - 1); 49 jd.endLine = end.line; 50 jd.endColumn = end.column; 51 52 if (subs.size() > 0) { 53 Iterator it = subs.iterator(); 54 55 Point descPos = (Point )it.next(); 56 if (descPos != null) { 57 Location[] descLocations = lines.getLocations(descPos); 58 59 61 65 70 jd.description = new JavadocDescriptionNode(text.substring(descPos.x, descPos.y), descLocations[0], descLocations[1]); 71 } 72 73 jd.tagged = new JavadocTaggedNode[subs.size() - 1]; 74 for (int i = 0; it.hasNext(); ++i) { 75 Point pos = (Point )it.next(); 76 Location[] locations = lines.getLocations(pos); 77 78 jd.tagged[i] = new JavadocTaggedNode(text.substring(pos.x, pos.y), locations[0], locations[1]); 79 } 80 } 81 82 return jd; 83 } 84 } 85 86 public JavadocDescriptionNode getDescription() 87 { 88 return description; 89 } 90 91 public JavadocTaggedNode[] getTaggedComments() 92 { 93 return tagged; 94 } 95 96 public int getStartLine() 97 { 98 return startLine; 99 } 100 101 public int getStartColumn() 102 { 103 return startColumn; 104 } 105 106 public int getEndLine() 107 { 108 return endLine; 109 } 110 111 public int getEndColumn() 112 { 113 return endColumn; 114 } 115 116 } 117 | Popular Tags |