1 52 53 package com.go.beandoc.teadoc; 54 55 import java.util.StringTokenizer ; 56 import java.util.ArrayList ; 57 58 64 public class Doc implements java.io.Serializable , Comparable { 65 66 protected RootDoc mRootDoc; 67 68 private com.sun.javadoc.Doc mDoc; 69 private String [] mPath; 70 71 public Doc(RootDoc root, com.sun.javadoc.Doc doc) { 72 mRootDoc = root; 73 mDoc = doc; 74 } 75 76 protected String [] parseName(String name) { 77 ArrayList list = new ArrayList (); 78 StringTokenizer st = new StringTokenizer (name, "."); 79 while (st.hasMoreElements()) { 80 list.add(st.nextElement()); 81 } 82 83 return (String [])list.toArray(new String [list.size()]); 84 } 85 86 public com.sun.javadoc.Doc getInnerDoc() { 87 return mDoc; 88 } 89 90 public RootDoc getRootDoc() { 91 return mRootDoc; 92 } 93 94 public String getCommentText() { 95 96 String commentText = mDoc.commentText(); 97 if (commentText != null && commentText.trim().length() > 0) { 98 return commentText; 99 } 100 101 return null; 102 } 103 104 107 public boolean isTagPresent(String tagName) { 108 109 Tag[] tags = getTagMap().get(tagName); 110 return (tags != null && tags.length > 0); 111 } 112 113 114 117 public String getTagValue(String tagName) { 118 119 Tag[] tags = getTagMap().get(tagName); 120 if (tags == null || tags.length == 0) { 121 return null; 122 } 123 124 return tags[tags.length - 1].getText(); 125 } 126 127 public Tag[] getTags() { 128 return Tag.convert(mRootDoc, mDoc.tags()); 129 } 130 131 public TagMap getTagMap() { 132 return new TagMap(); 133 } 134 135 public SeeTag[] getSeeTags() { 136 return SeeTag.convert(mRootDoc, mDoc.seeTags()); 137 } 138 139 public Tag[] getInlineTags() { 140 return Tag.convert(mRootDoc, mDoc.inlineTags()); 141 } 142 143 public Tag[] getFirstSentenceTags() { 144 return Tag.convert(mRootDoc, mDoc.firstSentenceTags()); 145 } 146 147 public String getRawCommentText() { 148 return mDoc.getRawCommentText(); 149 } 150 151 public String getName() { 152 return mDoc.name(); 153 } 154 155 public String [] getPath() { 156 if (mPath == null) { 157 mPath = parseName(getName()); 158 } 159 160 return mPath; 161 } 162 163 public int compareTo(Object obj) { 164 if (obj instanceof Doc) { 165 return mDoc.compareTo(((Doc)obj).mDoc); 166 } 167 else { 168 return 0; 169 } 170 } 171 172 public boolean isField() { 173 return mDoc.isField(); 174 } 175 176 public boolean isMethod() { 177 return mDoc.isMethod(); 178 } 179 180 public boolean isConstructor() { 181 return mDoc.isConstructor(); 182 } 183 184 public boolean isInterface() { 185 return mDoc.isInterface(); 186 } 187 188 public boolean isException() { 189 return mDoc.isException(); 190 } 191 192 public boolean isError() { 193 return mDoc.isError(); 194 } 195 196 public boolean isOrdinaryClass() { 197 return mDoc.isOrdinaryClass(); 198 } 199 200 public boolean isClass() { 201 return mDoc.isClass(); 202 } 203 204 public boolean isIncluded() { 205 return mDoc.isIncluded(); 206 } 207 208 public boolean equals(Object obj) { 209 return obj instanceof Doc && mDoc.equals(((Doc)obj).mDoc); 210 } 211 212 public class TagMap { 213 214 public TagMap() { 215 } 216 217 public Tag[] get(String tagName) { 218 return Tag.convert(mRootDoc, mDoc.tags(tagName)); 219 } 220 221 } 222 223 } 224 | Popular Tags |