feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2016, 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.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* The superclass for all builders. A builder is a class that provides
|
||||
* the structure and content of API documentation. A builder is completely
|
||||
* doclet independent which means that any doclet can use builders to
|
||||
* construct documentation, as long as it impelements the appropriate
|
||||
* writer interfaces. For example, if a doclet wanted to use
|
||||
* {@link ConstantsSummaryBuilder} to build a constant summary, all it has to
|
||||
* do is implement the ConstantsSummaryWriter interface and pass it to the
|
||||
* builder using a WriterFactory.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public abstract class AbstractBuilder {
|
||||
public static class Context {
|
||||
/**
|
||||
* The configuration used in this run of the doclet.
|
||||
*/
|
||||
final Configuration configuration;
|
||||
|
||||
/**
|
||||
* Keep track of which packages we have seen for
|
||||
* efficiency purposes. We don't want to copy the
|
||||
* doc files multiple times for a single package.
|
||||
*/
|
||||
final Set<String> containingPackagesSeen;
|
||||
|
||||
/**
|
||||
* Shared parser for the builder XML file
|
||||
*/
|
||||
final LayoutParser layoutParser;
|
||||
|
||||
Context(Configuration configuration,
|
||||
Set<String> containingPackagesSeen,
|
||||
LayoutParser layoutParser) {
|
||||
this.configuration = configuration;
|
||||
this.containingPackagesSeen = containingPackagesSeen;
|
||||
this.layoutParser = layoutParser;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The configuration used in this run of the doclet.
|
||||
*/
|
||||
protected final Configuration configuration;
|
||||
|
||||
/**
|
||||
* Keep track of which packages we have seen for
|
||||
* efficiency purposes. We don't want to copy the
|
||||
* doc files multiple times for a single package.
|
||||
*/
|
||||
protected final Set<String> containingPackagesSeen;
|
||||
|
||||
protected final LayoutParser layoutParser;
|
||||
|
||||
/**
|
||||
* True if we want to print debug output.
|
||||
*/
|
||||
protected static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
* Construct a Builder.
|
||||
* @param configuration the configuration used in this run
|
||||
* of the doclet.
|
||||
*/
|
||||
public AbstractBuilder(Context c) {
|
||||
this.configuration = c.configuration;
|
||||
this.containingPackagesSeen = c.containingPackagesSeen;
|
||||
this.layoutParser = c.layoutParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of this builder.
|
||||
*
|
||||
* @return the name of the builder.
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Build the documentation.
|
||||
*
|
||||
* @throws IOException there was a problem writing the output.
|
||||
*/
|
||||
public abstract void build() throws IOException;
|
||||
|
||||
/**
|
||||
* Build the documentation, as specified by the given XML element.
|
||||
*
|
||||
* @param node the XML element that specifies which component to document.
|
||||
* @param contentTree content tree to which the documentation will be added
|
||||
*/
|
||||
protected void build(XMLNode node, Content contentTree) {
|
||||
String component = node.name;
|
||||
try {
|
||||
invokeMethod("build" + component,
|
||||
new Class<?>[]{XMLNode.class, Content.class},
|
||||
new Object[]{node, contentTree});
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
configuration.root.printError("Unknown element: " + component);
|
||||
throw new DocletAbortException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof FatalError) {
|
||||
throw (FatalError) cause;
|
||||
} else if (cause instanceof DocletAbortException) {
|
||||
throw (DocletAbortException) cause;
|
||||
} else {
|
||||
throw new DocletAbortException(cause);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
configuration.root.printError("Exception " +
|
||||
e.getClass().getName() +
|
||||
" thrown while processing element: " + component);
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the documentation, as specified by the children of the given XML element.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document.
|
||||
* @param contentTree content tree to which the documentation will be added
|
||||
*/
|
||||
protected void buildChildren(XMLNode node, Content contentTree) {
|
||||
for (XMLNode child : node.children)
|
||||
build(child, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name and parameters, invoke the method in the builder. This
|
||||
* method is required to invoke the appropriate build method as instructed
|
||||
* by the builder XML file.
|
||||
*
|
||||
* @param methodName the name of the method that we would like to invoke.
|
||||
* @param paramClasses the types for each parameter.
|
||||
* @param params the parameters of the method.
|
||||
*/
|
||||
protected 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.Set;
|
||||
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* The superclass for all member builders. Member builders are only executed
|
||||
* within Class Builders. They essentially build sub-components. For example,
|
||||
* method documentation is a sub-component of class documentation.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class AbstractMemberBuilder extends AbstractBuilder {
|
||||
|
||||
/**
|
||||
* Construct a SubBuilder.
|
||||
* @param configuration the configuration used in this run
|
||||
* of the doclet.
|
||||
*/
|
||||
public AbstractMemberBuilder(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by sub-builders.
|
||||
*
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it is not supported.
|
||||
*/
|
||||
public void build() throws DocletAbortException {
|
||||
//You may not call the build method in a subbuilder.
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build the sub component if there is anything to document.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document.
|
||||
* @param contentTree content tree to which the documentation will be added
|
||||
*/
|
||||
@Override
|
||||
public void build(XMLNode node, Content contentTree) {
|
||||
if (hasMembersToDocument()) {
|
||||
super.build(node, contentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this subbuilder has anything to document.
|
||||
*
|
||||
* @return true if this subbuilder has anything to document.
|
||||
*/
|
||||
public abstract boolean hasMembersToDocument();
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the summary for a given annotation type.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class AnnotationTypeBuilder extends AbstractBuilder {
|
||||
|
||||
/**
|
||||
* The root element of the annotation type XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "AnnotationTypeDoc";
|
||||
|
||||
/**
|
||||
* The annotation type being documented.
|
||||
*/
|
||||
private final AnnotationTypeDoc annotationTypeDoc;
|
||||
|
||||
/**
|
||||
* The doclet specific writer.
|
||||
*/
|
||||
private final AnnotationTypeWriter writer;
|
||||
|
||||
/**
|
||||
* The content tree for the annotation documentation.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* Construct a new ClassBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param annotationTypeDoc the class being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private AnnotationTypeBuilder(Context context,
|
||||
AnnotationTypeDoc annotationTypeDoc,
|
||||
AnnotationTypeWriter writer) {
|
||||
super(context);
|
||||
this.annotationTypeDoc = annotationTypeDoc;
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ClassBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param annotationTypeDoc the class being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static AnnotationTypeBuilder getInstance(Context context,
|
||||
AnnotationTypeDoc annotationTypeDoc,
|
||||
AnnotationTypeWriter writer)
|
||||
throws Exception {
|
||||
return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception {
|
||||
contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
|
||||
" " + annotationTypeDoc.name());
|
||||
Content annotationContentTree = writer.getAnnotationContentHeader();
|
||||
buildChildren(node, annotationContentTree);
|
||||
contentTree.addContent(annotationContentTree);
|
||||
writer.addFooter(contentTree);
|
||||
writer.printDocument(contentTree);
|
||||
writer.close();
|
||||
copyDocFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the doc files for the current ClassDoc if necessary.
|
||||
*/
|
||||
private void copyDocFiles() {
|
||||
PackageDoc containingPackage = annotationTypeDoc.containingPackage();
|
||||
if((configuration.packages == null ||
|
||||
Arrays.binarySearch(configuration.packages,
|
||||
containingPackage) < 0) &&
|
||||
! containingPackagesSeen.contains(containingPackage.name())){
|
||||
//Only copy doc files dir if the containing package is not
|
||||
//documented AND if we have not documented a class from the same
|
||||
//package already. Otherwise, we are making duplicate copies.
|
||||
Util.copyDocFiles(configuration, containingPackage);
|
||||
containingPackagesSeen.add(containingPackage.name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation information tree documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) {
|
||||
Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
|
||||
buildChildren(node, annotationInfoTree);
|
||||
annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* If this annotation is deprecated, build the appropriate information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo (XMLNode node, Content annotationInfoTree) {
|
||||
writer.addAnnotationTypeDeprecationInfo(annotationInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature of the current annotation type.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
|
||||
StringBuilder modifiers = new StringBuilder(
|
||||
annotationTypeDoc.modifiers() + " ");
|
||||
writer.addAnnotationTypeSignature(Util.replaceText(
|
||||
modifiers.toString(), "interface", "@interface"), annotationInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type description.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeDescription(XMLNode node, Content annotationInfoTree) {
|
||||
writer.addAnnotationTypeDescription(annotationInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information for the current annotation type.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeTagInfo(XMLNode node, Content annotationInfoTree) {
|
||||
writer.addAnnotationTypeTagInfo(annotationInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member summary contents of the page.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMemberSummary(XMLNode node, Content annotationContentTree)
|
||||
throws Exception {
|
||||
Content memberSummaryTree = writer.getMemberTreeHeader();
|
||||
configuration.getBuilderFactory().
|
||||
getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
|
||||
annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member details contents of the page.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) {
|
||||
Content memberDetailsTree = writer.getMemberTreeHeader();
|
||||
buildChildren(node, memberDetailsTree);
|
||||
if (memberDetailsTree.isValid()) {
|
||||
annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type field documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeFieldDetails(XMLNode node, Content memberDetailsTree)
|
||||
throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getAnnotationTypeFieldsBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type optional member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree)
|
||||
throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type required member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree)
|
||||
throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for annotation type fields.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
* @since 1.8
|
||||
*/
|
||||
public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The annotation type whose members are being documented.
|
||||
*/
|
||||
protected ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible members for the given class.
|
||||
*/
|
||||
protected VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the member documentation.
|
||||
*/
|
||||
protected AnnotationTypeFieldWriter writer;
|
||||
|
||||
/**
|
||||
* The list of members being documented.
|
||||
*/
|
||||
protected List<ProgramElementDoc> members;
|
||||
|
||||
/**
|
||||
* The index of the current member that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
protected int currentMemberIndex;
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeFieldsBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
* @param memberType the type of member that is being documented.
|
||||
*/
|
||||
protected AnnotationTypeFieldBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
AnnotationTypeFieldWriter writer,
|
||||
int memberType) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
|
||||
configuration);
|
||||
this.members = new ArrayList<ProgramElementDoc>(
|
||||
this.visibleMemberMap.getMembersFor(classDoc));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(this.members, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeFieldBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static AnnotationTypeFieldBuilder getInstance(
|
||||
Context context, ClassDoc classDoc,
|
||||
AnnotationTypeFieldWriter writer) {
|
||||
return new AnnotationTypeFieldBuilder(context, classDoc,
|
||||
writer, VisibleMemberMap.ANNOTATION_TYPE_FIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "AnnotationTypeFieldDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of members that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of members that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the members of this class.
|
||||
*
|
||||
* @return the visible member map for the members of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* summaryOrder.size()
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return members.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type field documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeField(XMLNode node, Content memberDetailsTree) {
|
||||
buildAnnotationTypeMember(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = members.size();
|
||||
if (size > 0) {
|
||||
writer.addAnnotationFieldDetailsMarker(memberDetailsTree);
|
||||
for (currentMemberIndex = 0; currentMemberIndex < size;
|
||||
currentMemberIndex++) {
|
||||
Content detailsTree = writer.getMemberTreeHeader();
|
||||
writer.addAnnotationDetailsTreeHeader(classDoc, detailsTree);
|
||||
Content annotationDocTree = writer.getAnnotationDocTreeHeader(
|
||||
(MemberDoc) members.get(currentMemberIndex),
|
||||
detailsTree);
|
||||
buildChildren(node, annotationDocTree);
|
||||
detailsTree.addContent(writer.getAnnotationDoc(
|
||||
annotationDocTree, (currentMemberIndex == size - 1)));
|
||||
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content annotationDocTree) {
|
||||
annotationDocTree.addContent(
|
||||
writer.getSignature((MemberDoc) members.get(currentMemberIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) {
|
||||
writer.addDeprecated((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the member. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMemberComments(XMLNode node, Content annotationDocTree) {
|
||||
if(! configuration.nocomment){
|
||||
writer.addComments((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content annotationDocTree) {
|
||||
writer.addTags((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the annotation type field writer for this builder.
|
||||
*
|
||||
* @return the annotation type field writer for this builder.
|
||||
*/
|
||||
public AnnotationTypeFieldWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, 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 com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for optional annotation type members.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class AnnotationTypeOptionalMemberBuilder extends
|
||||
AnnotationTypeRequiredMemberBuilder {
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeMemberBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private AnnotationTypeOptionalMemberBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
AnnotationTypeOptionalMemberWriter writer) {
|
||||
super(context, classDoc, writer,
|
||||
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeMemberBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static AnnotationTypeOptionalMemberBuilder getInstance(
|
||||
Context context, ClassDoc classDoc,
|
||||
AnnotationTypeOptionalMemberWriter writer) {
|
||||
return new AnnotationTypeOptionalMemberBuilder(context,
|
||||
classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AnnotationTypeOptionalMemberDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type optional member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) {
|
||||
buildAnnotationTypeMember(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the default value for this optional member.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDefaultValueInfo(XMLNode node, Content annotationDocTree) {
|
||||
((AnnotationTypeOptionalMemberWriter) writer).addDefaultValueInfo(
|
||||
(MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnnotationTypeRequiredMemberWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for required annotation type members.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The annotation type whose members are being documented.
|
||||
*/
|
||||
protected ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible members for the given class.
|
||||
*/
|
||||
protected VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the member documentation.
|
||||
*/
|
||||
protected AnnotationTypeRequiredMemberWriter writer;
|
||||
|
||||
/**
|
||||
* The list of members being documented.
|
||||
*/
|
||||
protected List<ProgramElementDoc> members;
|
||||
|
||||
/**
|
||||
* The index of the current member that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
protected int currentMemberIndex;
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeRequiredMemberBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
protected AnnotationTypeRequiredMemberBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
AnnotationTypeRequiredMemberWriter writer,
|
||||
int memberType) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
|
||||
configuration);
|
||||
this.members = new ArrayList<ProgramElementDoc>(
|
||||
this.visibleMemberMap.getMembersFor(classDoc));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(this.members, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeMemberBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whose members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static AnnotationTypeRequiredMemberBuilder getInstance(
|
||||
Context context, ClassDoc classDoc,
|
||||
AnnotationTypeRequiredMemberWriter writer) {
|
||||
return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
|
||||
writer,
|
||||
VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "AnnotationTypeRequiredMemberDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of members that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of members that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the members of this class.
|
||||
*
|
||||
* @return the visible member map for the members of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* summaryOrder.size()
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return members.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the annotation type required member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) {
|
||||
buildAnnotationTypeMember(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = members.size();
|
||||
if (size > 0) {
|
||||
writer.addAnnotationDetailsMarker(memberDetailsTree);
|
||||
for (currentMemberIndex = 0; currentMemberIndex < size;
|
||||
currentMemberIndex++) {
|
||||
Content detailsTree = writer.getMemberTreeHeader();
|
||||
writer.addAnnotationDetailsTreeHeader(classDoc, detailsTree);
|
||||
Content annotationDocTree = writer.getAnnotationDocTreeHeader(
|
||||
(MemberDoc) members.get(currentMemberIndex), detailsTree);
|
||||
buildChildren(node, annotationDocTree);
|
||||
detailsTree.addContent(writer.getAnnotationDoc(
|
||||
annotationDocTree, (currentMemberIndex == size - 1)));
|
||||
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content annotationDocTree) {
|
||||
annotationDocTree.addContent(
|
||||
writer.getSignature((MemberDoc) members.get(currentMemberIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) {
|
||||
writer.addDeprecated((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the member. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMemberComments(XMLNode node, Content annotationDocTree) {
|
||||
if(! configuration.nocomment){
|
||||
writer.addComments((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param annotationDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content annotationDocTree) {
|
||||
writer.addTags((MemberDoc) members.get(currentMemberIndex),
|
||||
annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the annotation type required member writer for this builder.
|
||||
*
|
||||
* @return the annotation type required member constant writer for this
|
||||
* builder.
|
||||
*/
|
||||
public AnnotationTypeRequiredMemberWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* The factory for constructing builders.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @since 1.4
|
||||
*/
|
||||
|
||||
public class BuilderFactory {
|
||||
|
||||
/**
|
||||
* The current configuration of the doclet.
|
||||
*/
|
||||
private final Configuration configuration;
|
||||
|
||||
/**
|
||||
* The factory to retrieve the required writers from.
|
||||
*/
|
||||
private final WriterFactory writerFactory;
|
||||
|
||||
private final AbstractBuilder.Context context;
|
||||
|
||||
/**
|
||||
* Construct a builder factory using the given configuration.
|
||||
* @param configuration the configuration for the current doclet
|
||||
* being executed.
|
||||
*/
|
||||
public BuilderFactory (Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
this.writerFactory = configuration.getWriterFactory();
|
||||
|
||||
Set<String> containingPackagesSeen = new HashSet<String>();
|
||||
context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
|
||||
LayoutParser.getInstance(configuration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder that builds the constant summary.
|
||||
* @return the builder that builds the constant summary.
|
||||
*/
|
||||
public AbstractBuilder getConstantsSummaryBuider() throws Exception {
|
||||
return ConstantsSummaryBuilder.getInstance(context,
|
||||
writerFactory.getConstantsSummaryWriter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder that builds the package summary.
|
||||
*
|
||||
* @param pkg the package being documented.
|
||||
* @param prevPkg the previous package being documented.
|
||||
* @param nextPkg the next package being documented.
|
||||
* @return the builder that builds the constant summary.
|
||||
*/
|
||||
public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
|
||||
PackageDoc nextPkg) throws Exception {
|
||||
return PackageSummaryBuilder.getInstance(context, pkg,
|
||||
writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder that builds the profile summary.
|
||||
*
|
||||
* @param profile the profile being documented.
|
||||
* @param prevProfile the previous profile being documented.
|
||||
* @param nextProfile the next profile being documented.
|
||||
* @return the builder that builds the profile summary.
|
||||
*/
|
||||
public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
|
||||
Profile nextProfile) throws Exception {
|
||||
return ProfileSummaryBuilder.getInstance(context, profile,
|
||||
writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder that builds the profile package summary.
|
||||
*
|
||||
* @param pkg the profile package being documented.
|
||||
* @param prevPkg the previous profile package being documented.
|
||||
* @param nextPkg the next profile package being documented.
|
||||
* @param profile the profile being documented.
|
||||
* @return the builder that builds the profile package summary.
|
||||
*/
|
||||
public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
|
||||
PackageDoc nextPkg, Profile profile) throws Exception {
|
||||
return ProfilePackageSummaryBuilder.getInstance(context, pkg,
|
||||
writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
|
||||
profile), profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder for the class.
|
||||
*
|
||||
* @param classDoc the class being documented.
|
||||
* @param prevClass the previous class that was documented.
|
||||
* @param nextClass the next class being documented.
|
||||
* @param classTree the class tree.
|
||||
* @return the writer for the class. Return null if this
|
||||
* writer is not supported by the doclet.
|
||||
*/
|
||||
public AbstractBuilder getClassBuilder(ClassDoc classDoc,
|
||||
ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
|
||||
throws Exception {
|
||||
return ClassBuilder.getInstance(context, classDoc,
|
||||
writerFactory.getClassWriter(classDoc, prevClass, nextClass,
|
||||
classTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder for the annotation type.
|
||||
*
|
||||
* @param annotationType the annotation type being documented.
|
||||
* @param prevType the previous type that was documented.
|
||||
* @param nextType the next type being documented.
|
||||
* @return the writer for the annotation type. Return null if this
|
||||
* writer is not supported by the doclet.
|
||||
*/
|
||||
public AbstractBuilder getAnnotationTypeBuilder(
|
||||
AnnotationTypeDoc annotationType,
|
||||
Type prevType, Type nextType)
|
||||
throws Exception {
|
||||
return AnnotationTypeBuilder.getInstance(context, annotationType,
|
||||
writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the method builder for the given class.
|
||||
*
|
||||
* @return an instance of the method builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return MethodBuilder.getInstance(context,
|
||||
classWriter.getClassDoc(),
|
||||
writerFactory.getMethodWriter(classWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the annotation type fields builder for the given
|
||||
* class.
|
||||
*
|
||||
* @return an instance of the annotation type field builder for the given
|
||||
* annotation type.
|
||||
*/
|
||||
public AbstractBuilder getAnnotationTypeFieldsBuilder(
|
||||
AnnotationTypeWriter annotationTypeWriter)
|
||||
throws Exception {
|
||||
return AnnotationTypeFieldBuilder.getInstance(context,
|
||||
annotationTypeWriter.getAnnotationTypeDoc(),
|
||||
writerFactory.getAnnotationTypeFieldWriter(
|
||||
annotationTypeWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the annotation type member builder for the given
|
||||
* class.
|
||||
*
|
||||
* @return an instance of the annotation type member builder for the given
|
||||
* annotation type.
|
||||
*/
|
||||
public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
|
||||
AnnotationTypeWriter annotationTypeWriter)
|
||||
throws Exception {
|
||||
return AnnotationTypeOptionalMemberBuilder.getInstance(context,
|
||||
annotationTypeWriter.getAnnotationTypeDoc(),
|
||||
writerFactory.getAnnotationTypeOptionalMemberWriter(
|
||||
annotationTypeWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the annotation type member builder for the given
|
||||
* class.
|
||||
*
|
||||
* @return an instance of the annotation type member builder for the given
|
||||
* annotation type.
|
||||
*/
|
||||
public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
|
||||
AnnotationTypeWriter annotationTypeWriter)
|
||||
throws Exception {
|
||||
return AnnotationTypeRequiredMemberBuilder.getInstance(context,
|
||||
annotationTypeWriter.getAnnotationTypeDoc(),
|
||||
writerFactory.getAnnotationTypeRequiredMemberWriter(
|
||||
annotationTypeWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the enum constants builder for the given class.
|
||||
*
|
||||
* @return an instance of the enum constants builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
|
||||
writerFactory.getEnumConstantWriter(classWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the field builder for the given class.
|
||||
*
|
||||
* @return an instance of the field builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
|
||||
writerFactory.getFieldWriter(classWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the property builder for the given class.
|
||||
*
|
||||
* @return an instance of the field builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception {
|
||||
final PropertyWriter propertyWriter =
|
||||
writerFactory.getPropertyWriter(classWriter);
|
||||
return PropertyBuilder.getInstance(context,
|
||||
classWriter.getClassDoc(),
|
||||
propertyWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the constructor builder for the given class.
|
||||
*
|
||||
* @return an instance of the constructor builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return ConstructorBuilder.getInstance(context,
|
||||
classWriter.getClassDoc(),
|
||||
writerFactory.getConstructorWriter(classWriter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the member summary builder for the given class.
|
||||
*
|
||||
* @return an instance of the member summary builder for the given class.
|
||||
*/
|
||||
public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return MemberSummaryBuilder.getInstance(classWriter, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the member summary builder for the given annotation
|
||||
* type.
|
||||
*
|
||||
* @return an instance of the member summary builder for the given
|
||||
* annotation type.
|
||||
*/
|
||||
public AbstractBuilder getMemberSummaryBuilder(
|
||||
AnnotationTypeWriter annotationTypeWriter)
|
||||
throws Exception {
|
||||
return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the builder that builds the serialized form.
|
||||
*
|
||||
* @return the builder that builds the serialized form.
|
||||
*/
|
||||
public AbstractBuilder getSerializedFormBuilder()
|
||||
throws Exception {
|
||||
return SerializedFormBuilder.getInstance(context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the summary for a given class.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class ClassBuilder extends AbstractBuilder {
|
||||
|
||||
/**
|
||||
* The root element of the class XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "ClassDoc";
|
||||
|
||||
/**
|
||||
* The class being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The doclet specific writer.
|
||||
*/
|
||||
private final ClassWriter writer;
|
||||
|
||||
/**
|
||||
* Keep track of whether or not this classdoc is an interface.
|
||||
*/
|
||||
private final boolean isInterface;
|
||||
|
||||
/**
|
||||
* Keep track of whether or not this classdoc is an enum.
|
||||
*/
|
||||
private final boolean isEnum;
|
||||
|
||||
/**
|
||||
* The content tree for the class documentation.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* Construct a new ClassBuilder.
|
||||
*
|
||||
* @param context the build context
|
||||
* @param classDoc the class being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private ClassBuilder(Context context,
|
||||
ClassDoc classDoc, ClassWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
if (classDoc.isInterface()) {
|
||||
isInterface = true;
|
||||
isEnum = false;
|
||||
} else if (classDoc.isEnum()) {
|
||||
isInterface = false;
|
||||
isEnum = true;
|
||||
Util.setEnumDocumentation(configuration, classDoc);
|
||||
} else {
|
||||
isInterface = false;
|
||||
isEnum = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ClassBuilder.
|
||||
*
|
||||
* @param context the build context
|
||||
* @param classDoc the class being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static ClassBuilder getInstance(Context context,
|
||||
ClassDoc classDoc, ClassWriter writer) {
|
||||
return new ClassBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@literal <ClassDoc>} tag.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassDoc(XMLNode node, Content contentTree) throws Exception {
|
||||
String key;
|
||||
if (isInterface) {
|
||||
key = "doclet.Interface";
|
||||
} else if (isEnum) {
|
||||
key = "doclet.Enum";
|
||||
} else {
|
||||
key = "doclet.Class";
|
||||
}
|
||||
contentTree = writer.getHeader(configuration.getText(key) + " " +
|
||||
classDoc.name());
|
||||
Content classContentTree = writer.getClassContentHeader();
|
||||
buildChildren(node, classContentTree);
|
||||
contentTree.addContent(classContentTree);
|
||||
writer.addFooter(contentTree);
|
||||
writer.printDocument(contentTree);
|
||||
writer.close();
|
||||
copyDocFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the class tree documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassTree(XMLNode node, Content classContentTree) {
|
||||
writer.addClassTree(classContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the class information tree documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassInfo(XMLNode node, Content classContentTree) {
|
||||
Content classInfoTree = writer.getClassInfoTreeHeader();
|
||||
buildChildren(node, classInfoTree);
|
||||
classContentTree.addContent(writer.getClassInfo(classInfoTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the typeparameters of this class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTypeParamInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addTypeParamInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an interface, list all super interfaces.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSuperInterfacesInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addSuperInterfacesInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a class, list all interfaces implemented by this class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildImplementedInterfacesInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addImplementedInterfacesInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the classes extend this one.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSubClassInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addSubClassInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the interfaces that extend this one.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSubInterfacesInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addSubInterfacesInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an interface, list all classes that implement this interface.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildInterfaceUsageInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addInterfaceUsageInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an functional interface, display appropriate message.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFunctionalInterfaceInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addFunctionalInterfaceInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this class is deprecated, build the appropriate information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo (XMLNode node, Content classInfoTree) {
|
||||
writer.addClassDeprecationInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is an inner class or interface, list the enclosing class or interface.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildNestedClassInfo (XMLNode node, Content classInfoTree) {
|
||||
writer.addNestedClassInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the doc files for the current ClassDoc if necessary.
|
||||
*/
|
||||
private void copyDocFiles() {
|
||||
PackageDoc containingPackage = classDoc.containingPackage();
|
||||
if((configuration.packages == null ||
|
||||
Arrays.binarySearch(configuration.packages,
|
||||
containingPackage) < 0) &&
|
||||
! containingPackagesSeen.contains(containingPackage.name())){
|
||||
//Only copy doc files dir if the containing package is not
|
||||
//documented AND if we have not documented a class from the same
|
||||
//package already. Otherwise, we are making duplicate copies.
|
||||
Util.copyDocFiles(configuration, containingPackage);
|
||||
containingPackagesSeen.add(containingPackage.name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature of the current class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassSignature(XMLNode node, Content classInfoTree) {
|
||||
StringBuilder modifiers = new StringBuilder(classDoc.modifiers());
|
||||
modifiers.append(modifiers.length() == 0 ? "" : " ");
|
||||
if (isEnum) {
|
||||
modifiers.append("enum ");
|
||||
int index;
|
||||
if ((index = modifiers.indexOf("abstract")) >= 0) {
|
||||
modifiers.delete(index, index + "abstract".length());
|
||||
modifiers = new StringBuilder(
|
||||
Util.replaceText(modifiers.toString(), " ", " "));
|
||||
}
|
||||
if ((index = modifiers.indexOf("final")) >= 0) {
|
||||
modifiers.delete(index, index + "final".length());
|
||||
modifiers = new StringBuilder(
|
||||
Util.replaceText(modifiers.toString(), " ", " "));
|
||||
}
|
||||
//} else if (classDoc.isAnnotationType()) {
|
||||
//modifiers.append("@interface ");
|
||||
} else if (! isInterface) {
|
||||
modifiers.append("class ");
|
||||
}
|
||||
writer.addClassSignature(modifiers.toString(), classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the class description.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassDescription(XMLNode node, Content classInfoTree) {
|
||||
writer.addClassDescription(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information for the current class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classInfoTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassTagInfo(XMLNode node, Content classInfoTree) {
|
||||
writer.addClassTagInfo(classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member summary contents of the page.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMemberSummary(XMLNode node, Content classContentTree) throws Exception {
|
||||
Content memberSummaryTree = writer.getMemberTreeHeader();
|
||||
configuration.getBuilderFactory().
|
||||
getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
|
||||
classContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member details contents of the page.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMemberDetails(XMLNode node, Content classContentTree) {
|
||||
Content memberDetailsTree = writer.getMemberTreeHeader();
|
||||
buildChildren(node, memberDetailsTree);
|
||||
classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the enum constants documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildEnumConstantsDetails(XMLNode node,
|
||||
Content memberDetailsTree) throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getEnumConstantsBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldDetails(XMLNode node,
|
||||
Content memberDetailsTree) throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getFieldBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the property documentation.
|
||||
*
|
||||
* @param elements the XML elements that specify how a field is documented.
|
||||
*/
|
||||
public void buildPropertyDetails(XMLNode node,
|
||||
Content memberDetailsTree) throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getPropertyBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the constructor documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildConstructorDetails(XMLNode node,
|
||||
Content memberDetailsTree) throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getConstructorBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the method documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodDetails(XMLNode node,
|
||||
Content memberDetailsTree) throws Exception {
|
||||
configuration.getBuilderFactory().
|
||||
getMethodBuilder(writer).buildChildren(node, memberDetailsTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the Constants Summary Page.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class ConstantsSummaryBuilder extends AbstractBuilder {
|
||||
|
||||
/**
|
||||
* The root element of the constant summary XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "ConstantSummary";
|
||||
|
||||
/**
|
||||
* The maximum number of package directories shown in the constant
|
||||
* value index.
|
||||
*/
|
||||
public static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2;
|
||||
|
||||
/**
|
||||
* The writer used to write the results.
|
||||
*/
|
||||
protected final ConstantsSummaryWriter writer;
|
||||
|
||||
/**
|
||||
* The set of ClassDocs that have constant fields.
|
||||
*/
|
||||
protected final Set<ClassDoc> classDocsWithConstFields;
|
||||
|
||||
/**
|
||||
* The set of printed package headers.
|
||||
*/
|
||||
protected Set<String> printedPackageHeaders;
|
||||
|
||||
/**
|
||||
* The current package being documented.
|
||||
*/
|
||||
private PackageDoc currentPackage;
|
||||
|
||||
/**
|
||||
* The current class being documented.
|
||||
*/
|
||||
private ClassDoc currentClass;
|
||||
|
||||
/**
|
||||
* The content tree for the constant summary documentation.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* Construct a new ConstantsSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param writer the writer for the summary.
|
||||
*/
|
||||
private ConstantsSummaryBuilder(Context context,
|
||||
ConstantsSummaryWriter writer) {
|
||||
super(context);
|
||||
this.writer = writer;
|
||||
this.classDocsWithConstFields = new HashSet<ClassDoc>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a ConstantsSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param writer the writer for the summary.
|
||||
*/
|
||||
public static ConstantsSummaryBuilder getInstance(Context context,
|
||||
ConstantsSummaryWriter writer) {
|
||||
return new ConstantsSummaryBuilder(context, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
if (writer == null) {
|
||||
//Doclet does not support this output.
|
||||
return;
|
||||
}
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the constant summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception {
|
||||
contentTree = writer.getHeader();
|
||||
buildChildren(node, contentTree);
|
||||
writer.addFooter(contentTree);
|
||||
writer.printDocument(contentTree);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the list of packages.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the content list will be added
|
||||
*/
|
||||
public void buildContents(XMLNode node, Content contentTree) {
|
||||
Content contentListTree = writer.getContentsHeader();
|
||||
PackageDoc[] packages = configuration.packages;
|
||||
printedPackageHeaders = new HashSet<String>();
|
||||
for (int i = 0; i < packages.length; i++) {
|
||||
if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) {
|
||||
writer.addLinkToPackageContent(packages[i],
|
||||
parsePackageName(packages[i].name()),
|
||||
printedPackageHeaders, contentListTree);
|
||||
}
|
||||
}
|
||||
contentTree.addContent(writer.getContentsList(contentListTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for each documented package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the tree to which the summaries will be added
|
||||
*/
|
||||
public void buildConstantSummaries(XMLNode node, Content contentTree) {
|
||||
PackageDoc[] packages = configuration.packages;
|
||||
printedPackageHeaders = new HashSet<String>();
|
||||
Content summariesTree = writer.getConstantSummaries();
|
||||
for (int i = 0; i < packages.length; i++) {
|
||||
if (hasConstantField(packages[i])) {
|
||||
currentPackage = packages[i];
|
||||
//Build the documentation for the current package.
|
||||
buildChildren(node, summariesTree);
|
||||
}
|
||||
}
|
||||
contentTree.addContent(summariesTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the header for the given package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summariesTree the tree to which the package header will be added
|
||||
*/
|
||||
public void buildPackageHeader(XMLNode node, Content summariesTree) {
|
||||
String parsedPackageName = parsePackageName(currentPackage.name());
|
||||
if (! printedPackageHeaders.contains(parsedPackageName)) {
|
||||
writer.addPackageName(currentPackage,
|
||||
parsePackageName(currentPackage.name()), summariesTree);
|
||||
printedPackageHeaders.add(parsedPackageName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the current class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summariesTree the tree to which the class constant summary will be added
|
||||
*/
|
||||
public void buildClassConstantSummary(XMLNode node, Content summariesTree) {
|
||||
ClassDoc[] classes = currentPackage.name().length() > 0 ?
|
||||
currentPackage.allClasses() :
|
||||
configuration.classDocCatalog.allClasses(
|
||||
DocletConstants.DEFAULT_PACKAGE_NAME);
|
||||
Arrays.sort(classes);
|
||||
Content classConstantTree = writer.getClassConstantHeader();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (! classDocsWithConstFields.contains(classes[i]) ||
|
||||
! classes[i].isIncluded()) {
|
||||
continue;
|
||||
}
|
||||
currentClass = classes[i];
|
||||
//Build the documentation for the current class.
|
||||
buildChildren(node, classConstantTree);
|
||||
}
|
||||
summariesTree.addContent(classConstantTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary of constant members in the class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classConstantTree the tree to which the constant members table
|
||||
* will be added
|
||||
*/
|
||||
public void buildConstantMembers(XMLNode node, Content classConstantTree) {
|
||||
new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given package has constant fields to document.
|
||||
*
|
||||
* @param pkg the package being checked.
|
||||
* @return true if the given package has constant fields to document.
|
||||
*/
|
||||
private boolean hasConstantField(PackageDoc pkg) {
|
||||
ClassDoc[] classes;
|
||||
if (pkg.name().length() > 0) {
|
||||
classes = pkg.allClasses();
|
||||
} else {
|
||||
classes = configuration.classDocCatalog.allClasses(
|
||||
DocletConstants.DEFAULT_PACKAGE_NAME);
|
||||
}
|
||||
boolean found = false;
|
||||
for (int j = 0; j < classes.length; j++){
|
||||
if (classes[j].isIncluded() && hasConstantField(classes[j])) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given class has constant fields to document.
|
||||
*
|
||||
* @param classDoc the class being checked.
|
||||
* @return true if the given package has constant fields to document.
|
||||
*/
|
||||
private boolean hasConstantField (ClassDoc classDoc) {
|
||||
VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(classDoc,
|
||||
VisibleMemberMap.FIELDS, configuration);
|
||||
List<?> fields = visibleMemberMapFields.getLeafClassMembers(configuration);
|
||||
for (Iterator<?> iter = fields.iterator(); iter.hasNext(); ) {
|
||||
FieldDoc field = (FieldDoc) iter.next();
|
||||
if (field.constantValueExpression() != null) {
|
||||
classDocsWithConstFields.add(classDoc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given package name has been printed. Also
|
||||
* return true if the root of this package has been printed.
|
||||
*
|
||||
* @param pkgname the name of the package to check.
|
||||
*/
|
||||
private boolean hasPrintedPackageIndex(String pkgname) {
|
||||
String[] list = printedPackageHeaders.toArray(new String[] {});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (pkgname.startsWith(list[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the table of constants.
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @since 1.4
|
||||
*/
|
||||
private class ConstantFieldBuilder {
|
||||
|
||||
/**
|
||||
* The map used to get the visible variables.
|
||||
*/
|
||||
protected VisibleMemberMap visibleMemberMapFields = null;
|
||||
|
||||
/**
|
||||
* The map used to get the visible variables.
|
||||
*/
|
||||
protected VisibleMemberMap visibleMemberMapEnumConst = null;
|
||||
|
||||
/**
|
||||
* The classdoc that we are examining constants for.
|
||||
*/
|
||||
protected ClassDoc classdoc;
|
||||
|
||||
/**
|
||||
* Construct a ConstantFieldSubWriter.
|
||||
* @param classdoc the classdoc that we are examining constants for.
|
||||
*/
|
||||
public ConstantFieldBuilder(ClassDoc classdoc) {
|
||||
this.classdoc = classdoc;
|
||||
visibleMemberMapFields = new VisibleMemberMap(classdoc,
|
||||
VisibleMemberMap.FIELDS, configuration);
|
||||
visibleMemberMapEnumConst = new VisibleMemberMap(classdoc,
|
||||
VisibleMemberMap.ENUM_CONSTANTS, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the table of constants for a given class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classConstantTree the tree to which the class constants table
|
||||
* will be added
|
||||
*/
|
||||
protected void buildMembersSummary(XMLNode node, Content classConstantTree) {
|
||||
List<FieldDoc> members = new ArrayList<FieldDoc>(members());
|
||||
if (members.size() > 0) {
|
||||
Collections.sort(members);
|
||||
writer.addConstantMembers(classdoc, members, classConstantTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of visible constant fields for the given classdoc.
|
||||
* @return the list of visible constant fields for the given classdoc.
|
||||
*/
|
||||
protected List<FieldDoc> members() {
|
||||
List<ProgramElementDoc> l = visibleMemberMapFields.getLeafClassMembers(configuration);
|
||||
l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration));
|
||||
Iterator<ProgramElementDoc> iter;
|
||||
|
||||
if(l != null){
|
||||
iter = l.iterator();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
List<FieldDoc> inclList = new LinkedList<FieldDoc>();
|
||||
FieldDoc member;
|
||||
while(iter.hasNext()){
|
||||
member = (FieldDoc)iter.next();
|
||||
if(member.constantValue() != null){
|
||||
inclList.add(member);
|
||||
}
|
||||
}
|
||||
return inclList;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the package name. We only want to display package name up to
|
||||
* 2 levels.
|
||||
*/
|
||||
private String parsePackageName(String pkgname) {
|
||||
int index = -1;
|
||||
for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) {
|
||||
index = pkgname.indexOf(".", index + 1);
|
||||
}
|
||||
if (index != -1) {
|
||||
pkgname = pkgname.substring(0, index);
|
||||
}
|
||||
return pkgname;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for a constructor.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class ConstructorBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The name of this builder.
|
||||
*/
|
||||
public static final String NAME = "ConstructorDetails";
|
||||
|
||||
/**
|
||||
* The index of the current field that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
private int currentConstructorIndex;
|
||||
|
||||
/**
|
||||
* The class whose constructors are being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible constructors for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the constructor documentation.
|
||||
*/
|
||||
private final ConstructorWriter writer;
|
||||
|
||||
/**
|
||||
* The constructors being documented.
|
||||
*/
|
||||
private final List<ProgramElementDoc> constructors;
|
||||
|
||||
/**
|
||||
* Construct a new ConstructorBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private ConstructorBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
ConstructorWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
visibleMemberMap =
|
||||
new VisibleMemberMap(
|
||||
classDoc,
|
||||
VisibleMemberMap.CONSTRUCTORS,
|
||||
configuration);
|
||||
constructors =
|
||||
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
|
||||
for (int i = 0; i < constructors.size(); i++) {
|
||||
if (constructors.get(i).isProtected()
|
||||
|| constructors.get(i).isPrivate()) {
|
||||
writer.setFoundNonPubConstructor(true);
|
||||
}
|
||||
}
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(constructors,configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ConstructorBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static ConstructorBuilder getInstance(Context context,
|
||||
ClassDoc classDoc, ConstructorWriter writer) {
|
||||
return new ConstructorBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return constructors.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of constructors that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @return a list of constructors that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the constructor writer for this builder.
|
||||
*
|
||||
* @return the constructor writer for this builder.
|
||||
*/
|
||||
public ConstructorWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the constructor documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildConstructorDoc(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = constructors.size();
|
||||
if (size > 0) {
|
||||
Content constructorDetailsTree = writer.getConstructorDetailsTreeHeader(
|
||||
classDoc, memberDetailsTree);
|
||||
for (currentConstructorIndex = 0; currentConstructorIndex < size;
|
||||
currentConstructorIndex++) {
|
||||
Content constructorDocTree = writer.getConstructorDocTreeHeader(
|
||||
(ConstructorDoc) constructors.get(currentConstructorIndex),
|
||||
constructorDetailsTree);
|
||||
buildChildren(node, constructorDocTree);
|
||||
constructorDetailsTree.addContent(writer.getConstructorDoc(
|
||||
constructorDocTree, (currentConstructorIndex == size - 1)));
|
||||
}
|
||||
memberDetailsTree.addContent(
|
||||
writer.getConstructorDetails(constructorDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param constructorDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content constructorDocTree) {
|
||||
constructorDocTree.addContent(
|
||||
writer.getSignature(
|
||||
(ConstructorDoc) constructors.get(currentConstructorIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param constructorDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content constructorDocTree) {
|
||||
writer.addDeprecated(
|
||||
(ConstructorDoc) constructors.get(currentConstructorIndex), constructorDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the constructor. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param constructorDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildConstructorComments(XMLNode node, Content constructorDocTree) {
|
||||
if (!configuration.nocomment) {
|
||||
writer.addComments(
|
||||
(ConstructorDoc) constructors.get(currentConstructorIndex),
|
||||
constructorDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param constructorDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content constructorDocTree) {
|
||||
writer.addTags((ConstructorDoc) constructors.get(currentConstructorIndex),
|
||||
constructorDocTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for a enum constants.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class EnumConstantBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The class whose enum constants are being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible enum constantss for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the enum constants documentation.
|
||||
*/
|
||||
private final EnumConstantWriter writer;
|
||||
|
||||
/**
|
||||
* The list of enum constants being documented.
|
||||
*/
|
||||
private final List<ProgramElementDoc> enumConstants;
|
||||
|
||||
/**
|
||||
* The index of the current enum constant that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
private int currentEnumConstantsIndex;
|
||||
|
||||
/**
|
||||
* Construct a new EnumConstantsBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private EnumConstantBuilder(Context context,
|
||||
ClassDoc classDoc, EnumConstantWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
visibleMemberMap =
|
||||
new VisibleMemberMap(
|
||||
classDoc,
|
||||
VisibleMemberMap.ENUM_CONSTANTS,
|
||||
configuration);
|
||||
enumConstants =
|
||||
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(enumConstants, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new EnumConstantsBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static EnumConstantBuilder getInstance(Context context,
|
||||
ClassDoc classDoc, EnumConstantWriter writer) {
|
||||
return new EnumConstantBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "EnumConstantDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of enum constants that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of enum constants that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the enum constants of this class.
|
||||
*
|
||||
* @return the visible member map for the enum constants of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* summaryOrder.size()
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return enumConstants.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the enum constant documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildEnumConstant(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = enumConstants.size();
|
||||
if (size > 0) {
|
||||
Content enumConstantsDetailsTree = writer.getEnumConstantsDetailsTreeHeader(
|
||||
classDoc, memberDetailsTree);
|
||||
for (currentEnumConstantsIndex = 0; currentEnumConstantsIndex < size;
|
||||
currentEnumConstantsIndex++) {
|
||||
Content enumConstantsTree = writer.getEnumConstantsTreeHeader(
|
||||
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
|
||||
enumConstantsDetailsTree);
|
||||
buildChildren(node, enumConstantsTree);
|
||||
enumConstantsDetailsTree.addContent(writer.getEnumConstants(
|
||||
enumConstantsTree, (currentEnumConstantsIndex == size - 1)));
|
||||
}
|
||||
memberDetailsTree.addContent(
|
||||
writer.getEnumConstantsDetails(enumConstantsDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param enumConstantsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content enumConstantsTree) {
|
||||
enumConstantsTree.addContent(writer.getSignature(
|
||||
(FieldDoc) enumConstants.get(currentEnumConstantsIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param enumConstantsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content enumConstantsTree) {
|
||||
writer.addDeprecated(
|
||||
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
|
||||
enumConstantsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the enum constant. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param enumConstantsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildEnumConstantComments(XMLNode node, Content enumConstantsTree) {
|
||||
if (!configuration.nocomment) {
|
||||
writer.addComments(
|
||||
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
|
||||
enumConstantsTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param enumConstantsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content enumConstantsTree) {
|
||||
writer.addTags(
|
||||
(FieldDoc) enumConstants.get(currentEnumConstantsIndex),
|
||||
enumConstantsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enum constant writer for this builder.
|
||||
*
|
||||
* @return the enum constant writer for this builder.
|
||||
*/
|
||||
public EnumConstantWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for a field.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class FieldBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The class whose fields are being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible fields for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the field documentation.
|
||||
*/
|
||||
private final FieldWriter writer;
|
||||
|
||||
/**
|
||||
* The list of fields being documented.
|
||||
*/
|
||||
private final List<ProgramElementDoc> fields;
|
||||
|
||||
/**
|
||||
* The index of the current field that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
private int currentFieldIndex;
|
||||
|
||||
/**
|
||||
* Construct a new FieldBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private FieldBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
FieldWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
visibleMemberMap =
|
||||
new VisibleMemberMap(
|
||||
classDoc,
|
||||
VisibleMemberMap.FIELDS,
|
||||
configuration);
|
||||
fields =
|
||||
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
|
||||
configuration));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(fields, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new FieldBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static FieldBuilder getInstance(Context context,
|
||||
ClassDoc classDoc,
|
||||
FieldWriter writer) {
|
||||
return new FieldBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "FieldDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of fields that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of fields that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the fields of this class.
|
||||
*
|
||||
* @return the visible member map for the fields of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* summaryOrder.size()
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return fields.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldDoc(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = fields.size();
|
||||
if (size > 0) {
|
||||
Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(
|
||||
classDoc, memberDetailsTree);
|
||||
for (currentFieldIndex = 0; currentFieldIndex < size;
|
||||
currentFieldIndex++) {
|
||||
Content fieldDocTree = writer.getFieldDocTreeHeader(
|
||||
(FieldDoc) fields.get(currentFieldIndex),
|
||||
fieldDetailsTree);
|
||||
buildChildren(node, fieldDocTree);
|
||||
fieldDetailsTree.addContent(writer.getFieldDoc(
|
||||
fieldDocTree, (currentFieldIndex == size - 1)));
|
||||
}
|
||||
memberDetailsTree.addContent(
|
||||
writer.getFieldDetails(fieldDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content fieldDocTree) {
|
||||
fieldDocTree.addContent(
|
||||
writer.getSignature((FieldDoc) fields.get(currentFieldIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content fieldDocTree) {
|
||||
writer.addDeprecated(
|
||||
(FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the field. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldComments(XMLNode node, Content fieldDocTree) {
|
||||
if (!configuration.nocomment) {
|
||||
writer.addComments((FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content fieldDocTree) {
|
||||
writer.addTags((FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the field writer for this builder.
|
||||
*
|
||||
* @return the field writer for this builder.
|
||||
*/
|
||||
public FieldWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.xml.parsers.*;
|
||||
|
||||
import org.xml.sax.*;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Parse the XML that specified the order of operation for the builders. This
|
||||
* Parser uses SAX parsing.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @since 1.5
|
||||
* @see SAXParser
|
||||
*/
|
||||
public class LayoutParser extends DefaultHandler {
|
||||
|
||||
/**
|
||||
* The map of XML elements that have been parsed.
|
||||
*/
|
||||
private Map<String,XMLNode> xmlElementsMap;
|
||||
private XMLNode currentNode;
|
||||
private final Configuration configuration;
|
||||
private String currentRoot;
|
||||
private boolean isParsing;
|
||||
|
||||
private LayoutParser(Configuration configuration) {
|
||||
xmlElementsMap = new HashMap<String,XMLNode>();
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of the BuilderXML.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
* @return an instance of the BuilderXML.
|
||||
*/
|
||||
public static LayoutParser getInstance(Configuration configuration) {
|
||||
return new LayoutParser(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the XML specifying the layout of the documentation.
|
||||
*
|
||||
* @return the list of XML elements parsed.
|
||||
*/
|
||||
public XMLNode parseXML(String root) {
|
||||
if (xmlElementsMap.containsKey(root)) {
|
||||
return xmlElementsMap.get(root);
|
||||
}
|
||||
try {
|
||||
currentRoot = root;
|
||||
isParsing = false;
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
InputStream in = configuration.getBuilderXML();
|
||||
saxParser.parse(in, this);
|
||||
return xmlElementsMap.get(root);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
throw new DocletAbortException(t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String namespaceURI, String sName, String qName,
|
||||
Attributes attrs)
|
||||
throws SAXException {
|
||||
if (isParsing || qName.equals(currentRoot)) {
|
||||
isParsing = true;
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
currentNode = currentNode.parent;
|
||||
isParsing = ! qName.equals(currentRoot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the member summary.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class MemberSummaryBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The XML root for this builder.
|
||||
*/
|
||||
public static final String NAME = "MemberSummary";
|
||||
|
||||
/**
|
||||
* The visible members for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap[] visibleMemberMaps;
|
||||
|
||||
/**
|
||||
* The member summary writers for the given class.
|
||||
*/
|
||||
private MemberSummaryWriter[] memberSummaryWriters;
|
||||
|
||||
/**
|
||||
* The type being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* Construct a new MemberSummaryBuilder.
|
||||
*
|
||||
* @param classWriter the writer for the class whose members are being
|
||||
* summarized.
|
||||
* @param context the build context.
|
||||
*/
|
||||
private MemberSummaryBuilder(Context context, ClassDoc classDoc) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
visibleMemberMaps =
|
||||
new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
|
||||
for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
|
||||
visibleMemberMaps[i] =
|
||||
new VisibleMemberMap(
|
||||
classDoc,
|
||||
i,
|
||||
configuration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new MemberSummaryBuilder.
|
||||
*
|
||||
* @param classWriter the writer for the class whose members are being
|
||||
* summarized.
|
||||
* @param context the build context.
|
||||
*/
|
||||
public static MemberSummaryBuilder getInstance(
|
||||
ClassWriter classWriter, Context context)
|
||||
throws Exception {
|
||||
MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
|
||||
classWriter.getClassDoc());
|
||||
builder.memberSummaryWriters =
|
||||
new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
|
||||
WriterFactory wf = context.configuration.getWriterFactory();
|
||||
for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
|
||||
builder.memberSummaryWriters[i] =
|
||||
builder.visibleMemberMaps[i].noVisibleMembers() ?
|
||||
null :
|
||||
wf.getMemberSummaryWriter(classWriter, i);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new MemberSummaryBuilder.
|
||||
*
|
||||
* @param annotationTypeWriter the writer for the class whose members are
|
||||
* being summarized.
|
||||
* @param configuration the current configuration of the doclet.
|
||||
*/
|
||||
public static MemberSummaryBuilder getInstance(
|
||||
AnnotationTypeWriter annotationTypeWriter, Context context)
|
||||
throws Exception {
|
||||
MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
|
||||
annotationTypeWriter.getAnnotationTypeDoc());
|
||||
builder.memberSummaryWriters =
|
||||
new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
|
||||
WriterFactory wf = context.configuration.getWriterFactory();
|
||||
for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
|
||||
builder.memberSummaryWriters[i] =
|
||||
builder.visibleMemberMaps[i].noVisibleMembers()?
|
||||
null :
|
||||
wf.getMemberSummaryWriter(
|
||||
annotationTypeWriter, i);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the specified visible member map.
|
||||
*
|
||||
* @param type the type of visible member map to return.
|
||||
* @return the specified visible member map.
|
||||
* @throws ArrayIndexOutOfBoundsException when the type is invalid.
|
||||
* @see VisibleMemberMap
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap(int type) {
|
||||
return visibleMemberMaps[type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the specified member summary writer.
|
||||
*
|
||||
* @param type the type of member summary writer to return.
|
||||
* @return the specified member summary writer.
|
||||
* @throws ArrayIndexOutOfBoundsException when the type is invalid.
|
||||
* @see VisibleMemberMap
|
||||
*/
|
||||
public MemberSummaryWriter getMemberSummaryWriter(int type) {
|
||||
return memberSummaryWriters[type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of methods that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param type the type of members to return.
|
||||
* @return a list of methods that will be documented.
|
||||
* @see VisibleMemberMap
|
||||
*/
|
||||
public List<ProgramElementDoc> members(int type) {
|
||||
return visibleMemberMaps[type].getLeafClassMembers(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true it there are any members to summarize.
|
||||
*
|
||||
* @return true if there are any members to summarize.
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
if (classDoc instanceof AnnotationTypeDoc) {
|
||||
return ((AnnotationTypeDoc) classDoc).elements().length > 0;
|
||||
}
|
||||
for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
|
||||
VisibleMemberMap members = visibleMemberMaps[i];
|
||||
if (!members.noVisibleMembers()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the enum constants.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildEnumConstantsSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS];
|
||||
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for fields.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeFieldsSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_FIELDS];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_FIELDS];
|
||||
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the optional members.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeOptionalMemberSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL];
|
||||
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the optional members.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildAnnotationTypeRequiredMemberSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED];
|
||||
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the fields.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldsSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.FIELDS];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.FIELDS];
|
||||
addSummary(writer, visibleMemberMap, true, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the fields.
|
||||
*/
|
||||
public void buildPropertiesSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.PROPERTIES];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.PROPERTIES];
|
||||
addSummary(writer, visibleMemberMap, true, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the nested classes.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildNestedClassesSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.INNERCLASSES];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.INNERCLASSES];
|
||||
addSummary(writer, visibleMemberMap, true, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the method summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodsSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.METHODS];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.METHODS];
|
||||
addSummary(writer, visibleMemberMap, true, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the constructor summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildConstructorsSummary(XMLNode node, Content memberSummaryTree) {
|
||||
MemberSummaryWriter writer =
|
||||
memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS];
|
||||
VisibleMemberMap visibleMemberMap =
|
||||
visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS];
|
||||
addSummary(writer, visibleMemberMap, false, memberSummaryTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the member summary for the given members.
|
||||
*
|
||||
* @param writer the summary writer to write the output.
|
||||
* @param visibleMemberMap the given members to summarize.
|
||||
* @param summaryTreeList list of content trees to which the documentation will be added
|
||||
*/
|
||||
private void buildSummary(MemberSummaryWriter writer,
|
||||
VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
|
||||
List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
|
||||
configuration));
|
||||
if (members.size() > 0) {
|
||||
Collections.sort(members);
|
||||
List<Content> tableContents = new LinkedList<Content>();
|
||||
for (int i = 0; i < members.size(); i++) {
|
||||
ProgramElementDoc member = members.get(i);
|
||||
final ProgramElementDoc propertyDoc =
|
||||
visibleMemberMap.getPropertyMemberDoc(member);
|
||||
if (propertyDoc != null) {
|
||||
processProperty(visibleMemberMap, member, propertyDoc);
|
||||
}
|
||||
Tag[] firstSentenceTags = member.firstSentenceTags();
|
||||
if (member instanceof MethodDoc && firstSentenceTags.length == 0) {
|
||||
//Inherit comments from overriden or implemented method if
|
||||
//necessary.
|
||||
DocFinder.Output inheritedDoc =
|
||||
DocFinder.search(new DocFinder.Input((MethodDoc) member));
|
||||
if (inheritedDoc.holder != null
|
||||
&& inheritedDoc.holder.firstSentenceTags().length > 0) {
|
||||
firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
|
||||
}
|
||||
}
|
||||
writer.addMemberSummary(classDoc, member, firstSentenceTags,
|
||||
tableContents, i);
|
||||
}
|
||||
summaryTreeList.add(writer.getSummaryTableTree(classDoc, tableContents));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the property method, property setter and/or property getter
|
||||
* comment text so that it contains the documentation from
|
||||
* the property field. The method adds the leading sentence,
|
||||
* copied documentation including the defaultValue tag and
|
||||
* the see tags if the appropriate property getter and setter are
|
||||
* available.
|
||||
*
|
||||
* @param visibleMemberMap the members information.
|
||||
* @param member the member which is to be augmented.
|
||||
* @param propertyDoc the original property documentation.
|
||||
*/
|
||||
private void processProperty(VisibleMemberMap visibleMemberMap,
|
||||
ProgramElementDoc member,
|
||||
ProgramElementDoc propertyDoc) {
|
||||
StringBuilder commentTextBuilder = new StringBuilder();
|
||||
final boolean isSetter = isSetter(member);
|
||||
final boolean isGetter = isGetter(member);
|
||||
if (isGetter || isSetter) {
|
||||
//add "[GS]ets the value of the property PROPERTY_NAME."
|
||||
if (isSetter) {
|
||||
commentTextBuilder.append(
|
||||
MessageFormat.format(
|
||||
configuration.getText("doclet.PropertySetterWithName"),
|
||||
Util.propertyNameFromMethodName(configuration, member.name())));
|
||||
}
|
||||
if (isGetter) {
|
||||
commentTextBuilder.append(
|
||||
MessageFormat.format(
|
||||
configuration.getText("doclet.PropertyGetterWithName"),
|
||||
Util.propertyNameFromMethodName(configuration, member.name())));
|
||||
}
|
||||
if (propertyDoc.commentText() != null
|
||||
&& !propertyDoc.commentText().isEmpty()) {
|
||||
commentTextBuilder.append(" \n @propertyDescription ");
|
||||
}
|
||||
}
|
||||
commentTextBuilder.append(propertyDoc.commentText());
|
||||
|
||||
// copy certain tags
|
||||
List<Tag> allTags = new LinkedList<Tag>();
|
||||
String[] tagNames = {"@defaultValue", "@since"};
|
||||
for (String tagName: tagNames) {
|
||||
Tag[] tags = propertyDoc.tags(tagName);
|
||||
if (tags != null) {
|
||||
allTags.addAll(Arrays.asList(tags));
|
||||
}
|
||||
}
|
||||
for (Tag tag: allTags) {
|
||||
commentTextBuilder.append("\n")
|
||||
.append(tag.name())
|
||||
.append(" ")
|
||||
.append(tag.text());
|
||||
}
|
||||
|
||||
//add @see tags
|
||||
if (!isGetter && !isSetter) {
|
||||
MethodDoc getter = (MethodDoc) visibleMemberMap.getGetterForProperty(member);
|
||||
MethodDoc setter = (MethodDoc) visibleMemberMap.getSetterForProperty(member);
|
||||
|
||||
if ((null != getter)
|
||||
&& (commentTextBuilder.indexOf("@see #" + getter.name()) == -1)) {
|
||||
commentTextBuilder.append("\n @see #")
|
||||
.append(getter.name())
|
||||
.append("() ");
|
||||
}
|
||||
|
||||
if ((null != setter)
|
||||
&& (commentTextBuilder.indexOf("@see #" + setter.name()) == -1)) {
|
||||
String typeName = setter.parameters()[0].typeName();
|
||||
// Removal of type parameters and package information.
|
||||
typeName = typeName.split("<")[0];
|
||||
if (typeName.contains(".")) {
|
||||
typeName = typeName.substring(typeName.lastIndexOf(".") + 1);
|
||||
}
|
||||
commentTextBuilder.append("\n @see #").append(setter.name());
|
||||
|
||||
if (setter.parameters()[0].type().asTypeVariable() == null) {
|
||||
commentTextBuilder.append("(").append(typeName).append(")");
|
||||
}
|
||||
commentTextBuilder.append(" \n");
|
||||
}
|
||||
}
|
||||
member.setRawCommentText(commentTextBuilder.toString());
|
||||
}
|
||||
/**
|
||||
* Test whether the method is a getter.
|
||||
* @param ped property method documentation. Needs to be either property
|
||||
* method, property getter, or property setter.
|
||||
* @return true if the given documentation belongs to a getter.
|
||||
*/
|
||||
private boolean isGetter(ProgramElementDoc ped) {
|
||||
final String pedName = ped.name();
|
||||
return pedName.startsWith("get") || pedName.startsWith("is");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the method is a setter.
|
||||
* @param ped property method documentation. Needs to be either property
|
||||
* method, property getter, or property setter.
|
||||
* @return true if the given documentation belongs to a setter.
|
||||
*/
|
||||
private boolean isSetter(ProgramElementDoc ped) {
|
||||
return ped.name().startsWith("set");
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the inherited member summary for the given methods.
|
||||
*
|
||||
* @param writer the writer for this member summary.
|
||||
* @param visibleMemberMap the map for the members to document.
|
||||
* @param summaryTreeList list of content trees to which the documentation will be added
|
||||
*/
|
||||
private void buildInheritedSummary(MemberSummaryWriter writer,
|
||||
VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
|
||||
for (Iterator<ClassDoc> iter = visibleMemberMap.getVisibleClassesList().iterator();
|
||||
iter.hasNext();) {
|
||||
ClassDoc inhclass = iter.next();
|
||||
if (! (inhclass.isPublic() ||
|
||||
Util.isLinkable(inhclass, configuration))) {
|
||||
continue;
|
||||
}
|
||||
if (inhclass == classDoc) {
|
||||
continue;
|
||||
}
|
||||
List<ProgramElementDoc> inhmembers = visibleMemberMap.getMembersFor(inhclass);
|
||||
if (inhmembers.size() > 0) {
|
||||
Collections.sort(inhmembers);
|
||||
Content inheritedTree = writer.getInheritedSummaryHeader(inhclass);
|
||||
Content linksTree = writer.getInheritedSummaryLinksTree();
|
||||
for (int j = 0; j < inhmembers.size(); ++j) {
|
||||
writer.addInheritedMemberSummary(
|
||||
inhclass.isPackagePrivate() &&
|
||||
! Util.isLinkable(inhclass, configuration) ?
|
||||
classDoc : inhclass,
|
||||
inhmembers.get(j),
|
||||
j == 0,
|
||||
j == inhmembers.size() - 1, linksTree);
|
||||
}
|
||||
inheritedTree.addContent(linksTree);
|
||||
summaryTreeList.add(writer.getMemberTree(inheritedTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary for the documentation.
|
||||
*
|
||||
* @param writer the writer for this member summary.
|
||||
* @param visibleMemberMap the map for the members to document.
|
||||
* @param showInheritedSummary true if inherited summary should be documented
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
private void addSummary(MemberSummaryWriter writer,
|
||||
VisibleMemberMap visibleMemberMap, boolean showInheritedSummary,
|
||||
Content memberSummaryTree) {
|
||||
LinkedList<Content> summaryTreeList = new LinkedList<Content>();
|
||||
buildSummary(writer, visibleMemberMap, summaryTreeList);
|
||||
if (showInheritedSummary)
|
||||
buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);
|
||||
if (!summaryTreeList.isEmpty()) {
|
||||
Content memberTree = writer.getMemberSummaryHeader(
|
||||
classDoc, memberSummaryTree);
|
||||
for (int i = 0; i < summaryTreeList.size(); i++) {
|
||||
memberTree.addContent(summaryTreeList.get(i));
|
||||
}
|
||||
memberSummaryTree.addContent(writer.getMemberTree(memberTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for a method.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class MethodBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The index of the current field that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
private int currentMethodIndex;
|
||||
|
||||
/**
|
||||
* The class whose methods are being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible methods for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the method documentation.
|
||||
*/
|
||||
private final MethodWriter writer;
|
||||
|
||||
/**
|
||||
* The methods being documented.
|
||||
*/
|
||||
private List<ProgramElementDoc> methods;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new MethodBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private MethodBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
MethodWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
visibleMemberMap = new VisibleMemberMap(
|
||||
classDoc,
|
||||
VisibleMemberMap.METHODS,
|
||||
configuration);
|
||||
methods =
|
||||
new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
|
||||
configuration));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(methods, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new MethodBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*
|
||||
* @return an instance of a MethodBuilder.
|
||||
*/
|
||||
public static MethodBuilder getInstance(Context context,
|
||||
ClassDoc classDoc, MethodWriter writer) {
|
||||
return new MethodBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "MethodDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of methods that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of methods that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the methods of this class.
|
||||
*
|
||||
* @return the visible member map for the methods of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return methods.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the method documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodDoc(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = methods.size();
|
||||
if (size > 0) {
|
||||
Content methodDetailsTree = writer.getMethodDetailsTreeHeader(
|
||||
classDoc, memberDetailsTree);
|
||||
for (currentMethodIndex = 0; currentMethodIndex < size;
|
||||
currentMethodIndex++) {
|
||||
Content methodDocTree = writer.getMethodDocTreeHeader(
|
||||
(MethodDoc) methods.get(currentMethodIndex),
|
||||
methodDetailsTree);
|
||||
buildChildren(node, methodDocTree);
|
||||
methodDetailsTree.addContent(writer.getMethodDoc(
|
||||
methodDocTree, (currentMethodIndex == size - 1)));
|
||||
}
|
||||
memberDetailsTree.addContent(
|
||||
writer.getMethodDetails(methodDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content methodDocTree) {
|
||||
methodDocTree.addContent(
|
||||
writer.getSignature((MethodDoc) methods.get(currentMethodIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content methodDocTree) {
|
||||
writer.addDeprecated(
|
||||
(MethodDoc) methods.get(currentMethodIndex), methodDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the method. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodComments(XMLNode node, Content methodDocTree) {
|
||||
if (!configuration.nocomment) {
|
||||
MethodDoc method = (MethodDoc) methods.get(currentMethodIndex);
|
||||
|
||||
if (method.inlineTags().length == 0) {
|
||||
DocFinder.Output docs = DocFinder.search(
|
||||
new DocFinder.Input(method));
|
||||
method = docs.inlineTags != null && docs.inlineTags.length > 0 ?
|
||||
(MethodDoc) docs.holder : method;
|
||||
}
|
||||
//NOTE: When we fix the bug where ClassDoc.interfaceTypes() does
|
||||
// not pass all implemented interfaces, holder will be the
|
||||
// interface type. For now, it is really the erasure.
|
||||
writer.addComments(method.containingClass(), method, methodDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content methodDocTree) {
|
||||
writer.addTags((MethodDoc) methods.get(currentMethodIndex),
|
||||
methodDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the method writer for this builder.
|
||||
*
|
||||
* @return the method writer for this builder.
|
||||
*/
|
||||
public MethodWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the summary for a given package.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class PackageSummaryBuilder extends AbstractBuilder {
|
||||
/**
|
||||
* The root element of the package summary XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "PackageDoc";
|
||||
|
||||
/**
|
||||
* The package being documented.
|
||||
*/
|
||||
private final PackageDoc packageDoc;
|
||||
|
||||
/**
|
||||
* The doclet specific writer that will output the result.
|
||||
*/
|
||||
private final PackageSummaryWriter packageWriter;
|
||||
|
||||
/**
|
||||
* The content that will be added to the package summary documentation tree.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* Construct a new PackageSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param pkg the package being documented.
|
||||
* @param packageWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
*/
|
||||
private PackageSummaryBuilder(Context context,
|
||||
PackageDoc pkg,
|
||||
PackageSummaryWriter packageWriter) {
|
||||
super(context);
|
||||
this.packageDoc = pkg;
|
||||
this.packageWriter = packageWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new PackageSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param pkg the package being documented.
|
||||
* @param packageWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
*
|
||||
* @return an instance of a PackageSummaryBuilder.
|
||||
*/
|
||||
public static PackageSummaryBuilder getInstance(Context context,
|
||||
PackageDoc pkg, PackageSummaryWriter packageWriter) {
|
||||
return new PackageSummaryBuilder(context, pkg, packageWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the package summary.
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
if (packageWriter == null) {
|
||||
//Doclet does not support this output.
|
||||
return;
|
||||
}
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the package documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
|
||||
contentTree = packageWriter.getPackageHeader(Util.getPackageName(packageDoc));
|
||||
buildChildren(node, contentTree);
|
||||
packageWriter.addPackageFooter(contentTree);
|
||||
packageWriter.printDocument(contentTree);
|
||||
packageWriter.close();
|
||||
Util.copyDocFiles(configuration, packageDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the content for the package doc.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the package contents
|
||||
* will be added
|
||||
*/
|
||||
public void buildContent(XMLNode node, Content contentTree) {
|
||||
Content packageContentTree = packageWriter.getContentHeader();
|
||||
buildChildren(node, packageContentTree);
|
||||
contentTree.addContent(packageContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the package summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the package content tree to which the summaries will
|
||||
* be added
|
||||
*/
|
||||
public void buildSummary(XMLNode node, Content packageContentTree) {
|
||||
Content summaryContentTree = packageWriter.getSummaryHeader();
|
||||
buildChildren(node, summaryContentTree);
|
||||
packageContentTree.addContent(summaryContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the interfaces in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the interface summary
|
||||
* will be added
|
||||
*/
|
||||
public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
|
||||
String interfaceTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
configuration.getText("doclet.interfaces"));
|
||||
String[] interfaceTableHeader = new String[] {
|
||||
configuration.getText("doclet.Interface"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] interfaces =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.interfaces()
|
||||
: configuration.classDocCatalog.interfaces(
|
||||
Util.getPackageName(packageDoc));
|
||||
interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx);
|
||||
if (interfaces.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
interfaces,
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
interfaceTableSummary, interfaceTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the classes in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the class summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildClassSummary(XMLNode node, Content summaryContentTree) {
|
||||
String classTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
configuration.getText("doclet.classes"));
|
||||
String[] classTableHeader = new String[] {
|
||||
configuration.getText("doclet.Class"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] classes =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.ordinaryClasses()
|
||||
: configuration.classDocCatalog.ordinaryClasses(
|
||||
Util.getPackageName(packageDoc));
|
||||
classes = Util.filterOutPrivateClasses(classes, configuration.javafx);
|
||||
if (classes.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
classes,
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
classTableSummary, classTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the enums in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the enum summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
|
||||
String enumTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
configuration.getText("doclet.enums"));
|
||||
String[] enumTableHeader = new String[] {
|
||||
configuration.getText("doclet.Enum"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] enums =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.enums()
|
||||
: configuration.classDocCatalog.enums(
|
||||
Util.getPackageName(packageDoc));
|
||||
enums = Util.filterOutPrivateClasses(enums, configuration.javafx);
|
||||
if (enums.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
enums,
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
enumTableSummary, enumTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the exceptions in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the exception summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
|
||||
String exceptionTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
configuration.getText("doclet.exceptions"));
|
||||
String[] exceptionTableHeader = new String[] {
|
||||
configuration.getText("doclet.Exception"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] exceptions =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.exceptions()
|
||||
: configuration.classDocCatalog.exceptions(
|
||||
Util.getPackageName(packageDoc));
|
||||
exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx);
|
||||
if (exceptions.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
exceptions,
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
exceptionTableSummary, exceptionTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the errors in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the error summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
|
||||
String errorTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
configuration.getText("doclet.errors"));
|
||||
String[] errorTableHeader = new String[] {
|
||||
configuration.getText("doclet.Error"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] errors =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.errors()
|
||||
: configuration.classDocCatalog.errors(
|
||||
Util.getPackageName(packageDoc));
|
||||
errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
|
||||
if (errors.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
errors,
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
errorTableSummary, errorTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the annotation type in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the annotation type
|
||||
* summary will be added
|
||||
*/
|
||||
public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
|
||||
String annotationtypeTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
configuration.getText("doclet.annotationtypes"));
|
||||
String[] annotationtypeTableHeader = new String[] {
|
||||
configuration.getText("doclet.AnnotationType"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] annotationTypes =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.annotationTypes()
|
||||
: configuration.classDocCatalog.annotationTypes(
|
||||
Util.getPackageName(packageDoc));
|
||||
annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx);
|
||||
if (annotationTypes.length > 0) {
|
||||
packageWriter.addClassesSummary(
|
||||
annotationTypes,
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
annotationtypeTableSummary, annotationtypeTableHeader,
|
||||
summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the description of the summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the tree to which the package description will
|
||||
* be added
|
||||
*/
|
||||
public void buildPackageDescription(XMLNode node, Content packageContentTree) {
|
||||
if (configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
packageWriter.addPackageDescription(packageContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tags of the summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the tree to which the package tags will be added
|
||||
*/
|
||||
public void buildPackageTags(XMLNode node, Content packageContentTree) {
|
||||
if (configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
packageWriter.addPackageTags(packageContentTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.io.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the summary for a given profile package.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class ProfilePackageSummaryBuilder extends AbstractBuilder {
|
||||
/**
|
||||
* The root element of the profile package summary XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "PackageDoc";
|
||||
|
||||
/**
|
||||
* The profile package being documented.
|
||||
*/
|
||||
private final PackageDoc packageDoc;
|
||||
|
||||
/**
|
||||
* The name of the profile being documented.
|
||||
*/
|
||||
private final String profileName;
|
||||
|
||||
/**
|
||||
* The value of the profile being documented.
|
||||
*/
|
||||
private final int profileValue;
|
||||
|
||||
/**
|
||||
* The doclet specific writer that will output the result.
|
||||
*/
|
||||
private final ProfilePackageSummaryWriter profilePackageWriter;
|
||||
|
||||
/**
|
||||
* The content that will be added to the profile package summary documentation tree.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* Construct a new ProfilePackageSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param pkg the profile package being documented.
|
||||
* @param profilePackageWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
* @param profile the profile being documented.
|
||||
*/
|
||||
private ProfilePackageSummaryBuilder(Context context,
|
||||
PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
|
||||
Profile profile) {
|
||||
super(context);
|
||||
this.packageDoc = pkg;
|
||||
this.profilePackageWriter = profilePackageWriter;
|
||||
this.profileName = profile.name;
|
||||
this.profileValue = profile.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ProfilePackageSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param pkg the profile package being documented.
|
||||
* @param profilePackageWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
* @param profile the profile being documented.
|
||||
*
|
||||
* @return an instance of a ProfilePackageSummaryBuilder.
|
||||
*/
|
||||
public static ProfilePackageSummaryBuilder getInstance(Context context,
|
||||
PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
|
||||
Profile profile) {
|
||||
return new ProfilePackageSummaryBuilder(context, pkg, profilePackageWriter,
|
||||
profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile package summary.
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
if (profilePackageWriter == null) {
|
||||
//Doclet does not support this output.
|
||||
return;
|
||||
}
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile package documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
|
||||
contentTree = profilePackageWriter.getPackageHeader(
|
||||
Util.getPackageName(packageDoc));
|
||||
buildChildren(node, contentTree);
|
||||
profilePackageWriter.addPackageFooter(contentTree);
|
||||
profilePackageWriter.printDocument(contentTree);
|
||||
profilePackageWriter.close();
|
||||
Util.copyDocFiles(configuration, packageDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the content for the profile package doc.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the package contents
|
||||
* will be added
|
||||
*/
|
||||
public void buildContent(XMLNode node, Content contentTree) {
|
||||
Content packageContentTree = profilePackageWriter.getContentHeader();
|
||||
buildChildren(node, packageContentTree);
|
||||
contentTree.addContent(packageContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile package summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the package content tree to which the summaries will
|
||||
* be added
|
||||
*/
|
||||
public void buildSummary(XMLNode node, Content packageContentTree) {
|
||||
Content summaryContentTree = profilePackageWriter.getSummaryHeader();
|
||||
buildChildren(node, summaryContentTree);
|
||||
packageContentTree.addContent(summaryContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the interfaces in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the interface summary
|
||||
* will be added
|
||||
*/
|
||||
public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
|
||||
String interfaceTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
configuration.getText("doclet.interfaces"));
|
||||
String[] interfaceTableHeader = new String[] {
|
||||
configuration.getText("doclet.Interface"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] interfaces =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.interfaces()
|
||||
: configuration.classDocCatalog.interfaces(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (interfaces.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
interfaces,
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
interfaceTableSummary, interfaceTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the classes in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the class summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildClassSummary(XMLNode node, Content summaryContentTree) {
|
||||
String classTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
configuration.getText("doclet.classes"));
|
||||
String[] classTableHeader = new String[] {
|
||||
configuration.getText("doclet.Class"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] classes =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.ordinaryClasses()
|
||||
: configuration.classDocCatalog.ordinaryClasses(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (classes.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
classes,
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
classTableSummary, classTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the enums in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the enum summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
|
||||
String enumTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
configuration.getText("doclet.enums"));
|
||||
String[] enumTableHeader = new String[] {
|
||||
configuration.getText("doclet.Enum"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] enums =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.enums()
|
||||
: configuration.classDocCatalog.enums(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (enums.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
enums,
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
enumTableSummary, enumTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the exceptions in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the exception summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
|
||||
String exceptionTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
configuration.getText("doclet.exceptions"));
|
||||
String[] exceptionTableHeader = new String[] {
|
||||
configuration.getText("doclet.Exception"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] exceptions =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.exceptions()
|
||||
: configuration.classDocCatalog.exceptions(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (exceptions.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
exceptions,
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
exceptionTableSummary, exceptionTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the errors in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the error summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
|
||||
String errorTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
configuration.getText("doclet.errors"));
|
||||
String[] errorTableHeader = new String[] {
|
||||
configuration.getText("doclet.Error"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] errors =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.errors()
|
||||
: configuration.classDocCatalog.errors(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (errors.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
errors,
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
errorTableSummary, errorTableHeader, summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the annotation type in this package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the summary tree to which the annotation type
|
||||
* summary will be added
|
||||
*/
|
||||
public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
|
||||
String annotationtypeTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
configuration.getText("doclet.annotationtypes"));
|
||||
String[] annotationtypeTableHeader = new String[] {
|
||||
configuration.getText("doclet.AnnotationType"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] annotationTypes =
|
||||
packageDoc.isIncluded()
|
||||
? packageDoc.annotationTypes()
|
||||
: configuration.classDocCatalog.annotationTypes(
|
||||
Util.getPackageName(packageDoc));
|
||||
if (annotationTypes.length > 0) {
|
||||
profilePackageWriter.addClassesSummary(
|
||||
annotationTypes,
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
annotationtypeTableSummary, annotationtypeTableHeader,
|
||||
summaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the description of the summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the tree to which the package description will
|
||||
* be added
|
||||
*/
|
||||
public void buildPackageDescription(XMLNode node, Content packageContentTree) {
|
||||
if (configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
profilePackageWriter.addPackageDescription(packageContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tags of the summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageContentTree the tree to which the package tags will be added
|
||||
*/
|
||||
public void buildPackageTags(XMLNode node, Content packageContentTree) {
|
||||
if (configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
profilePackageWriter.addPackageTags(packageContentTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.io.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
|
||||
/**
|
||||
* Builds the summary for a given profile.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class ProfileSummaryBuilder extends AbstractBuilder {
|
||||
/**
|
||||
* The root element of the profile summary XML is {@value}.
|
||||
*/
|
||||
public static final String ROOT = "ProfileDoc";
|
||||
|
||||
/**
|
||||
* The profile being documented.
|
||||
*/
|
||||
private final Profile profile;
|
||||
|
||||
/**
|
||||
* The doclet specific writer that will output the result.
|
||||
*/
|
||||
private final ProfileSummaryWriter profileWriter;
|
||||
|
||||
/**
|
||||
* The content that will be added to the profile summary documentation tree.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
/**
|
||||
* The profile package being documented.
|
||||
*/
|
||||
private PackageDoc pkg;
|
||||
|
||||
/**
|
||||
* Construct a new ProfileSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param profile the profile being documented.
|
||||
* @param profileWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
*/
|
||||
private ProfileSummaryBuilder(Context context,
|
||||
Profile profile, ProfileSummaryWriter profileWriter) {
|
||||
super(context);
|
||||
this.profile = profile;
|
||||
this.profileWriter = profileWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ProfileSummaryBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param profile the profile being documented.
|
||||
* @param profileWriter the doclet specific writer that will output the
|
||||
* result.
|
||||
*
|
||||
* @return an instance of a ProfileSummaryBuilder.
|
||||
*/
|
||||
public static ProfileSummaryBuilder getInstance(Context context,
|
||||
Profile profile, ProfileSummaryWriter profileWriter) {
|
||||
return new ProfileSummaryBuilder(context, profile, profileWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile summary.
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
if (profileWriter == null) {
|
||||
//Doclet does not support this output.
|
||||
return;
|
||||
}
|
||||
build(layoutParser.parseXML(ROOT), contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
|
||||
contentTree = profileWriter.getProfileHeader(profile.name);
|
||||
buildChildren(node, contentTree);
|
||||
profileWriter.addProfileFooter(contentTree);
|
||||
profileWriter.printDocument(contentTree);
|
||||
profileWriter.close();
|
||||
Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the content for the profile doc.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param contentTree the content tree to which the profile contents
|
||||
* will be added
|
||||
*/
|
||||
public void buildContent(XMLNode node, Content contentTree) {
|
||||
Content profileContentTree = profileWriter.getContentHeader();
|
||||
buildChildren(node, profileContentTree);
|
||||
contentTree.addContent(profileContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param profileContentTree the profile content tree to which the summaries will
|
||||
* be added
|
||||
*/
|
||||
public void buildSummary(XMLNode node, Content profileContentTree) {
|
||||
Content summaryContentTree = profileWriter.getSummaryHeader();
|
||||
buildChildren(node, summaryContentTree);
|
||||
profileContentTree.addContent(profileWriter.getSummaryTree(summaryContentTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the profile package summary.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param summaryContentTree the content tree to which the summaries will
|
||||
* be added
|
||||
*/
|
||||
public void buildPackageSummary(XMLNode node, Content summaryContentTree) {
|
||||
PackageDoc[] packages = configuration.profilePackages.get(profile.name);
|
||||
for (int i = 0; i < packages.length; i++) {
|
||||
this.pkg = packages[i];
|
||||
Content packageSummaryContentTree = profileWriter.getPackageSummaryHeader(this.pkg);
|
||||
buildChildren(node, packageSummaryContentTree);
|
||||
summaryContentTree.addContent(profileWriter.getPackageSummaryTree(
|
||||
packageSummaryContentTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the interfaces in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the interface summary
|
||||
* will be added
|
||||
*/
|
||||
public void buildInterfaceSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String interfaceTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
configuration.getText("doclet.interfaces"));
|
||||
String[] interfaceTableHeader = new String[] {
|
||||
configuration.getText("doclet.Interface"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] interfaces = pkg.interfaces();
|
||||
if (interfaces.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
interfaces,
|
||||
configuration.getText("doclet.Interface_Summary"),
|
||||
interfaceTableSummary, interfaceTableHeader, packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the classes in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the class summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String classTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
configuration.getText("doclet.classes"));
|
||||
String[] classTableHeader = new String[] {
|
||||
configuration.getText("doclet.Class"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] classes = pkg.ordinaryClasses();
|
||||
if (classes.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
classes,
|
||||
configuration.getText("doclet.Class_Summary"),
|
||||
classTableSummary, classTableHeader, packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the enums in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the enum summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildEnumSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String enumTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
configuration.getText("doclet.enums"));
|
||||
String[] enumTableHeader = new String[] {
|
||||
configuration.getText("doclet.Enum"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] enums = pkg.enums();
|
||||
if (enums.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
enums,
|
||||
configuration.getText("doclet.Enum_Summary"),
|
||||
enumTableSummary, enumTableHeader, packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the exceptions in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the exception summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildExceptionSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String exceptionTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
configuration.getText("doclet.exceptions"));
|
||||
String[] exceptionTableHeader = new String[] {
|
||||
configuration.getText("doclet.Exception"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] exceptions = pkg.exceptions();
|
||||
if (exceptions.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
exceptions,
|
||||
configuration.getText("doclet.Exception_Summary"),
|
||||
exceptionTableSummary, exceptionTableHeader, packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the errors in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the error summary will
|
||||
* be added
|
||||
*/
|
||||
public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String errorTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
configuration.getText("doclet.errors"));
|
||||
String[] errorTableHeader = new String[] {
|
||||
configuration.getText("doclet.Error"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] errors = pkg.errors();
|
||||
if (errors.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
errors,
|
||||
configuration.getText("doclet.Error_Summary"),
|
||||
errorTableSummary, errorTableHeader, packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary for the annotation type in the package.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSummaryContentTree the tree to which the annotation type
|
||||
* summary will be added
|
||||
*/
|
||||
public void buildAnnotationTypeSummary(XMLNode node, Content packageSummaryContentTree) {
|
||||
String annotationtypeTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
configuration.getText("doclet.annotationtypes"));
|
||||
String[] annotationtypeTableHeader = new String[] {
|
||||
configuration.getText("doclet.AnnotationType"),
|
||||
configuration.getText("doclet.Description")
|
||||
};
|
||||
ClassDoc[] annotationTypes = pkg.annotationTypes();
|
||||
if (annotationTypes.length > 0) {
|
||||
profileWriter.addClassesSummary(
|
||||
annotationTypes,
|
||||
configuration.getText("doclet.Annotation_Types_Summary"),
|
||||
annotationtypeTableSummary, annotationtypeTableHeader,
|
||||
packageSummaryContentTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.*;
|
||||
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.javadoc.*;
|
||||
|
||||
/**
|
||||
* Builds documentation for a property.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.7
|
||||
*/
|
||||
public class PropertyBuilder extends AbstractMemberBuilder {
|
||||
|
||||
/**
|
||||
* The class whose properties are being documented.
|
||||
*/
|
||||
private final ClassDoc classDoc;
|
||||
|
||||
/**
|
||||
* The visible properties for the given class.
|
||||
*/
|
||||
private final VisibleMemberMap visibleMemberMap;
|
||||
|
||||
/**
|
||||
* The writer to output the property documentation.
|
||||
*/
|
||||
private final PropertyWriter writer;
|
||||
|
||||
/**
|
||||
* The list of properties being documented.
|
||||
*/
|
||||
private final List<ProgramElementDoc> properties;
|
||||
|
||||
/**
|
||||
* The index of the current property that is being documented at this point
|
||||
* in time.
|
||||
*/
|
||||
private int currentPropertyIndex;
|
||||
|
||||
/**
|
||||
* Construct a new PropertyBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
private PropertyBuilder(Context context,
|
||||
ClassDoc classDoc,
|
||||
PropertyWriter writer) {
|
||||
super(context);
|
||||
this.classDoc = classDoc;
|
||||
this.writer = writer;
|
||||
visibleMemberMap =
|
||||
new VisibleMemberMap(
|
||||
classDoc,
|
||||
VisibleMemberMap.PROPERTIES,
|
||||
configuration);
|
||||
properties =
|
||||
new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
|
||||
if (configuration.getMemberComparator() != null) {
|
||||
Collections.sort(properties, configuration.getMemberComparator());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new PropertyBuilder.
|
||||
*
|
||||
* @param context the build context.
|
||||
* @param classDoc the class whoses members are being documented.
|
||||
* @param writer the doclet specific writer.
|
||||
*/
|
||||
public static PropertyBuilder getInstance(Context context,
|
||||
ClassDoc classDoc,
|
||||
PropertyWriter writer) {
|
||||
return new PropertyBuilder(context, classDoc, writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return "PropertyDetails";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties that will be documented for the given class.
|
||||
* This information can be used for doclet specific documentation
|
||||
* generation.
|
||||
*
|
||||
* @param classDoc the {@link ClassDoc} we want to check.
|
||||
* @return a list of properties that will be documented.
|
||||
*/
|
||||
public List<ProgramElementDoc> members(ClassDoc classDoc) {
|
||||
return visibleMemberMap.getMembersFor(classDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visible member map for the properties of this class.
|
||||
*
|
||||
* @return the visible member map for the properties of this class.
|
||||
*/
|
||||
public VisibleMemberMap getVisibleMemberMap() {
|
||||
return visibleMemberMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* summaryOrder.size()
|
||||
*/
|
||||
public boolean hasMembersToDocument() {
|
||||
return properties.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the property documentation.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param memberDetailsTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) {
|
||||
if (writer == null) {
|
||||
return;
|
||||
}
|
||||
int size = properties.size();
|
||||
if (size > 0) {
|
||||
Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(
|
||||
classDoc, memberDetailsTree);
|
||||
for (currentPropertyIndex = 0; currentPropertyIndex < size;
|
||||
currentPropertyIndex++) {
|
||||
Content propertyDocTree = writer.getPropertyDocTreeHeader(
|
||||
(MethodDoc) properties.get(currentPropertyIndex),
|
||||
propertyDetailsTree);
|
||||
buildChildren(node, propertyDocTree);
|
||||
propertyDetailsTree.addContent(writer.getPropertyDoc(
|
||||
propertyDocTree, (currentPropertyIndex == size - 1)));
|
||||
}
|
||||
memberDetailsTree.addContent(
|
||||
writer.getPropertyDetails(propertyDetailsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the signature.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param propertyDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSignature(XMLNode node, Content propertyDocTree) {
|
||||
propertyDocTree.addContent(
|
||||
writer.getSignature((MethodDoc) properties.get(currentPropertyIndex)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param propertyDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecationInfo(XMLNode node, Content propertyDocTree) {
|
||||
writer.addDeprecated(
|
||||
(MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the comments for the property. Do nothing if
|
||||
* {@link Configuration#nocomment} is set to true.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param propertyDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPropertyComments(XMLNode node, Content propertyDocTree) {
|
||||
if (!configuration.nocomment) {
|
||||
writer.addComments((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the tag information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param propertyDocTree the content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildTagInfo(XMLNode node, Content propertyDocTree) {
|
||||
writer.addTags((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the property writer for this builder.
|
||||
*
|
||||
* @return the property writer for this builder.
|
||||
*/
|
||||
public PropertyWriter getWriter() {
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,595 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.tools.javac.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Builds the serialized form.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SerializedFormBuilder extends AbstractBuilder {
|
||||
|
||||
/**
|
||||
* The root element of the serialized form XML is {@value}.
|
||||
*/
|
||||
public static final String NAME = "SerializedForm";
|
||||
|
||||
/**
|
||||
* The writer for this builder.
|
||||
*/
|
||||
private SerializedFormWriter writer;
|
||||
|
||||
/**
|
||||
* The writer for serializable fields.
|
||||
*/
|
||||
private SerializedFormWriter.SerialFieldWriter fieldWriter;
|
||||
|
||||
/**
|
||||
* The writer for serializable method documentation.
|
||||
*/
|
||||
private SerializedFormWriter.SerialMethodWriter methodWriter;
|
||||
|
||||
/**
|
||||
* The header for the serial version UID. Save the string
|
||||
* here instead of the properties file because we do not want
|
||||
* this string to be localized.
|
||||
*/
|
||||
private static final String SERIAL_VERSION_UID_HEADER = "serialVersionUID:";
|
||||
|
||||
/**
|
||||
* The current package being documented.
|
||||
*/
|
||||
private PackageDoc currentPackage;
|
||||
|
||||
/**
|
||||
* The current class being documented.
|
||||
*/
|
||||
private ClassDoc currentClass;
|
||||
|
||||
/**
|
||||
* The current member being documented.
|
||||
*/
|
||||
protected MemberDoc currentMember;
|
||||
|
||||
/**
|
||||
* The content that will be added to the serialized form documentation tree.
|
||||
*/
|
||||
private Content contentTree;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new SerializedFormBuilder.
|
||||
* @param context the build context.
|
||||
*/
|
||||
private SerializedFormBuilder(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new SerializedFormBuilder.
|
||||
* @param context the build context.
|
||||
*/
|
||||
public static SerializedFormBuilder getInstance(Context context) {
|
||||
return new SerializedFormBuilder(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serialized form.
|
||||
*/
|
||||
public void build() throws IOException {
|
||||
if (! serialClassFoundToDocument(configuration.root.classes())) {
|
||||
//Nothing to document.
|
||||
return;
|
||||
}
|
||||
try {
|
||||
writer = configuration.getWriterFactory().getSerializedFormWriter();
|
||||
if (writer == null) {
|
||||
//Doclet does not support this output.
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
build(layoutParser.parseXML(NAME), contentTree);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serialized form.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param serializedTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSerializedForm(XMLNode node, Content serializedTree) throws Exception {
|
||||
serializedTree = writer.getHeader(configuration.getText(
|
||||
"doclet.Serialized_Form"));
|
||||
buildChildren(node, serializedTree);
|
||||
writer.addFooter(serializedTree);
|
||||
writer.printDocument(serializedTree);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serialized form summaries.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param serializedTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSerializedFormSummaries(XMLNode node, Content serializedTree) {
|
||||
Content serializedSummariesTree = writer.getSerializedSummariesHeader();
|
||||
PackageDoc[] packages = configuration.packages;
|
||||
for (int i = 0; i < packages.length; i++) {
|
||||
currentPackage = packages[i];
|
||||
buildChildren(node, serializedSummariesTree);
|
||||
}
|
||||
serializedTree.addContent(writer.getSerializedContent(
|
||||
serializedSummariesTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the package serialized form for the current package being processed.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param serializedSummariesTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) {
|
||||
Content packageSerializedTree = writer.getPackageSerializedHeader();
|
||||
String foo = currentPackage.name();
|
||||
ClassDoc[] classes = currentPackage.allClasses(false);
|
||||
if (classes == null || classes.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (!serialInclude(currentPackage)) {
|
||||
return;
|
||||
}
|
||||
if (!serialClassFoundToDocument(classes)) {
|
||||
return;
|
||||
}
|
||||
buildChildren(node, packageSerializedTree);
|
||||
serializedSummariesTree.addContent(packageSerializedTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the package header.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSerializedTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildPackageHeader(XMLNode node, Content packageSerializedTree) {
|
||||
packageSerializedTree.addContent(writer.getPackageHeader(
|
||||
Util.getPackageName(currentPackage)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the class serialized form.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param packageSerializedTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) {
|
||||
Content classSerializedTree = writer.getClassSerializedHeader();
|
||||
ClassDoc[] classes = currentPackage.allClasses(false);
|
||||
Arrays.sort(classes);
|
||||
for (int j = 0; j < classes.length; j++) {
|
||||
currentClass = classes[j];
|
||||
fieldWriter = writer.getSerialFieldWriter(currentClass);
|
||||
methodWriter = writer.getSerialMethodWriter(currentClass);
|
||||
if(currentClass.isClass() && currentClass.isSerializable()) {
|
||||
if(!serialClassInclude(currentClass)) {
|
||||
continue;
|
||||
}
|
||||
Content classTree = writer.getClassHeader(currentClass);
|
||||
buildChildren(node, classTree);
|
||||
classSerializedTree.addContent(classTree);
|
||||
}
|
||||
}
|
||||
packageSerializedTree.addContent(classSerializedTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serial UID information for the given class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classTree content tree to which the serial UID information will be added
|
||||
*/
|
||||
public void buildSerialUIDInfo(XMLNode node, Content classTree) {
|
||||
Content serialUidTree = writer.getSerialUIDInfoHeader();
|
||||
FieldDoc[] fields = currentClass.fields(false);
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
if (fields[i].name().equals("serialVersionUID") &&
|
||||
fields[i].constantValueExpression() != null) {
|
||||
writer.addSerialUIDInfo(SERIAL_VERSION_UID_HEADER,
|
||||
fields[i].constantValueExpression(), serialUidTree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
classTree.addContent(serialUidTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summaries for the methods and fields.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildClassContent(XMLNode node, Content classTree) {
|
||||
Content classContentTree = writer.getClassContentHeader();
|
||||
buildChildren(node, classContentTree);
|
||||
classTree.addContent(classContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summaries for the methods that belong to the given
|
||||
* class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSerializableMethods(XMLNode node, Content classContentTree) {
|
||||
Content serializableMethodTree = methodWriter.getSerializableMethodsHeader();
|
||||
MemberDoc[] members = currentClass.serializationMethods();
|
||||
int membersLength = members.length;
|
||||
if (membersLength > 0) {
|
||||
for (int i = 0; i < membersLength; i++) {
|
||||
currentMember = members[i];
|
||||
Content methodsContentTree = methodWriter.getMethodsContentHeader(
|
||||
(i == membersLength - 1));
|
||||
buildChildren(node, methodsContentTree);
|
||||
serializableMethodTree.addContent(methodsContentTree);
|
||||
}
|
||||
}
|
||||
if (currentClass.serializationMethods().length > 0) {
|
||||
classContentTree.addContent(methodWriter.getSerializableMethods(
|
||||
configuration.getText("doclet.Serialized_Form_methods"),
|
||||
serializableMethodTree));
|
||||
if (currentClass.isSerializable() && !currentClass.isExternalizable()) {
|
||||
if (currentClass.serializationMethods().length == 0) {
|
||||
Content noCustomizationMsg = methodWriter.getNoCustomizationMsg(
|
||||
configuration.getText(
|
||||
"doclet.Serializable_no_customization"));
|
||||
classContentTree.addContent(methodWriter.getSerializableMethods(
|
||||
configuration.getText("doclet.Serialized_Form_methods"),
|
||||
noCustomizationMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the method sub header.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodSubHeader(XMLNode node, Content methodsContentTree) {
|
||||
methodWriter.addMemberHeader((MethodDoc)currentMember, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the deprecated method description.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildDeprecatedMethodInfo(XMLNode node, Content methodsContentTree) {
|
||||
methodWriter.addDeprecatedMemberInfo((MethodDoc) currentMember, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the information for the method.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodInfo(XMLNode node, Content methodsContentTree) {
|
||||
if(configuration.nocomment){
|
||||
return;
|
||||
}
|
||||
buildChildren(node, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build method description.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodDescription(XMLNode node, Content methodsContentTree) {
|
||||
methodWriter.addMemberDescription((MethodDoc) currentMember, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the method tags.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param methodsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildMethodTags(XMLNode node, Content methodsContentTree) {
|
||||
methodWriter.addMemberTags((MethodDoc) currentMember, methodsContentTree);
|
||||
MethodDoc method = (MethodDoc)currentMember;
|
||||
if (method.name().compareTo("writeExternal") == 0
|
||||
&& method.tags("serialData").length == 0) {
|
||||
if (configuration.serialwarn) {
|
||||
configuration.getDocletSpecificMsg().warning(
|
||||
currentMember.position(), "doclet.MissingSerialDataTag",
|
||||
method.containingClass().qualifiedName(), method.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field header.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldHeader(XMLNode node, Content classContentTree) {
|
||||
if (currentClass.serializableFields().length > 0) {
|
||||
buildFieldSerializationOverview(currentClass, classContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serialization overview for the given class.
|
||||
*
|
||||
* @param classDoc the class to print the overview for.
|
||||
* @param classContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
|
||||
if (classDoc.definesSerializableFields()) {
|
||||
FieldDoc serialPersistentField = classDoc.serializableFields()[0];
|
||||
// Check to see if there are inline comments, tags or deprecation
|
||||
// information to be printed.
|
||||
if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
|
||||
Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
|
||||
Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
|
||||
fieldWriter.addMemberDeprecatedInfo(serialPersistentField,
|
||||
fieldsOverviewContentTree);
|
||||
if (!configuration.nocomment) {
|
||||
fieldWriter.addMemberDescription(serialPersistentField,
|
||||
fieldsOverviewContentTree);
|
||||
fieldWriter.addMemberTags(serialPersistentField,
|
||||
fieldsOverviewContentTree);
|
||||
}
|
||||
serializableFieldsTree.addContent(fieldsOverviewContentTree);
|
||||
classContentTree.addContent(fieldWriter.getSerializableFields(
|
||||
configuration.getText("doclet.Serialized_Form_class"),
|
||||
serializableFieldsTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summaries for the fields that belong to the given class.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param classContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSerializableFields(XMLNode node, Content classContentTree) {
|
||||
MemberDoc[] members = currentClass.serializableFields();
|
||||
int membersLength = members.length;
|
||||
if (membersLength > 0) {
|
||||
Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
|
||||
for (int i = 0; i < membersLength; i++) {
|
||||
currentMember = members[i];
|
||||
if (!currentClass.definesSerializableFields()) {
|
||||
Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
|
||||
(i == membersLength - 1));
|
||||
buildChildren(node, fieldsContentTree);
|
||||
serializableFieldsTree.addContent(fieldsContentTree);
|
||||
}
|
||||
else {
|
||||
buildSerialFieldTagsInfo(serializableFieldsTree);
|
||||
}
|
||||
}
|
||||
classContentTree.addContent(fieldWriter.getSerializableFields(
|
||||
configuration.getText("doclet.Serialized_Form_fields"),
|
||||
serializableFieldsTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field sub header.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldSubHeader(XMLNode node, Content fieldsContentTree) {
|
||||
if (!currentClass.definesSerializableFields()) {
|
||||
FieldDoc field = (FieldDoc) currentMember;
|
||||
fieldWriter.addMemberHeader(field.type().asClassDoc(),
|
||||
field.type().typeName(), field.type().dimension(), field.name(),
|
||||
fieldsContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field deprecation information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldDeprecationInfo(XMLNode node, Content fieldsContentTree) {
|
||||
if (!currentClass.definesSerializableFields()) {
|
||||
FieldDoc field = (FieldDoc)currentMember;
|
||||
fieldWriter.addMemberDeprecatedInfo(field, fieldsContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the serial field tags information.
|
||||
*
|
||||
* @param serializableFieldsTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildSerialFieldTagsInfo(Content serializableFieldsTree) {
|
||||
if(configuration.nocomment){
|
||||
return;
|
||||
}
|
||||
FieldDoc field = (FieldDoc)currentMember;
|
||||
// Process Serializable Fields specified as array of
|
||||
// ObjectStreamFields. Print a member for each serialField tag.
|
||||
// (There should be one serialField tag per ObjectStreamField
|
||||
// element.)
|
||||
SerialFieldTag[] tags = field.serialFieldTags();
|
||||
Arrays.sort(tags);
|
||||
int tagsLength = tags.length;
|
||||
for (int i = 0; i < tagsLength; i++) {
|
||||
if (tags[i].fieldName() == null || tags[i].fieldType() == null) // ignore malformed @serialField tags
|
||||
continue;
|
||||
Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
|
||||
(i == tagsLength - 1));
|
||||
fieldWriter.addMemberHeader(tags[i].fieldTypeDoc(),
|
||||
tags[i].fieldType(), "", tags[i].fieldName(), fieldsContentTree);
|
||||
fieldWriter.addMemberDescription(tags[i], fieldsContentTree);
|
||||
serializableFieldsTree.addContent(fieldsContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the field information.
|
||||
*
|
||||
* @param node the XML element that specifies which components to document
|
||||
* @param fieldsContentTree content tree to which the documentation will be added
|
||||
*/
|
||||
public void buildFieldInfo(XMLNode node, Content fieldsContentTree) {
|
||||
if(configuration.nocomment){
|
||||
return;
|
||||
}
|
||||
FieldDoc field = (FieldDoc)currentMember;
|
||||
ClassDoc cd = field.containingClass();
|
||||
// Process default Serializable field.
|
||||
if ((field.tags("serial").length == 0) && ! field.isSynthetic()
|
||||
&& configuration.serialwarn) {
|
||||
configuration.message.warning(field.position(),
|
||||
"doclet.MissingSerialTag", cd.qualifiedName(),
|
||||
field.name());
|
||||
}
|
||||
fieldWriter.addMemberDescription(field, fieldsContentTree);
|
||||
fieldWriter.addMemberTags(field, fieldsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given Doc should be included
|
||||
* in the serialized form.
|
||||
*
|
||||
* @param doc the Doc object to check for serializability.
|
||||
*/
|
||||
public static boolean serialInclude(Doc doc) {
|
||||
if (doc == null) {
|
||||
return false;
|
||||
}
|
||||
return doc.isClass() ?
|
||||
serialClassInclude((ClassDoc)doc) :
|
||||
serialDocInclude(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given ClassDoc should be included
|
||||
* in the serialized form.
|
||||
*
|
||||
* @param cd the ClassDoc object to check for serializability.
|
||||
*/
|
||||
private static boolean serialClassInclude(ClassDoc cd) {
|
||||
if (cd.isEnum()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
cd.superclassType();
|
||||
} catch (NullPointerException e) {
|
||||
//Workaround for null pointer bug in ClassDoc.superclassType().
|
||||
return false;
|
||||
}
|
||||
if (cd.isSerializable()) {
|
||||
if (cd.tags("serial").length > 0) {
|
||||
return serialDocInclude(cd);
|
||||
} else if (cd.isPublic() || cd.isProtected()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given Doc should be included
|
||||
* in the serialized form.
|
||||
*
|
||||
* @param doc the Doc object to check for serializability.
|
||||
*/
|
||||
private static boolean serialDocInclude(Doc doc) {
|
||||
if (doc.isEnum()) {
|
||||
return false;
|
||||
}
|
||||
Tag[] serial = doc.tags("serial");
|
||||
if (serial.length > 0) {
|
||||
String serialtext = StringUtils.toLowerCase(serial[0].text());
|
||||
if (serialtext.indexOf("exclude") >= 0) {
|
||||
return false;
|
||||
} else if (serialtext.indexOf("include") >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if any of the given classes have a @serialinclude tag.
|
||||
*
|
||||
* @param classes the classes to check.
|
||||
* @return true if any of the given classes have a @serialinclude tag.
|
||||
*/
|
||||
private boolean serialClassFoundToDocument(ClassDoc[] classes) {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (serialClassInclude(classes[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012, 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.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class XMLNode {
|
||||
XMLNode(XMLNode parent, String qname) {
|
||||
this.parent = parent;
|
||||
name = qname;
|
||||
attrs = new HashMap<String,String>();
|
||||
children = new ArrayList<XMLNode>();
|
||||
|
||||
if (parent != null)
|
||||
parent.children.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<");
|
||||
sb.append(name);
|
||||
for (Map.Entry<String,String> 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("</" + name + ">");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
final XMLNode parent;
|
||||
final String name;
|
||||
final Map<String,String> attrs;
|
||||
final List<XMLNode> children;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
This doclet-independent package has a set of classes and
|
||||
interfaces that are the building blocks for doclets. They
|
||||
define the basic structure of doclets and make doclet
|
||||
writing much easier because they provide the content generation
|
||||
code to be shared among different doclets. Builders only provide
|
||||
the structure and content of API documentation.
|
||||
They will not provide any style markup.
|
||||
|
||||
<p><b>This is NOT part of any supported API.
|
||||
If you write code that depends on this, you do so at your own risk.
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
@jdk.Exported(false)
|
||||
package com.sun.tools.doclets.internal.toolkit.builders;
|
||||
Reference in New Issue
Block a user