List of usage examples for javax.swing.text.html.parser TagElement getHTMLTag
public HTML.Tag getHTMLTag()
From source file:org.apache.camel.maven.JavadocParser.java
@Override protected void startTag(TagElement tag) throws ChangedCharSetException { super.startTag(tag); final HTML.Tag htmlTag = tag.getHTMLTag(); if (htmlTag != null) { if (HTML.Tag.A.equals(htmlTag)) { final SimpleAttributeSet attributes = getAttributes(); final Object name = attributes.getAttribute(HTML.Attribute.NAME); if (name != null) { final String nameAttr = (String) name; if (parserState == ParserState.INIT && ("method_summary".equals(nameAttr) || "method.summary".equals(nameAttr))) { parserState = ParserState.METHOD_SUMMARY; } else if (parserState == ParserState.METHOD) { if (methodWithTypes == null) { final String hrefAttr = (String) attributes.getAttribute(HTML.Attribute.HREF); if (hrefAttr != null && hrefAttr.contains(hrefPattern)) { // unescape HTML String methodSignature = hrefAttr.substring(hrefAttr.indexOf('#') + 1); final int firstHyphen = methodSignature.indexOf('-'); if (firstHyphen != -1) { final int lastHyphen = methodSignature.lastIndexOf('-'); methodSignature = methodSignature.substring(0, firstHyphen) + "(" + methodSignature.substring(firstHyphen + 1, lastHyphen) + ")"; methodSignature = methodSignature.replaceAll("-", ","); }/*from ww w . j a va2 s .c om*/ // support varargs if (methodSignature.contains("...)")) { methodSignature = methodSignature.replaceAll("\\.\\.\\.\\)", "[])"); } // map Java8 array types if (methodSignature.contains(":A")) { methodSignature = methodSignature.replaceAll(":A", "[]"); } methodWithTypes = unescapeHtml(methodSignature); } } else { final String title = (String) attributes.getAttribute(HTML.Attribute.TITLE); if (title != null) { // append package name to type name text methodTextBuilder.append(title.substring(title.lastIndexOf(' '))).append('.'); } } } } } else if (parserState == ParserState.METHOD_SUMMARY && HTML.Tag.CODE.equals(htmlTag)) { parserState = ParserState.METHOD; } } }
From source file:org.apache.camel.maven.JavadocParser.java
@Override protected void handleEmptyTag(TagElement tag) { if (parserState == ParserState.METHOD && HTML.Tag.CODE.equals(tag.getHTMLTag())) { if (methodWithTypes != null) { // process collected method data methods.add(methodWithTypes); this.methodText.put(methodWithTypes, getArgSignature()); // clear the text builder for next method methodTextBuilder.delete(0, methodTextBuilder.length()); methodWithTypes = null;//from w w w.ja v a 2s .c om } parserState = ParserState.METHOD_SUMMARY; } else if (parserState == ParserState.METHOD_SUMMARY && HTML.Tag.TABLE.equals(tag.getHTMLTag())) { // end of method summary table parserState = ParserState.INIT; } }