private Document _getJavadocDocument(JavaClass javaClass) throws Exception { Element rootElement = _saxReaderUtil.createElement("javadoc"); Document document = _saxReaderUtil.createDocument(rootElement); DocUtil.add(rootElement, "name", javaClass.getName()); DocUtil.add(rootElement, "type", javaClass.getFullyQualifiedName()); _addClassCommentElement(rootElement, javaClass); _addDocletElements(rootElement, javaClass, "author"); _addDocletElements(rootElement, javaClass, "version"); _addDocletElements(rootElement, javaClass, "see"); _addDocletElements(rootElement, javaClass, "since"); _addDocletElements(rootElement, javaClass, "serial"); _addDocletElements(rootElement, javaClass, "deprecated"); JavaMethod[] javaMethods = javaClass.getMethods(); for (JavaMethod javaMethod : javaMethods) { _addMethodElement(rootElement, javaMethod); } JavaField[] javaFields = javaClass.getFields(); for (JavaField javaField : javaFields) { _addFieldElement(rootElement, javaField); } return document; }
private void _addThrowsElement( Element methodElement, Type exception, DocletTag[] throwsDocletTags) { String name = exception.getJavaClass().getName(); String value = null; for (DocletTag throwsDocletTag : throwsDocletTags) { String curValue = throwsDocletTag.getValue(); if (!curValue.startsWith(name)) { continue; } else { curValue = value; break; } } Element throwsElement = methodElement.addElement("throws"); DocUtil.add(throwsElement, "name", name); DocUtil.add(throwsElement, "type", exception.getValue()); if (value != null) { value = value.substring(name.length()); } Element commentElement = throwsElement.addElement("comment"); commentElement.addCDATA(_getCDATA(value)); }
private void _addParamElement( Element methodElement, JavaParameter javaParameter, DocletTag[] paramDocletTags) { String name = javaParameter.getName(); String type = javaParameter.getType().getValue(); String value = null; for (DocletTag paramDocletTag : paramDocletTags) { String curValue = paramDocletTag.getValue(); if (!curValue.startsWith(name)) { continue; } else { curValue = value; break; } } Element paramElement = methodElement.addElement("param"); DocUtil.add(paramElement, "name", name); DocUtil.add(paramElement, "type", type); if (value != null) { value = value.substring(name.length()); } Element commentElement = paramElement.addElement("comment"); commentElement.addCDATA(_getCDATA(value)); }
private void _addReturnElement(Element methodElement, JavaMethod javaMethod) throws Exception { Type returns = javaMethod.getReturns(); if (returns == null) { return; } String returnsValue = returns.getValue(); if (returnsValue.equals("void")) { return; } Element returnElement = methodElement.addElement("return"); DocletTag[] returnDocletTags = javaMethod.getTagsByName("return"); String comment = StringPool.BLANK; if (returnDocletTags.length > 0) { DocletTag returnDocletTag = returnDocletTags[0]; comment = GetterUtil.getString(returnDocletTag.getValue()); DocUtil.add(returnElement, "required", true); } comment = _trimMultilineText(comment); Element commentElement = returnElement.addElement("comment"); commentElement.addCDATA(comment); }
private void _addDocletElements( Element parentElement, AbstractJavaEntity abstractJavaEntity, String name) { DocletTag[] docletTags = abstractJavaEntity.getTagsByName(name); for (DocletTag docletTag : docletTags) { String value = docletTag.getValue(); if (name.equals("author") || name.equals("see") || name.equals("since") || name.equals("version")) { /*if (value.startsWith("Raymond Aug")) { value = "Raymond Aug\u00c3\u00a9"; }*/ DocUtil.add(parentElement, name, value); } else { Element element = parentElement.addElement(name); element.addCDATA(value); } } }
public ExtInfoBuilder(String basedir, String outputDir, String servletContextName) throws Exception { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(basedir); ds.setExcludes( new String[] { ".svn/**", "**/.svn/**", "ext-impl/ext-impl.jar", "ext-impl/src/**", "ext-service/ext-service.jar", "ext-service/src/**", "ext-util-bridges/ext-util-bridges.jar", "ext-util-bridges/src/**", "ext-util-java/ext-util-java.jar", "ext-util-java/src/**", "ext-util-taglib/ext-util-taglib.jar", "ext-util-taglib/src/**", "liferay-plugin-package.properties" }); ds.scan(); String[] files = ds.getIncludedFiles(); Arrays.sort(files); Element rootElement = new ElementImpl(DocumentHelper.createElement("ext-info")); Document document = new DocumentImpl(DocumentHelper.createDocument()); document.setRootElement(rootElement); DocUtil.add(rootElement, "servlet-context-name", servletContextName); Element filesElement = rootElement.addElement("files"); for (String file : files) { DocUtil.add( filesElement, "file", StringUtil.replace(file, StringPool.BACK_SLASH, StringPool.SLASH)); } _fileUtil.write(outputDir + "/ext-" + servletContextName + ".xml", document.formattedString()); }
private void _addFieldElement(Element rootElement, JavaField javaField) { Element fieldElement = rootElement.addElement("field"); DocUtil.add(fieldElement, "name", javaField.getName()); Element commentElement = fieldElement.addElement("comment"); commentElement.addCDATA(_getCDATA(javaField)); _addDocletElements(fieldElement, javaField, "deprecated"); _addDocletElements(fieldElement, javaField, "see"); _addDocletElements(fieldElement, javaField, "since"); _addDocletElements(fieldElement, javaField, "version"); }
private void _addMethodElement(Element rootElement, JavaMethod javaMethod) { Element methodElement = rootElement.addElement("method"); DocUtil.add(methodElement, "name", javaMethod.getName()); Element commentElement = methodElement.addElement("comment"); commentElement.addCDATA(_getCDATA(javaMethod)); _addDocletElements(methodElement, javaMethod, "deprecated"); _addParamElements(methodElement, javaMethod); _addReturnElement(methodElement, javaMethod); _addDocletElements(methodElement, javaMethod, "see"); _addDocletElements(methodElement, javaMethod, "since"); _addThrowsElements(methodElement, javaMethod); _addDocletElements(methodElement, javaMethod, "version"); }
private void _addFieldElement(Element rootElement, JavaField javaField) throws Exception { Element fieldElement = rootElement.addElement("field"); DocUtil.add(fieldElement, "name", javaField.getName()); String comment = _getCDATA(javaField); if (Validator.isNotNull(comment)) { Element commentElement = fieldElement.addElement("comment"); commentElement.addCDATA(comment); } _addDocletElements(fieldElement, javaField, "version"); _addDocletElements(fieldElement, javaField, "see"); _addDocletElements(fieldElement, javaField, "since"); _addDocletElements(fieldElement, javaField, "deprecated"); }
protected void exportExpandoTables(PortletDataContext portletDataContext) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("expando-tables"); Map<String, List<ExpandoColumn>> expandoColumnsMap = portletDataContext.getExpandoColumns(); for (Map.Entry<String, List<ExpandoColumn>> entry : expandoColumnsMap.entrySet()) { String className = entry.getKey(); Element expandoTableElement = rootElement.addElement("expando-table"); expandoTableElement.addAttribute("class-name", className); List<ExpandoColumn> expandoColumns = entry.getValue(); for (ExpandoColumn expandoColumn : expandoColumns) { Element expandoColumnElement = expandoTableElement.addElement("expando-column"); expandoColumnElement.addAttribute("column-id", String.valueOf(expandoColumn.getColumnId())); expandoColumnElement.addAttribute("name", expandoColumn.getName()); expandoColumnElement.addAttribute("type", String.valueOf(expandoColumn.getType())); DocUtil.add(expandoColumnElement, "default-data", expandoColumn.getDefaultData()); Element typeSettingsElement = expandoColumnElement.addElement("type-settings"); UnicodeProperties typeSettingsProperties = expandoColumn.getTypeSettingsProperties(); typeSettingsElement.addCDATA(typeSettingsProperties.toString()); } } portletDataContext.addZipEntry( ExportImportPathUtil.getRootPath(portletDataContext) + "/expando-tables.xml", document.formattedString()); }
private void _addMethodElement(Element rootElement, JavaMethod javaMethod) throws Exception { Element methodElement = rootElement.addElement("method"); DocUtil.add(methodElement, "name", javaMethod.getName()); String comment = _getCDATA(javaMethod); if (Validator.isNotNull(comment)) { Element commentElement = methodElement.addElement("comment"); commentElement.addCDATA(_getCDATA(javaMethod)); } _addDocletElements(methodElement, javaMethod, "version"); _addParamElements(methodElement, javaMethod); _addReturnElement(methodElement, javaMethod); _addThrowsElements(methodElement, javaMethod); _addDocletElements(methodElement, javaMethod, "see"); _addDocletElements(methodElement, javaMethod, "since"); _addDocletElements(methodElement, javaMethod, "deprecated"); }