@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equalsIgnoreCase("class")) { classInfo.put(className, oci); className = null; oci = null; } else if (qName.equalsIgnoreCase("comment") && oci != null) { if (methodName != null) { // do nothing if (isGetter(methodName)) { MethodInfo mi = oci.getMethods.get(methodName); if (mi == null) { mi = new MethodInfo(); oci.getMethods.put(methodName, mi); } mi.comment = comment.toString(); } else if (isSetter(methodName)) { MethodInfo mi = oci.setMethods.get(methodName); if (mi == null) { mi = new MethodInfo(); oci.setMethods.put(methodName, mi); } mi.comment = comment.toString(); } } else if (fieldName != null) { oci.fields.put(fieldName, comment.toString()); } else { oci.comment = comment.toString(); } comment = null; } else if (qName.equalsIgnoreCase("field")) { fieldName = null; } else if (qName.equalsIgnoreCase("method")) { methodName = null; } }
private static String decamelizeClassName(String className) { Matcher match = CAPS.matcher(className); StringBuilder deCameled = new StringBuilder(); while (match.find()) { if (deCameled.length() == 0) { deCameled.append(match.group()); } else { deCameled.append(" "); deCameled.append(match.group().toLowerCase()); } } return deCameled.toString(); }
@Override public void characters(char ch[], int start, int length) throws SAXException { if (comment != null) { comment.append(ch, start, length); } }