diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java index 82e7e7e3437074f96b748599cc60afb5073f5887..4145af7cb90767bb2574337e2c91f63f8ad42e5b 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java @@ -92,43 +92,41 @@ public abstract class AbstractBuilder { public abstract void build() throws IOException; /** - * Build the documentation, as specified by the given XML elements. + * Build the documentation, as specified by the given XML element. * - * @param elements the XML elements that specify which components to - * document. + * @param node the XML element that specifies which component to document. */ - protected void build(List elements) { - for (int i = 0; i < elements.size(); i++ ) { - Object element = elements.get(i); - String component = (String) - ((element instanceof String) ? - element : - ((List) element).get(0)); - try { - invokeMethod("build" + component, - element instanceof String ? - new Class[] {} : - new Class[] {List.class}, - element instanceof String ? - new Object[] {} : - new Object[] {((List) element).subList(1, - ((List) element).size())}); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - configuration.root.printError("Unknown element: " + component); - throw new DocletAbortException(); - } catch (InvocationTargetException e) { - e.getCause().printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - configuration.root.printError("Exception " + - e.getClass().getName() + - " thrown while processing element: " + component); - throw new DocletAbortException(); - } + protected void build(XMLNode node) { + String component = node.name; + try { + invokeMethod("build" + component, + new Class[] { XMLNode.class }, + new Object[] { node }); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + configuration.root.printError("Unknown element: " + component); + throw new DocletAbortException(); + } catch (InvocationTargetException e) { + e.getCause().printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + configuration.root.printError("Exception " + + e.getClass().getName() + + " thrown while processing element: " + component); + throw new DocletAbortException(); } } + /** + * Build the documentation, as specified by the children of the given XML element. + * + * @param node the XML element that specifies which components to document. + */ + protected void buildChildren(XMLNode node) { + for (XMLNode child: node.children) + build(child); + } + /** * Given the name and parameters, invoke the method in the builder. This * method is required to invoke the appropriate build method as instructed @@ -138,7 +136,14 @@ public abstract class AbstractBuilder { * @param paramClasses the types for each parameter. * @param params the parameters of the method. */ - protected abstract void invokeMethod(String methodName, Class[] paramClasses, + protected void invokeMethod(String methodName, Class[] paramClasses, Object[] params) - throws Exception; + throws Exception { + if (DEBUG) { + configuration.root.printError("DEBUG: " + this.getClass().getName() + + "." + methodName); + } + Method method = this.getClass().getMethod(methodName, paramClasses); + method.invoke(this, params); + } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java index 0d5b77dba4857522e800472bea13a4a131e02ad8..f91fbd62cc9994ea739ab2782834c370fcfe8707 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java @@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.builders; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; -import java.util.*; /** * The superclass for all member builders. Member builders are only executed @@ -69,9 +68,10 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder { * * @param elements {@inheritDoc} */ - public void build(List elements) { + @Override + public void build(XMLNode node) { if (hasMembersToDocument()) { - super.build(elements); + super.build(node); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java index aa8d73f5aac109aaa999fa8ee3b93d450b5bf930..8df119853c863d8a78272717673b4274766054d3 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java @@ -30,7 +30,6 @@ import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; import java.util.*; -import java.lang.reflect.*; /** * Builds the summary for a given annotation type. @@ -89,20 +88,6 @@ public class AnnotationTypeBuilder extends AbstractBuilder { return builder; } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * {@inheritDoc} */ @@ -122,8 +107,8 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param elements the XML elements that specify how to document a class. */ - public void buildAnnotationTypeDoc(List elements) throws Exception { - build(elements); + public void buildAnnotationTypeDoc(XMLNode node) throws Exception { + buildChildren(node); writer.close(); copyDocFiles(); } @@ -154,7 +139,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder { /** * Build the header of the page. */ - public void buildAnnotationTypeHeader() { + public void buildAnnotationTypeHeader(XMLNode node) { writer.writeHeader(configuration.getText("doclet.AnnotationType") + " " + annotationTypeDoc.name()); } @@ -162,14 +147,14 @@ public class AnnotationTypeBuilder extends AbstractBuilder { /** * If this class is deprecated, print the appropriate information. */ - public void buildDeprecationInfo () { + public void buildDeprecationInfo (XMLNode node) { writer.writeAnnotationTypeDeprecationInfo(); } /** * Build the signature of the current annotation type. */ - public void buildAnnotationTypeSignature() { + public void buildAnnotationTypeSignature(XMLNode node) { StringBuffer modifiers = new StringBuffer( annotationTypeDoc.modifiers() + " "); writer.writeAnnotationTypeSignature( @@ -180,14 +165,14 @@ public class AnnotationTypeBuilder extends AbstractBuilder { /** * Build the class description. */ - public void buildAnnotationTypeDescription() { + public void buildAnnotationTypeDescription(XMLNode node) { writer.writeAnnotationTypeDescription(); } /** * Build the tag information for the current class. */ - public void buildAnnotationTypeTagInfo() { + public void buildAnnotationTypeTagInfo(XMLNode node) { writer.writeAnnotationTypeTagInfo(); } @@ -197,9 +182,9 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * @param elements the XML elements that specify how a member summary is * documented. */ - public void buildMemberSummary(List elements) throws Exception { + public void buildMemberSummary(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getMemberSummaryBuilder(writer).build(elements); + getMemberSummaryBuilder(writer).buildChildren(node); writer.completeMemberSummaryBuild(); } @@ -209,10 +194,10 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * @param elements the XML elements that specify how a annotation type * members are documented. */ - public void buildAnnotationTypeOptionalMemberDetails(List elements) + public void buildAnnotationTypeOptionalMemberDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getAnnotationTypeOptionalMemberBuilder(writer).build(elements); + getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node); } /** @@ -221,17 +206,17 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * @param elements the XML elements that specify how a annotation type * members are documented. */ - public void buildAnnotationTypeRequiredMemberDetails(List elements) + public void buildAnnotationTypeRequiredMemberDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getAnnotationTypeRequiredMemberBuilder(writer).build(elements); + getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node); } /** * Build the footer of the page. */ - public void buildAnnotationTypeFooter() { + public void buildAnnotationTypeFooter(XMLNode node) { writer.writeFooter(); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java index 9cc8522838def7490e89a2379881ad4c2c9dfb33..632f26a7ce1b214b78b7402787811c16f82c99fc 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java @@ -30,7 +30,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; /** * Builds documentation for optional annotation type members. @@ -85,6 +84,7 @@ public class AnnotationTypeOptionalMemberBuilder extends /** * {@inheritDoc} */ + @Override public String getName() { return "AnnotationTypeOptionalMemberDetails"; } @@ -95,34 +95,20 @@ public class AnnotationTypeOptionalMemberBuilder extends * @param elements the XML elements that specify how to construct this * documentation. */ - public void buildAnnotationTypeOptionalMember(List elements) { + public void buildAnnotationTypeOptionalMember(XMLNode node) { if (writer == null) { return; } for (currentMemberIndex = 0; currentMemberIndex < members.size(); currentMemberIndex++) { - build(elements); + buildChildren(node); } } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Document the default value for this optional member. */ - public void buildDefaultValueInfo() { + public void buildDefaultValueInfo(XMLNode node) { ((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo( (MemberDoc) members.get(currentMemberIndex)); } @@ -130,6 +116,7 @@ public class AnnotationTypeOptionalMemberBuilder extends /** * {@inheritDoc} */ + @Override public AnnotationTypeRequiredMemberWriter getWriter() { return writer; } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index add03d16895df92aaa8cbbc8432d3b2d9cf11218..f278e696b984b80b77e0bdd5d3a8ec0a155a1054 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -30,7 +30,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; /** * Builds documentation for required annotation type members. @@ -113,20 +112,6 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { return "AnnotationTypeRequiredMemberDetails"; } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Returns a list of members that will be documented for the given class. * This information can be used for doclet specific documentation @@ -161,20 +146,20 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { * @param elements the XML elements that specify how to construct this * documentation. */ - public void buildAnnotationTypeRequiredMember(List elements) { + public void buildAnnotationTypeRequiredMember(XMLNode node) { if (writer == null) { return; } for (currentMemberIndex = 0; currentMemberIndex < members.size(); currentMemberIndex++) { - build(elements); + buildChildren(node); } } /** * Build the overall header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader(classDoc, configuration.getText("doclet.Annotation_Type_Member_Detail")); } @@ -182,7 +167,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { /** * Build the header for the individual members. */ - public void buildMemberHeader() { + public void buildMemberHeader(XMLNode node) { writer.writeMemberHeader((MemberDoc) members.get( currentMemberIndex), currentMemberIndex == 0); @@ -191,14 +176,14 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { /** * Build the signature. */ - public void buildSignature() { + public void buildSignature(XMLNode node) { writer.writeSignature((MemberDoc) members.get(currentMemberIndex)); } /** * Build the deprecation information. */ - public void buildDeprecationInfo() { + public void buildDeprecationInfo(XMLNode node) { writer.writeDeprecated((MemberDoc) members.get(currentMemberIndex)); } @@ -206,7 +191,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { * Build the comments for the member. Do nothing if * {@link Configuration#nocomment} is set to true. */ - public void buildMemberComments() { + public void buildMemberComments(XMLNode node) { if(! configuration.nocomment){ writer.writeComments((MemberDoc) members.get(currentMemberIndex)); } @@ -215,21 +200,21 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { /** * Build the tag information. */ - public void buildTagInfo() { + public void buildTagInfo(XMLNode node) { writer.writeTags((MemberDoc) members.get(currentMemberIndex)); } /** * Build the footer for the individual member. */ - public void buildMemberFooter() { + public void buildMemberFooter(XMLNode node) { writer.writeMemberFooter(); } /** * Build the overall footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(classDoc); } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java index 6ff14c64e202f1f572cf7551b96f247118481e46..15a5341d8d1956c94db1c1b245978d042ff4f3a1 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java @@ -30,7 +30,6 @@ import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; import java.util.*; -import java.lang.reflect.*; /** * Builds the summary for a given class. @@ -105,20 +104,6 @@ public class ClassBuilder extends AbstractBuilder { return builder; } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * {@inheritDoc} */ @@ -138,8 +123,8 @@ public class ClassBuilder extends AbstractBuilder { * * @param elements the XML elements that specify how to document a class. */ - public void buildClassDoc(List elements) throws Exception { - build(elements); + public void buildClassDoc(XMLNode node) throws Exception { + buildChildren(node); writer.close(); copyDocFiles(); } @@ -169,7 +154,7 @@ public class ClassBuilder extends AbstractBuilder { /** * Build the header of the page. */ - public void buildClassHeader() { + public void buildClassHeader(XMLNode node) { String key; if (isInterface) { key = "doclet.Interface"; @@ -185,7 +170,7 @@ public class ClassBuilder extends AbstractBuilder { /** * Build the class tree documentation. */ - public void buildClassTree() { + public void buildClassTree(XMLNode node) { writer.writeClassTree(); } @@ -193,42 +178,42 @@ public class ClassBuilder extends AbstractBuilder { * If this is a class, list all interfaces * implemented by this class. */ - public void buildImplementedInterfacesInfo() { + public void buildImplementedInterfacesInfo(XMLNode node) { writer.writeImplementedInterfacesInfo(); } /** * If this is an interface, list all super interfaces. */ - public void buildSuperInterfacesInfo() { + public void buildSuperInterfacesInfo(XMLNode node) { writer.writeSuperInterfacesInfo(); } /** * List the parameters of this class. */ - public void buildTypeParamInfo() { + public void buildTypeParamInfo(XMLNode node) { writer.writeTypeParamInfo(); } /** * List all the classes extend this one. */ - public void buildSubClassInfo() { + public void buildSubClassInfo(XMLNode node) { writer.writeSubClassInfo(); } /** * List all the interfaces that extend this one. */ - public void buildSubInterfacesInfo() { + public void buildSubInterfacesInfo(XMLNode node) { writer.writeSubInterfacesInfo(); } /** * If this is an interface, list all classes that implement this interface. */ - public void buildInterfaceUsageInfo () { + public void buildInterfaceUsageInfo (XMLNode node) { writer.writeInterfaceUsageInfo(); } @@ -236,21 +221,21 @@ public class ClassBuilder extends AbstractBuilder { * If this is an inner class or interface, list the enclosing class or * interface. */ - public void buildNestedClassInfo () { + public void buildNestedClassInfo (XMLNode node) { writer.writeNestedClassInfo(); } /** * If this class is deprecated, print the appropriate information. */ - public void buildDeprecationInfo () { + public void buildDeprecationInfo (XMLNode node) { writer.writeClassDeprecationInfo(); } /** * Build the signature of the current class. */ - public void buildClassSignature() { + public void buildClassSignature(XMLNode node) { StringBuffer modifiers = new StringBuffer(classDoc.modifiers() + " "); if (isEnum) { modifiers.append("enum "); @@ -276,14 +261,14 @@ public class ClassBuilder extends AbstractBuilder { /** * Build the class description. */ - public void buildClassDescription() { + public void buildClassDescription(XMLNode node) { writer.writeClassDescription(); } /** * Build the tag information for the current class. */ - public void buildClassTagInfo() { + public void buildClassTagInfo(XMLNode node) { writer.writeClassTagInfo(); } @@ -293,9 +278,9 @@ public class ClassBuilder extends AbstractBuilder { * @param elements the XML elements that specify how a member summary is * documented. */ - public void buildMemberSummary(List elements) throws Exception { + public void buildMemberSummary(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getMemberSummaryBuilder(writer).build(elements); + getMemberSummaryBuilder(writer).buildChildren(node); writer.completeMemberSummaryBuild(); } @@ -305,9 +290,9 @@ public class ClassBuilder extends AbstractBuilder { * @param elements the XML elements that specify how a enum constants are * documented. */ - public void buildEnumConstantsDetails(List elements) throws Exception { + public void buildEnumConstantsDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getEnumConstantsBuilder(writer).build(elements); + getEnumConstantsBuilder(writer).buildChildren(node); } /** @@ -315,9 +300,9 @@ public class ClassBuilder extends AbstractBuilder { * * @param elements the XML elements that specify how a field is documented. */ - public void buildFieldDetails(List elements) throws Exception { + public void buildFieldDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getFieldBuilder(writer).build(elements); + getFieldBuilder(writer).buildChildren(node); } /** @@ -326,9 +311,9 @@ public class ClassBuilder extends AbstractBuilder { * @param elements the XML elements that specify how to document a * constructor. */ - public void buildConstructorDetails(List elements) throws Exception { + public void buildConstructorDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getConstructorBuilder(writer).build(elements); + getConstructorBuilder(writer).buildChildren(node); } /** @@ -336,15 +321,15 @@ public class ClassBuilder extends AbstractBuilder { * * @param elements the XML elements that specify how a method is documented. */ - public void buildMethodDetails(List elements) throws Exception { + public void buildMethodDetails(XMLNode node) throws Exception { configuration.getBuilderFactory(). - getMethodBuilder(writer).build(elements); + getMethodBuilder(writer).buildChildren(node); } /** * Build the footer of the page. */ - public void buildClassFooter() { + public void buildClassFooter(XMLNode node) { writer.writeFooter(); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java index 61971b055525af6a39df236c7c1f0f7719869fa9..2126b619ba73912185182575266338adb8d35703 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java @@ -30,7 +30,6 @@ import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; import java.util.*; -import java.lang.reflect.*; /** * Builds the Constants Summary Page. @@ -106,20 +105,6 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { return builder; } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * {@inheritDoc} */ @@ -144,29 +129,29 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param elements the list of elements describing constant summary * documentation. */ - public void buildConstantSummary(List elements) throws Exception { - build(elements); + public void buildConstantSummary(XMLNode node) throws Exception { + buildChildren(node); writer.close(); } /** * Build the header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader(); } /** * Build the footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(); } /** * Build the table of contents. */ - public void buildContents() { + public void buildContents(XMLNode node) { writer.writeContentsHeader(); PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet(); @@ -186,14 +171,14 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param elements the XML elements that represent the components * of documentation for each package. */ - public void buildConstantSummaries(List elements) { + public void buildConstantSummaries(XMLNode node) { PackageDoc[] packages = configuration.packages; printedPackageHeaders = new HashSet(); for (int i = 0; i < packages.length; i++) { if (hasConstantField(packages[i])) { currentPackage = packages[i]; //Build the documentation for the current package. - build(elements); + buildChildren(node); } } } @@ -204,8 +189,8 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param elements the list of XML elements that make up package * documentation. */ - public void buildPackageConstantSummary(List elements) { - build(elements); + public void buildPackageConstantSummary(XMLNode node) { + buildChildren(node); } /** @@ -214,7 +199,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * @param elements the list of XML elements that make up the class * constant summary. */ - public void buildClassConstantSummary(List elements) { + public void buildClassConstantSummary(XMLNode node) { ClassDoc[] classes = currentPackage.name().length() > 0 ? currentPackage.allClasses() : configuration.classDocCatalog.allClasses( @@ -227,14 +212,14 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { } currentClass = classes[i]; //Build the documentation for the current class. - build(elements); + buildChildren(node); } } /** * Build the header for the given class. */ - public void buildPackageHeader() { + public void buildPackageHeader(XMLNode node) { String parsedPackageName = parsePackageName(currentPackage.name()); if (! printedPackageHeaders.contains(parsedPackageName)) { writer.writePackageName(currentPackage, @@ -246,7 +231,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * Build the header for the given class. */ - public void buildClassHeader() { + public void buildClassHeader(XMLNode node) { writer.writeConstantMembersHeader(currentClass); } @@ -254,14 +239,14 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * Print summary of constant members in the * class. */ - public void buildConstantMembers() { - new ConstantFieldBuilder(currentClass).buildMembersSummary(); + public void buildConstantMembers(XMLNode node) { + new ConstantFieldBuilder(currentClass).buildMembersSummary(node); } /** * Build the footer for the given class. */ - public void buildClassFooter() { + public void buildClassFooter(XMLNode node) { writer.writeConstantMembersFooter(currentClass); } @@ -362,7 +347,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * Builds the table of constants for a given class. */ - protected void buildMembersSummary() { + protected void buildMembersSummary(XMLNode node) { List members = new ArrayList(members()); if (members.size() > 0) { Collections.sort(members); diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java index f5b4ae072dec56f9102f31a5b426ef1913436df5..ea3b3bee97c0acf3d41daddd8cd57a36ff4c5898 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java @@ -28,7 +28,6 @@ package com.sun.tools.doclets.internal.toolkit.builders; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; -import java.lang.reflect.*; import java.util.*; /** @@ -133,22 +132,6 @@ public class ConstructorBuilder extends AbstractMemberBuilder { return constructors.size() > 0; } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Returns a list of constructors that will be documented for the given class. * This information can be used for doclet specific documentation @@ -175,21 +158,21 @@ public class ConstructorBuilder extends AbstractMemberBuilder { * @param elements the XML elements that specify how to construct this * documentation. */ - public void buildConstructorDoc(List elements) { + public void buildConstructorDoc(XMLNode node) { if (writer == null) { return; } for (currentMethodIndex = 0; currentMethodIndex < constructors.size(); currentMethodIndex++) { - build(elements); + buildChildren(node); } } /** * Build the overall header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader( classDoc, configuration.getText("doclet.Constructor_Detail")); @@ -198,7 +181,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * Build the header for the individual constructor. */ - public void buildConstructorHeader() { + public void buildConstructorHeader(XMLNode node) { writer.writeConstructorHeader( (ConstructorDoc) constructors.get(currentMethodIndex), currentMethodIndex == 0); @@ -207,7 +190,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * Build the signature. */ - public void buildSignature() { + public void buildSignature(XMLNode node) { writer.writeSignature( (ConstructorDoc) constructors.get(currentMethodIndex)); } @@ -215,7 +198,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * Build the deprecation information. */ - public void buildDeprecationInfo() { + public void buildDeprecationInfo(XMLNode node) { writer.writeDeprecated( (ConstructorDoc) constructors.get(currentMethodIndex)); } @@ -224,7 +207,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { * Build the comments for the constructor. Do nothing if * {@link Configuration#nocomment} is set to true. */ - public void buildConstructorComments() { + public void buildConstructorComments(XMLNode node) { if (!configuration.nocomment) { writer.writeComments( (ConstructorDoc) constructors.get(currentMethodIndex)); @@ -234,21 +217,21 @@ public class ConstructorBuilder extends AbstractMemberBuilder { /** * Build the tag information. */ - public void buildTagInfo() { + public void buildTagInfo(XMLNode node) { writer.writeTags((ConstructorDoc) constructors.get(currentMethodIndex)); } /** * Build the footer for the individual constructor. */ - public void buildConstructorFooter() { + public void buildConstructorFooter(XMLNode node) { writer.writeConstructorFooter(); } /** * Build the overall footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(classDoc); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java index 038e03f03fd512cbd2fdede797175291d4fb0c80..f0cff8374b5ebe028d0cb3a2daedd3036d40e687 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java @@ -29,7 +29,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; /** * Builds documentation for a enum constants. @@ -115,22 +114,6 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { return "EnumConstantDetails"; } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Returns a list of enum constants that will be documented for the given class. * This information can be used for doclet specific documentation @@ -165,21 +148,21 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { * @param elements the XML elements that specify how to construct this * documentation. */ - public void buildEnumConstant(List elements) { + public void buildEnumConstant(XMLNode node) { if (writer == null) { return; } for (currentEnumConstantsIndex = 0; currentEnumConstantsIndex < enumConstants.size(); currentEnumConstantsIndex++) { - build(elements); + buildChildren(node); } } /** * Build the overall header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader( classDoc, configuration.getText("doclet.Enum_Constant_Detail")); @@ -188,7 +171,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Build the header for the individual enum constants. */ - public void buildEnumConstantHeader() { + public void buildEnumConstantHeader(XMLNode node) { writer.writeEnumConstantHeader( (FieldDoc) enumConstants.get(currentEnumConstantsIndex), currentEnumConstantsIndex == 0); @@ -197,7 +180,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Build the signature. */ - public void buildSignature() { + public void buildSignature(XMLNode node) { writer.writeSignature( (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); } @@ -205,7 +188,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Build the deprecation information. */ - public void buildDeprecationInfo() { + public void buildDeprecationInfo(XMLNode node) { writer.writeDeprecated( (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); } @@ -214,7 +197,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { * Build the comments for the enum constant. Do nothing if * {@link Configuration#nocomment} is set to true. */ - public void buildEnumConstantComments() { + public void buildEnumConstantComments(XMLNode node) { if (!configuration.nocomment) { writer.writeComments( (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); @@ -224,7 +207,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Build the tag information. */ - public void buildTagInfo() { + public void buildTagInfo(XMLNode node) { writer.writeTags( (FieldDoc) enumConstants.get(currentEnumConstantsIndex)); } @@ -232,14 +215,14 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * Build the footer for the individual enum constants. */ - public void buildEnumConstantFooter() { + public void buildEnumConstantFooter(XMLNode node) { writer.writeEnumConstantFooter(); } /** * Build the overall footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(classDoc); } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java index 0c1d121bccefe39809312585bc548898f5c45da7..0e381f2ed0da433c7a7f035918e6fe371f46bc21 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java @@ -29,7 +29,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; /** * Builds documentation for a field. @@ -116,22 +115,6 @@ public class FieldBuilder extends AbstractMemberBuilder { return "FieldDetails"; } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Returns a list of fields that will be documented for the given class. * This information can be used for doclet specific documentation @@ -166,21 +149,21 @@ public class FieldBuilder extends AbstractMemberBuilder { * @param elements the XML elements that specify how to construct this * documentation. */ - public void buildFieldDoc(List elements) { + public void buildFieldDoc(XMLNode node) { if (writer == null) { return; } for (currentFieldIndex = 0; currentFieldIndex < fields.size(); currentFieldIndex++) { - build(elements); + buildChildren(node); } } /** * Build the overall header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader( classDoc, configuration.getText("doclet.Field_Detail")); @@ -189,7 +172,7 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * Build the header for the individual field. */ - public void buildFieldHeader() { + public void buildFieldHeader(XMLNode node) { writer.writeFieldHeader( (FieldDoc) fields.get(currentFieldIndex), currentFieldIndex == 0); @@ -198,14 +181,14 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * Build the signature. */ - public void buildSignature() { + public void buildSignature(XMLNode node) { writer.writeSignature((FieldDoc) fields.get(currentFieldIndex)); } /** * Build the deprecation information. */ - public void buildDeprecationInfo() { + public void buildDeprecationInfo(XMLNode node) { writer.writeDeprecated((FieldDoc) fields.get(currentFieldIndex)); } @@ -213,7 +196,7 @@ public class FieldBuilder extends AbstractMemberBuilder { * Build the comments for the field. Do nothing if * {@link Configuration#nocomment} is set to true. */ - public void buildFieldComments() { + public void buildFieldComments(XMLNode node) { if (!configuration.nocomment) { writer.writeComments((FieldDoc) fields.get(currentFieldIndex)); } @@ -222,21 +205,21 @@ public class FieldBuilder extends AbstractMemberBuilder { /** * Build the tag information. */ - public void buildTagInfo() { + public void buildTagInfo(XMLNode node) { writer.writeTags((FieldDoc) fields.get(currentFieldIndex)); } /** * Build the footer for the individual field. */ - public void buildFieldFooter() { + public void buildFieldFooter(XMLNode node) { writer.writeFieldFooter(); } /** * Build the overall footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(classDoc); } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java index 321c42b6b09f6540eef43ad8e9bcc228b1bbdc71..3b413e7b75b536236e797bfdb347ef6b5eea2dac 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java @@ -45,8 +45,8 @@ public class LayoutParser extends DefaultHandler { /** * The map of XML elements that have been parsed. */ - private Map> xmlElementsMap; - + private Map xmlElementsMap; + private XMLNode currentNode; private Configuration configuration; private static LayoutParser instance; private String currentRoot; @@ -56,7 +56,7 @@ public class LayoutParser extends DefaultHandler { * This class is a singleton. */ private LayoutParser(Configuration configuration) { - xmlElementsMap = new HashMap>(); + xmlElementsMap = new HashMap(); this.configuration = configuration; } @@ -78,20 +78,18 @@ public class LayoutParser extends DefaultHandler { * * @return List the list of XML elements parsed. */ - public List parseXML(String root) { + public XMLNode parseXML(String root) { if (xmlElementsMap.containsKey(root)) { return xmlElementsMap.get(root); } try { - List xmlElements = new ArrayList(); - xmlElementsMap.put(root, xmlElements); currentRoot = root; isParsing = false; SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); InputStream in = configuration.getBuilderXML(); saxParser.parse(in, this); - return xmlElements; + return xmlElementsMap.get(root); } catch (Throwable t) { t.printStackTrace(); throw new DocletAbortException(); @@ -101,39 +99,30 @@ public class LayoutParser extends DefaultHandler { /** * {@inheritDoc} */ + @Override public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException { if (isParsing || qName.equals(currentRoot)) { isParsing = true; - List xmlElements = xmlElementsMap.get(currentRoot); - xmlElements.add(qName); + currentNode = new XMLNode(currentNode, qName); + for (int i = 0; i < attrs.getLength(); i++) + currentNode.attrs.put(attrs.getLocalName(i), attrs.getValue(i)); + if (qName.equals(currentRoot)) + xmlElementsMap.put(qName, currentNode); } } /** * {@inheritDoc} */ + @Override public void endElement(String namespaceURI, String sName, String qName) throws SAXException { if (! isParsing) { - isParsing = false; - return; - } - List xmlElements = xmlElementsMap.get(currentRoot); - if (xmlElements.get(xmlElements.size()-1).equals(qName)) { return; - } else { - List subElements = new ArrayList(); - int targetIndex = xmlElements.indexOf(qName); - int size = xmlElements.size(); - for (int i = targetIndex; i < size; i++) { - subElements.add(xmlElements.get(targetIndex)); - xmlElements.remove(targetIndex); - } - //Save the sub elements as a list. - xmlElements.add(subElements); } + currentNode = currentNode.parent; isParsing = ! qName.equals(currentRoot); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java index 0b4e6e73be9a4b64c4eaa0e950c121f53639a240..404b2e6d1cfac44c3cc813261388837a68e674d7 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java @@ -29,7 +29,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; /** * Builds the member summary. @@ -174,22 +173,6 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { return visibleMemberMaps[type].getLeafClassMembers(configuration); } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Return true it there are any members to summarize. * @@ -211,7 +194,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the summary for the enum constants. */ - public void buildEnumConstantsSummary() { + public void buildEnumConstantsSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS], visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS]); @@ -220,7 +203,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the summary for the optional members. */ - public void buildAnnotationTypeOptionalMemberSummary() { + public void buildAnnotationTypeOptionalMemberSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL], visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL]); @@ -229,7 +212,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the summary for the optional members. */ - public void buildAnnotationTypeRequiredMemberSummary() { + public void buildAnnotationTypeRequiredMemberSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED], visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED]); @@ -238,7 +221,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the summary for the fields. */ - public void buildFieldsSummary() { + public void buildFieldsSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.FIELDS], visibleMemberMaps[VisibleMemberMap.FIELDS]); @@ -247,7 +230,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the inherited summary for the fields. */ - public void buildFieldsInheritedSummary() { + public void buildFieldsInheritedSummary(XMLNode node) { buildInheritedSummary( memberSummaryWriters[VisibleMemberMap.FIELDS], visibleMemberMaps[VisibleMemberMap.FIELDS]); @@ -256,7 +239,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the summary for the nested classes. */ - public void buildNestedClassesSummary() { + public void buildNestedClassesSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.INNERCLASSES], visibleMemberMaps[VisibleMemberMap.INNERCLASSES]); @@ -265,7 +248,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the inherited summary for the nested classes. */ - public void buildNestedClassesInheritedSummary() { + public void buildNestedClassesInheritedSummary(XMLNode node) { buildInheritedSummary( memberSummaryWriters[VisibleMemberMap.INNERCLASSES], visibleMemberMaps[VisibleMemberMap.INNERCLASSES]); @@ -274,7 +257,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the method summary. */ - public void buildMethodsSummary() { + public void buildMethodsSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.METHODS], visibleMemberMaps[VisibleMemberMap.METHODS]); @@ -283,7 +266,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the inherited method summary. */ - public void buildMethodsInheritedSummary() { + public void buildMethodsInheritedSummary(XMLNode node) { buildInheritedSummary( memberSummaryWriters[VisibleMemberMap.METHODS], visibleMemberMaps[VisibleMemberMap.METHODS]); @@ -292,7 +275,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { /** * Build the constructor summary. */ - public void buildConstructorsSummary() { + public void buildConstructorsSummary(XMLNode node) { buildSummary( memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS], visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS]); diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java index 18fa6e8e229acd5a6e6abdec3e55726ebb902168..04816ac65f2c16f15d831cc16987712e42c82f98 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java @@ -29,7 +29,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; -import java.lang.reflect.*; + /** * Builds documentation for a method. * @@ -111,22 +111,6 @@ public class MethodBuilder extends AbstractMemberBuilder { return "MethodDetails"; } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Returns a list of methods that will be documented for the given class. * This information can be used for doclet specific documentation @@ -158,21 +142,21 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * Build the method documentation. */ - public void buildMethodDoc(List elements) { + public void buildMethodDoc(XMLNode node) { if (writer == null) { return; } for (currentMethodIndex = 0; currentMethodIndex < methods.size(); currentMethodIndex++) { - build(elements); + buildChildren(node); } } /** * Build the overall header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader( classDoc, configuration.getText("doclet.Method_Detail")); @@ -181,7 +165,7 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * Build the header for the individual method. */ - public void buildMethodHeader() { + public void buildMethodHeader(XMLNode node) { writer.writeMethodHeader( (MethodDoc) methods.get(currentMethodIndex), currentMethodIndex == 0); @@ -190,14 +174,14 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * Build the signature. */ - public void buildSignature() { + public void buildSignature(XMLNode node) { writer.writeSignature((MethodDoc) methods.get(currentMethodIndex)); } /** * Build the deprecation information. */ - public void buildDeprecationInfo() { + public void buildDeprecationInfo(XMLNode node) { writer.writeDeprecated((MethodDoc) methods.get(currentMethodIndex)); } @@ -205,7 +189,7 @@ public class MethodBuilder extends AbstractMemberBuilder { * Build the comments for the method. Do nothing if * {@link Configuration#nocomment} is set to true. If this method */ - public void buildMethodComments() { + public void buildMethodComments(XMLNode node) { if (!configuration.nocomment) { MethodDoc method = (MethodDoc) methods.get(currentMethodIndex); @@ -228,21 +212,21 @@ public class MethodBuilder extends AbstractMemberBuilder { /** * Build the tag information. */ - public void buildTagInfo() { + public void buildTagInfo(XMLNode node) { writer.writeTags((MethodDoc) methods.get(currentMethodIndex)); } /** * Build the footer of the method. */ - public void buildMethodFooter() { + public void buildMethodFooter(XMLNode node) { writer.writeMethodFooter(); } /** * Build the overall footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(classDoc); } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java index ac3b5445ff4cd32bb284b254e67ae766aee9f0ba..acd382d35d4646f5a80be30db112b59e6066ba67 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java @@ -29,8 +29,6 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; -import java.util.*; -import java.lang.reflect.*; /** * Builds the summary for a given package. @@ -84,22 +82,6 @@ public class PackageSummaryBuilder extends AbstractBuilder { return builder; } - /** - * {@inheritDoc} - */ - public void invokeMethod( - String methodName, - Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError( - "DEBUG: " + this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Build the package summary. */ @@ -121,8 +103,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the package documentation. */ - public void buildPackageDoc(List elements) throws Exception { - build(elements); + public void buildPackageDoc(XMLNode node) throws Exception { + buildChildren(node); packageWriter.close(); Util.copyDocFiles( configuration, @@ -136,14 +118,14 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the header of the summary. */ - public void buildPackageHeader() { + public void buildPackageHeader(XMLNode node) { packageWriter.writePackageHeader(Util.getPackageName(packageDoc)); } /** * Build the description of the summary. */ - public void buildPackageDescription() { + public void buildPackageDescription(XMLNode node) { if (configuration.nocomment) { return; } @@ -153,7 +135,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the tags of the summary. */ - public void buildPackageTags() { + public void buildPackageTags(XMLNode node) { if (configuration.nocomment) { return; } @@ -163,28 +145,28 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the package summary. */ - public void buildSummary(List elements) { - build(elements); + public void buildSummary(XMLNode node) { + buildChildren(node); } /** * Build the overall header. */ - public void buildSummaryHeader() { + public void buildSummaryHeader(XMLNode node) { packageWriter.writeSummaryHeader(); } /** * Build the overall footer. */ - public void buildSummaryFooter() { + public void buildSummaryFooter(XMLNode node) { packageWriter.writeSummaryFooter(); } /** * Build the summary for the classes in this package. */ - public void buildClassSummary() { + public void buildClassSummary(XMLNode node) { String classTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Class_Summary"), @@ -209,7 +191,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the summary for the interfaces in this package. */ - public void buildInterfaceSummary() { + public void buildInterfaceSummary(XMLNode node) { String interfaceTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Interface_Summary"), @@ -234,7 +216,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the summary for the enums in this package. */ - public void buildAnnotationTypeSummary() { + public void buildAnnotationTypeSummary(XMLNode node) { String annotationtypeTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Annotation_Types_Summary"), @@ -259,7 +241,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the summary for the enums in this package. */ - public void buildEnumSummary() { + public void buildEnumSummary(XMLNode node) { String enumTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Enum_Summary"), @@ -284,7 +266,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the summary for the exceptions in this package. */ - public void buildExceptionSummary() { + public void buildExceptionSummary(XMLNode node) { String exceptionTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Exception_Summary"), @@ -309,7 +291,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the summary for the errors in this package. */ - public void buildErrorSummary() { + public void buildErrorSummary(XMLNode node) { String errorTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Error_Summary"), @@ -334,7 +316,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the footer of the summary. */ - public void buildPackageFooter() { + public void buildPackageFooter(XMLNode node) { packageWriter.writePackageFooter(); } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java index 505b4d4b68606ff2ab72fbbfe821350046b6f2f2..5cfc42a9009f43dd6f3bf482d1542498bd0ee336 100644 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java @@ -26,7 +26,6 @@ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; -import java.lang.reflect.*; import java.util.*; import com.sun.javadoc.*; @@ -132,47 +131,33 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the serialized form. */ - public void buildSerializedForm(List elements) throws Exception { - build(elements); + public void buildSerializedForm(XMLNode node) throws Exception { + buildChildren(node); writer.close(); } - /** - * {@inheritDoc} - */ - public void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.root.printError("DEBUG: " + this.getClass().getName() - + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } - /** * Build the header. */ - public void buildHeader() { + public void buildHeader(XMLNode node) { writer.writeHeader(configuration.getText("doclet.Serialized_Form")); } /** * Build the contents. */ - public void buildSerializedFormSummaries(List elements) { + public void buildSerializedFormSummaries(XMLNode node) { PackageDoc[] packages = configuration.packages; for (int i = 0; i < packages.length; i++) { currentPackage = packages[i]; - build(elements); + buildChildren(node); } } /** * Build the package serialized for for the current package being processed. */ - public void buildPackageSerializedForm(List elements) { + public void buildPackageSerializedForm(XMLNode node) { String foo = currentPackage.name(); ClassDoc[] classes = currentPackage.allClasses(false); if (classes == null || classes.length == 0) { @@ -184,14 +169,14 @@ public class SerializedFormBuilder extends AbstractBuilder { if (!serialClassFoundToDocument(classes)) { return; } - build(elements); + buildChildren(node); } - public void buildPackageHeader() { + public void buildPackageHeader(XMLNode node) { writer.writePackageHeader(Util.getPackageName(currentPackage)); } - public void buildClassSerializedForm(List elements) { + public void buildClassSerializedForm(XMLNode node) { ClassDoc[] classes = currentPackage.allClasses(false); Arrays.sort(classes); for (int j = 0; j < classes.length; j++) { @@ -202,19 +187,19 @@ public class SerializedFormBuilder extends AbstractBuilder { if(!serialClassInclude(currentClass)) { continue; } - build(elements); + buildChildren(node); } } } - public void buildClassHeader() { + public void buildClassHeader(XMLNode node) { writer.writeClassHeader(currentClass); } /** * Build the serial UID information for the given class. */ - public void buildSerialUIDInfo() { + public void buildSerialUIDInfo(XMLNode node) { FieldDoc[] fields = currentClass.fields(false); for (int i = 0; i < fields.length; i++) { if (fields[i].name().equals("serialVersionUID") && @@ -229,7 +214,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the footer. */ - public void buildFooter() { + public void buildFooter(XMLNode node) { writer.writeFooter(); } @@ -316,7 +301,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the method header. */ - public void buildMethodHeader() { + public void buildMethodHeader(XMLNode node) { if (currentClass.serializationMethods().length > 0) { methodWriter.writeHeader( configuration.getText("doclet.Serialized_Form_methods")); @@ -333,28 +318,28 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the method sub header. */ - public void buildMethodSubHeader() { + public void buildMethodSubHeader(XMLNode node) { methodWriter.writeMemberHeader((MethodDoc) currentMember); } /** * Build the deprecated method description. */ - public void buildDeprecatedMethodInfo() { + public void buildDeprecatedMethodInfo(XMLNode node) { methodWriter.writeDeprecatedMemberInfo((MethodDoc) currentMember); } /** * Build method tags. */ - public void buildMethodDescription() { + public void buildMethodDescription(XMLNode node) { methodWriter.writeMemberDescription((MethodDoc) currentMember); } /** * Build the method tags. */ - public void buildMethodTags() { + public void buildMethodTags(XMLNode node) { methodWriter.writeMemberTags((MethodDoc) currentMember); MethodDoc method = (MethodDoc)currentMember; if (method.name().compareTo("writeExternal") == 0 @@ -370,24 +355,24 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * build the information for the method. */ - public void buildMethodInfo(List elements) { + public void buildMethodInfo(XMLNode node) { if(configuration.nocomment){ return; } - build(elements); + buildChildren(node); } /** * Build the method footer. */ - public void buildMethodFooter() { + public void buildMethodFooter(XMLNode node) { methodWriter.writeMemberFooter(); } /** * Build the field header. */ - public void buildFieldHeader() { + public void buildFieldHeader(XMLNode node) { if (currentClass.serializableFields().length > 0) { buildFieldSerializationOverview(currentClass); fieldWriter.writeHeader(configuration.getText( @@ -426,7 +411,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the field sub header. */ - public void buildFieldSubHeader() { + public void buildFieldSubHeader(XMLNode node) { if (! currentClass.definesSerializableFields() ){ FieldDoc field = (FieldDoc) currentMember; fieldWriter.writeMemberHeader(field.type().asClassDoc(), @@ -437,7 +422,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the field deprecation information. */ - public void buildFieldDeprecationInfo() { + public void buildFieldDeprecationInfo(XMLNode node) { if (!currentClass.definesSerializableFields()) { FieldDoc field = (FieldDoc)currentMember; fieldWriter.writeMemberDeprecatedInfo(field); @@ -447,7 +432,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the field information. */ - public void buildFieldInfo() { + public void buildFieldInfo(XMLNode node) { if(configuration.nocomment){ return; } @@ -483,7 +468,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the field sub footer. */ - public void buildFieldSubFooter() { + public void buildFieldSubFooter(XMLNode node) { if (! currentClass.definesSerializableFields()) { fieldWriter.writeMemberFooter(); } @@ -493,12 +478,12 @@ public class SerializedFormBuilder extends AbstractBuilder { * Build the summaries for the methods that belong to the given * class. */ - public void buildSerializableMethods(List elements) { + public void buildSerializableMethods(XMLNode node) { MemberDoc[] members = currentClass.serializationMethods(); if (members.length > 0) { for (int i = 0; i < members.length; i++) { currentMember = members[i]; - build(elements); + buildChildren(node); } } } @@ -507,12 +492,12 @@ public class SerializedFormBuilder extends AbstractBuilder { * Build the summaries for the fields that belong to the given * class. */ - public void buildSerializableFields(List elements) { + public void buildSerializableFields(XMLNode node) { MemberDoc[] members = currentClass.serializableFields(); if (members.length > 0) { for (int i = 0; i < members.length; i++) { currentMember = members[i]; - build(elements); + buildChildren(node); } } } diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java new file mode 100644 index 0000000000000000000000000000000000000000..4b414dadd52e3364d645b90d8381488fcbdf2dff --- /dev/null +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.doclets.internal.toolkit.builders; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Simple class to represent the attribute and elements of an XML node. + */ +public class XMLNode { + XMLNode(XMLNode parent, String qname) { + this.parent = parent; + name = qname; + attrs = new HashMap(); + children = new ArrayList(); + + if (parent != null) + parent.children.add(this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("<"); + sb.append(name); + for (Map.Entry e: attrs.entrySet()) + sb.append(" " + e.getKey() + "=\"" + e.getValue() + "\""); + if (children.size() == 0) + sb.append("/>"); + else { + sb.append(">"); + for (XMLNode c: children) + sb.append(c.toString()); + sb.append(""); + } + return sb.toString(); + } + + final XMLNode parent; + final String name; + final Map attrs; + final List children; +}