file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
C4.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/com/sun/javadoc/testCmndLineClass/pkg2/C4.java
/* * Copyright (c) 2002, 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. * * 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 pkg2; /** *This is a description for C4. */ public class C4 { public static final int I = 1; }
1,166
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
C2.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/com/sun/javadoc/testCmndLineClass/pkg1/C2.java
/* * Copyright (c) 2002, 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. * * 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 pkg1; /** *This is a description for C2. */ public class C2 { public static final int I = 1; }
1,166
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
C1.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/com/sun/javadoc/testCmndLineClass/pkg1/C1.java
/* * Copyright (c) 2002, 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. * * 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 pkg1; /** *This is a description for C1. */ public class C1 { public static final int I = 1; }
1,165
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TestSimpleTag.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
/* * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * 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. */ /* * @test * @bug 4695326 4750173 4920381 * @summary Test the declarartion of simple tags using -tag. Verify that * "-tag name" is a shortcut for "-tag name:a:Name:". Also verity that * you can escape the ":" character with a back slash so that it is not * considered a separator when parsing the simple tag argument. * @author jamieh * @library ../lib/ * @build JavadocTester * @build TestSimpleTag * @run main TestSimpleTag */ public class TestSimpleTag extends JavadocTester { private static final String BUG_ID = "4695326-4750173-4920381"; private static final String[][] TEST = new String[][] { {"./" + BUG_ID + "/C.html", "<span class=\"strong\">Todo:</span>"}, {"./" + BUG_ID + "/C.html", "<span class=\"strong\">EJB Beans:</span>"}, {"./" + BUG_ID + "/C.html", "<span class=\"strong\">Regular Tag:</span>"}, {"./" + BUG_ID + "/C.html", "<span class=\"strong\">Back-Slash-Tag:</span>"}, }; private static final String[] ARGS = new String[] { "-d", BUG_ID, "-sourcepath", SRC_DIR, "-tag", "todo", "-tag", "ejb\\:bean:a:EJB Beans:", "-tag", "regular:a:Regular Tag:", "-tag", "back-slash\\:tag\\\\:a:Back-Slash-Tag:", SRC_DIR + FS + "C.java" }; /** * The entry point of the test. * @param args the array of command line arguments. */ public static void main(String[] args) { TestSimpleTag tester = new TestSimpleTag(); run(tester, ARGS, TEST, NO_TEST); tester.printSummary(); } /** * {@inheritDoc} */ public String getBugId() { return BUG_ID; } /** * {@inheritDoc} */ public String getBugName() { return getClass().getName(); } }
2,915
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
C.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/test/com/sun/javadoc/testSimpleTag/C.java
/* * Copyright (c) 2002, 2003, 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. * * 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. */ /** * @todo This is a comment. * @ejb:bean This is a bean. * @regular Just a regular simple tag. * @back-slash:tag\ a tag that ends with a back slash. */ public class C {}
1,236
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CheckNamesProcessor.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/sample/javac/processing/src/CheckNamesProcessor.java
/* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of Oracle nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.util.Set; import java.util.EnumSet; import javax.annotation.processing.*; import javax.lang.model.SourceVersion; import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; import static javax.lang.model.SourceVersion.*; import static javax.lang.model.element.Modifier.*; import static javax.lang.model.element.ElementKind.*; import static javax.lang.model.type.TypeKind.*; import static javax.lang.model.util.ElementFilter.*; import static javax.tools.Diagnostic.Kind.*; /** * A sample processor to check naming conventions are being followed. * * <h3>How to run this processor from the command line</h3> * <ol> * <li> Compile this file; for example<br> * {@code javac -d procdir CheckNamesProcessor.java} * <li> Use {@code javac} to run the annotation processor on itself:<br> * {@code javac -processorpath procdir -processor CheckNamesProcessor -proc:only CheckNamesProcessor.java} * </ol> * * <h3>Another way to run this processor from the command line</h3> * <ol> * <li> Compile the processor as before * * <li> Create a UTF-8 encoded text file named {@code * javax.annotation.processing.Processor} in the {@code * META-INF/services} directory. The contents of the file are a list * of the binary names of the concrete processor classes, one per * line. This provider-configuration file is used by {@linkplain * java.util.ServiceLoader service-loader} style lookup. * * <li> Create a {@code jar} file with the processor classes and * {@code META-INF} information. * * <li> Such a {@code jar} file can now be used with the <i>discovery * process</i> without explicitly naming the processor to run:<br> * {@code javac -processorpath procdir -proc:only CheckNamesProcessor.java} * * </ol> * * For some notes on how to run an annotation processor inside * NetBeans, see http://wiki.java.net/bin/view/Netbeans/FaqApt. * * <h3>Possible Enhancements</h3> * <ul> * * <li> Support an annotation processor option to control checking * exported API elements ({@code public} and {@code protected} ones) * or all elements * * <li> Print out warnings that are more informative * * <li> Return a true/false status if any warnings were printed or * compute and return name warning count * * <li> Implement checks of package names * * <li> Use the Tree API, com.sun.source, to examine names within method bodies * * <li> Define an annotation type whose presence can indicate a * different naming convention is being followed * * <li> Implement customized checks on elements in chosen packages * * </ul> * * @author Joseph D. Darcy */ @SupportedAnnotationTypes("*") // Process (check) everything public class CheckNamesProcessor extends AbstractProcessor { private NameChecker nameChecker; /** * Check that the names of the root elements (and their enclosed * elements) follow the appropriate naming conventions. This * processor examines all files regardless of whether or not * annotations are present; no new source or class files are * generated. * * <p>Processors that actually process specific annotations should * <em>not</em> report supporting {@code *}; this could cause * performance degradations and other undesirable outcomes. */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { for (Element element : roundEnv.getRootElements() ) nameChecker.checkNames(element); } return false; // Allow other processors to examine files too. } @Override public void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); nameChecker = new NameChecker(processingEnv); } @Override public SourceVersion getSupportedSourceVersion() { /* * Return latest source version instead of a fixed version * like RELEASE_7. To return a fixed version, this class * could be annotated with a SupportedSourceVersion * annotation. * * Warnings will be issued if any unknown language constructs * are encountered. */ return SourceVersion.latest(); } /** * Provide checks that an element and its enclosed elements follow * the usual naming conventions. * * <p> Conventions from section 6.8 of * <cite>The Java&trade; Language Specification</cite> * * <ul> * <li> Classes and interfaces: camel case, first letter is uppercase * <li> Methods: camel case, first letter is lowercase * <li> Type variables: one uppercase letter * <li> Fields * <ul> * <li> non-final: camel case, initial lowercase * <li> constant: uppercase separated by underscores * </ul> * <li> Packages: checks left as exercise for the reader, see section 7.7 of * <cite>The Java&trade; Language Specification</cite>. * </ul> */ private static class NameChecker { private final Messager messager; private final Types typeUtils; NameCheckScanner nameCheckScanner = new NameCheckScanner(); NameChecker(ProcessingEnvironment processsingEnv) { this.messager = processsingEnv.getMessager(); this.typeUtils = processsingEnv.getTypeUtils(); } /** * If the name of the argument or its enclosed elements * violates the naming conventions, report a warning. */ public void checkNames(Element element) { // Implement name checks with a visitor, but expose that // functionality through this method instead. nameCheckScanner.scan(element); } /** * Visitor to implement name checks. */ private class NameCheckScanner extends ElementScanner7<Void, Void> { // The visitor could be enhanced to return true/false if // there were warnings reported or a count of the number // of warnings. This could be facilitated by using // Boolean or Integer instead of Void for the actual type // arguments. In more detail, one way to tally the number // of warnings would be for each method to return the sum // of the warnings it and the methods it called issued, a // bottom-up computation. In that case, the first type // argument would be Integer and the second type argument // would still be Void. Alternatively, the current count // could be passed along in Integer parameter p and each // method could return the Integer sum of p and the // warnings the method issued. Some computations are more // naturally expressed in one form instead of the other. // If greater control is needed over traversal order, a // SimpleElementVisitor can be extended instead of an // ElementScanner. /** * Check the name of a type and its enclosed elements and * type parameters. */ @Override public Void visitType(TypeElement e, Void p) { scan(e.getTypeParameters(), p); // Check the names of any type parameters checkCamelCase(e, true); // Check the name of the class or interface super.visitType(e, p); // Check the names of any enclosed elements return null; } /** * Check the name of an executable (method, constructor, * etc.) and its type parameters. */ @Override public Void visitExecutable(ExecutableElement e, Void p) { scan(e.getTypeParameters(), p); // Check the names of any type parameters // Check the name of the executable if (e.getKind() == METHOD) { // Make sure that a method does not have the same // name as its class or interface. Name name = e.getSimpleName(); if (name.contentEquals(e.getEnclosingElement().getSimpleName())) messager.printMessage(WARNING, "A method should not have the same name as its enclosing type, ``" + name + "''." , e); checkCamelCase(e, false); } // else constructors and initializers don't have user-defined names // At this point, could use the Tree API, // com.sun.source, to examine the names of entities // inside a method. super.visitExecutable(e, p); return null; } /** * Check the name of a field, parameter, etc. */ @Override public Void visitVariable(VariableElement e, Void p) { if (!checkForSerial(e)) { // serialVersionUID checks // Is the variable a constant? if (e.getKind() == ENUM_CONSTANT || e.getConstantValue() != null || heuristicallyConstant(e) ) checkAllCaps(e); // includes enum constants else checkCamelCase(e, false); } // A call to super can be elided with the current language definition. // super.visitVariable(e, p); return null; } /** * Check the name of a type parameter. */ @Override public Void visitTypeParameter(TypeParameterElement e, Void p) { checkAllCaps(e); // A call to super can be elided with the current language definition. // super.visitTypeParameter(e, p); return null; } /** * Check the name of a package. */ @Override public Void visitPackage(PackageElement e, Void p) { /* * Implementing the checks of package names is left * as an exercise for the reader, see JLS section * 7.7 for conventions. */ // Whether or not this method should call // super.visitPackage, to visit the packages enclosed // elements, is a design decision based on what a // PackageElemement is used to mean in this context. // A PackageElement can represent a whole package, so // it can provide a concise way to indicate many // user-defined types should be visited. However, a // PackageElement can also represent a // package-info.java file, as would be in the case if // the PackageElement came from // RoundEnvironment.getRootElements. In that case, // the package-info file and other files in that // package could be passed in. Therefore, without // further checks, types in a package could be visited // more than once if a package's elements were visited // too. return null; } @Override public Void visitUnknown(Element e, Void p) { // This method will be called if a kind of element // added after JDK 7 is visited. Since as of this // writing the conventions for such constructs aren't // known, issue a warning. messager.printMessage(WARNING, "Unknown kind of element, " + e.getKind() + ", no name checking performed.", e); return null; } // All the name checking methods assume the examined names // are syntactically well-formed identifiers. /** * Return {@code true} if this variable is a field named * "serialVersionUID"; false otherwise. A true * serialVersionUID of a class has type {@code long} and * is static and final. * * <p>To check that a Serializable class defines a proper * serialVersionUID, run javac with -Xlint:serial. * * @return true if this variable is a serialVersionUID field and false otherwise */ private boolean checkForSerial(VariableElement e) { // If a field is named "serialVersionUID" ... if (e.getKind() == FIELD && e.getSimpleName().contentEquals("serialVersionUID")) { // ... issue a warning if it does not act as a serialVersionUID if (!(e.getModifiers().containsAll(EnumSet.of(STATIC, FINAL)) && typeUtils.isSameType(e.asType(), typeUtils.getPrimitiveType(LONG)) && e.getEnclosingElement().getKind() == CLASS )) // could check that class implements Serializable messager.printMessage(WARNING, "Field named ``serialVersionUID'' is not acting as such.", e); return true; } return false; } /** * Using heuristics, return {@code true} is the variable * should follow the naming conventions for constants and * {@code false} otherwise. For example, the public * static final fields ZERO, ONE, and TEN in * java.math.BigDecimal are logically constants (and named * as constants) even though BigDecimal values are not * regarded as constants by the language specification. * However, some final fields may not act as constants * since the field may be a reference to a mutable object. * * <p> These heuristics could be tweaked to provide better * fidelity. * * @return true if the current heuristics regard the * variable as a constant and false otherwise. */ private boolean heuristicallyConstant(VariableElement e) { // Fields declared in interfaces are logically // constants, JLSv3 section 9.3. if (e.getEnclosingElement().getKind() == INTERFACE) return true; else if (e.getKind() == FIELD && e.getModifiers().containsAll(EnumSet.of(PUBLIC, STATIC, FINAL))) return true; else { // A parameter declared final should not be named like // a constant, neither should exception parameters. return false; } } /** * Print a warning if an element's simple name is not in * camel case. If there are two adjacent uppercase * characters, the name is considered to violate the * camel case naming convention. * * @param e the element whose name will be checked * @param initialCaps whether or not the first character should be uppercase */ private void checkCamelCase(Element e, boolean initialCaps) { String name = e.getSimpleName().toString(); boolean previousUpper = false; boolean conventional = true; int firstCodePoint = name.codePointAt(0); if (Character.isUpperCase(firstCodePoint)) { previousUpper = true; if (!initialCaps) { messager.printMessage(WARNING, "Name, ``" + name + "'', should start in lowercase.", e); return; } } else if (Character.isLowerCase(firstCodePoint)) { if (initialCaps) { messager.printMessage(WARNING, "Name, ``" + name + "'', should start in uppercase.", e); return; } } else // underscore, etc. conventional = false; if (conventional) { int cp = firstCodePoint; for (int i = Character.charCount(cp); i < name.length(); i += Character.charCount(cp)) { cp = name.codePointAt(i); if (Character.isUpperCase(cp)){ if (previousUpper) { conventional = false; break; } previousUpper = true; } else previousUpper = false; } } if (!conventional) messager.printMessage(WARNING, "Name, ``" + name + "'', should be in camel case.", e); } /** * Print a warning if the element's name is not a sequence * of uppercase letters separated by underscores ("_"). * * @param e the element whose name will be checked */ private void checkAllCaps(Element e) { String name = e.getSimpleName().toString(); if (e.getKind() == TYPE_PARAMETER) { // Should be one character if (name.codePointCount(0, name.length()) > 1 || // Assume names are non-empty !Character.isUpperCase(name.codePointAt(0))) messager.printMessage(WARNING, "A type variable's name,``" + name + "'', should be a single uppercace character.", e); } else { boolean conventional = true; int firstCodePoint = name.codePointAt(0); // Starting with an underscore is not conventional if (!Character.isUpperCase(firstCodePoint)) conventional = false; else { // Was the previous character an underscore? boolean previousUnderscore = false; int cp = firstCodePoint; for (int i = Character.charCount(cp); i < name.length(); i += Character.charCount(cp)) { cp = name.codePointAt(i); if (cp == (int) '_') { if (previousUnderscore) { conventional = false; break; } previousUnderscore = true; } else { previousUnderscore = false; if (!Character.isUpperCase(cp) && !Character.isDigit(cp) ) { conventional = false; break; } } } } if (!conventional) messager.printMessage(WARNING, "A constant's name, ``" + name + "'', should be ALL_CAPS.", e); } } } } } /** * Lots of bad names. Don't write code like this! */ class BADLY_NAMED_CODE { enum colors { red, blue, green; } // Don't start the name of a constant with an underscore static final int _FORTY_TWO = 42; // Non-constants shouldn't use ALL_CAPS public static int NOT_A_CONSTANT = _FORTY_TWO; // *Not* a serialVersionUID private static final int serialVersionUID = _FORTY_TWO; // Not a constructor protected void BADLY_NAMED_CODE() { return; } public void NOTcamelCASEmethodNAME() { return; } }
22,526
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Taglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/Taglet.java
/* * Copyright (c) 2001, 2006, 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; import com.sun.javadoc.*; /** * The interface for a custom tag used by Doclets. A custom * tag must implement this interface. To be loaded and used by * doclets at run-time, the taglet must have a static method called * <code>register</code> that accepts a {@link java.util.Map} as an * argument with the following signature: * <pre> * public void register(Map map) * </pre> * This method should add an instance of the custom taglet to the map * with the name of the taglet as the key. If overriding a taglet, * to avoid a name conflict, the overridden taglet must be deleted from * the map before an instance of the new taglet is added to the map. * <p> * It is recommended that the taglet throw an exception when it fails * to register itself. The exception that it throws is up to the user. * <p> * Here are two sample taglets: <br> * <ul> * <li><a href="{@docRoot}/../../../../technotes/guides/javadoc/taglet/ToDoTaglet.java">ToDoTaglet.java</a> * - Standalone taglet</li> * <li><a href="{@docRoot}/../../../../technotes/guides/javadoc/taglet/UnderlineTaglet.java">UnderlineTaglet.java</a> * - Inline taglet</li> * </ul> * <p> * For more information on how to create your own Taglets, please see the * <a href="{@docRoot}/../../../../technotes/guides/javadoc/taglet/overview.html">Taglet Overview</a>. * * @since 1.4 * @author Jamie Ho */ public interface Taglet { /** * Return true if this <code>Taglet</code> * is used in field documentation. Set to * false for inline tags. * @return true if this <code>Taglet</code> * is used in field documentation and false * otherwise. */ public abstract boolean inField(); /** * Return true if this <code>Taglet</code> * is used in constructor documentation. Set to * false for inline tags. * @return true if this <code>Taglet</code> * is used in constructor documentation and false * otherwise. */ public abstract boolean inConstructor(); /** * Return true if this <code>Taglet</code> * is used in method documentation. Set to * false for inline tags. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public abstract boolean inMethod(); /** * Return true if this <code>Taglet</code> * is used in overview documentation. Set to * false for inline tags. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public abstract boolean inOverview(); /** * Return true if this <code>Taglet</code> * is used in package documentation. Set to * false for inline tags. * @return true if this <code>Taglet</code> * is used in package documentation and false * otherwise. */ public abstract boolean inPackage(); /** * Return true if this <code>Taglet</code> * is used in type documentation (classes or * interfaces). Set to false for inline tags. * @return true if this <code>Taglet</code> * is used in type documentation and false * otherwise. */ public abstract boolean inType(); /** * Return true if this <code>Taglet</code> * is an inline tag. Return false otherwise. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public abstract boolean isInlineTag(); /** * Return the name of this custom tag. * @return the name of this custom tag. */ public abstract String getName(); /** * Given the <code>Tag</code> representation of this custom * tag, return its string representation, which is output * to the generated page. * @param tag the <code>Tag</code> representation of this custom tag. * @return the string representation of this <code>Tag</code>. */ public abstract String toString(Tag tag); /** * Given an array of <code>Tag</code>s representing this custom * tag, return its string representation, which is output * to the generated page. This method should * return null if this taglet represents an inline tag. * @param tags the array of <code>Tag</code>s representing of this custom tag. * @return the string representation of this <code>Tag</code>. */ public abstract String toString(Tag[] tags); }
5,694
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstructorWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing constructor output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface ConstructorWriter { /** * Get the constructor details tree header. * * @param classDoc the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the constructor details header */ public Content getConstructorDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree); /** * Get the constructor documentation tree header. * * @param constructor the constructor being documented * @param constructorDetailsTree the content tree representing constructor details * @return content tree for the constructor documentation header */ public Content getConstructorDocTreeHeader(ConstructorDoc constructor, Content constructorDetailsTree); /** * Get the signature for the given constructor. * * @param constructor the constructor being documented * @return content tree for the constructor signature */ public Content getSignature(ConstructorDoc constructor); /** * Add the deprecated output for the given constructor. * * @param constructor the constructor being documented * @param constructorDocTree content tree to which the deprecated information will be added */ public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree); /** * Add the comments for the given constructor. * * @param constructor the constructor being documented * @param constructorDocTree the content tree to which the comments will be added */ public void addComments(ConstructorDoc constructor, Content constructorDocTree); /** * Add the tags for the given constructor. * * @param constructor the constructor being documented * @param constructorDocTree the content tree to which the tags will be added */ public void addTags(ConstructorDoc constructor, Content constructorDocTree); /** * Get the constructor details tree. * * @param memberDetailsTree the content tree representing member details * @return content tree for the constructor details */ public Content getConstructorDetails(Content memberDetailsTree); /** * Get the constructor documentation. * * @param constructorDocTree the content tree representing constructor documentation * @param isLastContent true if the content to be added is the last content * @return content tree for the constructor documentation */ public Content getConstructorDoc(Content constructorDocTree, boolean isLastContent); /** * Let the writer know whether a non public constructor was found. * * @param foundNonPubConstructor true if we found a non public constructor. */ public void setFoundNonPubConstructor(boolean foundNonPubConstructor); /** * Close the writer. */ public void close() throws IOException; }
4,547
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing method output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface MethodWriter { /** * Get the method details tree header. * * @param classDoc the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the method details header */ public Content getMethodDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree); /** * Get the method documentation tree header. * * @param method the method being documented * @param methodDetailsTree the content tree representing method details * @return content tree for the method documentation header */ public Content getMethodDocTreeHeader(MethodDoc method, Content methodDetailsTree); /** * Get the signature for the given method. * * @param method the method being documented * @return content tree for the method signature */ public Content getSignature(MethodDoc method); /** * Add the deprecated output for the given method. * * @param method the method being documented * @param methodDocTree content tree to which the deprecated information will be added */ public void addDeprecated(MethodDoc method, Content methodDocTree); /** * Add the comments for the given method. * * @param holder the holder type (not erasure) of the method * @param method the method being documented * @param methodDocTree the content tree to which the comments will be added */ public void addComments(Type holder, MethodDoc method, Content methodDocTree); /** * Add the tags for the given method. * * @param method the method being documented * @param methodDocTree the content tree to which the tags will be added */ public void addTags(MethodDoc method, Content methodDocTree); /** * Get the method details tree. * * @param methodDetailsTree the content tree representing method details * @return content tree for the method details */ public Content getMethodDetails(Content methodDetailsTree); /** * Get the method documentation. * * @param methodDocTree the content tree representing method documentation * @param isLastContent true if the content to be added is the last content * @return content tree for the method documentation */ public Content getMethodDoc(Content methodDocTree, boolean isLastContent); /** * Close the writer. */ public void close() throws IOException; }
4,120
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageSummaryWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import com.sun.javadoc.*; import java.io.*; /** * The interface for writing package summary output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface PackageSummaryWriter { /** * Return the name of the output file. * * @return the name of the output file. */ public abstract String getOutputFileName(); /** * Get the header for the summary. * * @param heading Package name. * @return the header to be added to the content tree */ public abstract Content getPackageHeader(String heading); /** * Get the header for the package content. * * @return a content tree for the package content header */ public abstract Content getContentHeader(); /** * Get the header for the package summary. * * @return a content tree with the package summary header */ public abstract Content getSummaryHeader(); /** * Adds the table of classes to the documentation tree. * * @param classes the array of classes to document. * @param label the label for this table. * @param tableSummary the summary string for the table * @param tableHeader array of table headers * @param summaryContentTree the content tree to which the summaries will be added */ public abstract void addClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader, Content summaryContentTree); /** * Adds the package description from the "packages.html" file to the documentation * tree. * * @param packageContentTree the content tree to which the package description * will be added */ public abstract void addPackageDescription(Content packageContentTree); /** * Adds the tag information from the "packages.html" file to the documentation * tree. * * @param packageContentTree the content tree to which the package tags will * be added */ public abstract void addPackageTags(Content packageContentTree); /** * Adds the footer to the documentation tree. * * @param contentTree the tree to which the footer will be added */ public abstract void addPackageFooter(Content contentTree); /** * Print the package summary document. * * @param contentTree the content tree that will be printed */ public abstract void printDocument(Content contentTree); /** * Close the writer. */ public abstract void close() throws IOException; }
4,021
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeRequiredMemberWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing annotation type required member output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface AnnotationTypeRequiredMemberWriter { /** * Add the annotation type details tree header. * * @param classDoc the annotation type being documented * @param memberDetailsTree the content tree representing member details */ public void addAnnotationDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree); /** * Get the annotation type documentation tree header. * * @param member the annotation type being documented * @param annotationDetailsTree the content tree representing annotation type details * @return content tree for the annotation type documentation header */ public Content getAnnotationDocTreeHeader(MemberDoc member, Content annotationDetailsTree); /** * Get the annotation type details tree. * * @param annotationDetailsTree the content tree representing annotation type details * @return content tree for the annotation type details */ public Content getAnnotationDetails(Content annotationDetailsTree); /** * Get the annotation type documentation. * * @param annotationDocTree the content tree representing annotation type documentation * @param isLastContent true if the content to be added is the last content * @return content tree for the annotation type documentation */ public Content getAnnotationDoc(Content annotationDocTree, boolean isLastContent); /** * Get the signature for the given member. * * @param member the member being documented * @return content tree for the annotation type signature */ public Content getSignature(MemberDoc member); /** * Add the deprecated output for the given member. * * @param member the member being documented * @param annotationDocTree content tree to which the deprecated information will be added */ public void addDeprecated(MemberDoc member, Content annotationDocTree); /** * Add the comments for the given member. * * @param member the member being documented * @param annotationDocTree the content tree to which the comments will be added */ public void addComments(MemberDoc member, Content annotationDocTree); /** * Add the tags for the given member. * * @param member the member being documented * @param annotationDocTree the content tree to which the tags will be added */ public void addTags(MemberDoc member, Content annotationDocTree); /** * Close the writer. */ public void close() throws IOException; }
4,210
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing class output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface ClassWriter { /** * Get the header of the page. * * @param header the header string to write * @return header content that needs to be added to the documentation */ public Content getHeader(String header); /** * Get the class content header. * * @return class content header that needs to be added to the documentation */ public Content getClassContentHeader(); /** * Add the class tree documentation. * * @param classContentTree class content tree to which the documentation will be added */ public void addClassTree(Content classContentTree); /** * Get the class information tree header. * * @return class informaion tree header that needs to be added to the documentation */ public Content getClassInfoTreeHeader(); /** * Add the type parameter information. * * @param classInfoTree content tree to which the documentation will be added */ public void addTypeParamInfo(Content classInfoTree); /** * Add all super interfaces if this is an interface. * * @param classInfoTree content tree to which the documentation will be added */ public void addSuperInterfacesInfo(Content classInfoTree); /** * Add all implemented interfaces if this is a class. * * @param classInfoTree content tree to which the documentation will be added */ public void addImplementedInterfacesInfo(Content classInfoTree); /** * Add all the classes that extend this one. * * @param classInfoTree content tree to which the documentation will be added */ public void addSubClassInfo(Content classInfoTree); /** * Add all the interfaces that extend this one. * * @param classInfoTree content tree to which the documentation will be added */ public void addSubInterfacesInfo(Content classInfoTree); /** * If this is an interface, add all classes that implement this * interface. * * @param classInfoTree content tree to which the documentation will be added */ public void addInterfaceUsageInfo(Content classInfoTree); /** * If this is an inner class or interface, add the enclosing class or * interface. * * @param classInfoTree content tree to which the documentation will be added */ public void addNestedClassInfo (Content classInfoTree); /** * Get the class information. * * @param classInfoTree content tree conatining the class information * @return a content tree for the class */ public Content getClassInfo(Content classInfoTree); /** * If this class is deprecated, add the appropriate information. * * @param classInfoTree content tree to which the documentation will be added */ public void addClassDeprecationInfo (Content classInfoTree); /** * Add the signature of the current class content tree. * * @param modifiers the modifiers for the signature * @param classInfoTree the class content tree to which the signature will be added */ public void addClassSignature(String modifiers, Content classInfoTree); /** * Build the class description. * * @param classInfoTree content tree to which the documentation will be added */ public void addClassDescription(Content classInfoTree); /** * Add the tag information for the current class. * * @param classInfoTree content tree to which the tag information will be added */ public void addClassTagInfo(Content classInfoTree); /** * Get the member tree header for the class. * * @return a content tree for the member tree header */ public Content getMemberTreeHeader(); /** * Add the footer of the page. * * @param contentTree content tree to which the footer will be added */ public void addFooter(Content contentTree); /** * Print the document. * * @param contentTree content tree that will be printed as a document */ public void printDocument(Content contentTree); /** * Close the writer. */ public void close() throws IOException; /** * Return the classDoc being documented. * * @return the classDoc being documented. */ public ClassDoc getClassDoc(); /** * Get the member summary tree. * * @param memberTree the content tree used to build the summary tree * @return a content tree for the member summary */ public Content getMemberSummaryTree(Content memberTree); /** * Get the member details tree. * * @param memberTree the content tree used to build the details tree * @return a content tree for the member details */ public Content getMemberDetailsTree(Content memberTree); }
6,472
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantsSummaryWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.util.*; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing constants summary output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface ConstantsSummaryWriter { /** * Close the writer. */ public abstract void close() throws IOException; /** * Get the header for the constant summary documentation. * * @return header that needs to be added to the documentation */ public abstract Content getHeader(); /** * Get the header for the constant content list. * * @return content header that needs to be added to the documentation */ public abstract Content getContentsHeader(); /** * Adds the given package name link to the constant content list tree. * * @param pkg the {@link PackageDoc} to index. * @param parsedPackageName the parsed package name. We only Write the * first 2 directory levels of the package * name. For example, java.lang.ref would be * indexed as java.lang.*. * @param WriteedPackageHeaders the set of package headers that have already * been indexed. We don't want to index * something more than once. * @param contentListTree the content tree to which the link will be added */ public abstract void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> WriteedPackageHeaders, Content contentListTree); /** * Get the content list to be added to the documentation tree. * * @param contentListTree the content that will be added to the list * @return content list that will be added to the documentation tree */ public abstract Content getContentsList(Content contentListTree); /** * Get the constant summaries for the document. * * @return constant summaries header to be added to the documentation tree */ public abstract Content getConstantSummaries(); /** * Adds the given package name. * * @param pkg the {@link PackageDoc} to index. * @param parsedPackageName the parsed package name. We only Write the * first 2 directory levels of the package * name. For example, java.lang.ref would be * indexed as java.lang.*. * @param summariesTree the documentation tree to which the package name will * be written */ public abstract void addPackageName(PackageDoc pkg, String parsedPackageName, Content summariesTree); /** * Get the class summary header for the constants summary. * * @return the header content for the class constants summary */ public abstract Content getClassConstantHeader(); /** * Adds the constant member table to the documentation tree. * * @param cd the class whose constants are being documented. * @param fields the constants being documented. * @param classConstantTree the documentation tree to which theconstant member * table content will be added */ public abstract void addConstantMembers(ClassDoc cd, List<FieldDoc> fields, Content classConstantTree); /** * Adds the footer for the summary documentation. * * @param contentTree content tree to which the footer will be added */ public abstract void addFooter(Content contentTree); /** * Print the constants summary document. * * @param contentTree content tree which should be printed */ public abstract void printDocument(Content contentTree); }
5,246
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WriterFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java
/* * Copyright (c) 2003, 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; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * The interface for a factory creates writers. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public interface WriterFactory { /** * Return the writer for the constant summary. * * @return the writer for the constant summary. Return null if this * writer is not supported by the doclet. */ public abstract ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception; /** * Return the writer for the package summary. * * @param packageDoc the package being documented. * @param prevPkg the previous package that was documented. * @param nextPkg the next package being documented. * @return the writer for the package summary. Return null if this * writer is not supported by the doclet. */ public abstract PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc, PackageDoc prevPkg, PackageDoc nextPkg) throws Exception; /** * Return the writer for a 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 abstract ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) throws Exception; /** * Return the writer for an annotation type. * * @param annotationType the 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 abstract AnnotationTypeWriter getAnnotationTypeWriter( AnnotationTypeDoc annotationType, Type prevType, Type nextType) throws Exception; /** * Return the method writer for a given class. * * @param classWriter the writer for the class being documented. * @return the method writer for the give class. Return null if this * writer is not supported by the doclet. */ public abstract MethodWriter getMethodWriter(ClassWriter classWriter) throws Exception; /** * Return the annotation type optional member writer for a given annotation * type. * * @param annotationTypeWriter the writer for the annotation type * being documented. * @return the member writer for the given annotation type. Return null if * this writer is not supported by the doclet. */ public abstract AnnotationTypeOptionalMemberWriter getAnnotationTypeOptionalMemberWriter( AnnotationTypeWriter annotationTypeWriter) throws Exception; /** * Return the annotation type required member writer for a given annotation type. * * @param annotationTypeWriter the writer for the annotation type * being documented. * @return the member writer for the given annotation type. Return null if * this writer is not supported by the doclet. */ public abstract AnnotationTypeRequiredMemberWriter getAnnotationTypeRequiredMemberWriter( AnnotationTypeWriter annotationTypeWriter) throws Exception; /** * Return the enum constant writer for a given class. * * @param classWriter the writer for the class being documented. * @return the enum constant writer for the give class. Return null if this * writer is not supported by the doclet. */ public abstract EnumConstantWriter getEnumConstantWriter( ClassWriter classWriter) throws Exception; /** * Return the field writer for a given class. * * @param classWriter the writer for the class being documented. * @return the field writer for the give class. Return null if this * writer is not supported by the doclet. */ public abstract FieldWriter getFieldWriter(ClassWriter classWriter) throws Exception; /** * Return the constructor writer for a given class. * * @param classWriter the writer for the class being documented. * @return the method writer for the give class. Return null if this * writer is not supported by the doclet. */ public abstract ConstructorWriter getConstructorWriter( ClassWriter classWriter) throws Exception; /** * Return the specified member summary writer for a given class. * * @param classWriter the writer for the class being documented. * @param memberType the {@link VisibleMemberMap} member type indicating * the type of member summary that should be returned. * @return the summary writer for the give class. Return null if this * writer is not supported by the doclet. * * @see VisibleMemberMap * @throws IllegalArgumentException if memberType is unknown. */ public abstract MemberSummaryWriter getMemberSummaryWriter( ClassWriter classWriter, int memberType) throws Exception; /** * Return the specified member summary writer for a given annotation type. * * @param annotationTypeWriter the writer for the annotation type being * documented. * @param memberType the {@link VisibleMemberMap} member type indicating * the type of member summary that should be returned. * @return the summary writer for the give class. Return null if this * writer is not supported by the doclet. * * @see VisibleMemberMap * @throws IllegalArgumentException if memberType is unknown. */ public abstract MemberSummaryWriter getMemberSummaryWriter( AnnotationTypeWriter annotationTypeWriter, int memberType) throws Exception; /** * Return the writer for the serialized form. * * @return the writer for the serialized form. */ public SerializedFormWriter getSerializedFormWriter() throws Exception; }
7,681
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AbstractDoclet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
/* * Copyright (c) 2003, 2008, 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; import com.sun.tools.doclets.internal.toolkit.builders.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; import java.util.*; import java.io.*; /** * An abstract implementation of a Doclet. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API. * * @author Jamie Ho */ public abstract class AbstractDoclet { /** * The global configuration information for this run. */ public Configuration configuration; /** * The only doclet that may use this toolkit is {@value} */ private static final String TOOLKIT_DOCLET_NAME = new com.sun.tools.doclets.formats.html.HtmlDoclet().getClass().getName(); /** * Verify that the only doclet that is using this toolkit is * {@value #TOOLKIT_DOCLET_NAME}. */ private boolean isValidDoclet(AbstractDoclet doclet) { if (! doclet.getClass().getName().equals(TOOLKIT_DOCLET_NAME)) { configuration.message.error("doclet.Toolkit_Usage_Violation", TOOLKIT_DOCLET_NAME); return false; } return true; } /** * The method that starts the execution of the doclet. * * @param doclet the doclet to start the execution for. * @param root the {@link RootDoc} that points to the source to document. * @return true if the doclet executed without error. False otherwise. */ public boolean start(AbstractDoclet doclet, RootDoc root) { configuration = configuration(); configuration.root = root; if (! isValidDoclet(doclet)) { return false; } try { doclet.startGeneration(root); } catch (Exception exc) { exc.printStackTrace(); return false; } return true; } /** * Indicate that this doclet supports the 1.5 language features. * @return JAVA_1_5, indicating that the new features are supported. */ public static LanguageVersion languageVersion() { return LanguageVersion.JAVA_1_5; } /** * Create the configuration instance and returns it. * @return the configuration of the doclet. */ public abstract Configuration configuration(); /** * Start the generation of files. Call generate methods in the individual * writers, which will in turn genrate the documentation files. Call the * TreeWriter generation first to ensure the Class Hierarchy is built * first and then can be used in the later generation. * * @see com.sun.javadoc.RootDoc */ private void startGeneration(RootDoc root) throws Exception { if (root.classes().length == 0) { configuration.message. error("doclet.No_Public_Classes_To_Document"); return; } configuration.setOptions(); configuration.getDocletSpecificMsg().notice("doclet.build_version", configuration.getDocletSpecificBuildDate()); ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated); generateClassFiles(root, classtree); if (configuration.sourcepath != null && configuration.sourcepath.length() > 0) { StringTokenizer pathTokens = new StringTokenizer(configuration.sourcepath, String.valueOf(File.pathSeparatorChar)); boolean first = true; while(pathTokens.hasMoreTokens()){ Util.copyDocFiles(configuration, pathTokens.nextToken() + File.separator, DocletConstants.DOC_FILES_DIR_NAME, first); first = false; } } PackageListWriter.generate(configuration); generatePackageFiles(classtree); generateOtherFiles(root, classtree); configuration.tagletManager.printReport(); } /** * Generate additional documentation that is added to the API documentation. * * @param root the RootDoc of source to document. * @param classtree the data structure representing the class tree. */ protected void generateOtherFiles(RootDoc root, ClassTree classtree) throws Exception { BuilderFactory builderFactory = configuration.getBuilderFactory(); AbstractBuilder constantsSummaryBuilder = builderFactory.getConstantsSummaryBuider(); constantsSummaryBuilder.build(); AbstractBuilder serializedFormBuilder = builderFactory.getSerializedFormBuilder(); serializedFormBuilder.build(); } /** * Generate the package documentation. * * @param classtree the data structure representing the class tree. */ protected abstract void generatePackageFiles(ClassTree classtree) throws Exception; /** * Generate the class documentation. * * @param classtree the data structure representing the class tree. */ protected abstract void generateClassFiles(ClassDoc[] arr, ClassTree classtree); /** * Iterate through all classes and construct documentation for them. * * @param root the RootDoc of source to document. * @param classtree the data structure representing the class tree. */ protected void generateClassFiles(RootDoc root, ClassTree classtree) { generateClassFiles(classtree); PackageDoc[] packages = root.specifiedPackages(); for (int i = 0; i < packages.length; i++) { generateClassFiles(packages[i].allClasses(), classtree); } } /** * Generate the class files for single classes specified on the command line. * * @param classtree the data structure representing the class tree. */ private void generateClassFiles(ClassTree classtree) { String[] packageNames = configuration.classDocCatalog.packageNames(); for (int packageNameIndex = 0; packageNameIndex < packageNames.length; packageNameIndex++) { generateClassFiles(configuration.classDocCatalog.allClasses( packageNames[packageNameIndex]), classtree); } } }
7,433
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FieldWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing field output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface FieldWriter { /** * Get the field details tree header. * * @param classDoc the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the field details header */ public Content getFieldDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree); /** * Get the field documentation tree header. * * @param field the constructor being documented * @param fieldDetailsTree the content tree representing field details * @return content tree for the field documentation header */ public Content getFieldDocTreeHeader(FieldDoc field, Content fieldDetailsTree); /** * Get the signature for the given field. * * @param field the field being documented * @return content tree for the field signature */ public Content getSignature(FieldDoc field); /** * Add the deprecated output for the given field. * * @param field the field being documented * @param fieldDocTree content tree to which the deprecated information will be added */ public void addDeprecated(FieldDoc field, Content fieldDocTree); /** * Add the comments for the given field. * * @param field the field being documented * @param fieldDocTree the content tree to which the comments will be added */ public void addComments(FieldDoc field, Content fieldDocTree); /** * Add the tags for the given field. * * @param field the field being documented * @param fieldDocTree the content tree to which the tags will be added */ public void addTags(FieldDoc field, Content fieldDocTree); /** * Get the field details tree. * * @param memberDetailsTree the content tree representing member details * @return content tree for the field details */ public Content getFieldDetails(Content memberDetailsTree); /** * Get the field documentation. * * @param fieldDocTree the content tree representing field documentation * @param isLastContent true if the content to be added is the last content * @return content tree for the field documentation */ public Content getFieldDoc(Content fieldDocTree, boolean isLastContent); /** * Close the writer. */ public void close() throws IOException; }
3,997
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Configuration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
/* * Copyright (c) 1997, 2011, 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; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; import com.sun.javadoc.*; import java.util.*; import java.io.*; /** * Configure the output based on the options. Doclets should sub-class * Configuration, to configure and add their own options. This class contains * all user options which are supported by the 1.1 doclet and the standard * doclet. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Robert Field. * @author Atul Dambalkar. * @author Jamie Ho */ public abstract class Configuration { /** * The factory for builders. */ protected BuilderFactory builderFactory; /** * The taglet manager. */ public TagletManager tagletManager; /** * The path to the builder XML input file. */ public String builderXMLPath; /** * The default path to the builder XML. */ private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; /** * The path to Taglets */ public String tagletpath = ""; /** * This is true if option "-serialwarn" is used. Defualt value is false to * supress excessive warnings about serial tag. */ public boolean serialwarn = false; /** * The specified amount of space between tab stops. */ public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; /** * True if we should generate browsable sources. */ public boolean linksource = false; /** * True if command line option "-nosince" is used. Default value is * false. */ public boolean nosince = false; /** * True if we should recursively copy the doc-file subdirectories */ public boolean copydocfilesubdirs = false; /** * The META charset tag used for cross-platform viewing. */ public String charset = ""; /** * True if user wants to add member names as meta keywords. * Set to false because meta keywords are ignored in general * by most Internet search engines. */ public boolean keywords = false; /** * The meta tag keywords instance. */ public final MetaKeywords metakeywords = new MetaKeywords(this); /** * The list of doc-file subdirectories to exclude */ protected Set<String> excludedDocFileDirs; /** * The list of qualifiers to exclude */ protected Set<String> excludedQualifiers; /** * The Root of the generated Program Structure from the Doclet API. */ public RootDoc root; /** * Destination directory name, in which doclet will generate the entire * documentation. Default is current directory. */ public String destDirName = ""; /** * Destination directory name, in which doclet will copy the doc-files to. */ public String docFileDestDirName = ""; /** * Encoding for this document. Default is default encoding for this * platform. */ public String docencoding = null; /** * True if user wants to suppress descriptions and tags. */ public boolean nocomment = false; /** * Encoding for this document. Default is default encoding for this * platform. */ public String encoding = null; /** * Generate author specific information for all the classes if @author * tag is used in the doc comment and if -author option is used. * <code>showauthor</code> is set to true if -author option is used. * Default is don't show author information. */ public boolean showauthor = false; /** * Generate version specific information for the all the classes * if @version tag is used in the doc comment and if -version option is * used. <code>showversion</code> is set to true if -version option is * used.Default is don't show version information. */ public boolean showversion = false; /** * Sourcepath from where to read the source files. Default is classpath. * */ public String sourcepath = ""; /** * Don't generate deprecated API information at all, if -nodeprecated * option is used. <code>nodepracted</code> is set to true if * -nodeprecated option is used. Default is generate deprected API * information. */ public boolean nodeprecated = false; /** * The catalog of classes specified on the command-line */ public ClassDocCatalog classDocCatalog; /** * Message Retriever for the doclet, to retrieve message from the resource * file for this Configuration, which is common for 1.1 and standard * doclets. * * TODO: Make this private!!! */ public MessageRetriever message = null; /** * True if user wants to suppress time stamp in output. * Default is false. */ public boolean notimestamp= false; /** * The package grouping instance. */ public final Group group = new Group(this); /** * The tracker of external package links. */ public final Extern extern = new Extern(this); /** * Return the build date for the doclet. */ public abstract String getDocletSpecificBuildDate(); /** * This method should be defined in all those doclets(configurations), * which want to derive themselves from this Configuration. This method * can be used to set its own command line options. * * @param options The array of option names and values. * @throws DocletAbortException */ public abstract void setSpecificDocletOptions(String[][] options); /** * Return the doclet specific {@link MessageRetriever} * @return the doclet specific MessageRetriever. */ public abstract MessageRetriever getDocletSpecificMsg(); /** * An array of the packages specified on the command-line merged * with the array of packages that contain the classes specified on the * command-line. The array is sorted. */ public PackageDoc[] packages; /** * Constructor. Constructs the message retriever with resource file. */ public Configuration() { message = new MessageRetriever(this, "com.sun.tools.doclets.internal.toolkit.resources.doclets"); excludedDocFileDirs = new HashSet<String>(); excludedQualifiers = new HashSet<String>(); } /** * Return the builder factory for this doclet. * * @return the builder factory for this doclet. */ public BuilderFactory getBuilderFactory() { if (builderFactory == null) { builderFactory = new BuilderFactory(this); } return builderFactory; } /** * This method should be defined in all those doclets * which want to inherit from this Configuration. This method * should return the number of arguments to the command line * option (including the option name). For example, * -notimestamp is a single-argument option, so this method would * return 1. * * @param option Command line option under consideration. * @return number of arguments to option (including the * option name). Zero return means option not known. * Negative value means error occurred. */ public int optionLength(String option) { option = option.toLowerCase(); if (option.equals("-author") || option.equals("-docfilessubdirs") || option.equals("-keywords") || option.equals("-linksource") || option.equals("-nocomment") || option.equals("-nodeprecated") || option.equals("-nosince") || option.equals("-notimestamp") || option.equals("-quiet") || option.equals("-xnodate") || option.equals("-version")) { return 1; } else if (option.equals("-d") || option.equals("-docencoding") || option.equals("-encoding") || option.equals("-excludedocfilessubdir") || option.equals("-link") || option.equals("-sourcetab") || option.equals("-noqualifier") || option.equals("-output") || option.equals("-sourcepath") || option.equals("-tag") || option.equals("-taglet") || option.equals("-tagletpath")) { return 2; } else if (option.equals("-group") || option.equals("-linkoffline")) { return 3; } else { return -1; // indicate we don't know about it } } /** * Perform error checking on the given options. * * @param options the given options to check. * @param reporter the reporter used to report errors. */ public abstract boolean validOptions(String options[][], DocErrorReporter reporter); private void initPackageArray() { Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages())); ClassDoc[] classes = root.specifiedClasses(); for (int i = 0; i < classes.length; i++) { set.add(classes[i].containingPackage()); } ArrayList<PackageDoc> results = new ArrayList<PackageDoc>(set); Collections.sort(results); packages = results.toArray(new PackageDoc[] {}); } /** * Set the command line options supported by this configuration. * * @param options the two dimensional array of options. */ public void setOptions(String[][] options) { LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>(); for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-d")) { destDirName = addTrailingFileSep(os[1]); docFileDestDirName = destDirName; } else if (opt.equals("-docfilessubdirs")) { copydocfilesubdirs = true; } else if (opt.equals("-docencoding")) { docencoding = os[1]; } else if (opt.equals("-encoding")) { encoding = os[1]; } else if (opt.equals("-author")) { showauthor = true; } else if (opt.equals("-version")) { showversion = true; } else if (opt.equals("-nodeprecated")) { nodeprecated = true; } else if (opt.equals("-sourcepath")) { sourcepath = os[1]; } else if (opt.equals("-classpath") && sourcepath.length() == 0) { sourcepath = os[1]; } else if (opt.equals("-excludedocfilessubdir")) { addToSet(excludedDocFileDirs, os[1]); } else if (opt.equals("-noqualifier")) { addToSet(excludedQualifiers, os[1]); } else if (opt.equals("-linksource")) { linksource = true; } else if (opt.equals("-sourcetab")) { linksource = true; try { sourcetab = Integer.parseInt(os[1]); } catch (NumberFormatException e) { //Set to -1 so that warning will be printed //to indicate what is valid argument. sourcetab = -1; } if (sourcetab <= 0) { message.warning("doclet.sourcetab_warning"); sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; } } else if (opt.equals("-notimestamp")) { notimestamp = true; } else if (opt.equals("-nocomment")) { nocomment = true; } else if (opt.equals("-tag") || opt.equals("-taglet")) { customTagStrs.add(os); } else if (opt.equals("-tagletpath")) { tagletpath = os[1]; } else if (opt.equals("-keywords")) { keywords = true; } else if (opt.equals("-serialwarn")) { serialwarn = true; } else if (opt.equals("-group")) { group.checkPackageGroups(os[1], os[2]); } else if (opt.equals("-link")) { String url = os[1]; extern.url(url, url, root, false); } else if (opt.equals("-linkoffline")) { String url = os[1]; String pkglisturl = os[2]; extern.url(url, pkglisturl, root, true); } } if (sourcepath.length() == 0) { sourcepath = System.getProperty("env.class.path") == null ? "" : System.getProperty("env.class.path"); } if (docencoding == null) { docencoding = encoding; } classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this); initTagletManager(customTagStrs); } /** * Set the command line options supported by this configuration. * * @throws DocletAbortException */ public void setOptions() { initPackageArray(); setOptions(root.options()); setSpecificDocletOptions(root.options()); } /** * Initialize the taglet manager. The strings to initialize the simple custom tags should * be in the following format: "[tag name]:[location str]:[heading]". * @param customTagStrs the set two dimentional arrays of strings. These arrays contain * either -tag or -taglet arguments. */ private void initTagletManager(Set<String[]> customTagStrs) { tagletManager = tagletManager == null ? new TagletManager(nosince, showversion, showauthor, message) : tagletManager; String[] args; for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) { args = it.next(); if (args[0].equals("-taglet")) { tagletManager.addCustomTag(args[1], tagletpath); continue; } String[] tokens = Util.tokenize(args[1], TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3); if (tokens.length == 1) { String tagName = args[1]; if (tagletManager.isKnownCustomTag(tagName)) { //reorder a standard tag tagletManager.addNewSimpleCustomTag(tagName, null, ""); } else { //Create a simple tag with the heading that has the same name as the tag. StringBuffer heading = new StringBuffer(tagName + ":"); heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0))); tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a"); } } else if (tokens.length == 2) { //Add simple taglet without heading, probably to excluding it in the output. tagletManager.addNewSimpleCustomTag(tokens[0], tokens[1], ""); } else if (tokens.length >= 3) { tagletManager.addNewSimpleCustomTag(tokens[0], tokens[2], tokens[1]); } else { message.error("doclet.Error_invalid_custom_tag_argument", args[1]); } } } private void addToSet(Set<String> s, String str){ StringTokenizer st = new StringTokenizer(str, ":"); String current; while(st.hasMoreTokens()){ current = st.nextToken(); s.add(current); } } /** * Add a traliling file separator, if not found or strip off extra trailing * file separators if any. * * @param path Path under consideration. * @return String Properly constructed path string. */ String addTrailingFileSep(String path) { String fs = System.getProperty("file.separator"); String dblfs = fs + fs; int indexDblfs; while ((indexDblfs = path.indexOf(dblfs)) >= 0) { path = path.substring(0, indexDblfs) + path.substring(indexDblfs + fs.length()); } if (!path.endsWith(fs)) path += fs; return path; } /** * This checks for the validity of the options used by the user. * This works exactly like * {@link com.sun.javadoc.Doclet#validOptions(String[][], * DocErrorReporter)}. This will validate the options which are shared * by our doclets. For example, this method will flag an error using * the DocErrorReporter if user has used "-nohelp" and "-helpfile" option * together. * * @param options options used on the command line. * @param reporter used to report errors. * @return true if all the options are valid. */ public boolean generalValidOptions(String options[][], DocErrorReporter reporter) { boolean docencodingfound = false; String encoding = ""; for (int oi = 0; oi < options.length; oi++) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-d")) { String destdirname = addTrailingFileSep(os[1]); File destDir = new File(destdirname); if (!destDir.exists()) { //Create the output directory (in case it doesn't exist yet) reporter.printNotice(getText("doclet.dest_dir_create", destdirname)); (new File(destdirname)).mkdirs(); } else if (!destDir.isDirectory()) { reporter.printError(getText( "doclet.destination_directory_not_directory_0", destDir.getPath())); return false; } else if (!destDir.canWrite()) { reporter.printError(getText( "doclet.destination_directory_not_writable_0", destDir.getPath())); return false; } } else if (opt.equals("-docencoding")) { docencodingfound = true; if (!checkOutputFileEncoding(os[1], reporter)) { return false; } } else if (opt.equals("-encoding")) { encoding = os[1]; } } if (!docencodingfound && encoding.length() > 0) { if (!checkOutputFileEncoding(encoding, reporter)) { return false; } } return true; } /** * Check the validity of the given Source or Output File encoding on this * platform. * * @param docencoding output file encoding. * @param reporter used to report errors. */ private boolean checkOutputFileEncoding(String docencoding, DocErrorReporter reporter) { OutputStream ost= new ByteArrayOutputStream(); OutputStreamWriter osw = null; try { osw = new OutputStreamWriter(ost, docencoding); } catch (UnsupportedEncodingException exc) { reporter.printError(getText("doclet.Encoding_not_supported", docencoding)); return false; } finally { try { if (osw != null) { osw.close(); } } catch (IOException exc) { } } return true; } /** * Return true if the given doc-file subdirectory should be excluded and * false otherwise. * @param docfilesubdir the doc-files subdirectory to check. */ public boolean shouldExcludeDocFileDir(String docfilesubdir){ if (excludedDocFileDirs.contains(docfilesubdir)) { return true; } else { return false; } } /** * Return true if the given qualifier should be excluded and false otherwise. * @param qualifier the qualifier to check. */ public boolean shouldExcludeQualifier(String qualifier){ if (excludedQualifiers.contains("all") || excludedQualifiers.contains(qualifier) || excludedQualifiers.contains(qualifier + ".*")) { return true; } else { int index = -1; while ((index = qualifier.indexOf(".", index + 1)) != -1) { if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) { return true; } } return false; } } /** * Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded. Otherwise, * return the unqualified <code>ClassDoc</code> name. * @param cd the <code>ClassDoc</code> to check. */ public String getClassName(ClassDoc cd) { PackageDoc pd = cd.containingPackage(); if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) { return cd.name(); } else { return cd.qualifiedName(); } } public String getText(String key) { try { //Check the doclet specific properties file. return getDocletSpecificMsg().getText(key); } catch (Exception e) { //Check the shared properties file. return message.getText(key); } } public String getText(String key, String a1) { try { //Check the doclet specific properties file. return getDocletSpecificMsg().getText(key, a1); } catch (Exception e) { //Check the shared properties file. return message.getText(key, a1); } } public String getText(String key, String a1, String a2) { try { //Check the doclet specific properties file. return getDocletSpecificMsg().getText(key, a1, a2); } catch (Exception e) { //Check the shared properties file. return message.getText(key, a1, a2); } } public String getText(String key, String a1, String a2, String a3) { try { //Check the doclet specific properties file. return getDocletSpecificMsg().getText(key, a1, a2, a3); } catch (Exception e) { //Check the shared properties file. return message.getText(key, a1, a2, a3); } } /** * Return true if the ClassDoc element is getting documented, depending upon * -nodeprecated option and the deprecation information. Return true if * -nodeprecated is not used. Return false if -nodeprecated is used and if * either ClassDoc element is deprecated or the containing package is deprecated. * * @param cd the ClassDoc for which the page generation is checked */ public boolean isGeneratedDoc(ClassDoc cd) { if (!nodeprecated) { return true; } return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage())); } /** * Return the doclet specific instance of a writer factory. * @return the {@link WriterFactory} for the doclet. */ public abstract WriterFactory getWriterFactory(); /** * Return the input stream to the builder XML. * * @return the input steam to the builder XML. * @throws FileNotFoundException when the given XML file cannot be found. */ public InputStream getBuilderXML() throws FileNotFoundException { return builderXMLPath == null ? Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : new FileInputStream(new File(builderXMLPath)); } /** * Return the Locale for this document. */ public abstract Locale getLocale(); /** * Return the comparator that will be used to sort member documentation. * To no do any sorting, return null. * * @return the {@link java.util.Comparator} used to sort members. */ public abstract Comparator<ProgramElementDoc> getMemberComparator(); }
25,644
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
NestedClassWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; /** * The interface for writing class output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface NestedClassWriter { /** * Close the writer. */ public void close() throws IOException; }
1,649
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing annotation type output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API. * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface AnnotationTypeWriter { /** * Get the header of the page. * * @param header the header string to write * @return a content tree for the header documentation */ public Content getHeader(String header); /** * Get the annotation content header. * * @return annotation content header that needs to be added to the documentation */ public Content getAnnotationContentHeader(); /** * Get the annotation information tree header. * * @return annotation information tree header that needs to be added to the documentation */ public Content getAnnotationInfoTreeHeader(); /** * Get the annotation information. * * @param annotationInfoTree content tree containing the annotation information * @return a content tree for the annotation */ public Content getAnnotationInfo(Content annotationInfoTree); /** * Add the signature of the current annotation type. * * @param modifiers the modifiers for the signature * @param annotationInfoTree the annotation content tree to which the signature will be added */ public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree); /** * Build the annotation type description. * * @param annotationInfoTree content tree to which the description will be added */ public void addAnnotationTypeDescription(Content annotationInfoTree); /** * Add the tag information for the current annotation type. * * @param annotationInfoTree content tree to which the tag information will be added */ public void addAnnotationTypeTagInfo(Content annotationInfoTree); /** * If this annotation is deprecated, add the appropriate information. * * @param annotationInfoTree content tree to which the deprecated information will be added */ public void addAnnotationTypeDeprecationInfo (Content annotationInfoTree); /** * Add the annotation type details marker. * * @param memberDetails the content tree representing member details marker */ public void addAnnotationDetailsMarker(Content memberDetails); /** * Get the member tree header for the annotation type. * * @return a content tree for the member tree header */ public Content getMemberTreeHeader(); /** * Get the member tree. * * @param memberTree the content tree that will be modified and returned * @return a content tree for the member */ public Content getMemberTree(Content memberTree); /** * Get the member summary tree. * * @param memberTree the content tree that will be used to build the summary tree * @return a content tree for the member summary */ public Content getMemberSummaryTree(Content memberTree); /** * Get the member details tree. * * @param memberTree the content tree that will be used to build the details tree * @return a content tree for the member details */ public Content getMemberDetailsTree(Content memberTree); /** * Add the footer of the page. * * @param contentTree content tree to which the footer will be added */ public void addFooter(Content contentTree); /** * Print the document. * * @param contentTree content tree that will be printed as a document */ public void printDocument(Content contentTree); /** * Close the writer. */ public void close() throws IOException; /** * Return the {@link AnnotationTypeDoc} being documented. * * @return the AnnotationTypeDoc being documented. */ public AnnotationTypeDoc getAnnotationTypeDoc(); }
5,355
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumConstantWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing enum constant output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface EnumConstantWriter { /** * Get the enum constants details tree header. * * @param classDoc the class being documented * @param memberDetailsTree the content tree representing member details * @return content tree for the enum constants details header */ public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree); /** * Get the enum constants documentation tree header. * * @param enumConstant the enum constant being documented * @param enumConstantDetailsTree the content tree representing enum constant details * @return content tree for the enum constant documentation header */ public Content getEnumConstantsTreeHeader(FieldDoc enumConstant, Content enumConstantsDetailsTree); /** * Get the signature for the given enum constant. * * @param enumConstant the enum constant being documented * @return content tree for the enum constant signature */ public Content getSignature(FieldDoc enumConstant); /** * Add the deprecated output for the given enum constant. * * @param enumConstant the enum constant being documented * @param enumConstantsTree content tree to which the deprecated information will be added */ public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree); /** * Add the comments for the given enum constant. * * @param enumConstant the enum constant being documented * @param enumConstantsTree the content tree to which the comments will be added */ public void addComments(FieldDoc enumConstant, Content enumConstantsTree); /** * Add the tags for the given enum constant. * * @param enumConstant the enum constant being documented * @param enumConstantsTree the content tree to which the tags will be added */ public void addTags(FieldDoc enumConstant, Content enumConstantsTree); /** * Get the enum constants details tree. * * @param memberDetailsTree the content tree representing member details * @return content tree for the enum constant details */ public Content getEnumConstantsDetails(Content memberDetailsTree); /** * Get the enum constants documentation. * * @param enumConstantsTree the content tree representing enum constants documentation * @param isLastContent true if the content to be added is the last content * @return content tree for the enum constants documentation */ public Content getEnumConstants(Content enumConstantsTree, boolean isLastContent); /** * Close the writer. */ public void close() throws IOException; }
4,324
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeOptionalMemberWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import com.sun.javadoc.*; /** * The interface for writing annotation type optional member output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface AnnotationTypeOptionalMemberWriter extends AnnotationTypeRequiredMemberWriter { /** * Add the the default value documentation. * * @param member the member being documented * @param annotationDocTree content tree to which the default value will be added */ public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree); }
1,954
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SerializedFormWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import com.sun.javadoc.*; /** * The interface for writing serialized form output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.5 */ public interface SerializedFormWriter { /** * Get the header. * * @param header the header to write. * @return the header content tree */ public Content getHeader(String header); /** * Get the serialized form summaries header. * * @return the serialized form summary header tree */ public Content getSerializedSummariesHeader(); /** * Get the package serialized form header. * * @return the package serialized form header tree */ public Content getPackageSerializedHeader(); /** * Get the given package header. * * @param packageName the package header to write * @return a content tree for the package header */ public Content getPackageHeader(String packageName); /** * Get the serialized class header. * * @return a content tree for the serialized class header */ public Content getClassSerializedHeader(); /** * Get the heading for the serializable class. * * @param classDoc the class being processed * @return a content tree for the class heading */ public Content getClassHeader(ClassDoc classDoc); /** * Get the serial UID info header. * * @return a content tree for the serial uid info header */ public Content getSerialUIDInfoHeader(); /** * Adds the serial UID info. * * @param header the header that will show up before the UID. * @param serialUID the serial UID to print. * @param serialUidTree the serial UID tree to which the content will be added. */ public void addSerialUIDInfo(String header, String serialUID, Content serialUidTree); /** * Get the class serialize content header. * * @return a content tree for the class serialize content header */ public Content getClassContentHeader(); /** * Return an instance of a SerialFieldWriter. * * @return an instance of a SerialFieldWriter. */ public SerialFieldWriter getSerialFieldWriter(ClassDoc classDoc); /** * Return an instance of a SerialMethodWriter. * * @return an instance of a SerialMethodWriter. */ public SerialMethodWriter getSerialMethodWriter(ClassDoc classDoc); /** * Close the writer. */ public abstract void close() throws IOException; /** * Get the serialized content. * * @param serializedTreeContent content for serialized data * @return a content tree for serialized information */ public Content getSerializedContent(Content serializedTreeContent); /** * Add the footer. * * @param serializedTree the serialized tree to be added */ public void addFooter(Content serializedTree); /** * Print the serialized form document. * * @param serializedTree the content tree that will be printed */ public abstract void printDocument(Content serializedTree); /** * Write the serialized form for a given field. */ public interface SerialFieldWriter { /** * Get the serializable field header. * * @return serialized fields header content tree */ public Content getSerializableFieldsHeader(); /** * Get the field content header. * * @param isLastContent true if this is the last content to be documented * @return fields header content tree */ public Content getFieldsContentHeader(boolean isLastContent); /** * Get the fields content. * * @param heading the heading to write. * @param contentTree content tree to which the heading will be added * @return serializable fields content tree */ public Content getSerializableFields(String heading, Content contentTree); /** * Adds the deprecated information for this member. * * @param field the field to document. * @param contentTree content tree to which the deprecated information will be added */ public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree); /** * Adds the description text for this member. * * @param field the field to document. * @param contentTree content tree to which the member description will be added */ public void addMemberDescription(FieldDoc field, Content contentTree); /** * Adds the description text for this member represented by the tag. * * @param serialFieldTag the field to document (represented by tag). * @param contentTree content tree to which the member description will be added */ public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree); /** * Adds the tag information for this member. * * @param field the field to document. * @param contentTree content tree to which the member tags will be added */ public void addMemberTags(FieldDoc field, Content contentTree); /** * Adds the member header. * * @param fieldType the type of the field. * @param fieldTypeStr the type of the field in string format. We will * print this out if we can't link to the type. * @param fieldDimensions the dimensions of the field. * @param fieldName the name of the field. * @param contentTree content tree to which the member header will be added */ public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr, String fieldDimensions, String fieldName, Content contentTree); /** * Check to see if overview details should be printed. If * nocomment option set or if there is no text to be printed * for deprecation info, inline comment or tags, * do not print overview details. * * @param field the field to check overview details for. * @return true if overview details need to be printed */ public boolean shouldPrintOverview(FieldDoc field); } /** * Write the serialized form for a given field. */ public interface SerialMethodWriter { /** * Get the serializable method header. * * @return serializable methods content tree */ public Content getSerializableMethodsHeader(); /** * Get the method content header. * * @param isLastContent true if this is the last content to be documented * @return methods content tree */ public Content getMethodsContentHeader(boolean isLastContent); /** * Write the given heading. * * @param heading the heading to write * @param serializableMethodTree content tree which will be added * @return serializable methods content tree */ public Content getSerializableMethods(String heading, Content serializableMethodTree); /** * Write a warning that no serializable methods exist. * * @param msg the warning to print * @return no customization message tree */ public Content getNoCustomizationMsg(String msg); /** * Adds the header. * * @param member the member to write the header for * @param methodsContentTree content tree to which the header will be added */ public void addMemberHeader(MethodDoc member, Content methodsContentTree); /** * Adds the deprecated information for this member. * * @param member the member to write the deprecated information for * @param methodsContentTree content tree to which the deprecated * information will be added */ public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree); /** * Adds the description for this member. * * @param member the member to write the information for * @param methodsContentTree content tree to which the member * information will be added */ public void addMemberDescription(MethodDoc member, Content methodsContentTree); /** * Adds the tag information for this member. * * @param member the member to write the tags information for * @param methodsContentTree content tree to which the tags * information will be added */ public void addMemberTags(MethodDoc member, Content methodsContentTree); } }
10,324
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MemberSummaryWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit; import java.io.*; import java.util.*; import com.sun.javadoc.*; /** * The interface for writing member summary output. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public interface MemberSummaryWriter { /** * Get the member summary header for the given class. * * @param classDoc the class the summary belongs to * @param memberSummaryTree the content tree to which the member summary will be added * @return a content tree for the member summary header */ public Content getMemberSummaryHeader(ClassDoc classDoc, Content memberSummaryTree); /** * Get the summary table for the given class. * * @param classDoc the class the summary table belongs to * @return a content tree for the member summary table */ public Content getSummaryTableTree(ClassDoc classDoc); /** * Add the member summary for the given class and member. * * @param classDoc the class the summary belongs to * @param member the member that is documented * @param firstSentenceTags the tags for the sentence being documented * @param tableTree the content treeto which the information will be added * @param counter the counter for determing style for the table row */ public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, Tag[] firstSentenceTags, Content tableTree, int counter); /** * Get the inherited member summary header for the given class. * * @param classDoc the class the summary belongs to * @return a content tree containing the inherited summary header */ public Content getInheritedSummaryHeader(ClassDoc classDoc); /** * Add the inherited member summary for the given class and member. * * @param classDoc the class the inherited member belongs to * @param member the inherited member that is being documented * @param isFirst true if this is the first member in the list * @param isLast true if this is the last member in the list * @param linksTree the content tree to which the links will be added */ public void addInheritedMemberSummary(ClassDoc classDoc, ProgramElementDoc member, boolean isFirst, boolean isLast, Content linksTree); /** * Get inherited summary links. * * @return a content tree conatining the inherited summary links */ public Content getInheritedSummaryLinksTree(); /** * Get the member tree. * * @param memberTree the content tree representating the member * @return a content tree for the member */ public Content getMemberTree(Content memberTree); /** * Close the writer. */ public void close() throws IOException; }
4,185
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Content.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
/* * Copyright (c) 2010, 2011, 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; import com.sun.tools.doclets.internal.toolkit.util.*; /** * A class to create content for javadoc output pages. * * @author Bhavesh Patel */ public abstract class Content { /** * Returns a string representation of the content. * * @return string representation of the content */ public String toString() { StringBuilder contentBuilder = new StringBuilder(); write(contentBuilder); return contentBuilder.toString(); } /** * Adds content to the existing content. * * @param content content that needs to be added */ public abstract void addContent(Content content); /** * Adds a string content to the existing content. * * @param stringContent the string content to be added */ public abstract void addContent(String stringContent); /** * Writes content to a StringBuilder. * */ public abstract void write(StringBuilder contentBuilder); /** * Returns true if the content is empty. * * @return true if no content to be displayed else return false */ public abstract boolean isEmpty(); /** * Returns true if the content is valid. * * @return true if the content is valid else return false */ public boolean isValid() { return !isEmpty(); } /** * Checks for null values. * * @param t reference type to check for null values * @return the reference type if not null or else throws a null pointer exception */ protected static <T> T nullCheck(T t) { t.getClass(); return t; } /** * Returns true if the content ends with a newline character. Empty content * is considered as ending with new line. * * @param contentBuilder content to test for newline character at the end * @return true if the content ends with newline. */ protected boolean endsWithNewLine(StringBuilder contentBuilder) { int contentLength = contentBuilder.length(); if (contentLength == 0) { return true; } int nlLength = DocletConstants.NL.length(); if (contentLength < nlLength) { return false; } int contentIndex = contentLength - 1; int nlIndex = nlLength - 1; while (nlIndex >= 0) { if (contentBuilder.charAt(contentIndex) != DocletConstants.NL.charAt(nlIndex)) { return false; } contentIndex--; nlIndex--; } return true; } }
3,842
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LayoutParser.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.io.*; import java.util.*; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.*; /** * Parse the XML that specified the order of operation for the builders. This * Parser uses SAX parsing. * * @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 Configuration configuration; private static LayoutParser instance; private String currentRoot; private boolean isParsing; /** * This class is a singleton. */ 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) { if (instance == null) { instance = new LayoutParser(configuration); } return instance; } /** * 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(); } } /** * {@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); } }
4,272
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SerializedFormBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
/* * Copyright (c) 2003, 2011, 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.util.*; import com.sun.tools.doclets.internal.toolkit.*; /** * Builds the serialized form. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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; private SerializedFormBuilder(Configuration configuration) { super(configuration); } /** * Construct a new SerializedFormBuilder. * @param configuration the current configuration of the doclet. */ public static SerializedFormBuilder getInstance(Configuration configuration) { SerializedFormBuilder builder = new SerializedFormBuilder(configuration); return builder; } /** * 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(); } build(LayoutParser.getInstance(configuration).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++) { 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 = serial[0].text().toLowerCase(); 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; } }
22,648
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
XMLNode.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
/* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Simple class to represent the attribute and elements of an XML node. */ public class XMLNode { XMLNode(XMLNode parent, String qname) { this.parent = parent; name = qname; attrs = new HashMap<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; }
2,398
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BuilderFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
/* * Copyright (c) 2003, 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.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * The factory for constructing builders. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class BuilderFactory { /** * The current configuration of the doclet. */ private Configuration configuration; /** * The factory to retrieve the required writers from. */ private WriterFactory writerFactory; /** * 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(); } /** * Return the builder that builds the constant summary. * @return the builder that builds the constant summary. */ public AbstractBuilder getConstantsSummaryBuider() throws Exception { return ConstantsSummaryBuilder.getInstance(configuration, 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(configuration, pkg, writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); } /** * 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(configuration, 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(configuration, 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(configuration, classWriter.getClassDoc(), writerFactory.getMethodWriter(classWriter)); } /** * Return an instance of the annotation type member builder for the given * class. * * @return an instance of the annotation type memebr builder for the given * annotation type. */ public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( AnnotationTypeWriter annotationTypeWriter) throws Exception { return AnnotationTypeOptionalMemberBuilder.getInstance(configuration, 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 memebr builder for the given * annotation type. */ public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( AnnotationTypeWriter annotationTypeWriter) throws Exception { return AnnotationTypeRequiredMemberBuilder.getInstance(configuration, 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(configuration, 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(configuration, classWriter.getClassDoc(), writerFactory.getFieldWriter(classWriter)); } /** * 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(configuration, 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, configuration); } /** * 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, configuration); } /** * Return the builder that builds the serialized form. * * @return the builder that builds the serialized form. */ public AbstractBuilder getSerializedFormBuilder() throws Exception { return SerializedFormBuilder.getInstance(configuration); } }
8,661
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MemberSummaryBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds the member summary. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 VisibleMemberMap[] visibleMemberMaps; /** * The member summary writers for the given class. */ private MemberSummaryWriter[] memberSummaryWriters; /** * The type being documented. */ private ClassDoc classDoc; private MemberSummaryBuilder(Configuration configuration) { super(configuration); } /** * Construct a new MemberSummaryBuilder. * * @param classWriter the writer for the class whose members are being * summarized. * @param configuration the current configuration of the doclet. */ public static MemberSummaryBuilder getInstance( ClassWriter classWriter, Configuration configuration) throws Exception { MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration); builder.classDoc = classWriter.getClassDoc(); builder.init(classWriter); 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, Configuration configuration) throws Exception { MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration); builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc(); builder.init(annotationTypeWriter); return builder; } private void init(Object writer) throws Exception { visibleMemberMaps = new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES]; for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { visibleMemberMaps[i] = new VisibleMemberMap( classDoc, i, configuration.nodeprecated); } memberSummaryWriters = new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES]; for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) { if (classDoc.isAnnotationType()) { memberSummaryWriters[i] = visibleMemberMaps[i].noVisibleMembers()? null : configuration.getWriterFactory().getMemberSummaryWriter( (AnnotationTypeWriter) writer, i); } else { memberSummaryWriters[i] = visibleMemberMaps[i].noVisibleMembers()? null : configuration.getWriterFactory().getMemberSummaryWriter( (ClassWriter) writer, i); } } } /** * {@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 classDoc the {@link ClassDoc} we want to check. * @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 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 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); Content tableTree = writer.getSummaryTableTree(classDoc); for (int i = 0; i < members.size(); i++) { ProgramElementDoc member = members.get(i); 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, tableTree, i); } summaryTreeList.add(tableTree); } } /** * 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)); } } }
15,809
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantsSummaryBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; /** * Builds the Constants Summary Page. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 ConstantsSummaryWriter writer; /** * The set of ClassDocs that have constant fields. */ protected 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 configuration the current configuration of the * doclet. */ private ConstantsSummaryBuilder(Configuration configuration) { super(configuration); } /** * Construct a ConstantsSummaryBuilder. * * @param configuration the configuration used in this run * of the doclet. * @param writer the writer for the summary. */ public static ConstantsSummaryBuilder getInstance( Configuration configuration, ConstantsSummaryWriter writer) { ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder( configuration); builder.writer = writer; builder.classDocsWithConstFields = new HashSet<ClassDoc>(); return builder; } /** * {@inheritDoc} */ public void build() throws IOException { if (writer == null) { //Doclet does not support this output. return; } build(LayoutParser.getInstance(configuration).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.nodeprecated); 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.nodeprecated); visibleMemberMapEnumConst = new VisibleMemberMap(classdoc, VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated); } /** * 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. * @param cd the classdoc to examine. * @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; } }
13,615
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageSummaryBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; /** * Builds the summary for a given package. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 PackageDoc packageDoc; /** * The doclet specific writer that will output the result. */ private PackageSummaryWriter packageWriter; /** * The content that will be added to the package summary documentation tree. */ private Content contentTree; private PackageSummaryBuilder(Configuration configuration) { super(configuration); } /** * Construct a new PackageSummaryBuilder. * @param configuration the current configuration of the doclet. * @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( Configuration configuration, PackageDoc pkg, PackageSummaryWriter packageWriter) { PackageSummaryBuilder builder = new PackageSummaryBuilder(configuration); builder.packageDoc = pkg; builder.packageWriter = packageWriter; return builder; } /** * Build the package summary. */ public void build() throws IOException { if (packageWriter == null) { //Doclet does not support this output. return; } build(LayoutParser.getInstance(configuration).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, Util.getPackageSourcePath(configuration, packageDoc), DirectoryManager.getDirectoryPath(packageDoc) + File.separator + DocletConstants.DOC_FILES_DIR_NAME, true); } /** * 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)); 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)); 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)); 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)); 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)); 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)); 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); } }
14,185
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeOptionalMemberBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for optional annotation type members. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public class AnnotationTypeOptionalMemberBuilder extends AnnotationTypeRequiredMemberBuilder { /** * Construct a new AnnotationTypeMemberBuilder. * * @param configuration the current configuration of the * doclet. */ private AnnotationTypeOptionalMemberBuilder(Configuration configuration) { super(configuration); } /** * Construct a new AnnotationTypeMemberBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ public static AnnotationTypeOptionalMemberBuilder getInstance( Configuration configuration, ClassDoc classDoc, AnnotationTypeOptionalMemberWriter writer) { AnnotationTypeOptionalMemberBuilder builder = new AnnotationTypeOptionalMemberBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated); builder.members = new ArrayList<ProgramElementDoc>( builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort(builder.members, configuration.getMemberComparator()); } return builder; } /** * {@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; } }
4,400
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds the summary for a given class. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 ClassDoc classDoc; /** * The doclet specific writer. */ private ClassWriter writer; /** * Keep track of whether or not this classdoc is an interface. */ private boolean isInterface = false; /** * Keep track of whether or not this classdoc is an enum. */ private boolean isEnum = false; /** * The content tree for the class documentation. */ private Content contentTree; /** * Construct a new ClassBuilder. * * @param configuration the current configuration of the * doclet. */ private ClassBuilder(Configuration configuration) { super(configuration); } /** * Construct a new ClassBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class being documented. * @param writer the doclet specific writer. */ public static ClassBuilder getInstance(Configuration configuration, ClassDoc classDoc, ClassWriter writer) throws Exception { ClassBuilder builder = new ClassBuilder(configuration); builder.configuration = configuration; builder.classDoc = classDoc; builder.writer = writer; if (classDoc.isInterface()) { builder.isInterface = true; } else if (classDoc.isEnum()) { builder.isEnum = true; Util.setEnumDocumentation(configuration, classDoc); } if(containingPackagesSeen == null) { containingPackagesSeen = new HashSet<String>(); } return builder; } /** * {@inheritDoc} */ public void build() throws IOException { build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree); } /** * {@inheritDoc} */ public String getName() { return ROOT; } /** * Handles the &lt;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 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, Util.getPackageSourcePath(configuration, classDoc.containingPackage()) + DirectoryManager.getDirectoryPath(classDoc.containingPackage()) + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true); 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) { StringBuffer modifiers = new StringBuffer(classDoc.modifiers() + " "); if (isEnum) { modifiers.append("enum "); int index; if ((index = modifiers.indexOf("abstract")) >= 0) { modifiers.delete(index, index + (new String("abstract")).length()); modifiers = new StringBuffer( Util.replaceText(modifiers.toString(), " ", " ")); } if ((index = modifiers.indexOf("final")) >= 0) { modifiers.delete(index, index + (new String("final")).length()); modifiers = new StringBuffer( 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 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); } }
14,887
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AbstractBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.io.*; import java.lang.reflect.*; import java.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. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.5 */ public abstract class AbstractBuilder { /** * The configuration used in this run of the doclet. */ protected 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 static Set<String> containingPackagesSeen; /** * 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(Configuration configuration) { this.configuration = configuration; } /** * 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(); } catch (InvocationTargetException e) { e.getCause().printStackTrace(); } catch (Exception e) { e.printStackTrace(); configuration.root.printError("Exception " + e.getClass().getName() + " thrown while processing element: " + component); throw new DocletAbortException(); } } /** * Build the documentation, as specified by the children of the given XML element. * * @param node the XML element that specifies which components to document. * @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); } }
5,555
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumConstantBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for a enum constants. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public class EnumConstantBuilder extends AbstractMemberBuilder { /** * The class whose enum constants are being documented. */ private ClassDoc classDoc; /** * The visible enum constantss for the given class. */ private VisibleMemberMap visibleMemberMap; /** * The writer to output the enum constants documentation. */ private EnumConstantWriter writer; /** * The list of enum constants being documented. */ private 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 configuration the current configuration of the * doclet. */ private EnumConstantBuilder(Configuration configuration) { super(configuration); } /** * Construct a new EnumConstantsBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ public static EnumConstantBuilder getInstance( Configuration configuration, ClassDoc classDoc, EnumConstantWriter writer) { EnumConstantBuilder builder = new EnumConstantBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap( classDoc, VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated); builder.enumConstants = new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort( builder.enumConstants, configuration.getMemberComparator()); } return builder; } /** * {@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; } }
8,155
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeRequiredMemberBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for required annotation type members. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 configuration the current configuration of the * doclet. */ protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) { super(configuration); } /** * Construct a new AnnotationTypeMemberBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ public static AnnotationTypeRequiredMemberBuilder getInstance( Configuration configuration, ClassDoc classDoc, AnnotationTypeRequiredMemberWriter writer) { AnnotationTypeRequiredMemberBuilder builder = new AnnotationTypeRequiredMemberBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated); builder.members = new ArrayList<ProgramElementDoc>( builder.visibleMemberMap.getMembersFor(classDoc)); if (configuration.getMemberComparator() != null) { Collections.sort(builder.members, configuration.getMemberComparator()); } return builder; } /** * {@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.addAnnotationDetailsTreeHeader( classDoc, memberDetailsTree); for (currentMemberIndex = 0; currentMemberIndex < size; currentMemberIndex++) { Content annotationDocTree = writer.getAnnotationDocTreeHeader( (MemberDoc) members.get(currentMemberIndex), memberDetailsTree); buildChildren(node, annotationDocTree); memberDetailsTree.addContent(writer.getAnnotationDoc( annotationDocTree, (currentMemberIndex == size - 1))); } } } /** * 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; } }
8,325
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds the summary for a given annotation type. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 AnnotationTypeDoc annotationTypeDoc; /** * The doclet specific writer. */ private AnnotationTypeWriter writer; /** * The content tree for the annotation documentation. */ private Content contentTree; /** * Construct a new ClassBuilder. * * @param configuration the current configuration of the * doclet. */ private AnnotationTypeBuilder(Configuration configuration) { super(configuration); } /** * Construct a new ClassBuilder. * * @param configuration the current configuration of the doclet. * @param annotationTypeDoc the class being documented. * @param writer the doclet specific writer. */ public static AnnotationTypeBuilder getInstance(Configuration configuration, AnnotationTypeDoc annotationTypeDoc, AnnotationTypeWriter writer) throws Exception { AnnotationTypeBuilder builder = new AnnotationTypeBuilder(configuration); builder.configuration = configuration; builder.annotationTypeDoc = annotationTypeDoc; builder.writer = writer; if(containingPackagesSeen == null) { containingPackagesSeen = new HashSet<String>(); } return builder; } /** * {@inheritDoc} */ public void build() throws IOException { build(LayoutParser.getInstance(configuration).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, Util.getPackageSourcePath(configuration, annotationTypeDoc.containingPackage()) + DirectoryManager.getDirectoryPath( annotationTypeDoc.containingPackage()) + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true); 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) { StringBuffer modifiers = new StringBuffer( 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()) { Content memberDetails = writer.getMemberTreeHeader(); writer.addAnnotationDetailsMarker(memberDetails); memberDetails.addContent(writer.getMemberTree(memberDetailsTree)); annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetails)); } } /** * 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); } }
10,375
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AbstractMemberBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.util.*; /** * The superclass for all member builders. Member builders are only executed * within Class Builders. They essentially build sub-components. For example, * method documentation is a sub-component of class documentation. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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(Configuration configuration) { super(configuration); } /** * 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(); } /** * 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(); }
3,086
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstructorBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for a constructor. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 ClassDoc classDoc; /** * The visible constructors for the given class. */ private VisibleMemberMap visibleMemberMap; /** * The writer to output the constructor documentation. */ private ConstructorWriter writer; /** * The constructors being documented. */ private List<ProgramElementDoc> constructors; /** * Construct a new ConstructorBuilder. * * @param configuration the current configuration of the * doclet. */ private ConstructorBuilder(Configuration configuration) { super(configuration); } /** * Construct a new ConstructorBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ public static ConstructorBuilder getInstance( Configuration configuration, ClassDoc classDoc, ConstructorWriter writer) { ConstructorBuilder builder = new ConstructorBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap( classDoc, VisibleMemberMap.CONSTRUCTORS, configuration.nodeprecated); builder.constructors = new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc)); for (int i = 0; i < builder.constructors.size(); i++) { if (builder.constructors.get(i).isProtected() || builder.constructors.get(i).isPrivate()) { writer.setFoundNonPubConstructor(true); } } if (configuration.getMemberComparator() != null) { Collections.sort( builder.constructors, configuration.getMemberComparator()); } return builder; } /** * {@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); } }
8,116
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for a method. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @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 ClassDoc classDoc; /** * The visible methods for the given class. */ private VisibleMemberMap visibleMemberMap; /** * The writer to output the method documentation. */ private MethodWriter writer; /** * The methods being documented. */ private List<ProgramElementDoc> methods; private MethodBuilder(Configuration configuration) { super(configuration); } /** * Construct a new MethodBuilder. * * @param configuration the current configuration of the doclet. * @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( Configuration configuration, ClassDoc classDoc, MethodWriter writer) { MethodBuilder builder = new MethodBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap( classDoc, VisibleMemberMap.METHODS, configuration.nodeprecated); builder.methods = new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers( configuration)); if (configuration.getMemberComparator() != null) { Collections.sort( builder.methods, configuration.getMemberComparator()); } return builder; } /** * {@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; } }
8,176
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FieldBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.builders; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; /** * Builds documentation for a field. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Bhavesh Patel (Modified) * @since 1.5 */ public class FieldBuilder extends AbstractMemberBuilder { /** * The class whose fields are being documented. */ private ClassDoc classDoc; /** * The visible fields for the given class. */ private VisibleMemberMap visibleMemberMap; /** * The writer to output the field documentation. */ private FieldWriter writer; /** * The list of fields being documented. */ private 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 configuration the current configuration of the * doclet. */ private FieldBuilder(Configuration configuration) { super(configuration); } /** * Construct a new FieldBuilder. * * @param configuration the current configuration of the doclet. * @param classDoc the class whoses members are being documented. * @param writer the doclet specific writer. */ public static FieldBuilder getInstance( Configuration configuration, ClassDoc classDoc, FieldWriter writer) { FieldBuilder builder = new FieldBuilder(configuration); builder.classDoc = classDoc; builder.writer = writer; builder.visibleMemberMap = new VisibleMemberMap( classDoc, VisibleMemberMap.FIELDS, configuration.nodeprecated); builder.fields = new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers( configuration)); if (configuration.getMemberComparator() != null) { Collections.sort( builder.fields, configuration.getMemberComparator()); } return builder; } /** * {@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; } }
7,597
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VisibleMemberMap.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
/* * Copyright (c) 1999, 2008, 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.util; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import java.util.*; /** * A data structure that encapsulates the visible members of a particular * type for a given class tree. To use this data structor, you must specify * the type of member you are interested in (nested class, field, constructor * or method) and the leaf of the class tree. The data structure will map * all visible members in the leaf and classes above the leaf in the tree. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar * @author Jamie Ho (rewrite) */ public class VisibleMemberMap { private boolean noVisibleMembers = true; public static final int INNERCLASSES = 0; public static final int ENUM_CONSTANTS = 1; public static final int FIELDS = 2; public static final int CONSTRUCTORS = 3; public static final int METHODS = 4; public static final int ANNOTATION_TYPE_MEMBER_OPTIONAL = 5; public static final int ANNOTATION_TYPE_MEMBER_REQUIRED = 6; /** * The total number of member types is {@value}. */ public static final int NUM_MEMBER_TYPES = 7; public static final String STARTLEVEL = "start"; /** * List of ClassDoc objects for which ClassMembers objects are built. */ private final List<ClassDoc> visibleClasses = new ArrayList<ClassDoc>(); /** * Map for each member name on to a map which contains members with same * name-signature. The mapped map will contain mapping for each MemberDoc * onto it's respecive level string. */ private final Map<Object,Map<ProgramElementDoc,String>> memberNameMap = new HashMap<Object,Map<ProgramElementDoc,String>>(); /** * Map of class and it's ClassMembers object. */ private final Map<ClassDoc,ClassMembers> classMap = new HashMap<ClassDoc,ClassMembers>(); /** * Type whose visible members are requested. This is the leaf of * the class tree being mapped. */ private final ClassDoc classdoc; /** * Member kind: InnerClasses/Fields/Methods? */ private final int kind; /** * Deprected members should be excluded or not? */ private final boolean nodepr; /** * Construct a VisibleMemberMap of the given type for the given * class. If nodepr is true, exclude the deprecated members from * the map. * * @param classdoc the class whose members are being mapped. * @param kind the kind of member that is being mapped. * @param nodepr if true, exclude the deprecated members from the map. */ public VisibleMemberMap(ClassDoc classdoc, int kind, boolean nodepr) { this.classdoc = classdoc; this.nodepr = nodepr; this.kind = kind; new ClassMembers(classdoc, STARTLEVEL).build(); } /** * Return the list of visible classes in this map. * * @return the list of visible classes in this map. */ public List<ClassDoc> getVisibleClassesList() { sort(visibleClasses); return visibleClasses; } /** * Return the package private members inherited by the class. Only return * if parent is package private and not documented. * * @param configuation the current configuration of the doclet. * @return the package private members inherited by the class. */ private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) { List<ProgramElementDoc> results = new ArrayList<ProgramElementDoc>(); for (Iterator<ClassDoc> iter = visibleClasses.iterator(); iter.hasNext(); ) { ClassDoc currentClass = iter.next(); if (currentClass != classdoc && currentClass.isPackagePrivate() && !Util.isLinkable(currentClass, configuration)) { // Document these members in the child class because // the parent is inaccessible. results.addAll(getMembersFor(currentClass)); } } return results; } /** * Return the visible members of the class being mapped. Also append at the * end of the list members that are inherited by inaccessible parents. We * document these members in the child because the parent is not documented. * * @param configuation the current configuration of the doclet. */ public List<ProgramElementDoc> getLeafClassMembers(Configuration configuration) { List<ProgramElementDoc> result = getMembersFor(classdoc); result.addAll(getInheritedPackagePrivateMethods(configuration)); return result; } /** * Retrn the list of members for the given class. * * @param cd the class to retrieve the list of visible members for. * * @return the list of members for the given class. */ public List<ProgramElementDoc> getMembersFor(ClassDoc cd) { ClassMembers clmembers = classMap.get(cd); if (clmembers == null) { return new ArrayList<ProgramElementDoc>(); } return clmembers.getMembers(); } /** * Sort the given mixed list of classes and interfaces to a list of * classes followed by interfaces traversed. Don't sort alphabetically. */ private void sort(List<ClassDoc> list) { List<ClassDoc> classes = new ArrayList<ClassDoc>(); List<ClassDoc> interfaces = new ArrayList<ClassDoc>(); for (int i = 0; i < list.size(); i++) { ClassDoc cd = list.get(i); if (cd.isClass()) { classes.add(cd); } else { interfaces.add(cd); } } list.clear(); list.addAll(classes); list.addAll(interfaces); } private void fillMemberLevelMap(List<ProgramElementDoc> list, String level) { for (int i = 0; i < list.size(); i++) { Object key = getMemberKey(list.get(i)); Map<ProgramElementDoc,String> memberLevelMap = memberNameMap.get(key); if (memberLevelMap == null) { memberLevelMap = new HashMap<ProgramElementDoc,String>(); memberNameMap.put(key, memberLevelMap); } memberLevelMap.put(list.get(i), level); } } private void purgeMemberLevelMap(List<ProgramElementDoc> list, String level) { for (int i = 0; i < list.size(); i++) { Object key = getMemberKey(list.get(i)); Map<ProgramElementDoc, String> memberLevelMap = memberNameMap.get(key); if (level.equals(memberLevelMap.get(list.get(i)))) memberLevelMap.remove(list.get(i)); } } /** * Represents a class member. We should be able to just use a * ProgramElementDoc instead of this class, but that doesn't take * type variables in consideration when comparing. */ private class ClassMember { private Set<ProgramElementDoc> members; public ClassMember(ProgramElementDoc programElementDoc) { members = new HashSet<ProgramElementDoc>(); members.add(programElementDoc); } public void addMember(ProgramElementDoc programElementDoc) { members.add(programElementDoc); } public boolean isEqual(MethodDoc member) { for (Iterator<ProgramElementDoc> iter = members.iterator(); iter.hasNext(); ) { MethodDoc member2 = (MethodDoc) iter.next(); if (Util.executableMembersEqual(member, member2)) { members.add(member); return true; } } return false; } } /** * A data structure that represents the class members for * a visible class. */ private class ClassMembers { /** * The mapping class, whose inherited members are put in the * {@link #members} list. */ private ClassDoc mappingClass; /** * List of inherited members from the mapping class. */ private List<ProgramElementDoc> members = new ArrayList<ProgramElementDoc>(); /** * Level/Depth of inheritance. */ private String level; /** * Return list of inherited members from mapping class. * * @return List Inherited members. */ public List<ProgramElementDoc> getMembers() { return members; } private ClassMembers(ClassDoc mappingClass, String level) { this.mappingClass = mappingClass; this.level = level; if (classMap.containsKey(mappingClass) && level.startsWith(classMap.get(mappingClass).level)) { //Remove lower level class so that it can be replaced with //same class found at higher level. purgeMemberLevelMap(getClassMembers(mappingClass, false), classMap.get(mappingClass).level); classMap.remove(mappingClass); visibleClasses.remove(mappingClass); } if (!classMap.containsKey(mappingClass)) { classMap.put(mappingClass, this); visibleClasses.add(mappingClass); } } private void build() { if (kind == CONSTRUCTORS) { addMembers(mappingClass); } else { mapClass(); } } private void mapClass() { addMembers(mappingClass); ClassDoc[] interfaces = mappingClass.interfaces(); for (int i = 0; i < interfaces.length; i++) { String locallevel = level + 1; ClassMembers cm = new ClassMembers(interfaces[i], locallevel); cm.mapClass(); } if (mappingClass.isClass()) { ClassDoc superclass = mappingClass.superclass(); if (!(superclass == null || mappingClass.equals(superclass))) { ClassMembers cm = new ClassMembers(superclass, level + "c"); cm.mapClass(); } } } /** * Get all the valid members from the mapping class. Get the list of * members for the class to be included into(ctii), also get the level * string for ctii. If mapping class member is not already in the * inherited member list and if it is visible in the ctii and not * overridden, put such a member in the inherited member list. * Adjust member-level-map, class-map. */ private void addMembers(ClassDoc fromClass) { List<ProgramElementDoc> cdmembers = getClassMembers(fromClass, true); List<ProgramElementDoc> incllist = new ArrayList<ProgramElementDoc>(); for (int i = 0; i < cdmembers.size(); i++) { ProgramElementDoc pgmelem = cdmembers.get(i); if (!found(members, pgmelem) && memberIsVisible(pgmelem) && !isOverridden(pgmelem, level)) { incllist.add(pgmelem); } } if (incllist.size() > 0) { noVisibleMembers = false; } members.addAll(incllist); fillMemberLevelMap(getClassMembers(fromClass, false), level); } /** * Is given doc item visible in given classdoc in terms fo inheritance? * The given doc item is visible in the given classdoc if it is public * or protected and if it is package-private if it's containing class * is in the same package as the given classdoc. */ private boolean memberIsVisible(ProgramElementDoc pgmdoc) { if (pgmdoc.containingClass().equals(classdoc)) { //Member is in class that we are finding visible members for. //Of course it is visible. return true; } else if (pgmdoc.isPrivate()) { //Member is in super class or implemented interface. //Private, so not inherited. return false; } else if (pgmdoc.isPackagePrivate()) { //Member is package private. Only return true if its class is in //same package. return pgmdoc.containingClass().containingPackage().equals( classdoc.containingPackage()); } else { //Public members are always inherited. return true; } } /** * Return all available class members. */ private List<ProgramElementDoc> getClassMembers(ClassDoc cd, boolean filter) { if (cd.isEnum() && kind == CONSTRUCTORS) { //If any of these rules are hit, return empty array because //we don't document these members ever. return Arrays.asList(new ProgramElementDoc[] {}); } ProgramElementDoc[] members = null; switch (kind) { case ANNOTATION_TYPE_MEMBER_OPTIONAL: members = cd.isAnnotationType() ? filter((AnnotationTypeDoc) cd, false) : new AnnotationTypeElementDoc[] {}; break; case ANNOTATION_TYPE_MEMBER_REQUIRED: members = cd.isAnnotationType() ? filter((AnnotationTypeDoc) cd, true) : new AnnotationTypeElementDoc[] {}; break; case INNERCLASSES: members = cd.innerClasses(filter); break; case ENUM_CONSTANTS: members = cd.enumConstants(); break; case FIELDS: members = cd.fields(filter); break; case CONSTRUCTORS: members = cd.constructors(); break; case METHODS: members = cd.methods(filter); break; default: members = new ProgramElementDoc[0]; } if (nodepr) { return Util.excludeDeprecatedMembersAsList(members); } return Arrays.asList(members); } /** * Filter the annotation type members and return either the required * members or the optional members, depending on the value of the * required parameter. * * @param doc The annotation type to process. * @param required * @return the annotation type members and return either the required * members or the optional members, depending on the value of the * required parameter. */ private AnnotationTypeElementDoc[] filter(AnnotationTypeDoc doc, boolean required) { AnnotationTypeElementDoc[] members = doc.elements(); List<AnnotationTypeElementDoc> targetMembers = new ArrayList<AnnotationTypeElementDoc>(); for (int i = 0; i < members.length; i++) { if ((required && members[i].defaultValue() == null) || ((!required) && members[i].defaultValue() != null)){ targetMembers.add(members[i]); } } return targetMembers.toArray(new AnnotationTypeElementDoc[]{}); } private boolean found(List<ProgramElementDoc> list, ProgramElementDoc elem) { for (int i = 0; i < list.size(); i++) { ProgramElementDoc pgmelem = list.get(i); if (Util.matches(pgmelem, elem)) { return true; } } return false; } /** * Is member overridden? The member is overridden if it is found in the * same level hierarchy e.g. member at level "11" overrides member at * level "111". */ private boolean isOverridden(ProgramElementDoc pgmdoc, String level) { Map<?,String> memberLevelMap = (Map<?,String>) memberNameMap.get(getMemberKey(pgmdoc)); if (memberLevelMap == null) return false; String mappedlevel = null; Iterator<String> iterator = memberLevelMap.values().iterator(); while (iterator.hasNext()) { mappedlevel = iterator.next(); if (mappedlevel.equals(STARTLEVEL) || (level.startsWith(mappedlevel) && !level.equals(mappedlevel))) { return true; } } return false; } } /** * Return true if this map has no visible members. * * @return true if this map has no visible members. */ public boolean noVisibleMembers() { return noVisibleMembers; } private ClassMember getClassMember(MethodDoc member) { for (Iterator<?> iter = memberNameMap.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if (key instanceof String) { continue; } else if (((ClassMember) key).isEqual(member)) { return (ClassMember) key; } } return new ClassMember(member); } /** * Return the key to the member map for the given member. */ private Object getMemberKey(ProgramElementDoc doc) { if (doc.isConstructor()) { return doc.name() + ((ExecutableMemberDoc)doc).signature(); } else if (doc.isMethod()) { return getClassMember((MethodDoc) doc); } else if (doc.isField() || doc.isEnumConstant() || doc.isAnnotationTypeElement()) { return doc.name(); } else { // it's a class or interface String classOrIntName = doc.name(); //Strip off the containing class name because we only want the member name. classOrIntName = classOrIntName.indexOf('.') != 0 ? classOrIntName.substring(classOrIntName.lastIndexOf('.'), classOrIntName.length()) : classOrIntName; return "clint" + classOrIntName; } } }
19,842
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MetaKeywords.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java
/* * Copyright (c) 2002, 2008, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; /** * Provides methods for creating an array of class, method and * field names to be included as meta keywords in the HTML header * of class pages. These keywords improve search results * on browsers that look for keywords. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Doug Kramer */ public class MetaKeywords { /** * The global configuration information for this run. */ private final Configuration configuration; /** * Constructor */ public MetaKeywords(Configuration configuration) { this.configuration = configuration; } /** * Returns an array of strings where each element * is a class, method or field name. This array is * used to create one meta keyword tag for each element. * Method parameter lists are converted to "()" and * overloads are combined. * * Constructors are not included because they have the same * name as the class, which is already included. * Nested class members are not included because their * definitions are on separate pages. */ public String[] getMetaKeywords(ClassDoc classdoc) { ArrayList<String> results = new ArrayList<String>(); // Add field and method keywords only if -keywords option is used if( configuration.keywords ) { results.addAll(getClassKeyword(classdoc)); results.addAll(getMemberKeywords(classdoc.fields())); results.addAll(getMemberKeywords(classdoc.methods())); } return results.toArray(new String[]{}); } /** * Get the current class for a meta tag keyword, as the first * and only element of an array list. */ protected ArrayList<String> getClassKeyword(ClassDoc classdoc) { String cltypelower = classdoc.isInterface() ? "interface" : "class"; ArrayList<String> metakeywords = new ArrayList<String>(1); metakeywords.add(classdoc.qualifiedName() + " " + cltypelower); return metakeywords; } /** * Get the package keywords. */ public String[] getMetaKeywords(PackageDoc packageDoc) { if( configuration.keywords ) { String pkgName = Util.getPackageName(packageDoc); return new String[] { pkgName + " " + "package" }; } else { return new String[] {}; } } /** * Get the overview keywords. */ public String[] getOverviewMetaKeywords(String title, String docTitle) { if( configuration.keywords ) { String windowOverview = configuration.getText(title); String[] metakeywords = { windowOverview }; if (docTitle.length() > 0 ) { metakeywords[0] += ", " + docTitle; } return metakeywords; } else { return new String[] {}; } } /** * Get members for meta tag keywords as an array, * where each member name is a string element of the array. * The parameter lists are not included in the keywords; * therefore all overloaded methods are combined.<br> * Example: getValue(Object) is returned in array as getValue() * * @param memberdocs array of MemberDoc objects to be added to keywords */ protected ArrayList<String> getMemberKeywords(MemberDoc[] memberdocs) { ArrayList<String> results = new ArrayList<String>(); String membername; for (int i=0; i < memberdocs.length; i++) { membername = memberdocs[i].name() + (memberdocs[i].isMethod() ? "()" : ""); if ( ! results.contains(membername) ) { results.add(membername); } } return results; } }
5,192
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassTree.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java
/* * Copyright (c) 1998, 2011, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; /** * Build Class Hierarchy for all the Classes. This class builds the Class * Tree and the Interface Tree separately. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @see java.util.HashMap * @see java.util.List * @see com.sun.javadoc.Type * @see com.sun.javadoc.ClassDoc * @author Atul M Dambalkar */ public class ClassTree { /** * List of baseclasses. Contains only java.lang.Object. Can be used to get * the mapped listing of sub-classes. */ private List<ClassDoc> baseclasses = new ArrayList<ClassDoc>(); /** * Mapping for each Class with their SubClasses */ private Map<ClassDoc,List<ClassDoc>> subclasses = new HashMap<ClassDoc,List<ClassDoc>>(); /** * List of base-interfaces. Contains list of all the interfaces who do not * have super-interfaces. Can be used to get the mapped listing of * sub-interfaces. */ private List<ClassDoc> baseinterfaces = new ArrayList<ClassDoc>(); /** * Mapping for each Interface with their SubInterfaces */ private Map<ClassDoc,List<ClassDoc>> subinterfaces = new HashMap<ClassDoc,List<ClassDoc>>(); private List<ClassDoc> baseEnums = new ArrayList<ClassDoc>(); private Map<ClassDoc,List<ClassDoc>> subEnums = new HashMap<ClassDoc,List<ClassDoc>>(); private List<ClassDoc> baseAnnotationTypes = new ArrayList<ClassDoc>(); private Map<ClassDoc,List<ClassDoc>> subAnnotationTypes = new HashMap<ClassDoc,List<ClassDoc>>(); /** * Mapping for each Interface with classes who implement it. */ private Map<ClassDoc,List<ClassDoc>> implementingclasses = new HashMap<ClassDoc,List<ClassDoc>>(); /** * Constructor. Build the Tree using the Root of this Javadoc run. * * @param configuration the configuration of the doclet. * @param noDeprecated Don't add deprecated classes in the class tree, if * true. */ public ClassTree(Configuration configuration, boolean noDeprecated) { configuration.message.notice("doclet.Building_Tree"); buildTree(configuration.root.classes(), configuration); } /** * Constructor. Build the Tree using the Root of this Javadoc run. * * @param root Root of the Document. * @param configuration The curren configuration of the doclet. */ public ClassTree(RootDoc root, Configuration configuration) { buildTree(root.classes(), configuration); } /** * Constructor. Build the tree for the given array of classes. * * @param classes Array of classes. * @param configuration The curren configuration of the doclet. */ public ClassTree(ClassDoc[] classes, Configuration configuration) { buildTree(classes, configuration); } /** * Generate mapping for the sub-classes for every class in this run. * Return the sub-class list for java.lang.Object which will be having * sub-class listing for itself and also for each sub-class itself will * have their own sub-class lists. * * @param classes all the classes in this run. * @param configuration the current configuration of the doclet. */ private void buildTree(ClassDoc[] classes, Configuration configuration) { for (int i = 0; i < classes.length; i++) { // In the tree page (e.g overview-tree.html) do not include // information of classes which are deprecated or are a part of a // deprecated package. if (configuration.nodeprecated && (Util.isDeprecated(classes[i]) || Util.isDeprecated(classes[i].containingPackage()))) { continue; } if (classes[i].isEnum()) { processType(classes[i], configuration, baseEnums, subEnums); } else if (classes[i].isClass()) { processType(classes[i], configuration, baseclasses, subclasses); } else if (classes[i].isInterface()) { processInterface(classes[i]); List<ClassDoc> list = implementingclasses.get(classes[i]); if (list != null) { Collections.sort(list); } } else if (classes[i].isAnnotationType()) { processType(classes[i], configuration, baseAnnotationTypes, subAnnotationTypes); } } Collections.sort(baseinterfaces); for (Iterator<List<ClassDoc>> it = subinterfaces.values().iterator(); it.hasNext(); ) { Collections.sort(it.next()); } for (Iterator<List<ClassDoc>> it = subclasses.values().iterator(); it.hasNext(); ) { Collections.sort(it.next()); } } /** * For the class passed map it to it's own sub-class listing. * For the Class passed, get the super class, * if superclass is non null, (it is not "java.lang.Object") * get the "value" from the hashmap for this key Class * if entry not found create one and get that. * add this Class as a sub class in the list * Recurse till hits java.lang.Object Null SuperClass. * * @param cd class for which sub-class mapping to be generated. * @param configuration the current configurtation of the doclet. */ private void processType(ClassDoc cd, Configuration configuration, List<ClassDoc> bases, Map<ClassDoc,List<ClassDoc>> subs) { ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration); if (superclass != null) { if (!add(subs, superclass, cd)) { return; } else { processType(superclass, configuration, bases, subs); } } else { // cd is java.lang.Object, add it once to the list if (!bases.contains(cd)) { bases.add(cd); } } List<Type> intfacs = Util.getAllInterfaces(cd, configuration); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext();) { add(implementingclasses, iter.next().asClassDoc(), cd); } } /** * For the interface passed get the interfaces which it extends, and then * put this interface in the sub-interface list of those interfaces. Do it * recursively. If a interface doesn't have super-interface just attach * that interface in the list of all the baseinterfaces. * * @param cd Interface under consideration. */ private void processInterface(ClassDoc cd) { ClassDoc[] intfacs = cd.interfaces(); if (intfacs.length > 0) { for (int i = 0; i < intfacs.length; i++) { if (!add(subinterfaces, intfacs[i], cd)) { return; } else { processInterface(intfacs[i]); // Recurse } } } else { // we need to add all the interfaces who do not have // super-interfaces to baseinterfaces list to traverse them if (!baseinterfaces.contains(cd)) { baseinterfaces.add(cd); } } } /** * Adjust the Class Tree. Add the class interface in to it's super-class' * or super-interface's sub-interface list. * * @param map the entire map. * @param superclass java.lang.Object or the super-interface. * @param cd sub-interface to be mapped. * @returns boolean true if class added, false if class already processed. */ private boolean add(Map<ClassDoc,List<ClassDoc>> map, ClassDoc superclass, ClassDoc cd) { List<ClassDoc> list = map.get(superclass); if (list == null) { list = new ArrayList<ClassDoc>(); map.put(superclass, list); } if (list.contains(cd)) { return false; } else { list.add(cd); } return true; } /** * From the map return the list of sub-classes or sub-interfaces. If list * is null create a new one and return it. * * @param map The entire map. * @param cd class for which the sub-class list is requested. * @returns List Sub-Class list for the class passed. */ private List<ClassDoc> get(Map<ClassDoc,List<ClassDoc>> map, ClassDoc cd) { List<ClassDoc> list = map.get(cd); if (list == null) { return new ArrayList<ClassDoc>(); } return list; } /** * Return the sub-class list for the class passed. * * @param cd class whose sub-class list is required. */ public List<ClassDoc> subclasses(ClassDoc cd) { return get(subclasses, cd); } /** * Return the sub-interface list for the interface passed. * * @param cd interface whose sub-interface list is required. */ public List<ClassDoc> subinterfaces(ClassDoc cd) { return get(subinterfaces, cd); } /** * Return the list of classes which implement the interface passed. * * @param cd interface whose implementing-classes list is required. */ public List<ClassDoc> implementingclasses(ClassDoc cd) { List<ClassDoc> result = get(implementingclasses, cd); List<ClassDoc> subinterfaces = allSubs(cd, false); //If class x implements a subinterface of cd, then it follows //that class x implements cd. Iterator<ClassDoc> implementingClassesIter, subInterfacesIter = subinterfaces.listIterator(); ClassDoc c; while(subInterfacesIter.hasNext()){ implementingClassesIter = implementingclasses( subInterfacesIter.next()).listIterator(); while(implementingClassesIter.hasNext()){ c = implementingClassesIter.next(); if(! result.contains(c)){ result.add(c); } } } Collections.sort(result); return result; } /** * Return the sub-class/interface list for the class/interface passed. * * @param cd class/interface whose sub-class/interface list is required. * @param isEnum true if the subclasses should be forced to come from the * enum tree. */ public List<ClassDoc> subs(ClassDoc cd, boolean isEnum) { if (isEnum) { return get(subEnums, cd); } else if (cd.isAnnotationType()) { return get(subAnnotationTypes, cd); } else if (cd.isInterface()) { return get(subinterfaces, cd); } else if (cd.isClass()) { return get(subclasses, cd); } else { return null; } } /** * Return a list of all direct or indirect, sub-classes and subinterfaces * of the ClassDoc argument. * * @param cd ClassDoc whose sub-classes or sub-interfaces are requested. * @param isEnum true if the subclasses should be forced to come from the * enum tree. */ public List<ClassDoc> allSubs(ClassDoc cd, boolean isEnum) { List<ClassDoc> list = subs(cd, isEnum); for (int i = 0; i < list.size(); i++) { cd = list.get(i); List<ClassDoc> tlist = subs(cd, isEnum); for (int j = 0; j < tlist.size(); j++) { ClassDoc tcd = tlist.get(j); if (!list.contains(tcd)) { list.add(tcd); } } } Collections.sort(list); return list; } /** * Return the base-classes list. This will have only one element namely * thw classdoc for java.lang.Object, since this is the base class for all * classes. */ public List<ClassDoc> baseclasses() { return baseclasses; } /** * Return the list of base interfaces. This is the list of interfaces * which do not have super-interface. */ public List<ClassDoc> baseinterfaces() { return baseinterfaces; } /** * Return the list of base enums. This is the list of enums * which do not have super-enums. */ public List<ClassDoc> baseEnums() { return baseEnums; } /** * Return the list of base annotation types. This is the list of * annotation types which do not have super-annotation types. */ public List<ClassDoc> baseAnnotationTypes() { return baseAnnotationTypes; } }
13,907
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ImplementedMethods.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java
/* * Copyright (c) 1999, 2008, 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.util; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Configuration; import java.util.*; /** * For a given class method, build an array of interface methods which it * implements. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar */ public class ImplementedMethods { private Map<MethodDoc,Type> interfaces = new HashMap<MethodDoc,Type>(); private List<MethodDoc> methlist = new ArrayList<MethodDoc>(); private Configuration configuration; private final ClassDoc classdoc; private final MethodDoc method; public ImplementedMethods(MethodDoc method, Configuration configuration) { this.method = method; this.configuration = configuration; classdoc = method.containingClass(); } /** * Return the array of interface methods which the method passed in the * constructor is implementing. The search/build order is as follows: * <pre> * 1. Search in all the immediate interfaces which this method's class is * implementing. Do it recursively for the superinterfaces as well. * 2. Traverse all the superclasses and search recursively in the * interfaces which those superclasses implement. *</pre> * * @return MethodDoc[] Array of implemented methods. */ public MethodDoc[] build(boolean sort) { buildImplementedMethodList(sort); return methlist.toArray(new MethodDoc[methlist.size()]); } public MethodDoc[] build() { return build(true); } public Type getMethodHolder(MethodDoc methodDoc) { return interfaces.get(methodDoc); } /** * Search for the method in the array of interfaces. If found check if it is * overridden by any other subinterface method which this class * implements. If it is not overidden, add it in the method list. * Do this recursively for all the extended interfaces for each interface * from the array passed. */ private void buildImplementedMethodList(boolean sort) { List<Type> intfacs = Util.getAllInterfaces(classdoc, configuration, sort); for (Iterator<Type> iter = intfacs.iterator(); iter.hasNext(); ) { Type interfaceType = iter.next(); MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); if (!overridingMethodFound(found)) { methlist.add(found); interfaces.put(found, interfaceType); } } } } /** * Search in the method list and check if it contains a method which * is overridden by the method as parameter. If found, remove the * overridden method from the method list. * * @param method Is this method overriding a method in the method list. */ private void removeOverriddenMethod(MethodDoc method) { ClassDoc overriddenClass = method.overriddenClass(); if (overriddenClass != null) { for (int i = 0; i < methlist.size(); i++) { ClassDoc cd = methlist.get(i).containingClass(); if (cd == overriddenClass || overriddenClass.subclassOf(cd)) { methlist.remove(i); // remove overridden method return; } } } } /** * Search in the already found methods' list and check if it contains * a method which is overriding the method parameter or is the method * parameter itself. * * @param method MethodDoc Method to be searched in the Method List for * an overriding method. */ private boolean overridingMethodFound(MethodDoc method) { ClassDoc containingClass = method.containingClass(); for (int i = 0; i < methlist.size(); i++) { MethodDoc listmethod = methlist.get(i); if (containingClass == listmethod.containingClass()) { // it's the same method. return true; } ClassDoc cd = listmethod.overriddenClass(); if (cd == null) { continue; } if (cd == containingClass || cd.subclassOf(containingClass)) { return true; } } return false; } }
5,716
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CommentedMethodFinder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java
/* * Copyright (c) 1999, 2003, 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.util; import com.sun.javadoc.*; /** * Find a commented method. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * */ public class CommentedMethodFinder extends MethodFinder { public boolean isCorrectMethod(MethodDoc method) { return method.inlineTags().length > 0; } }
1,619
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Group.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java
/* * Copyright (c) 1998, 2008, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; /** * Process and manage grouping of packages, as specified by "-group" option on * the command line. * <p> * For example, if user has used -group option as * -group "Core Packages" "java.*" -group "CORBA Packages" "org.omg.*", then * the packages specified on the command line will be grouped according to their * names starting with either "java." or "org.omg.". All the other packages * which do not fall in the user given groups, are grouped in default group, * named as either "Other Packages" or "Packages" depending upon if "-group" * option used or not at all used respectively. * </p> * <p> * Also the packages are grouped according to the longest possible match of * their names with the grouping information provided. For example, if there * are two groups, like -group "Lang" "java.lang" and -group "Core" "java.*", * will put the package java.lang in the group "Lang" and not in group "Core". * </p> * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar */ public class Group { /** * Map of regular expressions with the corresponding group name. */ private Map<String,String> regExpGroupMap = new HashMap<String,String>(); /** * List of regular expressions sorted according to the length. Regular * expression with longest length will be first in the sorted order. */ private List<String> sortedRegExpList = new ArrayList<String>(); /** * List of group names in the same order as given on the command line. */ private List<String> groupList = new ArrayList<String>(); /** * Map of non-regular expressions(possible package names) with the * corresponding group name. */ private Map<String,String> pkgNameGroupMap = new HashMap<String,String>(); /** * The global configuration information for this run. */ private final Configuration configuration; /** * Since we need to sort the keys in the reverse order(longest key first), * the compare method in the implementing class is doing the reverse * comparison. */ private static class MapKeyComparator implements Comparator<String> { public int compare(String key1, String key2) { return key2.length() - key1.length(); } } public Group(Configuration configuration) { this.configuration = configuration; } /** * Depending upon the format of the package name provided in the "-group" * option, generate two separate maps. There will be a map for mapping * regular expression(only meta character allowed is '*' and that is at the * end of the regular expression) on to the group name. And another map * for mapping (possible) package names(if the name format doesen't contain * meta character '*', then it is assumed to be a package name) on to the * group name. This will also sort all the regular expressions found in the * reverse order of their lengths, i.e. longest regular expression will be * first in the sorted list. * * @param groupname The name of the group from -group option. * @param pkgNameFormList List of the package name formats. */ public boolean checkPackageGroups(String groupname, String pkgNameFormList) { StringTokenizer strtok = new StringTokenizer(pkgNameFormList, ":"); if (groupList.contains(groupname)) { configuration.message.warning("doclet.Groupname_already_used", groupname); return false; } groupList.add(groupname); while (strtok.hasMoreTokens()) { String id = strtok.nextToken(); if (id.length() == 0) { configuration.message.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList); return false; } if (id.endsWith("*")) { id = id.substring(0, id.length() - 1); if (foundGroupFormat(regExpGroupMap, id)) { return false; } regExpGroupMap.put(id, groupname); sortedRegExpList.add(id); } else { if (foundGroupFormat(pkgNameGroupMap, id)) { return false; } pkgNameGroupMap.put(id, groupname); } } Collections.sort(sortedRegExpList, new MapKeyComparator()); return true; } /** * Search if the given map has given the package format. * * @param map Map to be searched. * @param pkgFormat The pacakge format to search. * * @return true if package name format found in the map, else false. */ boolean foundGroupFormat(Map<String,?> map, String pkgFormat) { if (map.containsKey(pkgFormat)) { configuration.message.error("doclet.Same_package_name_used", pkgFormat); return true; } return false; } /** * Group the packages according the grouping information provided on the * command line. Given a list of packages, search each package name in * regular expression map as well as package name map to get the * corresponding group name. Create another map with mapping of group name * to the package list, which will fall under the specified group. If any * package doesen't belong to any specified group on the comamnd line, then * a new group named "Other Packages" will be created for it. If there are * no groups found, in other words if "-group" option is not at all used, * then all the packages will be grouped under group "Packages". * * @param packages Packages specified on the command line. */ public Map<String,List<PackageDoc>> groupPackages(PackageDoc[] packages) { Map<String,List<PackageDoc>> groupPackageMap = new HashMap<String,List<PackageDoc>>(); String defaultGroupName = (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())? configuration.message.getText("doclet.Packages") : configuration.message.getText("doclet.Other_Packages"); // if the user has not used the default group name, add it if (!groupList.contains(defaultGroupName)) { groupList.add(defaultGroupName); } for (int i = 0; i < packages.length; i++) { PackageDoc pkg = packages[i]; String pkgName = pkg.name(); String groupName = pkgNameGroupMap.get(pkgName); // if this package is not explicitly assigned to a group, // try matching it to group specified by regular expression if (groupName == null) { groupName = regExpGroupName(pkgName); } // if it is in neither group map, put it in the default // group if (groupName == null) { groupName = defaultGroupName; } getPkgList(groupPackageMap, groupName).add(pkg); } return groupPackageMap; } /** * Search for package name in the sorted regular expression * list, if found return the group name. If not, return null. * * @param pkgName Name of package to be found in the regular * expression list. */ String regExpGroupName(String pkgName) { for (int j = 0; j < sortedRegExpList.size(); j++) { String regexp = sortedRegExpList.get(j); if (pkgName.startsWith(regexp)) { return regExpGroupMap.get(regexp); } } return null; } /** * For the given group name, return the package list, on which it is mapped. * Create a new list, if not found. * * @param map Map to be searched for gorup name. * @param groupname Group name to search. */ List<PackageDoc> getPkgList(Map<String,List<PackageDoc>> map, String groupname) { List<PackageDoc> list = map.get(groupname); if (list == null) { list = new ArrayList<PackageDoc>(); map.put(groupname, list); } return list; } /** * Return the list of groups, in the same order as specified * on the command line. */ public List<String> getGroupList() { return groupList; } }
9,769
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DeprecatedAPIListBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java
/* * Copyright (c) 1998, 2011, 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.util; import com.sun.javadoc.*; import java.util.*; import com.sun.tools.doclets.internal.toolkit.Configuration; /** * Build list of all the deprecated packages, classes, constructors, fields and methods. * * @author Atul M Dambalkar */ public class DeprecatedAPIListBuilder { public static final int NUM_TYPES = 12; public static final int PACKAGE = 0; public static final int INTERFACE = 1; public static final int CLASS = 2; public static final int ENUM = 3; public static final int EXCEPTION = 4; public static final int ERROR = 5; public static final int ANNOTATION_TYPE = 6; public static final int FIELD = 7; public static final int METHOD = 8; public static final int CONSTRUCTOR = 9; public static final int ENUM_CONSTANT = 10; public static final int ANNOTATION_TYPE_MEMBER = 11; /** * List of deprecated type Lists. */ private List<List<Doc>> deprecatedLists; /** * Constructor. * * @param configuration the current configuration of the doclet */ public DeprecatedAPIListBuilder(Configuration configuration) { deprecatedLists = new ArrayList<List<Doc>>(); for (int i = 0; i < NUM_TYPES; i++) { deprecatedLists.add(i, new ArrayList<Doc>()); } buildDeprecatedAPIInfo(configuration); } /** * Build the sorted list of all the deprecated APIs in this run. * Build separate lists for deprecated packages, classes, constructors, * methods and fields. * * @param configuration the current configuration of the doclet. */ private void buildDeprecatedAPIInfo(Configuration configuration) { PackageDoc[] packages = configuration.packages; PackageDoc pkg; for (int c = 0; c < packages.length; c++) { pkg = packages[c]; if (Util.isDeprecated(pkg)) { getList(PACKAGE).add(pkg); } } ClassDoc[] classes = configuration.root.classes(); for (int i = 0; i < classes.length; i++) { ClassDoc cd = classes[i]; if (Util.isDeprecated(cd)) { if (cd.isOrdinaryClass()) { getList(CLASS).add(cd); } else if (cd.isInterface()) { getList(INTERFACE).add(cd); } else if (cd.isException()) { getList(EXCEPTION).add(cd); } else if (cd.isEnum()) { getList(ENUM).add(cd); } else if (cd.isError()) { getList(ERROR).add(cd); } else if (cd.isAnnotationType()) { getList(ANNOTATION_TYPE).add(cd); } } composeDeprecatedList(getList(FIELD), cd.fields()); composeDeprecatedList(getList(METHOD), cd.methods()); composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors()); if (cd.isEnum()) { composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants()); } if (cd.isAnnotationType()) { composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER), ((AnnotationTypeDoc) cd).elements()); } } sortDeprecatedLists(); } /** * Add the members into a single list of deprecated members. * * @param list List of all the particular deprecated members, e.g. methods. * @param members members to be added in the list. */ private void composeDeprecatedList(List<Doc> list, MemberDoc[] members) { for (int i = 0; i < members.length; i++) { if (Util.isDeprecated(members[i])) { list.add(members[i]); } } } /** * Sort the deprecated lists for class kinds, fields, methods and * constructors. */ private void sortDeprecatedLists() { for (int i = 0; i < NUM_TYPES; i++) { Collections.sort(getList(i)); } } /** * Return the list of deprecated Doc objects of a given type. * * @param the constant representing the type of list being returned. */ public List<Doc> getList(int type) { return deprecatedLists.get(type); } /** * Return true if the list of a given type has size greater than 0. * * @param type the type of list being checked. */ public boolean hasDocumentation(int type) { return (deprecatedLists.get(type)).size() > 0; } }
5,799
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
IndexBuilder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java
/* * Copyright (c) 1998, 2011, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.*; /** * Build the mapping of each Unicode character with it's member lists * containing members names starting with it. Also build a list for all the * Unicode characters which start a member name. Member name is * classkind or field or method or constructor name. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @since 1.2 * @see java.lang.Character * @author Atul M Dambalkar */ public class IndexBuilder { /** * Mapping of each Unicode Character with the member list containing * members with names starting with it. */ private Map<Character,List<Doc>> indexmap = new HashMap<Character,List<Doc>>(); /** * Don't generate deprecated information if true. */ private boolean noDeprecated; /** * Build this Index only for classes? */ private boolean classesOnly; // make ProgramElementDoc[] when new toArray is available protected final Object[] elements; /** * A comparator used to sort classes and members. * Note: Maybe this compare code belongs in the tool? */ private class DocComparator implements Comparator<Doc> { public int compare(Doc d1, Doc d2) { String doc1 = d1.name(); String doc2 = d2.name(); int compareResult; if ((compareResult = doc1.compareToIgnoreCase(doc2)) != 0) { return compareResult; } else if (d1 instanceof ProgramElementDoc && d2 instanceof ProgramElementDoc) { doc1 = (((ProgramElementDoc) d1).qualifiedName()); doc2 = (((ProgramElementDoc) d2).qualifiedName()); return doc1.compareToIgnoreCase(doc2); } else { return 0; } } } /** * Constructor. Build the index map. * * @param configuration the current configuration of the doclet. * @param noDeprecated true if -nodeprecated option is used, * false otherwise. */ public IndexBuilder(Configuration configuration, boolean noDeprecated) { this(configuration, noDeprecated, false); } /** * Constructor. Build the index map. * * @param configuration the current configuration of the doclet. * @param noDeprecated true if -nodeprecated option is used, * false otherwise. * @param classesOnly Include only classes in index. */ public IndexBuilder(Configuration configuration, boolean noDeprecated, boolean classesOnly) { if (classesOnly) { configuration.message.notice("doclet.Building_Index_For_All_Classes"); } else { configuration.message.notice("doclet.Building_Index"); } this.noDeprecated = noDeprecated; this.classesOnly = classesOnly; buildIndexMap(configuration.root); Set<Character> set = indexmap.keySet(); elements = set.toArray(); Arrays.sort(elements); } /** * Sort the index map. Traverse the index map for all it's elements and * sort each element which is a list. */ protected void sortIndexMap() { for (Iterator<List<Doc>> it = indexmap.values().iterator(); it.hasNext(); ) { Collections.sort(it.next(), new DocComparator()); } } /** * Get all the members in all the Packages and all the Classes * given on the command line. Form separate list of those members depending * upon their names. * * @param root Root of the documemt. */ protected void buildIndexMap(RootDoc root) { PackageDoc[] packages = root.specifiedPackages(); ClassDoc[] classes = root.classes(); if (!classesOnly) { if (packages.length == 0) { Set<PackageDoc> set = new HashSet<PackageDoc>(); PackageDoc pd; for (int i = 0; i < classes.length; i++) { pd = classes[i].containingPackage(); if (pd != null && pd.name().length() > 0) { set.add(pd); } } adjustIndexMap(set.toArray(packages)); } else { adjustIndexMap(packages); } } adjustIndexMap(classes); if (!classesOnly) { for (int i = 0; i < classes.length; i++) { if (shouldAddToIndexMap(classes[i])) { putMembersInIndexMap(classes[i]); } } } sortIndexMap(); } /** * Put all the members(fields, methods and constructors) in the classdoc * to the indexmap. * * @param classdoc ClassDoc whose members will be added to the indexmap. */ protected void putMembersInIndexMap(ClassDoc classdoc) { adjustIndexMap(classdoc.fields()); adjustIndexMap(classdoc.methods()); adjustIndexMap(classdoc.constructors()); } /** * Adjust list of members according to their names. Check the first * character in a member name, and then add the member to a list of members * for that particular unicode character. * * @param elements Array of members. */ protected void adjustIndexMap(Doc[] elements) { for (int i = 0; i < elements.length; i++) { if (shouldAddToIndexMap(elements[i])) { String name = elements[i].name(); char ch = (name.length()==0)? '*' : Character.toUpperCase(name.charAt(0)); Character unicode = new Character(ch); List<Doc> list = indexmap.get(unicode); if (list == null) { list = new ArrayList<Doc>(); indexmap.put(unicode, list); } list.add(elements[i]); } } } /** * Should this doc element be added to the index map? */ protected boolean shouldAddToIndexMap(Doc element) { if (element instanceof PackageDoc) // Do not add to index map if -nodeprecated option is set and the // package is marked as deprecated. return !(noDeprecated && Util.isDeprecated(element)); else // Do not add to index map if -nodeprecated option is set and if the // Doc is marked as deprecated or the containing package is marked as // deprecated. return !(noDeprecated && (Util.isDeprecated(element) || Util.isDeprecated(((ProgramElementDoc)element).containingPackage()))); } /** * Return a map of all the individual member lists with Unicode character. * * @return Map index map. */ public Map<Character,List<Doc>> getIndexMap() { return indexmap; } /** * Return the sorted list of members, for passed Unicode Character. * * @param index index Unicode character. * @return List member list for specific Unicode character. */ public List<Doc> getMemberList(Character index) { return indexmap.get(index); } /** * Array of IndexMap keys, Unicode characters. */ public Object[] elements() { return elements; } }
8,766
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TaggedMethodFinder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java
/* * Copyright (c) 1999, 2003, 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.util; import com.sun.javadoc.*; /** * Find a tagged method. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar */ public class TaggedMethodFinder extends MethodFinder { public boolean isCorrectMethod(MethodDoc method) { return method.paramTags().length + method.tags("return").length + method.throwsTags().length + method.seeTags().length > 0; } }
1,741
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourcePath.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java
/* * Copyright (c) 1998, 2003, 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.util; import java.io.File; /** * This class is used to represent a source path which can contain only * directories no zip files. If a zip file is specified in the command line it * will not get reflected in the SourcePath. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar */ public class SourcePath { private final char dirSeparator = File.pathSeparatorChar; /** * The original class path string */ private String pathstr; /** * List of source path entries. Each entry is a directory. */ private File[] sourcePath; /** * Build a source path from the specified path string on the command line. */ public SourcePath(String pathstr) { init(pathstr); } /** * Build a default source path from the path strings specified by * the properties env.class.path. */ public SourcePath() { init(System.getProperty("env.class.path")); } /** * Initialize the SourcePath File array, which will contain only the * directory names from the given path string. * * @param pathstr Path String. */ private void init(String pathstr) { if (pathstr == null || pathstr.length() == 0) { pathstr = "."; } int noOfFileSep = 0; int index = 0; this.pathstr = pathstr; // Save original class path string // Count the number of path separators while ((index = pathstr.indexOf(dirSeparator, index)) != -1) { noOfFileSep++; index++; } // Build the source path File[] tempPath = new File[noOfFileSep + 1]; int tempPathIndex = 0; int len = pathstr.length(); int sepPos = 0; for (index = 0; index < len; index = sepPos + 1) { sepPos = pathstr.indexOf(dirSeparator, index); if (sepPos < 0) { sepPos = len; } File file = new File(pathstr.substring(index, sepPos)); if (file.isDirectory()) { tempPath[tempPathIndex++] = file; } // if it is really a file, ignore it. } sourcePath = new File[tempPathIndex]; System.arraycopy((Object)tempPath, 0, (Object)sourcePath, 0, tempPathIndex); } /** * Find the specified directory in the source path. * * @param name Name of the directory to be searched for in the source path. * @return File Return the directory if found else return null. */ public File getDirectory(String name) { for (int i = 0; i < sourcePath.length; i++) { File directoryNeeded = new File(sourcePath[i], name); if (directoryNeeded.isDirectory()) { return directoryNeeded; } } return null; } /** * Return original source path string. */ public String toString() { return pathstr; } }
4,321
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodFinder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java
/* * Copyright (c) 1999, 2004, 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.util; import com.sun.javadoc.*; /** * This class is useful for searching a method which has documentation * comment and documentation tags. The method is searched in all the * superclasses and interfaces(subsequently super-interfaces also) * recursively. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API. */ public abstract class MethodFinder { abstract boolean isCorrectMethod(MethodDoc method); public MethodDoc search(ClassDoc cd, MethodDoc method) { MethodDoc meth = searchInterfaces(cd, method); if (meth != null) { return meth; } ClassDoc icd = cd.superclass(); if (icd != null) { meth = Util.findMethod(icd, method); if (meth != null) { if (isCorrectMethod(meth)) { return meth; } } return search(icd, method); } return null; } public MethodDoc searchInterfaces(ClassDoc cd, MethodDoc method) { MethodDoc[] implementedMethods = (new ImplementedMethods(method, null)).build(); for (int i = 0; i < implementedMethods.length; i++) { if (isCorrectMethod(implementedMethods[i])) { return implementedMethods[i]; } } return null; } }
2,629
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageListWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
/* * Copyright (c) 1998, 2011, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; import java.util.*; /** * Write out the package index. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @see com.sun.javadoc.PackageDoc * @author Atul M Dambalkar */ public class PackageListWriter extends PrintWriter { private Configuration configuration; /** * Constructor. * * @param configuration the current configuration of the doclet. */ public PackageListWriter(Configuration configuration) throws IOException { super(Util.genWriter(configuration, configuration.destDirName, DocletConstants.PACKAGE_LIST_FILE_NAME, configuration.docencoding)); this.configuration = configuration; } /** * Generate the package index. * * @param configuration the current configuration of the doclet. * @throws DocletAbortException */ public static void generate(Configuration configuration) { PackageListWriter packgen; try { packgen = new PackageListWriter(configuration); packgen.generatePackageListFile(configuration.root); packgen.close(); } catch (IOException exc) { configuration.message.error("doclet.exception_encountered", exc.toString(), DocletConstants.PACKAGE_LIST_FILE_NAME); throw new DocletAbortException(); } } protected void generatePackageListFile(RootDoc root) { PackageDoc[] packages = configuration.packages; ArrayList<String> names = new ArrayList<String>(); for (int i = 0; i < packages.length; i++) { // if the -nodeprecated option is set and the package is marked as // deprecated, do not include it in the packages list. if (!(configuration.nodeprecated && Util.isDeprecated(packages[i]))) names.add(packages[i].name()); } Collections.sort(names); for (int i = 0; i < names.size(); i++) { println(names.get(i)); } } }
3,413
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Util.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
/* * Copyright (c) 1999, 2011, 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.util; import java.io.*; import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; /** * Utilities Class for Doclets. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar * @author Jamie Ho */ public class Util { /** * A mapping between characters and their * corresponding HTML escape character. */ public static final String[][] HTML_ESCAPE_CHARS = {{"&", "&amp;"}, {"<", "&lt;"}, {">", "&gt;"}}; /** * Name of the resource directory. */ public static final String RESOURCESDIR = "resources"; /** * Return array of class members whose documentation is to be generated. * If the member is deprecated do not include such a member in the * returned array. * * @param members Array of members to choose from. * @return ProgramElementDoc[] Array of eligible members for whom * documentation is getting generated. */ public static ProgramElementDoc[] excludeDeprecatedMembers( ProgramElementDoc[] members) { return toProgramElementDocArray(excludeDeprecatedMembersAsList(members)); } /** * Return array of class members whose documentation is to be generated. * If the member is deprecated do not include such a member in the * returned array. * * @param members Array of members to choose from. * @return List List of eligible members for whom * documentation is getting generated. */ public static List<ProgramElementDoc> excludeDeprecatedMembersAsList( ProgramElementDoc[] members) { List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>(); for (int i = 0; i < members.length; i++) { if (members[i].tags("deprecated").length == 0) { list.add(members[i]); } } Collections.sort(list); return list; } /** * Return the list of ProgramElementDoc objects as Array. */ public static ProgramElementDoc[] toProgramElementDocArray(List<ProgramElementDoc> list) { ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()]; for (int i = 0; i < list.size(); i++) { pgmarr[i] = list.get(i); } return pgmarr; } /** * Return true if a non-public member found in the given array. * * @param members Array of members to look into. * @return boolean True if non-public member found, false otherwise. */ public static boolean nonPublicMemberFound(ProgramElementDoc[] members) { for (int i = 0; i < members.length; i++) { if (!members[i].isPublic()) { return true; } } return false; } /** * Search for the given method in the given class. * * @param cd Class to search into. * @param method Method to be searched. * @return MethodDoc Method found, null otherwise. */ public static MethodDoc findMethod(ClassDoc cd, MethodDoc method) { MethodDoc[] methods = cd.methods(); for (int i = 0; i < methods.length; i++) { if (executableMembersEqual(method, methods[i])) { return methods[i]; } } return null; } /** * @param member1 the first method to compare. * @param member2 the second method to compare. * @return true if member1 overrides/hides or is overriden/hidden by member2. */ public static boolean executableMembersEqual(ExecutableMemberDoc member1, ExecutableMemberDoc member2) { if (! (member1 instanceof MethodDoc && member2 instanceof MethodDoc)) return false; MethodDoc method1 = (MethodDoc) member1; MethodDoc method2 = (MethodDoc) member2; if (method1.isStatic() && method2.isStatic()) { Parameter[] targetParams = method1.parameters(); Parameter[] currentParams; if (method1.name().equals(method2.name()) && (currentParams = method2.parameters()).length == targetParams.length) { int j; for (j = 0; j < targetParams.length; j++) { if (! (targetParams[j].typeName().equals( currentParams[j].typeName()) || currentParams[j].type() instanceof TypeVariable || targetParams[j].type() instanceof TypeVariable)) { break; } } if (j == targetParams.length) { return true; } } return false; } else { return method1.overrides(method2) || method2.overrides(method1) || member1 == member2; } } /** * According to * <cite>The Java&trade; Language Specification</cite>, * all the outer classes and static inner classes are core classes. */ public static boolean isCoreClass(ClassDoc cd) { return cd.containingClass() == null || cd.isStatic(); } public static boolean matches(ProgramElementDoc doc1, ProgramElementDoc doc2) { if (doc1 instanceof ExecutableMemberDoc && doc2 instanceof ExecutableMemberDoc) { ExecutableMemberDoc ed1 = (ExecutableMemberDoc)doc1; ExecutableMemberDoc ed2 = (ExecutableMemberDoc)doc2; return executableMembersEqual(ed1, ed2); } else { return doc1.name().equals(doc2.name()); } } /** * Copy source file to destination file. * * @throws SecurityException * @throws IOException */ public static void copyFile(File destfile, File srcfile) throws IOException { byte[] bytearr = new byte[512]; int len = 0; FileInputStream input = new FileInputStream(srcfile); File destDir = destfile.getParentFile(); destDir.mkdirs(); FileOutputStream output = new FileOutputStream(destfile); try { while ((len = input.read(bytearr)) != -1) { output.write(bytearr, 0, len); } } catch (FileNotFoundException exc) { } catch (SecurityException exc) { } finally { input.close(); output.close(); } } /** * Copy the given directory contents from the source package directory * to the generated documentation directory. For example for a package * java.lang this method find out the source location of the package using * {@link SourcePath} and if given directory is found in the source * directory structure, copy the entire directory, to the generated * documentation hierarchy. * * @param configuration The configuration of the current doclet. * @param path The relative path to the directory to be copied. * @param dir The original directory name to copy from. * @param overwrite Overwrite files if true. */ public static void copyDocFiles(Configuration configuration, String path, String dir, boolean overwrite) { if (checkCopyDocFilesErrors(configuration, path, dir)) { return; } String destname = configuration.docFileDestDirName; File srcdir = new File(path + dir); if (destname.length() > 0 && !destname.endsWith( DirectoryManager.URL_FILE_SEPARATOR)) { destname += DirectoryManager.URL_FILE_SEPARATOR; } String dest = destname + dir; try { File destdir = new File(dest); DirectoryManager.createDirectory(configuration, dest); String[] files = srcdir.list(); for (int i = 0; i < files.length; i++) { File srcfile = new File(srcdir, files[i]); File destfile = new File(destdir, files[i]); if (srcfile.isFile()) { if(destfile.exists() && ! overwrite) { configuration.message.warning((SourcePosition) null, "doclet.Copy_Overwrite_warning", srcfile.toString(), destdir.toString()); } else { configuration.message.notice( "doclet.Copying_File_0_To_Dir_1", srcfile.toString(), destdir.toString()); Util.copyFile(destfile, srcfile); } } else if(srcfile.isDirectory()) { if(configuration.copydocfilesubdirs && ! configuration.shouldExcludeDocFileDir( srcfile.getName())){ copyDocFiles(configuration, path, dir + DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(), overwrite); } } } } catch (SecurityException exc) { throw new DocletAbortException(); } catch (IOException exc) { throw new DocletAbortException(); } } /** * Given the parameters for copying doc-files, check for errors. * * @param configuration The configuration of the current doclet. * @param path The relative path to the directory to be copied. * @param dirName The original directory name to copy from. */ private static boolean checkCopyDocFilesErrors (Configuration configuration, String path, String dirName) { if ((configuration.sourcepath == null || configuration.sourcepath.length() == 0) && (configuration.destDirName == null || configuration.destDirName.length() == 0)) { //The destination path and source path are definitely equal. return true; } File sourcePath, destPath = new File(configuration.destDirName); StringTokenizer pathTokens = new StringTokenizer( configuration.sourcepath == null ? "" : configuration.sourcepath, File.pathSeparator); //Check if the destination path is equal to the source path. If yes, //do not copy doc-file directories. while(pathTokens.hasMoreTokens()){ sourcePath = new File(pathTokens.nextToken()); if(destPath.equals(sourcePath)){ return true; } } //Make sure the doc-file being copied exists. File srcdir = new File(path + dirName); if (! srcdir.exists()) { return true; } return false; } /** * Copy a file in the resources directory to the destination * directory (if it is not there already). If * <code>overwrite</code> is true and the destination file * already exists, overwrite it. * * @param configuration Holds the destination directory and error message * @param resourcefile The name of the resource file to copy * @param overwrite A flag to indicate whether the file in the * destination directory will be overwritten if * it already exists. */ public static void copyResourceFile(Configuration configuration, String resourcefile, boolean overwrite) { String destresourcesdir = configuration.destDirName + RESOURCESDIR; copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir, overwrite, false); } /** * Copy a file from a source directory to a destination directory * (if it is not there already). If <code>overwrite</code> is true and * the destination file already exists, overwrite it. * * @param configuration Holds the error message * @param file The name of the file to copy * @param source The source directory * @param destination The destination directory where the file needs to be copied * @param overwrite A flag to indicate whether the file in the * destination directory will be overwritten if * it already exists. * @param replaceNewLine true if the newline needs to be replaced with platform- * specific newline. */ public static void copyFile(Configuration configuration, String file, String source, String destination, boolean overwrite, boolean replaceNewLine) { DirectoryManager.createDirectory(configuration, destination); File destfile = new File(destination, file); if(destfile.exists() && (! overwrite)) return; try { InputStream in = Configuration.class.getResourceAsStream( source + DirectoryManager.URL_FILE_SEPARATOR + file); if(in==null) return; OutputStream out = new FileOutputStream(destfile); try { if (!replaceNewLine) { byte[] buf = new byte[2048]; int n; while((n = in.read(buf))>0) out.write(buf,0,n); } else { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out)); try { String line; while ((line = reader.readLine()) != null) { writer.write(line); writer.write(DocletConstants.NL); } } finally { reader.close(); writer.close(); } } } finally { in.close(); out.close(); } } catch (IOException ie) { ie.printStackTrace(System.err); throw new DocletAbortException(); } } /** * Given a PackageDoc, return the source path for that package. * @param configuration The Configuration for the current Doclet. * @param pkgDoc The package to seach the path for. * @return A string representing the path to the given package. */ public static String getPackageSourcePath(Configuration configuration, PackageDoc pkgDoc){ try{ String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc); String completePath = new SourcePath(configuration.sourcepath). getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR; //Make sure that both paths are using the same separators. completePath = Util.replaceText(completePath, File.separator, DirectoryManager.URL_FILE_SEPARATOR); pkgPath = Util.replaceText(pkgPath, File.separator, DirectoryManager.URL_FILE_SEPARATOR); return completePath.substring(0, completePath.lastIndexOf(pkgPath)); } catch (Exception e){ return ""; } } /** * We want the list of types in alphabetical order. However, types are not * comparable. We need a comparator for now. */ private static class TypeComparator implements Comparator<Type> { public int compare(Type type1, Type type2) { return type1.qualifiedTypeName().toLowerCase().compareTo( type2.qualifiedTypeName().toLowerCase()); } } /** * For the class return all implemented interfaces including the * superinterfaces of the implementing interfaces, also iterate over for * all the superclasses. For interface return all the extended interfaces * as well as superinterfaces for those extended interfaces. * * @param type type whose implemented or * super interfaces are sought. * @param configuration the current configuration of the doclet. * @param sort if true, return list of interfaces sorted alphabetically. * @return List of all the required interfaces. */ public static List<Type> getAllInterfaces(Type type, Configuration configuration, boolean sort) { Map<ClassDoc,Type> results = sort ? new TreeMap<ClassDoc,Type>() : new LinkedHashMap<ClassDoc,Type>(); Type[] interfaceTypes = null; Type superType = null; if (type instanceof ParameterizedType) { interfaceTypes = ((ParameterizedType) type).interfaceTypes(); superType = ((ParameterizedType) type).superclassType(); } else if (type instanceof ClassDoc) { interfaceTypes = ((ClassDoc) type).interfaceTypes(); superType = ((ClassDoc) type).superclassType(); } else { interfaceTypes = type.asClassDoc().interfaceTypes(); superType = type.asClassDoc().superclassType(); } for (int i = 0; i < interfaceTypes.length; i++) { Type interfaceType = interfaceTypes[i]; ClassDoc interfaceClassDoc = interfaceType.asClassDoc(); if (! (interfaceClassDoc.isPublic() || (configuration == null || isLinkable(interfaceClassDoc, configuration)))) { continue; } results.put(interfaceClassDoc, interfaceType); List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration, sort); for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) { Type t = iter.next(); results.put(t.asClassDoc(), t); } } if (superType == null) return new ArrayList<Type>(results.values()); //Try walking the tree. addAllInterfaceTypes(results, superType, superType instanceof ClassDoc ? ((ClassDoc) superType).interfaceTypes() : ((ParameterizedType) superType).interfaceTypes(), false, configuration); List<Type> resultsList = new ArrayList<Type>(results.values()); if (sort) { Collections.sort(resultsList, new TypeComparator()); } return resultsList; } public static List<Type> getAllInterfaces(Type type, Configuration configuration) { return getAllInterfaces(type, configuration, true); } private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ClassDoc c, boolean raw, Configuration configuration) { Type superType = c.superclassType(); if (superType == null) return; addAllInterfaceTypes(results, superType, superType instanceof ClassDoc ? ((ClassDoc) superType).interfaceTypes() : ((ParameterizedType) superType).interfaceTypes(), raw, configuration); } private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ParameterizedType p, Configuration configuration) { Type superType = p.superclassType(); if (superType == null) return; addAllInterfaceTypes(results, superType, superType instanceof ClassDoc ? ((ClassDoc) superType).interfaceTypes() : ((ParameterizedType) superType).interfaceTypes(), false, configuration); } private static void addAllInterfaceTypes(Map<ClassDoc,Type> results, Type type, Type[] interfaceTypes, boolean raw, Configuration configuration) { for (int i = 0; i < interfaceTypes.length; i++) { Type interfaceType = interfaceTypes[i]; ClassDoc interfaceClassDoc = interfaceType.asClassDoc(); if (! (interfaceClassDoc.isPublic() || (configuration != null && isLinkable(interfaceClassDoc, configuration)))) { continue; } if (raw) interfaceType = interfaceType.asClassDoc(); results.put(interfaceClassDoc, interfaceType); List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration); for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) { Type superInterface = iter.next(); results.put(superInterface.asClassDoc(), superInterface); } } if (type instanceof ParameterizedType) findAllInterfaceTypes(results, (ParameterizedType) type, configuration); else if (((ClassDoc) type).typeParameters().length == 0) findAllInterfaceTypes(results, (ClassDoc) type, raw, configuration); else findAllInterfaceTypes(results, (ClassDoc) type, true, configuration); } /** * Enclose in quotes, used for paths and filenames that contains spaces */ public static String quote(String filepath) { return ("\"" + filepath + "\""); } /** * Given a package, return it's name. * @param packageDoc the package to check. * @return the name of the given package. */ public static String getPackageName(PackageDoc packageDoc) { return packageDoc == null || packageDoc.name().length() == 0 ? DocletConstants.DEFAULT_PACKAGE_NAME : packageDoc.name(); } /** * Given a package, return it's file name without the extension. * @param packageDoc the package to check. * @return the file name of the given package. */ public static String getPackageFileHeadName(PackageDoc packageDoc) { return packageDoc == null || packageDoc.name().length() == 0 ? DocletConstants.DEFAULT_PACKAGE_FILE_NAME : packageDoc.name(); } /** * Given a string, replace all occurraces of 'newStr' with 'oldStr'. * @param originalStr the string to modify. * @param oldStr the string to replace. * @param newStr the string to insert in place of the old string. */ public static String replaceText(String originalStr, String oldStr, String newStr) { if (oldStr == null || newStr == null || oldStr.equals(newStr)) { return originalStr; } return originalStr.replace(oldStr, newStr); } /** * Given a string, escape all special html characters and * return the result. * * @param s The string to check. * @return the original string with all of the HTML characters * escaped. * * @see #HTML_ESCAPE_CHARS */ public static String escapeHtmlChars(String s) { String result = s; for (int i = 0; i < HTML_ESCAPE_CHARS.length; i++) { result = Util.replaceText(result, HTML_ESCAPE_CHARS[i][0], HTML_ESCAPE_CHARS[i][1]); } return result; } /** * Given a string, strips all html characters and * return the result. * * @param rawString The string to check. * @return the original string with all of the HTML characters * stripped. * */ public static String stripHtml(String rawString) { // remove HTML tags rawString = rawString.replaceAll("\\<.*?>", " "); // consolidate multiple spaces between a word to a single space rawString = rawString.replaceAll("\\b\\s{2,}\\b", " "); // remove extra whitespaces return rawString.trim(); } /** * Create the directory path for the file to be generated, construct * FileOutputStream and OutputStreamWriter depending upon docencoding. * * @param path The directory path to be created for this file. * @param filename File Name to which the PrintWriter will do the Output. * @param docencoding Encoding to be used for this file. * @exception IOException Exception raised by the FileWriter is passed on * to next level. * @exception UnsupportedEncodingException Exception raised by the * OutputStreamWriter is passed on to next level. * @return Writer Writer for the file getting generated. * @see java.io.FileOutputStream * @see java.io.OutputStreamWriter */ public static Writer genWriter(Configuration configuration, String path, String filename, String docencoding) throws IOException, UnsupportedEncodingException { FileOutputStream fos; if (path != null) { DirectoryManager.createDirectory(configuration, path); fos = new FileOutputStream(((path.length() > 0)? path + File.separator: "") + filename); } else { fos = new FileOutputStream(filename); } if (docencoding == null) { return new OutputStreamWriter(fos); } else { return new OutputStreamWriter(fos, docencoding); } } /** * Given an annotation, return true if it should be documented and false * otherwise. * * @param annotationDoc the annotation to check. * * @return true return true if it should be documented and false otherwise. */ public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { AnnotationDesc[] annotationDescList = annotationDoc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.annotation.Documented.class.getName())){ return true; } } return false; } /** * Given a string, return an array of tokens. The separator can be escaped * with the '\' character. The '\' character may also be escaped by the * '\' character. * * @param s the string to tokenize. * @param separator the separator char. * @param maxTokens the maxmimum number of tokens returned. If the * max is reached, the remaining part of s is appended * to the end of the last token. * * @return an array of tokens. */ public static String[] tokenize(String s, char separator, int maxTokens) { List<String> tokens = new ArrayList<String>(); StringBuilder token = new StringBuilder (); boolean prevIsEscapeChar = false; for (int i = 0; i < s.length(); i += Character.charCount(i)) { int currentChar = s.codePointAt(i); if (prevIsEscapeChar) { // Case 1: escaped character token.appendCodePoint(currentChar); prevIsEscapeChar = false; } else if (currentChar == separator && tokens.size() < maxTokens-1) { // Case 2: separator tokens.add(token.toString()); token = new StringBuilder(); } else if (currentChar == '\\') { // Case 3: escape character prevIsEscapeChar = true; } else { // Case 4: regular character token.appendCodePoint(currentChar); } } if (token.length() > 0) { tokens.add(token.toString()); } return tokens.toArray(new String[] {}); } /** * Return true if this class is linkable and false if we can't link to the * desired class. * <br> * <b>NOTE:</b> You can only link to external classes if they are public or * protected. * * @param classDoc the class to check. * @param configuration the current configuration of the doclet. * * @return true if this class is linkable and false if we can't link to the * desired class. */ public static boolean isLinkable(ClassDoc classDoc, Configuration configuration) { return ((classDoc.isIncluded() && configuration.isGeneratedDoc(classDoc))) || (configuration.extern.isExternal(classDoc) && (classDoc.isPublic() || classDoc.isProtected())); } /** * Given a class, return the closest visible super class. * * @param classDoc the class we are searching the parent for. * @param configuration the current configuration of the doclet. * @return the closest visible super class. Return null if it cannot * be found (i.e. classDoc is java.lang.Object). */ public static Type getFirstVisibleSuperClass(ClassDoc classDoc, Configuration configuration) { if (classDoc == null) { return null; } Type sup = classDoc.superclassType(); ClassDoc supClassDoc = classDoc.superclass(); while (sup != null && (! (supClassDoc.isPublic() || isLinkable(supClassDoc, configuration))) ) { if (supClassDoc.superclass().qualifiedName().equals(supClassDoc.qualifiedName())) break; sup = supClassDoc.superclassType(); supClassDoc = supClassDoc.superclass(); } if (classDoc.equals(supClassDoc)) { return null; } return sup; } /** * Given a class, return the closest visible super class. * * @param classDoc the class we are searching the parent for. * @param configuration the current configuration of the doclet. * @return the closest visible super class. Return null if it cannot * be found (i.e. classDoc is java.lang.Object). */ public static ClassDoc getFirstVisibleSuperClassCD(ClassDoc classDoc, Configuration configuration) { if (classDoc == null) { return null; } ClassDoc supClassDoc = classDoc.superclass(); while (supClassDoc != null && (! (supClassDoc.isPublic() || isLinkable(supClassDoc, configuration))) ) { supClassDoc = supClassDoc.superclass(); } if (classDoc.equals(supClassDoc)) { return null; } return supClassDoc; } /** * Given a ClassDoc, return the name of its type (Class, Interface, etc.). * * @param cd the ClassDoc to check. * @param lowerCaseOnly true if you want the name returned in lower case. * If false, the first letter of the name is capatilized. * @return */ public static String getTypeName(Configuration config, ClassDoc cd, boolean lowerCaseOnly) { String typeName = ""; if (cd.isOrdinaryClass()) { typeName = "doclet.Class"; } else if (cd.isInterface()) { typeName = "doclet.Interface"; } else if (cd.isException()) { typeName = "doclet.Exception"; } else if (cd.isError()) { typeName = "doclet.Error"; } else if (cd.isAnnotationType()) { typeName = "doclet.AnnotationType"; } else if (cd.isEnum()) { typeName = "doclet.Enum"; } return config.getText( lowerCaseOnly ? typeName.toLowerCase() : typeName); } /** * Given a string, replace all tabs with the appropriate * number of spaces. * @param tabLength the length of each tab. * @param s the String to scan. */ public static void replaceTabs(int tabLength, StringBuilder s) { if (whitespace == null || whitespace.length() < tabLength) whitespace = String.format("%" + tabLength + "s", " "); int index = 0; while ((index = s.indexOf("\t", index)) != -1) { int spaceCount = tabLength - index % tabLength; s.replace(index, index+1, whitespace.substring(0, spaceCount)); index += spaceCount; } } private static String whitespace; /** * The documentation for values() and valueOf() in Enums are set by the * doclet. */ public static void setEnumDocumentation(Configuration configuration, ClassDoc classDoc) { MethodDoc[] methods = classDoc.methods(); for (int j = 0; j < methods.length; j++) { MethodDoc currentMethod = methods[j]; if (currentMethod.name().equals("values") && currentMethod.parameters().length == 0) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_values_doc", classDoc.name())); } else if (currentMethod.name().equals("valueOf") && currentMethod.parameters().length == 1) { Type paramType = currentMethod.parameters()[0].type(); if (paramType != null && paramType.qualifiedTypeName().equals(String.class.getName())) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_valueof_doc")); } } } } /** * Return true if the given Doc is deprecated. * * @param doc the Doc to check. * @return true if the given Doc is deprecated. */ public static boolean isDeprecated(Doc doc) { if (doc.tags("deprecated").length > 0) { return true; } AnnotationDesc[] annotationDescList; if (doc instanceof PackageDoc) annotationDescList = ((PackageDoc)doc).annotations(); else annotationDescList = ((ProgramElementDoc)doc).annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.Deprecated.class.getName())){ return true; } } return false; } }
35,378
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DocFinder.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java
/* * Copyright (c) 2003, 2008, 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.util; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import java.util.*; /** * Search for the requested documentation. Inherit documentation if necessary. * * @author Jamie Ho * @since 1.5 */ public class DocFinder { /** * The class that encapsulates the input. */ public static class Input { /** * The method to search documentation from. */ public MethodDoc method = null; /** * The taglet to search for documentation on behalf of. Null if we want * to search for overall documentation. */ public InheritableTaglet taglet = null; /** * The id of the tag to retrieve documentation for. */ public String tagId = null; /** * The tag to retrieve documentation for. This is only used for the * inheritDoc tag. */ public Tag tag = null; /** * True if we only want to search for the first sentence. */ public boolean isFirstSentence = false; /** * True if we are looking for documentation to replace the inheritDocTag. */ public boolean isInheritDocTag = false; /** * Used to distinguish between type variable param tags and regular * param tags. */ public boolean isTypeVariableParamTag = false; public Input() {} public Input(MethodDoc method, InheritableTaglet taglet, Tag tag, boolean isFirstSentence, boolean isInheritDocTag) { this.method = method; this.taglet = taglet; this.tag = tag; this.isFirstSentence = isFirstSentence; this.isInheritDocTag = isInheritDocTag; } public Input(MethodDoc method, InheritableTaglet taglet, String tagId) { this.method = method; this.taglet = taglet; this.tagId = tagId; } public Input(MethodDoc method, InheritableTaglet taglet, String tagId, boolean isTypeVariableParamTag) { this.method = method; this.taglet = taglet; this.tagId = tagId; this.isTypeVariableParamTag = isTypeVariableParamTag; } public Input(MethodDoc method, InheritableTaglet taglet) { this.method = method; this.taglet = taglet; } public Input(MethodDoc method) { this.method = method; } public Input(MethodDoc method, boolean isFirstSentence) { this.method = method; this.isFirstSentence = isFirstSentence; } public Input copy() { Input clone = new Input(); clone.method = this.method; clone.taglet = this.taglet; clone.tagId = this.tagId; clone.tag = this.tag; clone.isFirstSentence = this.isFirstSentence; clone.isInheritDocTag = this.isInheritDocTag; clone.isTypeVariableParamTag = this.isTypeVariableParamTag; return clone; } } /** * The class that encapsulates the output. */ public static class Output { /** * The tag that holds the documentation. Null if documentation * is not held by a tag. */ public Tag holderTag; /** * The Doc object that holds the documentation. */ public Doc holder; /** * The inherited documentation. */ public Tag[] inlineTags = new Tag[] {}; /** * False if documentation could not be inherited. */ public boolean isValidInheritDocTag = true; /** * When automatically inheriting throws tags, you sometime must inherit * more than one tag. For example if the method declares that it throws * IOException and the overidden method has throws tags for IOException and * ZipException, both tags would be inherited because ZipException is a * subclass of IOException. This subclass of DocFinder.Output allows * multiple tag inheritence. */ public List<Tag> tagList = new ArrayList<Tag>(); } /** * Search for the requested comments in the given method. If it does not * have comments, return documentation from the overriden method if possible. * If the overriden method does not exist or does not have documentation to * inherit, search for documentation to inherit from implemented methods. * * @param input the input object used to perform the search. * * @return an Output object representing the documentation that was found. */ public static Output search(Input input) { Output output = new Output(); if (input.isInheritDocTag) { //Do nothing because "method" does not have any documentation. //All it has it {@inheritDoc}. } else if (input.taglet == null) { //We want overall documentation. output.inlineTags = input.isFirstSentence ? input.method.firstSentenceTags() : input.method.inlineTags(); output.holder = input.method; } else { input.taglet.inherit(input, output); } if (output.inlineTags != null && output.inlineTags.length > 0) { return output; } output.isValidInheritDocTag = false; Input inheritedSearchInput = input.copy(); inheritedSearchInput.isInheritDocTag = false; if (input.method.overriddenMethod() != null) { inheritedSearchInput.method = input.method.overriddenMethod(); output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output != null && output.inlineTags.length > 0) { return output; } } //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does // not pass all implemented interfaces, we will use the // appropriate method here. MethodDoc[] implementedMethods = (new ImplementedMethods(input.method, null)).build(false); for (int i = 0; i < implementedMethods.length; i++) { inheritedSearchInput.method = implementedMethods[i]; output = search(inheritedSearchInput); output.isValidInheritDocTag = true; if (output != null && output.inlineTags.length > 0) { return output; } } return output; } }
7,926
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassDocCatalog.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java
/* * Copyright (c) 2001, 2011, 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.util; import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Configuration; /** * This class acts as an artificial PackageDoc for classes specified * on the command line when running Javadoc. For example, if you * specify several classes from package java.lang, this class will catalog * those classes so that we can retrieve all of the classes from a particular * package later. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class ClassDocCatalog { /** * Stores the set of packages that the classes specified on the command line * belong to. Note that the default package is "". */ private Set<String> packageSet; /** * Stores all classes for each package */ private Map<String,Set<ClassDoc>> allClasses; /** * Stores ordinary classes (excluding Exceptions and Errors) for each * package */ private Map<String,Set<ClassDoc>> ordinaryClasses; /** * Stores exceptions for each package */ private Map<String,Set<ClassDoc>> exceptions; /** * Stores enums for each package. */ private Map<String,Set<ClassDoc>> enums; /** * Stores annotation types for each package. */ private Map<String,Set<ClassDoc>> annotationTypes; /** * Stores errors for each package */ private Map<String,Set<ClassDoc>> errors; /** * Stores interfaces for each package */ private Map<String,Set<ClassDoc>> interfaces; private Configuration configuration; /** * Construct a new ClassDocCatalog. * * @param classdocs the array of ClassDocs to catalog */ public ClassDocCatalog (ClassDoc[] classdocs, Configuration config) { init(); this.configuration = config; for (int i = 0; i < classdocs.length; i++) { addClassDoc(classdocs[i]); } } /** * Construct a new ClassDocCatalog. * */ public ClassDocCatalog () { init(); } private void init() { allClasses = new HashMap<String,Set<ClassDoc>>(); ordinaryClasses = new HashMap<String,Set<ClassDoc>>(); exceptions = new HashMap<String,Set<ClassDoc>>(); enums = new HashMap<String,Set<ClassDoc>>(); annotationTypes = new HashMap<String,Set<ClassDoc>>(); errors = new HashMap<String,Set<ClassDoc>>(); interfaces = new HashMap<String,Set<ClassDoc>>(); packageSet = new HashSet<String>(); } /** * Add the given class to the catalog. * @param classdoc the ClassDoc to add to the catelog. */ public void addClassDoc(ClassDoc classdoc) { if (classdoc == null) { return; } addClass(classdoc, allClasses); if (classdoc.isOrdinaryClass()) { addClass(classdoc, ordinaryClasses); } else if (classdoc.isException()) { addClass(classdoc, exceptions); } else if (classdoc.isEnum()) { addClass(classdoc, enums); } else if (classdoc.isAnnotationType()) { addClass(classdoc, annotationTypes); } else if (classdoc.isError()) { addClass(classdoc, errors); } else if (classdoc.isInterface()) { addClass(classdoc, interfaces); } } /** * Add the given class to the given map. * @param classdoc the ClassDoc to add to the catelog. * @param map the Map to add the ClassDoc to. */ private void addClass(ClassDoc classdoc, Map<String,Set<ClassDoc>> map) { PackageDoc pkg = classdoc.containingPackage(); if (pkg.isIncluded() || (configuration.nodeprecated && Util.isDeprecated(pkg))) { //No need to catalog this class if it's package is //included on the command line or if -nodeprecated option is set // and the containing package is marked as deprecated. return; } String key = Util.getPackageName(pkg); Set<ClassDoc> s = map.get(key); if (s == null) { packageSet.add(key); s = new HashSet<ClassDoc>(); } s.add(classdoc); map.put(key, s); } private ClassDoc[] getArray(Map<String,Set<ClassDoc>> m, String key) { Set<ClassDoc> s = m.get(key); if (s == null) { return new ClassDoc[] {}; } else { return s.toArray(new ClassDoc[] {}); } } /** * Return all of the classes specified on the command-line that * belong to the given package. * @param packageDoc the package to return the classes for. */ public ClassDoc[] allClasses(PackageDoc pkgDoc) { return pkgDoc.isIncluded() ? pkgDoc.allClasses() : getArray(allClasses, Util.getPackageName(pkgDoc)); } /** * Return all of the classes specified on the command-line that * belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] allClasses(String packageName) { return getArray(allClasses, packageName); } /** * Return the array of package names that this catalog stores * ClassDocs for. */ public String[] packageNames() { return packageSet.toArray(new String[] {}); } /** * Return true if the given package is known to this catalog. * @param packageName the name to check. * @return true if this catalog has any information about * classes in the given package. */ public boolean isKnownPackage(String packageName) { return packageSet.contains(packageName); } /** * Return all of the errors specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] errors(String packageName) { return getArray(errors, packageName); } /** * Return all of the exceptions specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] exceptions(String packageName) { return getArray(exceptions, packageName); } /** * Return all of the enums specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] enums(String packageName) { return getArray(enums, packageName); } /** * Return all of the annotation types specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] annotationTypes(String packageName) { return getArray(annotationTypes, packageName); } /** * Return all of the interfaces specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] interfaces(String packageName) { return getArray(interfaces, packageName); } /** * Return all of the ordinary classes specified on the command-line * that belong to the given package. * @param packageName the name of the package specified on the * command-line. */ public ClassDoc[] ordinaryClasses(String packageName) { return getArray(ordinaryClasses, packageName); } }
9,311
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TextTag.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TextTag.java
/* * Copyright (c) 2003, 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.util; import com.sun.javadoc.*; /** * A tag that holds nothing but plain text. This is useful for passing * text to methods that only accept inline tags as a parameter. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.5 */ public class TextTag implements Tag { protected final String text; protected final String name = "Text"; protected final Doc holder; /** * Constructor */ public TextTag(Doc holder, String text) { super(); this.holder = holder; this.text = text; } /** * {@inheritDoc} */ public String name() { return name; } /** * {@inheritDoc} */ public Doc holder() { return holder; } /** * {@inheritDoc} */ public String kind() { return name; } /** * {@inheritDoc} */ public String text() { return text; } /** * {@inheritDoc} */ public String toString() { return name + ":" + text; } /** * {@inheritDoc} */ public Tag[] inlineTags() { return new Tag[] {this}; } /** * {@inheritDoc} */ public Tag[] firstSentenceTags() { return new Tag[] {this}; } /** * {@inheritDoc} */ public SourcePosition position() { return holder.position(); } }
2,715
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MessageRetriever.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
/* * Copyright (c) 1998, 2009, 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.util; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Configuration; import java.util.*; import java.text.MessageFormat; /** * Retrieve and format messages stored in a resource. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @since 1.2 * @author Atul M Dambalkar * @author Robert Field */ public class MessageRetriever { /** * The global configuration information for this run. */ private final Configuration configuration; /** * The location from which to lazily fetch the resource.. */ private final String resourcelocation; /** * The lazily fetched resource.. */ private ResourceBundle messageRB; /** * Initilize the ResourceBundle with the given resource. * * @param rb the esource bundle to read. */ public MessageRetriever(ResourceBundle rb) { this.configuration = null; this.messageRB = rb; this.resourcelocation = null; } /** * Initilize the ResourceBundle with the given resource. * * @param configuration the configuration * @param resourcelocation Resource. */ public MessageRetriever(Configuration configuration, String resourcelocation) { this.configuration = configuration; this.resourcelocation = resourcelocation; } /** * Get and format message string from resource * * @param key selects message from resource * @param args arguments to be replaced in the message. * @throws MissingResourceException when the key does not * exist in the properties file. */ public String getText(String key, Object... args) throws MissingResourceException { if (messageRB == null) { try { messageRB = ResourceBundle.getBundle(resourcelocation); } catch (MissingResourceException e) { throw new Error("Fatal: Resource (" + resourcelocation + ") for javadoc doclets is missing."); } } String message = messageRB.getString(key); return MessageFormat.format(message, args); } /** * Print error message, increment error count. * * @param pos the position of the source * @param msg message to print */ private void printError(SourcePosition pos, String msg) { configuration.root.printError(pos, msg); } /** * Print error message, increment error count. * * @param msg message to print */ private void printError(String msg) { configuration.root.printError(msg); } /** * Print warning message, increment warning count. * * @param pos the position of the source * @param msg message to print */ private void printWarning(SourcePosition pos, String msg) { configuration.root.printWarning(pos, msg); } /** * Print warning message, increment warning count. * * @param msg message to print */ private void printWarning(String msg) { configuration.root.printWarning(msg); } /** * Print a message. * * @param pos the position of the source * @param msg message to print */ private void printNotice(SourcePosition pos, String msg) { configuration.root.printNotice(pos, msg); } /** * Print a message. * * @param msg message to print */ private void printNotice(String msg) { configuration.root.printNotice(msg); } /** * Print error message, increment error count. * * @param pos the position of the source * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void error(SourcePosition pos, String key, Object... args) { printError(pos, getText(key, args)); } /** * Print error message, increment error count. * * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void error(String key, Object... args) { printError(getText(key, args)); } /** * Print warning message, increment warning count. * * @param pos the position of the source * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void warning(SourcePosition pos, String key, Object... args) { printWarning(pos, getText(key, args)); } /** * Print warning message, increment warning count. * * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void warning(String key, Object... args) { printWarning(getText(key, args)); } /** * Print a message. * * @param pos the position of the source * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void notice(SourcePosition pos, String key, Object... args) { printNotice(pos, getText(key, args)); } /** * Print a message. * * @param key selects message from resource * @param args arguments to be replaced in the message. */ public void notice(String key, Object... args) { printNotice(getText(key, args)); } }
6,770
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DirectoryManager.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
/* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.internal.toolkit.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.io.*; /** * Handle the directory creations and the path string generations. * All static - never instaniated. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @since 1.2 * @author Atul M Dambalkar */ public class DirectoryManager { /** * The file separator string, "/", used in the formation of the URL path. */ public static final String URL_FILE_SEPARATOR = "/"; /** * Never instaniated. */ private DirectoryManager() { } /** * Given a PackageDoc, return its URL path string. * * @param pd PackageDoc * @see #getPath(String) */ public static String createPathString(PackageDoc pd) { if (pd == null) { return ""; } return getPath(pd.name()); } /** * Given a ClassDoc, return its URL path string. * * @param cd ClassDoc * @see #getPath(String) */ public static String createPathString(ClassDoc cd) { if (cd == null) { return ""; } PackageDoc pd = cd.containingPackage(); return (pd == null)? "": getPath(pd.name()); } /** * Given a PackageDoc, return the corresponding directory name * with the platform-dependent file separator between subdirectory names. * For example, if name of the package is "java.lang" , then it * returns "java/lang" on Unix and "java\lang" on Windows. * If name of the package contains no dot, then the value * will be returned unchanged. Because package names cannot * end in a dot, the return value will never end with a slash. * <p> * Also see getPath for the URL separator version of this method * that takes a string instead of a PackageDoc. * * @param pd the PackageDoc * @return the platform-dependent directory path for the package */ public static String getDirectoryPath(PackageDoc pd) { return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name()); } /** * Given a package name, return the corresponding directory name * with the platform-dependent file separator between subdirectory names. * For example, if name of the package is "java.lang" , then it * returns "java/lang" on Unix and "java\lang" on Windows. * If name of the package contains no dot, then the value * will be returned unchanged. Because package names cannot * end in a dot, the return value will never end with a slash. * <p> * Also see getPath for the URL separator version of this method * that takes a string instead of a PackageDoc. * * @param packageName the name of the package * @return the platform-dependent directory path for the package */ public static String getDirectoryPath(String packageName) { if (packageName == null || packageName.length() == 0) { return ""; } StringBuffer pathstr = new StringBuffer(); for (int i = 0; i < packageName.length(); i++) { char ch = packageName.charAt(i); if (ch == '.') { pathstr.append(URL_FILE_SEPARATOR); } else { pathstr.append(ch); } } if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) { pathstr.append(URL_FILE_SEPARATOR); } return pathstr.toString(); } /** * Given a package name (a string), return the path string, * with the URL separator "/" separating the subdirectory names. * If name of the package contains no dot, then the value * will be returned unchanged. Because package names cannot * end in a dot, the return value will never end with a slash. * <p> * For example if the string is "com.sun.javadoc" then the URL * path string will be "com/sun/javadoc". * * @param name the package name as a String * @return the String URL path */ public static String getPath(String name) { if (name == null || name.length() == 0) { return ""; } StringBuffer pathstr = new StringBuffer(); for (int i = 0; i < name.length(); i++) { char ch = name.charAt(i); if (ch == '.') { pathstr.append(URL_FILE_SEPARATOR); } else { pathstr.append(ch); } } return pathstr.toString(); } /** * Given two package names as strings, return the relative path * from the package directory corresponding to the first string * to the package directory corresponding to the second string, * with the URL file separator "/" separating subdirectory names. * <p> * For example, if the parameter "from" is "java.lang" * and parameter "to" is "java.applet", return string * "../../java/applet". * * @param from the package name from which path is calculated * @param to the package name to which path is calculated * @return relative path between "from" and "to" with URL * separators * @see #getRelativePath(String) * @see #getPath(String) */ public static String getRelativePath(String from, String to) { StringBuffer pathstr = new StringBuffer(); pathstr.append(getRelativePath(from)); pathstr.append(getPath(to)); pathstr.append(URL_FILE_SEPARATOR); return pathstr.toString(); } /** * Given a package name as a string, return relative path string * from the corresponding package directory to the root of * the documentation, using the URL separator "/" between * subdirectory names. * <p> * For example, if the string "from" is "java.lang", * return "../../" * * @param from the package * @return String relative path from "from". * @see #getRelativePath(String, String) */ public static String getRelativePath(PackageDoc from) { return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name()); } /** * Given a package name as a string, return relative path string * from the corresponding package directory to the root of * the documentation, using the URL separator "/" between * subdirectory names. * <p> * For example, if the string "from" is "java.lang", * return "../../" * * @param from the package name * @return String relative path from "from". * @see #getRelativePath(String, String) */ public static String getRelativePath(String from) { if (from == null || from.length() == 0) { return ""; } StringBuffer pathstr = new StringBuffer(); for (int i = 0; i < from.length(); i++) { char ch = from.charAt(i); if (ch == '.') { pathstr.append(".." + URL_FILE_SEPARATOR); } } pathstr.append(".." + URL_FILE_SEPARATOR); return pathstr.toString(); } /** * Given a relative or absolute path that might be empty, * convert it to a path that does not end with a * URL separator "/". Used for converting * HtmlStandardWriter.relativepath when replacing {@docRoot}. * * @param path the path to convert. An empty path represents * the current directory. */ public static String getPathNoTrailingSlash(String path) { if ( path.equals("") ) { return "."; } if ( path.equals("/") ) { return "/."; } if ( path.endsWith("/") ) { // Remove trailing slash path = path.substring(0, path.length() -1); } return path; } /** * Given a path string create all the directories in the path. For example, * if the path string is "java/applet", the method will create directory * "java" and then "java/applet" if they don't exist. The file separator * string "/" is platform dependent system property. * * @param path Directory path string. */ public static void createDirectory(Configuration configuration, String path) { if (path == null || path.length() == 0) { return; } File dir = new File(path); if (dir.exists()) { return; } else { if (dir.mkdirs()) { return; } else { configuration.message.error( "doclet.Unable_to_create_directory_0", path); throw new DocletAbortException(); } } } /** * Given a package name and a file name, return the full path to that file. * For example, if PackageDoc passed is for "java.lang" and the filename * passed is "package-summary.html", then the string returned is * "java/lang/package-summary.html". * * @param pd PackageDoc. * @param filename File name to be appended to the path of the package. */ public static String getPathToPackage(PackageDoc pd, String filename) { StringBuffer buf = new StringBuffer(); String pathstr = createPathString(pd); if (pathstr.length() > 0) { buf.append(pathstr); buf.append(URL_FILE_SEPARATOR); } buf.append(filename); return buf.toString(); } /** * Given a class name return the full path to the class file. * For example, if ClassDoc passed is for "java.lang.Object" then the * string returned is "java/lang/Object.html". * * @param cd ClassDoc. */ public static String getPathToClass(ClassDoc cd) { return getPathToPackage(cd.containingPackage(), cd.name() + ".html"); } }
11,381
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DocletAbortException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java
/* * Copyright (c) 1997, 2009, 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.util; public class DocletAbortException extends RuntimeException { private static final long serialVersionUID = -9131058909576418984L; public DocletAbortException() { } }
1,446
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Extern.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
/* * Copyright (c) 1998, 2008, 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.util; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; import java.util.Map; import java.util.HashMap; import java.io.*; import java.net.*; /** * Process and manage "-link" and "-linkoffline" to external packages. The * options "-link" and "-linkoffline" both depend on the fact that Javadoc now * generates "package-list"(lists all the packages which are getting * documented) file in the current or the destination directory, while * generating the documentation. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Atul M Dambalkar * @author Robert Field */ public class Extern { /** * Map package names onto Extern Item objects. * Lazily initialized. */ private Map<String,Item> packageToItemMap; /** * The global configuration information for this run. */ private final Configuration configuration; /** * True if we are using -linkoffline and false if -link is used instead. */ private boolean linkoffline = false; /** * Stores the info for one external doc set */ private class Item { /** * Package name, found in the "package-list" file in the {@link path}. */ final String packageName; /** * The URL or the directory path at which the package documentation will be * avaliable. */ final String path; /** * If given path is directory path then true else if it is a URL then false. */ final boolean relative; /** * Constructor to build a Extern Item object and map it with the package name. * If the same package name is found in the map, then the first mapped * Item object or offline location will be retained. * * @param packagename Package name found in the "package-list" file. * @param path URL or Directory path from where the "package-list" * file is picked. * @param relative True if path is URL, false if directory path. */ Item(String packageName, String path, boolean relative) { this.packageName = packageName; this.path = path; this.relative = relative; if (packageToItemMap == null) { packageToItemMap = new HashMap<String,Item>(); } if (!packageToItemMap.containsKey(packageName)) { // save the previous packageToItemMap.put(packageName, this); // mapped location } } /** * String representation of "this" with packagename and the path. */ public String toString() { return packageName + (relative? " -> " : " => ") + path; } } public Extern(Configuration configuration) { this.configuration = configuration; } /** * Determine if a doc item is externally documented. * * @param doc A ProgramElementDoc. */ public boolean isExternal(ProgramElementDoc doc) { if (packageToItemMap == null) { return false; } return packageToItemMap.get(doc.containingPackage().name()) != null; } /** * Convert a link to be an external link if appropriate. * * @param pkgName The package name. * @param relativepath The relative path. * @param link The link to convert. * @return if external return converted link else return null */ public String getExternalLink(String pkgName, String relativepath, String link) { Item fnd = findPackageItem(pkgName); if (fnd != null) { String externlink = fnd.path + link; if (fnd.relative) { // it's a relative path. return relativepath + externlink; } else { return externlink; } } return null; } /** * Build the extern package list from given URL or the directory path. * Flag error if the "-link" or "-linkoffline" option is already used. * * @param url URL or Directory path. * @param pkglisturl This can be another URL for "package-list" or ordinary * file. * @param reporter The <code>DocErrorReporter</code> used to report errors. * @param linkoffline True if -linkoffline isused and false if -link is used. */ public boolean url(String url, String pkglisturl, DocErrorReporter reporter, boolean linkoffline) { this.linkoffline = linkoffline; String errMsg = composeExternPackageList(url, pkglisturl); if (errMsg != null) { reporter.printWarning(errMsg); return false; } else { return true; } } /** * Get the Extern Item object associated with this package name. * * @param pkgname Package name. */ private Item findPackageItem(String pkgName) { if (packageToItemMap == null) { return null; } return packageToItemMap.get(pkgName); } /** * Adjusts the end file separator if it is missing from the URL or the * directory path and depending upon the URL or file path, fetch or * read the "package-list" file. * * @param urlOrDirPath URL or the directory path. * @param pkgListUrlOrDirPath URL or directory path for the "package-list" file or the "package-list" * file itself. */ private String composeExternPackageList(String urlOrDirPath, String pkgListUrlOrDirPath) { urlOrDirPath = adjustEndFileSeparator(urlOrDirPath); pkgListUrlOrDirPath = adjustEndFileSeparator(pkgListUrlOrDirPath); return isUrl(pkgListUrlOrDirPath) ? fetchURLComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath) : readFileComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath); } /** * If the URL or Directory path is missing end file separator, add that. */ private String adjustEndFileSeparator(String url) { String filesep = "/"; if (!url.endsWith(filesep)) { url += filesep; } return url; } /** * Fetch the URL and read the "package-list" file. * * @param urlpath Path to the packages. * @param pkglisturlpath URL or the path to the "package-list" file. */ private String fetchURLComposeExternPackageList(String urlpath, String pkglisturlpath) { String link = pkglisturlpath + "package-list"; try { readPackageList((new URL(link)).openStream(), urlpath, false); } catch (MalformedURLException exc) { return configuration.getText("doclet.MalformedURL", link); } catch (IOException exc) { return configuration.getText("doclet.URL_error", link); } return null; } /** * Read the "package-list" file which is available locally. * * @param path URL or directory path to the packages. * @param pkgListPath Path to the local "package-list" file. */ private String readFileComposeExternPackageList(String path, String pkgListPath) { String link = pkgListPath + "package-list"; if (! ((new File(pkgListPath)).isAbsolute() || linkoffline)){ link = configuration.destDirName + link; } try { File file = new File(link); if (file.exists() && file.canRead()) { readPackageList(new FileInputStream(file), path, ! ((new File(path)).isAbsolute() || isUrl(path))); } else { return configuration.getText("doclet.File_error", link); } } catch (FileNotFoundException exc) { return configuration.getText("doclet.File_error", link); } catch (IOException exc) { return configuration.getText("doclet.File_error", link); } return null; } /** * Read the file "package-list" and for each package name found, create * Extern object and associate it with the package name in the map. * * @param input InputStream from the "package-list" file. * @param path URL or the directory path to the packages. * @param relative Is path relative? */ private void readPackageList(InputStream input, String path, boolean relative) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(input)); StringBuffer strbuf = new StringBuffer(); try { int c; while ((c = in.read()) >= 0) { char ch = (char)c; if (ch == '\n' || ch == '\r') { if (strbuf.length() > 0) { String packname = strbuf.toString(); String packpath = path + packname.replace('.', '/') + '/'; new Item(packname, packpath, relative); strbuf.setLength(0); } } else { strbuf.append(ch); } } } finally { input.close(); } } public boolean isUrl (String urlCandidate) { try { new URL(urlCandidate); //No exception was thrown, so this must really be a URL. return true; } catch (MalformedURLException e) { //Since exception is thrown, this must be a directory path. return false; } } }
11,169
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassUseMapper.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
/* * Copyright (c) 1998, 2008, 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.util; import com.sun.javadoc.*; import java.util.*; /** * Map all class uses for a given class. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @since 1.2 * @author Robert G. Field */ public class ClassUseMapper { private final ClassTree classtree; /** * Mapping of ClassDocs to set of PackageDoc used by that class. * Entries may be null. */ public Map<String,Set<PackageDoc>> classToPackage = new HashMap<String,Set<PackageDoc>>(); /** * Mapping of Annotations to set of PackageDoc that use the annotation. */ public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<String,List<PackageDoc>>(); /** * Mapping of ClassDocs to set of ClassDoc used by that class. * Entries may be null. */ public Map<String,Set<ClassDoc>> classToClass = new HashMap<String,Set<ClassDoc>>(); /** * Mapping of ClassDocs to list of ClassDoc which are direct or * indirect subclasses of that class. * Entries may be null. */ public Map<String,List<ClassDoc>> classToSubclass = new HashMap<String,List<ClassDoc>>(); /** * Mapping of ClassDocs to list of ClassDoc which are direct or * indirect subinterfaces of that interface. * Entries may be null. */ public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<String,List<ClassDoc>>(); /** * Mapping of ClassDocs to list of ClassDoc which implement * this interface. * Entries may be null. */ public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<String,List<ClassDoc>>(); /** * Mapping of ClassDocs to list of FieldDoc declared as that class. * Entries may be null. */ public Map<String,List<FieldDoc>> classToField = new HashMap<String,List<FieldDoc>>(); /** * Mapping of ClassDocs to list of MethodDoc returning that class. * Entries may be null. */ public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<String,List<MethodDoc>>(); /** * Mapping of ClassDocs to list of MethodDoc having that class * as an arg. * Entries may be null. */ public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<String,List<ExecutableMemberDoc>>(); /** * Mapping of ClassDocs to list of MethodDoc which throws that class. * Entries may be null. */ public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<String,List<ExecutableMemberDoc>>(); /** * Mapping of ClassDocs to list of ConstructorDoc having that class * as an arg. * Entries may be null. */ public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<String,List<ExecutableMemberDoc>>(); /** * Mapping of ClassDocs to list of ConstructorDoc which throws that class. * Entries may be null. */ public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<String,List<ExecutableMemberDoc>>(); /** * The mapping of AnnotationTypeDocs to constructors that use them. */ public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<String,List<ConstructorDoc>>(); /** * The mapping of AnnotationTypeDocs to Constructor parameters that use them. */ public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>(); /** * The mapping of ClassDocs to Constructor arguments that use them as type parameters. */ public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>(); /** * The mapping of ClassDocs to ClassDocs that use them as type parameters. */ public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<String,List<ClassDoc>>(); /** * The mapping of AnnotationTypeDocs to ClassDocs that use them. */ public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<String,List<ClassDoc>>(); /** * The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters. */ public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<String,List<MethodDoc>>(); /** * The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters. */ public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>(); /** * The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them. */ public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<String,List<MethodDoc>>(); /** * The mapping of ClassDocs to ExecutableMemberDocs that have return type * with type parameters of that class. */ public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<String,List<MethodDoc>>(); /** * The mapping of AnnotationTypeDocs to MethodDoc parameters that use them. */ public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>(); /** * The mapping of ClassDocs to FieldDocs that use them as type parameters. */ public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<String,List<FieldDoc>>(); /** * The mapping of AnnotationTypeDocs to FieldDocs that use them. */ public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<String,List<FieldDoc>>(); public ClassUseMapper(RootDoc root, ClassTree classtree) { this.classtree = classtree; // Map subclassing, subinterfacing implementing, ... for (Iterator<ClassDoc> it = classtree.baseclasses().iterator(); it.hasNext();) { subclasses(it.next()); } for (Iterator<ClassDoc> it = classtree.baseinterfaces().iterator(); it.hasNext();) { // does subinterfacing as side-effect implementingClasses(it.next()); } // Map methods, fields, constructors using a class. ClassDoc[] classes = root.classes(); for (int i = 0; i < classes.length; i++) { PackageDoc pkg = classes[i].containingPackage(); mapAnnotations(classToPackageAnnotations, pkg, pkg); ClassDoc cd = classes[i]; mapTypeParameters(classToClassTypeParam, cd, cd); mapAnnotations(classToClassAnnotations, cd, cd); FieldDoc[] fields = cd.fields(); for (int j = 0; j < fields.length; j++) { FieldDoc fd = fields[j]; mapTypeParameters(classToFieldDocTypeParam, fd, fd); mapAnnotations(annotationToFieldDoc, fd, fd); if (! fd.type().isPrimitive()) { add(classToField, fd.type().asClassDoc(), fd); } } ConstructorDoc[] cons = cd.constructors(); for (int j = 0; j < cons.length; j++) { mapAnnotations(classToConstructorAnnotations, cons[j], cons[j]); mapExecutable(cons[j]); } MethodDoc[] meths = cd.methods(); for (int j = 0; j < meths.length; j++) { MethodDoc md = meths[j]; mapExecutable(md); mapTypeParameters(classToExecMemberDocTypeParam, md, md); mapAnnotations(classToExecMemberDocAnnotations, md, md); if (! (md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) { mapTypeParameters(classToExecMemberDocReturnTypeParam, md.returnType(), md); add(classToMethodReturn, md.returnType().asClassDoc(), md); } } } } /** * Return all subclasses of a class AND fill-in classToSubclass map. */ private Collection<ClassDoc> subclasses(ClassDoc cd) { Collection<ClassDoc> ret = classToSubclass.get(cd.qualifiedName()); if (ret == null) { ret = new TreeSet<ClassDoc>(); List<ClassDoc> subs = classtree.subclasses(cd); if (subs != null) { ret.addAll(subs); for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) { ret.addAll(subclasses(it.next())); } } addAll(classToSubclass, cd, ret); } return ret; } /** * Return all subinterfaces of an interface AND fill-in classToSubinterface map. */ private Collection<ClassDoc> subinterfaces(ClassDoc cd) { Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName()); if (ret == null) { ret = new TreeSet<ClassDoc>(); List<ClassDoc> subs = classtree.subinterfaces(cd); if (subs != null) { ret.addAll(subs); for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) { ret.addAll(subinterfaces(it.next())); } } addAll(classToSubinterface, cd, ret); } return ret; } /** * Return all implementing classes of an interface (including * all subclasses of implementing classes and all classes * implementing subinterfaces) AND fill-in both classToImplementingClass * and classToSubinterface maps. */ private Collection<ClassDoc> implementingClasses(ClassDoc cd) { Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName()); if (ret == null) { ret = new TreeSet<ClassDoc>(); List<ClassDoc> impl = classtree.implementingclasses(cd); if (impl != null) { ret.addAll(impl); for (Iterator<ClassDoc> it = impl.iterator(); it.hasNext();) { ret.addAll(subclasses(it.next())); } } for (Iterator<ClassDoc> it = subinterfaces(cd).iterator(); it.hasNext();) { ret.addAll(implementingClasses(it.next())); } addAll(classToImplementingClass, cd, ret); } return ret; } /** * Determine classes used by a method or constructor, so they can be * inverse mapped. */ private void mapExecutable(ExecutableMemberDoc em) { Parameter[] params = em.parameters(); boolean isConstructor = em.isConstructor(); List<Type> classArgs = new ArrayList<Type>(); for (int k = 0; k < params.length; k++) { Type pcd = params[k].type(); // primitives don't get mapped, also avoid dups if ((! params[k].type().isPrimitive()) && ! classArgs.contains(pcd) && ! (pcd instanceof TypeVariable)) { add(isConstructor? classToConstructorArgs :classToMethodArgs, pcd.asClassDoc(), em); classArgs.add(pcd); mapTypeParameters(isConstructor? classToConstructorDocArgTypeParam : classToExecMemberDocArgTypeParam, pcd, em); } mapAnnotations( isConstructor ? classToConstructorParamAnnotation : classToExecMemberDocParamAnnotation, params[k], em); } ClassDoc[] thr = em.thrownExceptions(); for (int k = 0; k < thr.length; k++) { add(isConstructor? classToConstructorThrows : classToMethodThrows, thr[k], em); } } private <T> List<T> refList(Map<String,List<T>> map, ClassDoc cd) { List<T> list = map.get(cd.qualifiedName()); if (list == null) { List<T> l = new ArrayList<T>(); list = l; map.put(cd.qualifiedName(), list); } return list; } private Set<PackageDoc> packageSet(ClassDoc cd) { Set<PackageDoc> pkgSet = classToPackage.get(cd.qualifiedName()); if (pkgSet == null) { pkgSet = new TreeSet<PackageDoc>(); classToPackage.put(cd.qualifiedName(), pkgSet); } return pkgSet; } private Set<ClassDoc> classSet(ClassDoc cd) { Set<ClassDoc> clsSet = classToClass.get(cd.qualifiedName()); if (clsSet == null) { Set<ClassDoc> s = new TreeSet<ClassDoc>(); clsSet = s; classToClass.put(cd.qualifiedName(), clsSet); } return clsSet; } private <T extends ProgramElementDoc> void add(Map<String,List<T>> map, ClassDoc cd, T ref) { // add to specified map refList(map, cd).add(ref); // add ref's package to package map and class map packageSet(cd).add(ref.containingPackage()); classSet(cd).add(ref instanceof MemberDoc? ((MemberDoc)ref).containingClass() : (ClassDoc)ref); } private void addAll(Map<String,List<ClassDoc>> map, ClassDoc cd, Collection<ClassDoc> refs) { if (refs == null) { return; } // add to specified map refList(map, cd).addAll(refs); Set<PackageDoc> pkgSet = packageSet(cd); Set<ClassDoc> clsSet = classSet(cd); // add ref's package to package map and class map for (Iterator<ClassDoc> it = refs.iterator(); it.hasNext();) { ClassDoc cls = it.next(); pkgSet.add(cls.containingPackage()); clsSet.add(cls); } } /** * Map the ClassDocs to the ProgramElementDocs that use them as * type parameters. * * @param map the map the insert the information into. * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc, T holder) { TypeVariable[] typeVariables; if (doc instanceof ClassDoc) { typeVariables = ((ClassDoc) doc).typeParameters(); } else if (doc instanceof WildcardType) { Type[] extendsBounds = ((WildcardType) doc).extendsBounds(); for (int k = 0; k < extendsBounds.length; k++) { addTypeParameterToMap(map, extendsBounds[k], holder); } Type[] superBounds = ((WildcardType) doc).superBounds(); for (int k = 0; k < superBounds.length; k++) { addTypeParameterToMap(map, superBounds[k], holder); } return; } else if (doc instanceof ParameterizedType) { Type[] typeArguments = ((ParameterizedType) doc).typeArguments(); for (int k = 0; k < typeArguments.length; k++) { addTypeParameterToMap(map, typeArguments[k], holder); } return; } else if (doc instanceof ExecutableMemberDoc) { typeVariables = ((ExecutableMemberDoc) doc).typeParameters(); } else if (doc instanceof FieldDoc) { Type fieldType = ((FieldDoc) doc).type(); mapTypeParameters(map, fieldType, holder); return; } else { return; } for (int i = 0; i < typeVariables.length; i++) { Type[] bounds = typeVariables[i].bounds(); for (int j = 0; j < bounds.length; j++) { addTypeParameterToMap(map, bounds[j], holder); } } } /** * Map the AnnotationType to the ProgramElementDocs that use them as * type parameters. * * @param map the map the insert the information into. * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc, T holder) { AnnotationDesc[] annotations; boolean isPackage = false; if (doc instanceof ProgramElementDoc) { annotations = ((ProgramElementDoc) doc).annotations(); } else if (doc instanceof PackageDoc) { annotations = ((PackageDoc) doc).annotations(); isPackage = true; } else if (doc instanceof Parameter) { annotations = ((Parameter) doc).annotations(); } else { throw new DocletAbortException(); } for (int i = 0; i < annotations.length; i++) { AnnotationTypeDoc annotationDoc = annotations[i].annotationType(); if (isPackage) refList(map, annotationDoc).add(holder); else add(map, annotationDoc, holder); } } /** * Map the AnnotationType to the ProgramElementDocs that use them as * type parameters. * * @param map the map the insert the information into. * @param doc the doc whose type parameters are being checked. * @param holder the holder that owns the type parameters. */ private <T extends PackageDoc> void mapAnnotations(Map<String,List<T>> map, PackageDoc doc, T holder) { AnnotationDesc[] annotations; annotations = doc.annotations(); for (int i = 0; i < annotations.length; i++) { AnnotationTypeDoc annotationDoc = annotations[i].annotationType(); refList(map, annotationDoc).add(holder); } } private <T extends ProgramElementDoc> void addTypeParameterToMap(Map<String,List<T>> map, Type type, T holder) { if (type instanceof ClassDoc) { add(map, (ClassDoc) type, holder); } else if (type instanceof ParameterizedType) { add(map, ((ParameterizedType) type).asClassDoc(), holder); } mapTypeParameters(map, type, holder); } }
19,343
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DocletConstants.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
/* * Copyright (c) 2003, 2004, 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.util; /** * Stores all constants for a Doclet. Extend this class if you have doclet * specific constants to add. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.5 */ public class DocletConstants { /** * The default package name. */ public static final String DEFAULT_PACKAGE_NAME = "&lt;Unnamed&gt;"; /** * The default package file name. */ public static final String DEFAULT_PACKAGE_FILE_NAME = "default"; /** * The anchor for the default package. */ public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package"; /** * The name of the doc files directory. */ public static final String DOC_FILES_DIR_NAME = "doc-files"; /** * The default amount of space between tab stops. */ public static final int DEFAULT_TAB_STOP_LENGTH = 8; /** * The name of the directory where we will copy resource files to. */ public static final String RESOURE_DIR_NAME = "resources"; /** * The source output directory name */ public static final String SOURCE_OUTPUT_DIR_NAME = "src-html/"; /** * The name of the package list file. */ public static final String PACKAGE_LIST_FILE_NAME = "package-list"; /** * The line seperator for the current operating system. */ public static final String NL = System.getProperty("line.separator"); }
2,765
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LinkFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java
/* * Copyright (c) 2003, 2008, 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.util.links; import com.sun.javadoc.*; /** * A factory that constructs links from given link information. * * @author Jamie Ho * @since 1.5 */ public abstract class LinkFactory { /** * Return an empty instance of the link output object. * * @return an empty instance of the link output object. */ protected abstract LinkOutput getOutputInstance(); /** * Constructs a link from the given link information. * * @param linkInfo the information about the link. * @return the output of the link. */ public LinkOutput getLinkOutput(LinkInfo linkInfo) { if (linkInfo.type != null) { Type type = linkInfo.type; LinkOutput linkOutput = getOutputInstance(); if (type.isPrimitive()) { //Just a primitive. linkInfo.displayLength += type.typeName().length(); linkOutput.append(type.typeName()); } else if (type.asWildcardType() != null) { //Wildcard type. linkInfo.isTypeBound = true; linkInfo.displayLength += 1; linkOutput.append("?"); WildcardType wildcardType = type.asWildcardType(); Type[] extendsBounds = wildcardType.extendsBounds(); for (int i = 0; i < extendsBounds.length; i++) { linkInfo.displayLength += i > 0 ? 2 : 9; linkOutput.append(i > 0 ? ", " : " extends "); setBoundsLinkInfo(linkInfo, extendsBounds[i]); linkOutput.append(getLinkOutput(linkInfo)); } Type[] superBounds = wildcardType.superBounds(); for (int i = 0; i < superBounds.length; i++) { linkInfo.displayLength += i > 0 ? 2 : 7; linkOutput.append(i > 0 ? ", " : " super "); setBoundsLinkInfo(linkInfo, superBounds[i]); linkOutput.append(getLinkOutput(linkInfo)); } } else if (type.asTypeVariable()!= null) { linkInfo.isTypeBound = true; //A type variable. Doc owner = type.asTypeVariable().owner(); if ((! linkInfo.excludeTypeParameterLinks) && owner instanceof ClassDoc) { linkInfo.classDoc = (ClassDoc) owner; linkInfo.label = type.typeName(); linkOutput.append(getClassLink(linkInfo)); } else { //No need to link method type parameters. linkInfo.displayLength += type.typeName().length(); linkOutput.append(type.typeName()); } Type[] bounds = type.asTypeVariable().bounds(); if (! linkInfo.excludeTypeBounds) { linkInfo.excludeTypeBounds = true; for (int i = 0; i < bounds.length; i++) { linkInfo.displayLength += i > 0 ? 2 : 9; linkOutput.append(i > 0 ? " & " : " extends "); setBoundsLinkInfo(linkInfo, bounds[i]); linkOutput.append(getLinkOutput(linkInfo)); } } } else if (type.asClassDoc() != null) { //A class type. if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { //Since we are excluding type parameter links, we should not //be linking to the type bound. linkInfo.displayLength += type.typeName().length(); linkOutput.append(type.typeName()); linkOutput.append(getTypeParameterLinks(linkInfo)); return linkOutput; } else { linkInfo.classDoc = type.asClassDoc(); linkOutput = getClassLink(linkInfo); if (linkInfo.includeTypeAsSepLink) { linkOutput.append(getTypeParameterLinks(linkInfo, false)); } } } if (linkInfo.isVarArg) { if (type.dimension().length() > 2) { //Javadoc returns var args as array. //Strip out the first [] from the var arg. linkInfo.displayLength += type.dimension().length()-2; linkOutput.append(type.dimension().substring(2)); } linkInfo.displayLength += 3; linkOutput.append("..."); } else { linkInfo.displayLength += type.dimension().length(); linkOutput.append(type.dimension()); } return linkOutput; } else if (linkInfo.classDoc != null) { //Just a class link LinkOutput linkOutput = getClassLink(linkInfo); if (linkInfo.includeTypeAsSepLink) { linkOutput.append(getTypeParameterLinks(linkInfo, false)); } return linkOutput; } else { return null; } } private void setBoundsLinkInfo(LinkInfo linkInfo, Type bound) { linkInfo.classDoc = null; linkInfo.label = null; linkInfo.type = bound; } /** * Return the link to the given class. * * @param linkInfo the information about the link to construct. * * @return the link for the given class. */ protected abstract LinkOutput getClassLink(LinkInfo linkInfo); /** * Return the link to the given type parameter. * * @param linkInfo the information about the link to construct. * @param typeParam the type parameter to link to. */ protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo, Type typeParam); /** * Return the links to the type parameters. * * @param linkInfo the information about the link to construct. * @return the links to the type parameters. */ public LinkOutput getTypeParameterLinks(LinkInfo linkInfo) { return getTypeParameterLinks(linkInfo, true); } /** * Return the links to the type parameters. * * @param linkInfo the information about the link to construct. * @param isClassLabel true if this is a class label. False if it is * the type parameters portion of the link. * @return the links to the type parameters. */ public LinkOutput getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) { LinkOutput output = getOutputInstance(); Type[] vars; if (linkInfo.executableMemberDoc != null) { vars = linkInfo.executableMemberDoc.typeParameters(); } else if (linkInfo.type != null && linkInfo.type.asParameterizedType() != null){ vars = linkInfo.type.asParameterizedType().typeArguments(); } else if (linkInfo.classDoc != null){ vars = linkInfo.classDoc.typeParameters(); } else { //Nothing to document. return output; } if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) || (linkInfo.includeTypeAsSepLink && ! isClassLabel) ) && vars.length > 0) { linkInfo.displayLength += 1; output.append(getLessThanString()); for (int i = 0; i < vars.length; i++) { if (i > 0) { linkInfo.displayLength += 1; output.append(","); } output.append(getTypeParameterLink(linkInfo, vars[i])); } linkInfo.displayLength += 1; output.append(getGreaterThanString()); } return output; } /** * Return &amp;lt;, which is used in type parameters. Override this * if your doclet uses something different. * * @return return &amp;lt;, which is used in type parameters. */ protected String getLessThanString() { return "&lt;"; } /** * Return &amp;gt;, which is used in type parameters. Override this * if your doclet uses something different. * * @return return &amp;gt;, which is used in type parameters. */ protected String getGreaterThanString() { return "&gt;"; } }
9,746
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LinkInfo.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
/* * Copyright (c) 2003, 2005, 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.util.links; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Configuration; /** * Encapsulates information about a link. * * @author Jamie Ho * @since 1.5 */ public abstract class LinkInfo { /** * The ClassDoc we want to link to. Null if we are not linking * to a ClassDoc. */ public ClassDoc classDoc; /** * The executable member doc we want to link to. Null if we are not linking * to an executable member. */ public ExecutableMemberDoc executableMemberDoc; /** * The Type we want to link to. Null if we are not linking to a type. */ public Type type; /** * True if this is a link to a VarArg. */ public boolean isVarArg = false; /** * Set this to true to indicate that you are linking to a type parameter. */ public boolean isTypeBound = false; /** * The label for the link. */ public String label; /** * True if the link should be strong. */ public boolean isStrong = false; /** * True if we should include the type in the link label. False otherwise. */ public boolean includeTypeInClassLinkLabel = true; /** * True if we should include the type as seperate link. False otherwise. */ public boolean includeTypeAsSepLink = false; /** * True if we should exclude the type bounds for the type parameter. */ public boolean excludeTypeBounds = false; /** * True if we should print the type parameters, but not link them. */ public boolean excludeTypeParameterLinks = false; /** * True if we should print the type bounds, but not link them. */ public boolean excludeTypeBoundsLinks = false; /** * By default, the link can be to the page it's already on. However, * there are cases where we don't want this (e.g. heading of class page). */ public boolean linkToSelf = true; /** * The display length for the link. */ public int displayLength = 0; /** * Return the id indicating where the link appears in the documentation. * This is used for special processing of different types of links. * * @return the id indicating where the link appears in the documentation. */ public abstract int getContext(); /** * Set the context. * * @param c the context id to set. */ public abstract void setContext(int c); /** * Return true if this link is linkable and false if we can't link to the * desired place. * * @return true if this link is linkable and false if we can't link to the * desired place. */ public abstract boolean isLinkable(); /** * Return the label for this class link. * * @param configuration the current configuration of the doclet. * @return the label for this class link. */ public String getClassLinkLabel(Configuration configuration) { if (label != null && label.length() > 0) { return label; } else if (isLinkable()) { return classDoc.name(); } else { return configuration.getClassName(classDoc); } } }
4,500
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LinkOutput.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkOutput.java
/* * Copyright (c) 2003, 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.util.links; /** * Stores output of a link. * * @author Jamie Ho * @since 1.5 */ public interface LinkOutput { /** * Append the given object to the output. * * @param o the object to append. */ public void append(Object o); }
1,515
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BaseExecutableMemberTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseExecutableMemberTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; /** * An abstract class for that implements the {@link Taglet} interface * for tags in <code>ExecutableMembers</code>. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API. * * @author Jamie Ho * @since 1.4 */ public abstract class BaseExecutableMemberTaglet extends BaseTaglet { /** * Return true if this <code>Taglet</code> * is used in field documentation. * @return true if this <code>Taglet</code> * is used in field documentation and false * otherwise. */ public boolean inField() { return false; } /** * Return true if this <code>Taglet</code> * is used in overview documentation. * @return true if this <code>Taglet</code> * is used in overview documentation and false * otherwise. */ public boolean inOverview() { return false; } /** * Return true if this <code>Taglet</code> * is used in package documentation. * @return true if this <code>Taglet</code> * is used in package documentation and false * otherwise. */ public boolean inPackage() { return false; } /** * Return true if this <code>Taglet</code> * is used in type documentation (classes or interfaces). * @return true if this <code>Taglet</code> * is used in type documentation and false * otherwise. */ public boolean inType() { return false; } /** * Return true if this <code>Taglet</code> * is an inline tag. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public boolean isInlineTag() { return false; } }
3,008
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CodeTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java
/* * Copyright (c) 2003, 2008, 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.taglets; import java.util.Map; import com.sun.javadoc.Tag; import com.sun.tools.doclets.Taglet; /** * An inline Taglet used to denote literal code fragments. * The enclosed text is interpreted as not containing HTML markup or * nested javadoc tags, and is rendered in a font suitable for code. * * <p> The tag {@code {@code ...}} is equivalent to * {@code <code>{@literal ...}</code>}. * For example, the text: * <blockquote> The type {@code {@code List<P>}} </blockquote> * displays as: * <blockquote> The type {@code List<P>} </blockquote> * * @author Scott Seligman * @since 1.5 */ public class CodeTaglet extends LiteralTaglet { private static final String NAME = "code"; public static void register(Map<String, Taglet> map) { map.remove(NAME); map.put(NAME, new CodeTaglet()); } public String getName() { return NAME; } /* * Wraps @literal's result in a <code> element. */ public String toString(Tag tag) { return "<code>" + super.toString(tag) + "</code>"; } }
2,398
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DeprecatedTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java
/* * Copyright (c) 2003, 2011, 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.taglets; import com.sun.javadoc.*; /** * A taglet that represents the @deprecated tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.5 */ public class DeprecatedTaglet extends BaseTaglet{ public DeprecatedTaglet() { name = "deprecated"; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { return writer.deprecatedTagOutput(holder); } }
1,800
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BaseTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java
/* * Copyright (c) 2003, 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.taglets; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * An abstract class for that implements the {@link Taglet} interface. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public abstract class BaseTaglet implements Taglet { protected String name = "Default"; /** * Return true if this <code>Taglet</code> * is used in constructor documentation. * @return true if this <code>Taglet</code> * is used in constructor documentation and false * otherwise. */ public boolean inConstructor() { return true; } /** * Return true if this <code>Taglet</code> * is used in field documentation. * @return true if this <code>Taglet</code> * is used in field documentation and false * otherwise. */ public boolean inField() { return true; } /** * Return true if this <code>Taglet</code> * is used in method documentation. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public boolean inMethod() { return true; } /** * Return true if this <code>Taglet</code> * is used in overview documentation. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public boolean inOverview() { return true; } /** * Return true if this <code>Taglet</code> * is used in package documentation. * @return true if this <code>Taglet</code> * is used in package documentation and false * otherwise. */ public boolean inPackage() { return true; } /** * Return true if this <code>Taglet</code> * is used in type documentation (classes or interfaces). * @return true if this <code>Taglet</code> * is used in type documentation and false * otherwise. */ public boolean inType() { return true; } /** * Return true if this <code>Taglet</code> * is an inline tag. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public boolean isInlineTag() { return false; } /** * Return the name of this custom tag. * @return the name of this custom tag. */ public String getName() { return name; } /** * {@inheritDoc} * @throws IllegalArgumentException thrown when the method is not supported by the taglet. */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { throw new IllegalArgumentException("Method not supported in taglet " + getName() + "."); } /** * {@inheritDoc} * @throws IllegalArgumentException thrown when the method is not supported by the taglet. */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { throw new IllegalArgumentException("Method not supported in taglet " + getName() + "."); } }
4,404
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LiteralTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java
/* * Copyright (c) 2003, 2008, 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.taglets; import java.util.Map; import com.sun.javadoc.Tag; import com.sun.tools.doclets.Taglet; /** * An inline Taglet used to denote literal text. * The enclosed text is interpreted as not containing HTML markup or * nested javadoc tags. * For example, the text: * <blockquote> {@code {@literal a<B>c}} </blockquote> * displays as: * <blockquote> {@literal a<B>c} </blockquote> * * @author Scott Seligman * @since 1.5 */ public class LiteralTaglet implements Taglet { private static final String NAME = "literal"; public static void register(Map<String,Taglet> map) { map.remove(NAME); map.put(NAME, new LiteralTaglet()); } public String getName() { return NAME; } public String toString(Tag tag) { return textToString(tag.text()); } public String toString(Tag[] tags) { return null; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return false; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return false; } public boolean isInlineTag() { return true; } /* * Replace occurrences of the following characters: < > & */ protected static String textToString(String text) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); switch (c) { case '<': buf.append("&lt;"); break; case '>': buf.append("&gt;"); break; case '&': buf.append("&amp;"); break; default: buf.append(c); } } return buf.toString(); } }
3,263
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ReturnTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * A taglet that represents the @return tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class ReturnTaglet extends BaseExecutableMemberTaglet implements InheritableTaglet { public ReturnTaglet() { name = "return"; } /** * {@inheritDoc} */ public void inherit(DocFinder.Input input, DocFinder.Output output) { Tag[] tags = input.method.tags("return"); if (tags.length > 0) { output.holder = input.method; output.holderTag = tags[0]; output.inlineTags = input.isFirstSentence ? tags[0].firstSentenceTags() : tags[0].inlineTags(); } } /** * Return true if this <code>Taglet</code> * is used in constructor documentation. * @return true if this <code>Taglet</code> * is used in constructor documentation and false * otherwise. */ public boolean inConstructor() { return false; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { Type returnType = ((MethodDoc) holder).returnType(); Tag[] tags = holder.tags(name); //Make sure we are not using @return tag on method with void return type. if (returnType.isPrimitive() && returnType.typeName().equals("void")) { if (tags.length > 0) { writer.getMsgRetriever().warning(holder.position(), "doclet.Return_tag_on_void_method"); } return null; } //Inherit @return tag if necessary. if (tags.length == 0) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag}; } return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null; } }
3,400
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ParamTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java
/* * Copyright (c) 2001, 2008, 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.taglets; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.util.*; /** * A taglet that represents the @param tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { /** * Construct a ParamTaglet. */ public ParamTaglet() { name = "param"; } /** * Given an array of <code>Parameter</code>s, return * a name/rank number map. If the array is null, then * null is returned. * @param params The array of parmeters (from type or executable member) to * check. * @return a name-rank number map. */ private static Map<String,String> getRankMap(Object[] params){ if (params == null) { return null; } HashMap<String,String> result = new HashMap<String,String>(); for (int i = 0; i < params.length; i++) { String name = params[i] instanceof Parameter ? ((Parameter) params[i]).name() : ((TypeVariable) params[i]).typeName(); result.put(name, String.valueOf(i)); } return result; } /** * {@inheritDoc} */ public void inherit(DocFinder.Input input, DocFinder.Output output) { if (input.tagId == null) { input.isTypeVariableParamTag = ((ParamTag) input.tag).isTypeParameter(); Object[] parameters = input.isTypeVariableParamTag ? (Object[]) ((MethodDoc) input.tag.holder()).typeParameters() : (Object[]) ((MethodDoc) input.tag.holder()).parameters(); String target = ((ParamTag) input.tag).parameterName(); int i; for (i = 0; i < parameters.length; i++) { String name = parameters[i] instanceof Parameter ? ((Parameter) parameters[i]).name() : ((TypeVariable) parameters[i]).typeName(); if (name.equals(target)) { input.tagId = String.valueOf(i); break; } } if (i == parameters.length) { //Someone used {@inheritDoc} on an invalid @param tag. //We don't know where to inherit from. //XXX: in the future when Configuration is available here, //print a warning for this mistake. return; } } ParamTag[] tags = input.isTypeVariableParamTag ? input.method.typeParamTags() : input.method.paramTags(); Map<String, String> rankMap = getRankMap(input.isTypeVariableParamTag ? (Object[]) input.method.typeParameters() : (Object[]) input.method.parameters()); for (int i = 0; i < tags.length; i++) { if (rankMap.containsKey(tags[i].parameterName()) && rankMap.get(tags[i].parameterName()).equals((input.tagId))) { output.holder = input.method; output.holderTag = tags[i]; output.inlineTags = input.isFirstSentence ? tags[i].firstSentenceTags() : tags[i].inlineTags(); return; } } } /** * {@inheritDoc} */ public boolean inField() { return false; } /** * {@inheritDoc} */ public boolean inMethod() { return true; } /** * {@inheritDoc} */ public boolean inOverview() { return false; } /** * {@inheritDoc} */ public boolean inPackage() { return false; } /** * {@inheritDoc} */ public boolean inType() { return true; } /** * {@inheritDoc} */ public boolean isInlineTag() { return false; } /** * Given an array of <code>ParamTag</code>s,return its string representation. * @param holder the member that holds the param tags. * @param writer the TagletWriter that will write this tag. * @return the TagletOutput representation of these <code>ParamTag</code>s. */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { if (holder instanceof ExecutableMemberDoc) { ExecutableMemberDoc member = (ExecutableMemberDoc) holder; TagletOutput output = getTagletOutput(false, member, writer, member.typeParameters(), member.typeParamTags()); output.appendOutput(getTagletOutput(true, member, writer, member.parameters(), member.paramTags())); return output; } else { ClassDoc classDoc = (ClassDoc) holder; return getTagletOutput(false, classDoc, writer, classDoc.typeParameters(), classDoc.typeParamTags()); } } /** * Given an array of <code>ParamTag</code>s,return its string representation. * Try to inherit the param tags that are missing. * * @param doc the doc that holds the param tags. * @param writer the TagletWriter that will write this tag. * @param formalParameters The array of parmeters (from type or executable * member) to check. * * @return the TagletOutput representation of these <code>ParamTag</code>s. */ private TagletOutput getTagletOutput(boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) { TagletOutput result = writer.getOutputInstance(); Set<String> alreadyDocumented = new HashSet<String>(); if (paramTags.length > 0) { result.appendOutput( processParamTags(isNonTypeParams, paramTags, getRankMap(formalParameters), writer, alreadyDocumented) ); } if (alreadyDocumented.size() != formalParameters.length) { //Some parameters are missing corresponding @param tags. //Try to inherit them. result.appendOutput(getInheritedTagletOutput (isNonTypeParams, holder, writer, formalParameters, alreadyDocumented)); } return result; } /** * Loop through each indivitual parameter. It it does not have a * corresponding param tag, try to inherit it. */ private TagletOutput getInheritedTagletOutput(boolean isNonTypeParams, Doc holder, TagletWriter writer, Object[] formalParameters, Set<String> alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if ((! alreadyDocumented.contains(null)) && holder instanceof MethodDoc) { for (int i = 0; i < formalParameters.length; i++) { if (alreadyDocumented.contains(String.valueOf(i))) { continue; } //This parameter does not have any @param documentation. //Try to inherit it. DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, String.valueOf(i), ! isNonTypeParams)); if (inheritedDoc.inlineTags != null && inheritedDoc.inlineTags.length > 0) { result.appendOutput( processParamTag(isNonTypeParams, writer, (ParamTag) inheritedDoc.holderTag, isNonTypeParams ? ((Parameter) formalParameters[i]).name(): ((TypeVariable) formalParameters[i]).typeName(), alreadyDocumented.size() == 0)); } alreadyDocumented.add(String.valueOf(i)); } } return result; } /** * Given an array of <code>Tag</code>s representing this custom * tag, return its string representation. Print a warning for param * tags that do not map to parameters. Print a warning for param * tags that are duplicated. * * @param paramTags the array of <code>ParamTag</code>s to convert. * @param writer the TagletWriter that will write this tag. * @param alreadyDocumented the set of exceptions that have already * been documented. * @param rankMap a {@link java.util.Map} which holds ordering * information about the parameters. * @param nameMap a {@link java.util.Map} which holds a mapping * of a rank of a parameter to its name. This is * used to ensure that the right name is used * when parameter documentation is inherited. * @return the TagletOutput representation of this <code>Tag</code>. */ private TagletOutput processParamTags(boolean isNonTypeParams, ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer, Set<String> alreadyDocumented) { TagletOutput result = writer.getOutputInstance(); if (paramTags.length > 0) { for (int i = 0; i < paramTags.length; ++i) { ParamTag pt = paramTags[i]; String paramName = isNonTypeParams ? pt.parameterName() : "<" + pt.parameterName() + ">"; if (! rankMap.containsKey(pt.parameterName())) { writer.getMsgRetriever().warning(pt.position(), isNonTypeParams ? "doclet.Parameters_warn" : "doclet.Type_Parameters_warn", paramName); } String rank = rankMap.get(pt.parameterName()); if (rank != null && alreadyDocumented.contains(rank)) { writer.getMsgRetriever().warning(pt.position(), isNonTypeParams ? "doclet.Parameters_dup_warn" : "doclet.Type_Parameters_dup_warn", paramName); } result.appendOutput(processParamTag(isNonTypeParams, writer, pt, pt.parameterName(), alreadyDocumented.size() == 0)); alreadyDocumented.add(rank); } } return result; } /** * Convert the individual ParamTag into TagletOutput. * * @param isNonTypeParams true if this is just a regular param tag. False * if this is a type param tag. * @param writer the taglet writer for output writing. * @param paramTag the tag whose inline tags will be printed. * @param name the name of the parameter. We can't rely on * the name in the param tag because we might be * inheriting documentation. * @param isFirstParam true if this is the first param tag being printed. * */ private TagletOutput processParamTag(boolean isNonTypeParams, TagletWriter writer, ParamTag paramTag, String name, boolean isFirstParam) { TagletOutput result = writer.getOutputInstance(); String header = writer.configuration().getText( isNonTypeParams ? "doclet.Parameters" : "doclet.TypeParameters"); if (isFirstParam) { result.appendOutput(writer.getParamHeader(header)); } result.appendOutput(writer.paramTagOutput(paramTag, name)); return result; } }
12,992
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SimpleTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; import com.sun.javadoc.*; /** * A simple single argument custom tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho */ public class SimpleTaglet extends BaseTaglet { /** * The marker in the location string for excluded tags. */ public static final String EXCLUDED = "x"; /** * The marker in the location string for packages. */ public static final String PACKAGE = "p"; /** * The marker in the location string for types. */ public static final String TYPE = "t"; /** * The marker in the location string for constructors. */ public static final String CONSTRUCTOR = "c"; /** * The marker in the location string for fields. */ public static final String FIELD = "f"; /** * The marker in the location string for methods. */ public static final String METHOD = "m"; /** * The marker in the location string for overview. */ public static final String OVERVIEW = "o"; /** * Use in location string when the tag is to * appear in all locations. */ public static final String ALL = "a"; /** * The name of this tag. */ protected String tagName; /** * The header to output. */ protected String header; /** * The possible locations that this tag can appear in. */ protected String locations; /** * Construct a <code>SimpleTaglet</code>. * @param tagName the name of this tag * @param header the header to output. * @param locations the possible locations that this tag * can appear in. The <code>String</code> can contain 'p' * for package, 't' for type, 'm' for method, 'c' for constructor * and 'f' for field. */ public SimpleTaglet(String tagName, String header, String locations) { this.tagName = tagName; this.header = header; locations = locations.toLowerCase(); if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) { this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW; } else { this.locations = locations; } } /** * Return the name of this <code>Taglet</code>. */ public String getName() { return tagName; } /** * Return true if this <code>SimpleTaglet</code> * is used in constructor documentation. * @return true if this <code>SimpleTaglet</code> * is used in constructor documentation and false * otherwise. */ public boolean inConstructor() { return locations.indexOf(CONSTRUCTOR) != -1 && locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>SimpleTaglet</code> * is used in field documentation. * @return true if this <code>SimpleTaglet</code> * is used in field documentation and false * otherwise. */ public boolean inField() { return locations.indexOf(FIELD) != -1 && locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>SimpleTaglet</code> * is used in method documentation. * @return true if this <code>SimpleTaglet</code> * is used in method documentation and false * otherwise. */ public boolean inMethod() { return locations.indexOf(METHOD) != -1 && locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>SimpleTaglet</code> * is used in overview documentation. * @return true if this <code>SimpleTaglet</code> * is used in overview documentation and false * otherwise. */ public boolean inOverview() { return locations.indexOf(OVERVIEW) != -1 && locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>SimpleTaglet</code> * is used in package documentation. * @return true if this <code>SimpleTaglet</code> * is used in package documentation and false * otherwise. */ public boolean inPackage() { return locations.indexOf(PACKAGE) != -1 && locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>SimpleTaglet</code> * is used in type documentation (classes or interfaces). * @return true if this <code>SimpleTaglet</code> * is used in type documentation and false * otherwise. */ public boolean inType() { return locations.indexOf(TYPE) != -1&& locations.indexOf(EXCLUDED) == -1; } /** * Return true if this <code>Taglet</code> * is an inline tag. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public boolean isInlineTag() { return false; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { return header == null || tag == null ? null : writer.simpleTagOutput(tag, header); } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { if (header == null || holder.tags(getName()).length == 0) { return null; } return writer.simpleTagOutput(holder.tags(getName()), header); } }
6,597
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TagletOutput.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java
/* * Copyright (c) 2003, 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.taglets; /** * The interface for taglet output. This interface is needed because * different doclets work with different formats of output. A single taglet can * work with any doclet that provides an implementation of taglet output. * * @author Jamie Ho * @since 1.5 */ public interface TagletOutput { /** * Set the output for the taglet. * @param o an object representing the output. */ public abstract void setOutput(Object o); /** * Append the given output to this output. * @param o a TagletOutput representing the output. */ public abstract void appendOutput(TagletOutput o); /** * Return true if this output has any occurances of @inheritDoc. * @return true if inheritDoc tag is found. */ public abstract boolean hasInheritDocTag(); }
2,078
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TagletManager.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
/* * Copyright (c) 2001, 2008, 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.taglets; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.io.*; import java.lang.reflect.*; import java.net.*; import java.util.*; /** * Manages the<code>Taglet</code>s used by doclets. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class TagletManager { /** * The default seperator for the simple tag option. */ public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':'; /** * The alternate seperator for simple tag options. Use this * with you want the default seperator to be in the name of the * custom tag. */ public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-"; /** * The map of custom tags. */ private LinkedHashMap<String,Taglet> customTags; /** * The array of custom tags that can appear in packages. */ private Taglet[] packageTags; /** * The array of custom tags that can appear in classes or interfaces. */ private Taglet[] typeTags; /** * The array of custom tags that can appear in fields. */ private Taglet[] fieldTags; /** * The array of custom tags that can appear in constructors. */ private Taglet[] constructorTags; /** * The array of custom tags that can appear in methods. */ private Taglet[] methodTags; /** * The array of custom tags that can appear in the overview. */ private Taglet[] overviewTags; /** * The array of custom tags that can appear in comments. */ private Taglet[] inlineTags; /** * The array of custom tags that can appear in the serialized form. */ private Taglet[] serializedFormTags; /** * The message retriever that will be used to print error messages. */ private MessageRetriever message; /** * Keep track of standard tags. */ private Set<String> standardTags; /** * Keep track of standard tags in lowercase to compare for better * error messages when a tag like @docRoot is mistakenly spelled * lowercase @docroot. */ private Set<String> standardTagsLowercase; /** * Keep track of overriden standard tags. */ private Set<String> overridenStandardTags; /** * Keep track of the tags that may conflict * with standard tags in the future (any custom tag without * a period in its name). */ private Set<String> potentiallyConflictingTags; /** * The set of unseen custom tags. */ private Set<String> unseenCustomTags; /** * True if we do not want to use @since tags. */ private boolean nosince; /** * True if we want to use @version tags. */ private boolean showversion; /** * True if we want to use @author tags. */ private boolean showauthor; /** * Construct a new <code>TagletManager</code>. * @param nosince true if we do not want to use @since tags. * @param showversion true if we want to use @version tags. * @param showauthor true if we want to use @author tags. * @param message the message retriever to print warnings. */ public TagletManager(boolean nosince, boolean showversion, boolean showauthor, MessageRetriever message){ overridenStandardTags = new HashSet<String>(); potentiallyConflictingTags = new HashSet<String>(); standardTags = new HashSet<String>(); standardTagsLowercase = new HashSet<String>(); unseenCustomTags = new HashSet<String>(); customTags = new LinkedHashMap<String,Taglet>(); this.nosince = nosince; this.showversion = showversion; this.showauthor = showauthor; this.message = message; initStandardTags(); initStandardTagsLowercase(); } /** * Add a new <code>CustomTag</code>. This is used to add a Taglet from within * a Doclet. No message is printed to indicate that the Taglet is properly * registered because these Taglets are typically added for every execution of the * Doclet. We don't want to see this type of error message every time. * @param customTag the new <code>CustomTag</code> to add. */ public void addCustomTag(Taglet customTag) { if (customTag != null) { String name = customTag.getName(); if (customTags.containsKey(name)) { customTags.remove(name); } customTags.put(name, customTag); checkTagName(name); } } /** * Add a new <code>Taglet</code>. Print a message to indicate whether or not * the Taglet was registered properly. * @param classname the name of the class representing the custom tag. * @param tagletPath the path to the class representing the custom tag. */ public void addCustomTag(String classname, String tagletPath) { try { Class<?> customTagClass = null; // construct class loader String cpString = null; // make sure env.class.path defaults to dot // do prepends to get correct ordering cpString = appendPath(System.getProperty("env.class.path"), cpString); cpString = appendPath(System.getProperty("java.class.path"), cpString); cpString = appendPath(tagletPath, cpString); URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString)); customTagClass = appClassLoader.loadClass(classname); Method meth = customTagClass.getMethod("register", new Class<?>[] {java.util.Map.class}); Object[] list = customTags.values().toArray(); Taglet lastTag = (list != null && list.length > 0) ? (Taglet) list[list.length-1] : null; meth.invoke(null, new Object[] {customTags}); list = customTags.values().toArray(); Object newLastTag = (list != null&& list.length > 0) ? list[list.length-1] : null; if (lastTag != newLastTag) { //New taglets must always be added to the end of the LinkedHashMap. //If the current and previous last taglet are not equal, that //means a new Taglet has been added. message.notice("doclet.Notice_taglet_registered", classname); if (newLastTag != null) { checkTaglet(newLastTag); } } } catch (Exception exc) { message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname); } } private String appendPath(String path1, String path2) { if (path1 == null || path1.length() == 0) { return path2 == null ? "." : path2; } else if (path2 == null || path2.length() == 0) { return path1; } else { return path1 + File.pathSeparator + path2; } } /** * Utility method for converting a search path string to an array * of directory and JAR file URLs. * * @param path the search path string * @return the resulting array of directory and JAR file URLs */ private static URL[] pathToURLs(String path) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); URL[] urls = new URL[st.countTokens()]; int count = 0; while (st.hasMoreTokens()) { URL url = fileToURL(new File(st.nextToken())); if (url != null) { urls[count++] = url; } } if (urls.length != count) { URL[] tmp = new URL[count]; System.arraycopy(urls, 0, tmp, 0, count); urls = tmp; } return urls; } /** * Returns the directory or JAR file URL corresponding to the specified * local file name. * * @param file the File object * @return the resulting directory or JAR file URL, or null if unknown */ private static URL fileToURL(File file) { String name; try { name = file.getCanonicalPath(); } catch (IOException e) { name = file.getAbsolutePath(); } name = name.replace(File.separatorChar, '/'); if (!name.startsWith("/")) { name = "/" + name; } // If the file does not exist, then assume that it's a directory if (!file.isFile()) { name = name + "/"; } try { return new URL("file", "", name); } catch (MalformedURLException e) { throw new IllegalArgumentException("file"); } } /** * Add a new <code>SimpleTaglet</code>. If this tag already exists * and the header passed as an argument is null, move tag to the back of the * list. If this tag already exists and the header passed as an argument is * not null, overwrite previous tag with new one. Otherwise, add new * SimpleTaglet to list. * @param tagName the name of this tag * @param header the header to output. * @param locations the possible locations that this tag * can appear in. */ public void addNewSimpleCustomTag(String tagName, String header, String locations) { if (tagName == null || locations == null) { return; } Taglet tag = customTags.get(tagName); locations = locations.toLowerCase(); if (tag == null || header != null) { customTags.remove(tagName); customTags.put(tagName, new SimpleTaglet(tagName, header, locations)); if (locations != null && locations.indexOf('x') == -1) { checkTagName(tagName); } } else { //Move to back customTags.remove(tagName); customTags.put(tagName, tag); } } /** * Given a tag name, add it to the set of tags it belongs to. */ private void checkTagName(String name) { if (standardTags.contains(name)) { overridenStandardTags.add(name); } else { if (name.indexOf('.') == -1) { potentiallyConflictingTags.add(name); } unseenCustomTags.add(name); } } /** * Check the taglet to see if it is a legacy taglet. Also * check its name for errors. */ private void checkTaglet(Object taglet) { if (taglet instanceof Taglet) { checkTagName(((Taglet) taglet).getName()); } else if (taglet instanceof com.sun.tools.doclets.Taglet) { com.sun.tools.doclets.Taglet legacyTaglet = (com.sun.tools.doclets.Taglet) taglet; customTags.remove(legacyTaglet.getName()); customTags.put(legacyTaglet.getName(), new LegacyTaglet(legacyTaglet)); checkTagName(legacyTaglet.getName()); } else { throw new IllegalArgumentException("Given object is not a taglet."); } } /** * Given a name of a seen custom tag, remove it from the set of unseen * custom tags. * @param name the name of the seen custom tag. */ public void seenCustomTag(String name) { unseenCustomTags.remove(name); } /** * Given an array of <code>Tag</code>s, check for spelling mistakes. * @param doc the Doc object that holds the tags. * @param tags the list of <code>Tag</code>s to check. * @param areInlineTags true if the array of tags are inline and false otherwise. */ public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) { if (tags == null) { return; } Taglet taglet; for (int i = 0; i < tags.length; i++) { String name = tags[i].name(); if (name.length() > 0 && name.charAt(0) == '@') { name = name.substring(1, name.length()); } if (! (standardTags.contains(name) || customTags.containsKey(name))) { if (standardTagsLowercase.contains(name.toLowerCase())) { message.warning(tags[i].position(), "doclet.UnknownTagLowercase", tags[i].name()); continue; } else { message.warning(tags[i].position(), "doclet.UnknownTag", tags[i].name()); continue; } } //Check if this tag is being used in the wrong location. if ((taglet = customTags.get(name)) != null) { if (areInlineTags && ! taglet.isInlineTag()) { printTagMisuseWarn(taglet, tags[i], "inline"); } if ((doc instanceof RootDoc) && ! taglet.inOverview()) { printTagMisuseWarn(taglet, tags[i], "overview"); } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) { printTagMisuseWarn(taglet, tags[i], "package"); } else if ((doc instanceof ClassDoc) && ! taglet.inType()) { printTagMisuseWarn(taglet, tags[i], "class"); } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) { printTagMisuseWarn(taglet, tags[i], "constructor"); } else if ((doc instanceof FieldDoc) && ! taglet.inField()) { printTagMisuseWarn(taglet, tags[i], "field"); } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) { printTagMisuseWarn(taglet, tags[i], "method"); } } } } /** * Given the taglet, the tag and the type of documentation that the tag * was found in, print a tag misuse warning. * @param taglet the taglet representing the misused tag. * @param tag the misused tag. * @param holderType the type of documentation that the misused tag was found in. */ private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) { Set<String> locationsSet = new LinkedHashSet<String>(); if (taglet.inOverview()) { locationsSet.add("overview"); } if (taglet.inPackage()) { locationsSet.add("package"); } if (taglet.inType()) { locationsSet.add("class/interface"); } if (taglet.inConstructor()) { locationsSet.add("constructor"); } if (taglet.inField()) { locationsSet.add("field"); } if (taglet.inMethod()) { locationsSet.add("method"); } if (taglet.isInlineTag()) { locationsSet.add("inline text"); } String[] locations = locationsSet.toArray(new String[]{}); if (locations == null || locations.length == 0) { //This known tag is excluded. return; } StringBuffer combined_locations = new StringBuffer(); for (int i = 0; i < locations.length; i++) { if (i > 0) { combined_locations.append(", "); } combined_locations.append(locations[i]); } message.warning(tag.position(), "doclet.tag_misuse", "@" + taglet.getName(), holderType, combined_locations.toString()); } /** * Return the array of <code>Taglet</code>s that can * appear in packages. * @return the array of <code>Taglet</code>s that can * appear in packages. */ public Taglet[] getPackageCustomTags() { if (packageTags == null) { initCustomTagArrays(); } return packageTags; } /** * Return the array of <code>Taglet</code>s that can * appear in classes or interfaces. * @return the array of <code>Taglet</code>s that can * appear in classes or interfaces. */ public Taglet[] getTypeCustomTags() { if (typeTags == null) { initCustomTagArrays(); } return typeTags; } /** * Return the array of inline <code>Taglet</code>s that can * appear in comments. * @return the array of <code>Taglet</code>s that can * appear in comments. */ public Taglet[] getInlineCustomTags() { if (inlineTags == null) { initCustomTagArrays(); } return inlineTags; } /** * Return the array of <code>Taglet</code>s that can * appear in fields. * @return the array of <code>Taglet</code>s that can * appear in field. */ public Taglet[] getFieldCustomTags() { if (fieldTags == null) { initCustomTagArrays(); } return fieldTags; } /** * Return the array of <code>Taglet</code>s that can * appear in the serialized form. * @return the array of <code>Taglet</code>s that can * appear in the serialized form. */ public Taglet[] getSerializedFormTags() { if (serializedFormTags == null) { initCustomTagArrays(); } return serializedFormTags; } /** * @return the array of <code>Taglet</code>s that can * appear in the given Doc. */ public Taglet[] getCustomTags(Doc doc) { if (doc instanceof ConstructorDoc) { return getConstructorCustomTags(); } else if (doc instanceof MethodDoc) { return getMethodCustomTags(); } else if (doc instanceof FieldDoc) { return getFieldCustomTags(); } else if (doc instanceof ClassDoc) { return getTypeCustomTags(); } else if (doc instanceof PackageDoc) { return getPackageCustomTags(); } else if (doc instanceof RootDoc) { return getOverviewCustomTags(); } return null; } /** * Return the array of <code>Taglet</code>s that can * appear in constructors. * @return the array of <code>Taglet</code>s that can * appear in constructors. */ public Taglet[] getConstructorCustomTags() { if (constructorTags == null) { initCustomTagArrays(); } return constructorTags; } /** * Return the array of <code>Taglet</code>s that can * appear in methods. * @return the array of <code>Taglet</code>s that can * appear in methods. */ public Taglet[] getMethodCustomTags() { if (methodTags == null) { initCustomTagArrays(); } return methodTags; } /** * Return the array of <code>Taglet</code>s that can * appear in an overview. * @return the array of <code>Taglet</code>s that can * appear in overview. */ public Taglet[] getOverviewCustomTags() { if (overviewTags == null) { initCustomTagArrays(); } return overviewTags; } /** * Initialize the custom tag arrays. */ private void initCustomTagArrays() { Iterator<Taglet> it = customTags.values().iterator(); ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> fTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> cTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size()); ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size()); Taglet current; while (it.hasNext()) { current = it.next(); if (current.inPackage() && !current.isInlineTag()) { pTags.add(current); } if (current.inType() && !current.isInlineTag()) { tTags.add(current); } if (current.inField() && !current.isInlineTag()) { fTags.add(current); } if (current.inConstructor() && !current.isInlineTag()) { cTags.add(current); } if (current.inMethod() && !current.isInlineTag()) { mTags.add(current); } if (current.isInlineTag()) { iTags.add(current); } if (current.inOverview() && !current.isInlineTag()) { oTags.add(current); } } packageTags = pTags.toArray(new Taglet[] {}); typeTags = tTags.toArray(new Taglet[] {}); fieldTags = fTags.toArray(new Taglet[] {}); constructorTags = cTags.toArray(new Taglet[] {}); methodTags = mTags.toArray(new Taglet[] {}); overviewTags = oTags.toArray(new Taglet[] {}); inlineTags = iTags.toArray(new Taglet[] {}); //Init the serialized form tags serializedFormTags = new Taglet[4]; serializedFormTags[0] = customTags.get("serialData"); serializedFormTags[1] = customTags.get("throws"); serializedFormTags[2] = customTags.get("since"); serializedFormTags[3] = customTags.get("see"); } /** * Initialize standard Javadoc tags for ordering purposes. */ private void initStandardTags() { Taglet temp; customTags.put((temp = new ParamTaglet()).getName(), temp); customTags.put((temp = new ReturnTaglet()).getName(), temp); customTags.put((temp = new ThrowsTaglet()).getName(), temp); customTags.put((temp = new SimpleTaglet("exception", null, SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)).getName(), temp); if (!nosince) { customTags.put((temp = new SimpleTaglet("since", message.getText("doclet.Since"), SimpleTaglet.ALL)).getName(), temp); } if (showversion) { customTags.put((temp = new SimpleTaglet("version", message.getText("doclet.Version"), SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp); } if (showauthor) { customTags.put((temp = new SimpleTaglet("author", message.getText("doclet.Author"), SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp); } customTags.put((temp = new SimpleTaglet("serialData", message.getText("doclet.SerialData"), SimpleTaglet.EXCLUDED)).getName(), temp); customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"), SimpleTaglet.METHOD)).getName(), temp); customTags.put((temp = new SeeTaglet()).getName(), temp); //Standard inline tags customTags.put((temp = new DocRootTaglet()).getName(), temp); customTags.put((temp = new InheritDocTaglet()).getName(), temp); customTags.put((temp = new ValueTaglet()).getName(), temp); customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(), temp); customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(), temp); //Keep track of the names of standard tags for error //checking purposes. standardTags.add("param"); standardTags.add("return"); standardTags.add("throws"); standardTags.add("exception"); standardTags.add("since"); standardTags.add("version"); standardTags.add("author"); standardTags.add("see"); standardTags.add("deprecated"); standardTags.add("link"); standardTags.add("linkplain"); standardTags.add("inheritDoc"); standardTags.add("docRoot"); standardTags.add("value"); standardTags.add("serial"); standardTags.add("serialData"); standardTags.add("serialField"); standardTags.add("Text"); standardTags.add("literal"); standardTags.add("code"); } /** * Initialize lowercase version of standard Javadoc tags. */ private void initStandardTagsLowercase() { Iterator<String> it = standardTags.iterator(); while (it.hasNext()) { standardTagsLowercase.add(it.next().toLowerCase()); } } public boolean isKnownCustomTag(String tagName) { return customTags.containsKey(tagName); } /** * Print a list of {@link Taglet}s that might conflict with * standard tags in the future and a list of standard tags * that have been overriden. */ public void printReport() { printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags); printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags); printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags); } private void printReportHelper(String noticeKey, Set<String> names) { if (names.size() > 0) { String[] namesArray = names.toArray(new String[] {}); String result = " "; for (int i = 0; i < namesArray.length; i++) { result += "@" + namesArray[i]; if (i + 1 < namesArray.length) { result += ", "; } } message.notice(noticeKey, result); } } /** * Given the name of a tag, return the corresponding taglet. * Return null if the tag is unknown. * * @param name the name of the taglet to retrieve. * @return return the corresponding taglet. Return null if the tag is * unknown. */ public Taglet getTaglet(String name) { if (name.indexOf("@") == 0) { return customTags.get(name.substring(1)); } else { return customTags.get(name); } } }
27,223
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BaseInlineTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseInlineTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; /** * An abstract inline taglet that outputs HTML. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public abstract class BaseInlineTaglet extends BaseTaglet { /** * Will return true since this is an inline tag. * @return true since this is an inline tag. */ public boolean isInlineTag() { return true; } }
1,725
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InheritableTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritableTaglet.java
/* * Copyright (c) 2003, 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.taglets; import com.sun.tools.doclets.internal.toolkit.util.DocFinder; /** * A taglet should implement this interface if it supports the inheritDoc * tag or is automatically inherited if it is missing. * * @author Jamie Ho * @since 1.5 */ public interface InheritableTaglet extends Taglet { /** * Given an {@link com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output} * object, set its values with the appropriate information to inherit * documentation. * * @param input the input for documentation search. * @param output the output for documentation search. */ void inherit(DocFinder.Input input, DocFinder.Output output); }
1,942
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SeeTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * A taglet that represents the @see tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class SeeTaglet extends BaseTaglet implements InheritableTaglet { public SeeTaglet() { name = "see"; } /** * {@inheritDoc} */ public void inherit(DocFinder.Input input, DocFinder.Output output) { Tag[] tags = input.method.seeTags(); if (tags.length > 0) { output.holder = input.method; output.holderTag = tags[0]; output.inlineTags = input.isFirstSentence ? tags[0].firstSentenceTags() : tags[0].inlineTags(); } } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { SeeTag[] tags = holder.seeTags(); if (tags.length == 0 && holder instanceof MethodDoc) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); if (inheritedDoc.holder != null) { tags = inheritedDoc.holder.seeTags(); } } return writer.seeTagOutput(holder, tags); } }
2,619
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ThrowsTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java
/* * Copyright (c) 2001, 2008, 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.taglets; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import java.util.*; /** * A taglet that represents the @throws tag. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class ThrowsTaglet extends BaseExecutableMemberTaglet implements InheritableTaglet { public ThrowsTaglet() { name = "throws"; } /** * {@inheritDoc} */ public void inherit(DocFinder.Input input, DocFinder.Output output) { ClassDoc exception; if (input.tagId == null) { ThrowsTag throwsTag = (ThrowsTag) input.tag; exception = throwsTag.exception(); input.tagId = exception == null ? throwsTag.exceptionName() : throwsTag.exception().qualifiedName(); } else { exception = input.method.containingClass().findClass(input.tagId); } ThrowsTag[] tags = input.method.throwsTags(); for (int i = 0; i < tags.length; i++) { if (input.tagId.equals(tags[i].exceptionName()) || (tags[i].exception() != null && (input.tagId.equals(tags[i].exception().qualifiedName())))) { output.holder = input.method; output.holderTag = tags[i]; output.inlineTags = input.isFirstSentence ? tags[i].firstSentenceTags() : tags[i].inlineTags(); output.tagList.add(tags[i]); } else if (exception != null && tags[i].exception() != null && tags[i].exception().subclassOf(exception)) { output.tagList.add(tags[i]); } } } /** * Add links for exceptions that are declared but not documented. */ private TagletOutput linkToUndocumentedDeclaredExceptions( Type[] declaredExceptionTypes, Set<String> alreadyDocumented, TagletWriter writer) { TagletOutput result = writer.getOutputInstance(); //Add links to the exceptions declared but not documented. for (int i = 0; i < declaredExceptionTypes.length; i++) { if (declaredExceptionTypes[i].asClassDoc() != null && ! alreadyDocumented.contains( declaredExceptionTypes[i].asClassDoc().name()) && ! alreadyDocumented.contains( declaredExceptionTypes[i].asClassDoc().qualifiedName())) { if (alreadyDocumented.size() == 0) { result.appendOutput(writer.getThrowsHeader()); } result.appendOutput(writer.throwsTagOutput(declaredExceptionTypes[i])); alreadyDocumented.add(declaredExceptionTypes[i].asClassDoc().name()); } } return result; } /** * Inherit throws documentation for exceptions that were declared but not * documented. */ private TagletOutput inheritThrowsDocumentation(Doc holder, Type[] declaredExceptionTypes, Set<String> alreadyDocumented, TagletWriter writer) { TagletOutput result = writer.getOutputInstance(); if (holder instanceof MethodDoc) { Set<Tag> declaredExceptionTags = new LinkedHashSet<Tag>(); for (int j = 0; j < declaredExceptionTypes.length; j++) { DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, declaredExceptionTypes[j].typeName())); if (inheritedDoc.tagList.size() == 0) { inheritedDoc = DocFinder.search(new DocFinder.Input( (MethodDoc) holder, this, declaredExceptionTypes[j].qualifiedTypeName())); } declaredExceptionTags.addAll(inheritedDoc.tagList); } result.appendOutput(throwsTagsOutput( declaredExceptionTags.toArray(new ThrowsTag[] {}), writer, alreadyDocumented, false)); } return result; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { ExecutableMemberDoc execHolder = (ExecutableMemberDoc) holder; ThrowsTag[] tags = execHolder.throwsTags(); TagletOutput result = writer.getOutputInstance(); HashSet<String> alreadyDocumented = new HashSet<String>(); if (tags.length > 0) { result.appendOutput(throwsTagsOutput( execHolder.throwsTags(), writer, alreadyDocumented, true)); } result.appendOutput(inheritThrowsDocumentation(holder, execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); result.appendOutput(linkToUndocumentedDeclaredExceptions( execHolder.thrownExceptionTypes(), alreadyDocumented, writer)); return result; } /** * Given an array of <code>Tag</code>s representing this custom * tag, return its string representation. * @param throwTags the array of <code>ThrowsTag</code>s to convert. * @param writer the TagletWriter that will write this tag. * @param alreadyDocumented the set of exceptions that have already * been documented. * @param allowDups True if we allow duplicate throws tags to be documented. * @return the TagletOutput representation of this <code>Tag</code>. */ protected TagletOutput throwsTagsOutput(ThrowsTag[] throwTags, TagletWriter writer, Set<String> alreadyDocumented, boolean allowDups) { TagletOutput result = writer.getOutputInstance(); if (throwTags.length > 0) { for (int i = 0; i < throwTags.length; ++i) { ThrowsTag tt = throwTags[i]; ClassDoc cd = tt.exception(); if ((!allowDups) && (alreadyDocumented.contains(tt.exceptionName()) || (cd != null && alreadyDocumented.contains(cd.qualifiedName())))) { continue; } if (alreadyDocumented.size() == 0) { result.appendOutput(writer.getThrowsHeader()); } result.appendOutput(writer.throwsTagOutput(tt)); alreadyDocumented.add(cd != null ? cd.qualifiedName() : tt.exceptionName()); } } return result; } }
7,800
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TagletWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
/* * Copyright (c) 2003, 2005, 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.taglets; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; /** * The interface for the taglet writer. * * @since 1.5 * @author Jamie Ho */ public abstract class TagletWriter { /** * True if we only want to write the first sentence. */ protected boolean isFirstSentence = false; /** * @return an instance of the output object. */ public abstract TagletOutput getOutputInstance(); /** * Returns the output for the DocRoot inline tag. * @return the output for the DocRoot inline tag. */ protected abstract TagletOutput getDocRootOutput(); /** * Return the deprecated tag output. * * @param doc the doc to write deprecated documentation for. * @return the output of the deprecated tag. */ protected abstract TagletOutput deprecatedTagOutput(Doc doc); /** * Returns {@link MessageRetriever} for output purposes. * * @return {@link MessageRetriever} for output purposes. */ protected abstract MessageRetriever getMsgRetriever(); /** * Return the header for the param tags. * * @param header the header to display. * @return the header for the param tags. */ protected abstract TagletOutput getParamHeader(String header); /** * Return the output for param tags. * * @param paramTag the parameter to document. * @param paramName the name of the parameter. * @return the output of the param tag. */ protected abstract TagletOutput paramTagOutput(ParamTag paramTag, String paramName); /** * Return the return tag output. * * @param returnTag the return tag to output. * @return the output of the return tag. */ protected abstract TagletOutput returnTagOutput(Tag returnTag); /** * Return the see tag output. * * @param seeTags the array of See tags. * @return the output of the see tags. */ protected abstract TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags); /** * Return the output for a simple tag. * * @param simpleTags the array of simple tags. * @return the output of the simple tags. */ protected abstract TagletOutput simpleTagOutput(Tag[] simpleTags, String header); /** * Return the output for a simple tag. * * @param simpleTag the simple tag. * @return the output of the simple tag. */ protected abstract TagletOutput simpleTagOutput(Tag simpleTag, String header); /** * Return the header for the throws tag. * * @return the header for the throws tag. */ protected abstract TagletOutput getThrowsHeader(); /** * Return the header for the throws tag. * * @param throwsTag the throws tag. * @return the output of the throws tag. */ protected abstract TagletOutput throwsTagOutput(ThrowsTag throwsTag); /** * Return the output for the throws tag. * * @param throwsType the throws type. * @return the output of the throws type. */ protected abstract TagletOutput throwsTagOutput(Type throwsType); /** * Return the output for the value tag. * * @param field the constant field that holds the value tag. * @param constantVal the constant value to document. * @param includeLink true if we should link the constant text to the * constant field itself. * @return the output of the value tag. */ protected abstract TagletOutput valueTagOutput(FieldDoc field, String constantVal, boolean includeLink); /** * Given an output object, append to it the tag documentation for * the given member. * * @param tagletManager the manager that manages the taglets. * @param doc the Doc that we are print tags for. * @param taglets the taglets to print. * @param writer the writer that will generate the output strings. * @param output the output buffer to store the output in. */ public static void genTagOuput(TagletManager tagletManager, Doc doc, Taglet[] taglets, TagletWriter writer, TagletOutput output) { tagletManager.checkTags(doc, doc.tags(), false); tagletManager.checkTags(doc, doc.inlineTags(), true); TagletOutput currentOutput = null; for (int i = 0; i < taglets.length; i++) { if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) { //The type parameters are documented in a special section away //from the tag info, so skip here. continue; } if (taglets[i] instanceof DeprecatedTaglet) { //Deprecated information is documented "inline", not in tag info //section. continue; } try { currentOutput = taglets[i].getTagletOutput(doc, writer); } catch (IllegalArgumentException e) { //The taglet does not take a member as an argument. Let's try //a single tag. Tag[] tags = doc.tags(taglets[i].getName()); if (tags.length > 0) { currentOutput = taglets[i].getTagletOutput(tags[0], writer); } } if (currentOutput != null) { tagletManager.seenCustomTag(taglets[i].getName()); output.appendOutput(currentOutput); } } } /** * Given an inline tag, return its output. * @param tagletManager The taglet manager for the current doclet. * @param holderTag The tag this holds this inline tag. Null if there * is no tag that holds it. * @param inlineTag The inline tag to be documented. * @param tagletWriter The taglet writer to write the output. * @return The output of the inline tag. */ public static TagletOutput getInlineTagOuput(TagletManager tagletManager, Tag holderTag, Tag inlineTag, TagletWriter tagletWriter) { Taglet[] definedTags = tagletManager.getInlineCustomTags(); //This is a custom inline tag. for (int j = 0; j < definedTags.length; j++) { if (("@"+definedTags[j].getName()).equals(inlineTag.name())) { //Given a name of a seen custom tag, remove it from the // set of unseen custom tags. tagletManager.seenCustomTag(definedTags[j].getName()); TagletOutput output = definedTags[j].getTagletOutput( holderTag != null && definedTags[j].getName().equals("inheritDoc") ? holderTag : inlineTag, tagletWriter); return output; } } return null; } /** * Converts inline tags and text to TagOutput, expanding the * inline tags along the way. Called wherever text can contain * an inline tag, such as in comments or in free-form text arguments * to non-inline tags. * * @param holderTag the tag that holds the documentation. * @param tags array of text tags and inline tags (often alternating) * present in the text of interest for this doc. * @return the {@link TagletOutput} representing the comments. */ public abstract TagletOutput commentTagsToOutput(Tag holderTag, Tag[] tags); /** * Converts inline tags and text to TagOutput, expanding the * inline tags along the way. Called wherever text can contain * an inline tag, such as in comments or in free-form text arguments * to non-inline tags. * * @param holderDoc specific doc where comment resides. * @param tags array of text tags and inline tags (often alternating) * present in the text of interest for this doc. * @return the {@link TagletOutput} representing the comments. */ public abstract TagletOutput commentTagsToOutput(Doc holderDoc, Tag[] tags); /** * Converts inline tags and text to TagOutput, expanding the * inline tags along the way. Called wherever text can contain * an inline tag, such as in comments or in free-form text arguments * to non-inline tags. * * @param holderTag the tag that holds the documentation. * @param holderDoc specific doc where comment resides. * @param tags array of text tags and inline tags (often alternating) * present in the text of interest for this doc. * @param isFirstSentence true if this is the first sentence. * @return the {@link TagletOutput} representing the comments. */ public abstract TagletOutput commentTagsToOutput(Tag holderTag, Doc holderDoc, Tag[] tags, boolean isFirstSentence); /** * @return an instance of the configuration used for this doclet. */ public abstract Configuration configuration(); /** * @return an instance of the taglet output object. */ public abstract TagletOutput getTagletOutputInstance(); }
10,458
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ValueTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.Configuration; import com.sun.tools.doclets.internal.toolkit.util.*; import java.util.*; /** * An inline Taglet representing the value tag. This tag should only be used with * constant fields that have a value. It is used to access the value of constant * fields. This inline tag has an optional field name parameter. If the name is * specified, the constant value is retrieved from the specified field. A link * is also created to the specified field. If a name is not specified, the value * is retrieved for the field that the inline tag appears on. The name is specifed * in the following format: [fully qualified class name]#[constant field name]. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class ValueTaglet extends BaseInlineTaglet { /** * Construct a new ValueTaglet. */ public ValueTaglet() { name = "value"; } /** * Will return false because this inline tag may * only appear in Fields. * @return false since this is not a method. */ public boolean inMethod() { return true; } /** * Will return false because this inline tag may * only appear in Fields. * @return false since this is not a method. */ public boolean inConstructor() { return true; } /** * Will return false because this inline tag may * only appear in Fields. * @return false since this is not a method. */ public boolean inOverview() { return true; } /** * Will return false because this inline tag may * only appear in Fields. * @return false since this is not a method. */ public boolean inPackage() { return true; } /** * Will return false because this inline tag may * only appear in Fields. * @return false since this is not a method. */ public boolean inType() { return true; } /** * Given the name of the field, return the corresponding FieldDoc. * * @param config the current configuration of the doclet. * @param tag the value tag. * @param name the name of the field to search for. The name should be in * <qualified class name>#<field name> format. If the class name is omitted, * it is assumed that the field is in the current class. * * @return the corresponding FieldDoc. If the name is null or empty string, * return field that the value tag was used in. * * @throws DocletAbortException if the value tag does not specify a name to * a value field and it is not used within the comments of a valid field. */ private FieldDoc getFieldDoc(Configuration config, Tag tag, String name) { if (name == null || name.length() == 0) { //Base case: no label. if (tag.holder() instanceof FieldDoc) { return (FieldDoc) tag.holder(); } else { //This should never ever happen. throw new DocletAbortException(); } } StringTokenizer st = new StringTokenizer(name, "#"); String memberName = null; ClassDoc cd = null; if (st.countTokens() == 1) { //Case 2: @value in same class. Doc holder = tag.holder(); if (holder instanceof MemberDoc) { cd = ((MemberDoc) holder).containingClass(); } else if (holder instanceof ClassDoc) { cd = (ClassDoc) holder; } memberName = st.nextToken(); } else { //Case 3: @value in different class. cd = config.root.classNamed(st.nextToken()); memberName = st.nextToken(); } if (cd == null) { return null; } FieldDoc[] fields = cd.fields(); for (int i = 0; i < fields.length; i++) { if (fields[i].name().equals(memberName)) { return fields[i]; } } return null; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { FieldDoc field = getFieldDoc( writer.configuration(), tag, tag.text()); if (field == null) { //Reference is unknown. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_reference", tag.text()); } else if (field.constantValue() != null) { return writer.valueTagOutput(field, Util.escapeHtmlChars(field.constantValueExpression()), ! field.equals(tag.holder())); } else { //Referenced field is not a constant. writer.getMsgRetriever().warning(tag.holder().position(), "doclet.value_tag_invalid_constant", field.name()); } return writer.getOutputInstance(); } }
6,354
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Taglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java
/* * Copyright (c) 2003, 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.taglets; import com.sun.javadoc.*; /** * The interface for a custom tag used by Doclets. A custom * tag must implement this interface. To be loaded and used by * doclets at run-time, the taglet must have a static method called * <code>register</code> that accepts a {@link java.util.Map} as an * argument with the following signature: * <pre> * public void register(Map map) * </pre> * This method should add an instance of the custom taglet to the map * with the name of the taglet as the key. If overriding a taglet, * to avoid a name conflict, the overridden taglet must be deleted from * the map before an instance of the new taglet is added to the map. * <p> * It is recommended that the taglet throw an exception when it fails * to register itself. The exception that it throws is up to the user. * <p> * Here are two sample taglets: <br> * <ul> * <li><a href="{@docRoot}/ToDoTaglet.java">ToDoTaglet.java</a> * - Standalone taglet</li> * <li><a href="{@docRoot}/UnderlineTaglet.java">UnderlineTaglet.java</a> * - Inline taglet</li> * </ul> * <p> * For more information on how to create your own Taglets, please see the * <a href="{@docRoot}/overview.html">Taglet Overview</a>. * * @since 1.4 * @author Jamie Ho */ public interface Taglet { /** * Return true if this <code>Taglet</code> * is used in field documentation. * @return true if this <code>Taglet</code> * is used in field documentation and false * otherwise. */ public abstract boolean inField(); /** * Return true if this <code>Taglet</code> * is used in constructor documentation. * @return true if this <code>Taglet</code> * is used in constructor documentation and false * otherwise. */ public abstract boolean inConstructor(); /** * Return true if this <code>Taglet</code> * is used in method documentation. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public abstract boolean inMethod(); /** * Return true if this <code>Taglet</code> * is used in overview documentation. * @return true if this <code>Taglet</code> * is used in method documentation and false * otherwise. */ public abstract boolean inOverview(); /** * Return true if this <code>Taglet</code> * is used in package documentation. * @return true if this <code>Taglet</code> * is used in package documentation and false * otherwise. */ public abstract boolean inPackage(); /** * Return true if this <code>Taglet</code> * is used in type documentation (classes or * interfaces). * @return true if this <code>Taglet</code> * is used in type documentation and false * otherwise. */ public abstract boolean inType(); /** * Return true if this <code>Taglet</code> * is an inline tag. Return false otherwise. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public abstract boolean isInlineTag(); /** * Return the name of this custom tag. * @return the name of this custom tag. */ public abstract String getName(); /** * Given the <code>Tag</code> representation of this custom * tag, return its TagletOutput representation, which is output * to the generated page. * @param tag the <code>Tag</code> representation of this custom tag. * @param writer a {@link TagletWriter} Taglet writer. * @throws IllegalArgumentException thrown when the method is not supported by the taglet. * @return the TagletOutput representation of this <code>Tag</code>. */ public abstract TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException; /** * Given a <code>Doc</code> object, check if it holds any tags of * this type. If it does, return the string representing the output. * If it does not, return null. * @param holder a {@link Doc} object holding the custom tag. * @param writer a {@link TagletWriter} Taglet writer. * @throws IllegalArgumentException thrown when the method is not supported by the taglet. * @return the TagletOutput representation of this <code>Tag</code>. */ public abstract TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException; }
5,752
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InheritDocTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
/* * Copyright (c) 2001, 2005, 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.taglets; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; /** * An inline Taglet representing the <b>inheritDoc</b> tag. This tag should only * be used with a method. It is used to inherit documentation from overriden * and implemented methods. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @since 1.4 */ public class InheritDocTaglet extends BaseInlineTaglet { /** * The inline tag that would appear in the documentation if * the writer wanted documentation to be inherited. */ public static final String INHERIT_DOC_INLINE_TAG = "{@inheritDoc}"; /** * Construct a new InheritDocTaglet. */ public InheritDocTaglet () { name = "inheritDoc"; } /** * Will return false because this inline tag may * only appear in Methods. * @return false since this is not a method. */ public boolean inField() { return false; } /** * Will return false because this inline tag may * only appear in Methods. * @return false since this is not a method. */ public boolean inConstructor() { return false; } /** * Will return false because this inline tag may * only appear in Methods. * @return false since this is not a method. */ public boolean inOverview() { return false; } /** * Will return false because this inline tag may * only appear in Methods. * @return false since this is not a method. */ public boolean inPackage() { return false; } /** * Will return false because this inline tag may * only appear in Methods. * @return false since this is not a method. */ public boolean inType() { return false; } /** * Given a <code>MethodDoc</code> item, a <code>Tag</code> in the * <code>MethodDoc</code> item and a String, replace all occurances * of @inheritDoc with documentation from it's superclass or superinterface. * * @param writer the writer that is writing the output. * @param md the {@link MethodDoc} that we are documenting. * @param holderTag the tag that holds the inheritDoc tag. * @param isFirstSentence true if we only want to inherit the first sentence. */ private TagletOutput retrieveInheritedDocumentation(TagletWriter writer, MethodDoc md, Tag holderTag, boolean isFirstSentence) { TagletOutput replacement = writer.getTagletOutputInstance(); Taglet inheritableTaglet = holderTag == null ? null : writer.configuration().tagletManager.getTaglet(holderTag.name()); if (inheritableTaglet != null && !(inheritableTaglet instanceof InheritableTaglet)) { //This tag does not support inheritence. writer.configuration().message.warning(md.position(), "doclet.noInheritedDoc", md.name() + md.flatSignature()); } DocFinder.Output inheritedDoc = DocFinder.search(new DocFinder.Input(md, (InheritableTaglet) inheritableTaglet, holderTag, isFirstSentence, true)); if (inheritedDoc.isValidInheritDocTag == false) { writer.configuration().message.warning(md.position(), "doclet.noInheritedDoc", md.name() + md.flatSignature()); } else if (inheritedDoc.inlineTags.length > 0) { replacement = writer.commentTagsToOutput(inheritedDoc.holderTag, inheritedDoc.holder, inheritedDoc.inlineTags, isFirstSentence); } return replacement; } /** * Given the <code>Tag</code> representation of this custom * tag, return its string representation, which is output * to the generated page. * @param tag the <code>Tag</code> representation of this custom tag. * @param tagletWriter the taglet writer for output. * @return the TagletOutput representation of this <code>Tag</code>. */ public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) { if (! (tag.holder() instanceof MethodDoc)) { return tagletWriter.getOutputInstance(); } return tag.name().equals("@inheritDoc") ? retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), null, tagletWriter.isFirstSentence) : retrieveInheritedDocumentation(tagletWriter, (MethodDoc) tag.holder(), tag, tagletWriter.isFirstSentence); } }
5,872
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DocRootTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java
/* * Copyright (c) 2001, 2003, 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.taglets; import com.sun.javadoc.*; /** * An inline Taglet representing {&#064;docRoot}. This taglet is * used to get the relative path to the document's root output * directory. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @author Jamie Ho * @author Doug Kramer * @since 1.4 */ public class DocRootTaglet extends BaseInlineTaglet { /** * Construct a new DocRootTaglet. */ public DocRootTaglet() { name = "docRoot"; } /** * Given a <code>Doc</code> object, check if it holds any tags of * this type. If it does, return the string representing the output. * If it does not, return null. * @param tag a tag representing the custom tag. * @param writer a {@link TagletWriter} Taglet writer. * @return the string representation of this <code>Tag</code>. */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) { return writer.getDocRootOutput(); } }
2,296
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LegacyTaglet.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java
/* * Copyright (c) 2003, 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.taglets; import com.sun.javadoc.*; /** * This taglet acts as a wrapper to enable * {@link com.sun.tools.doclets.Taglet} type taglets to work * with the current version of Javadoc. * Note: this taglet only works with legacy taglets (those compatible with * Javadoc 1.4.x) that writes strings. * This taglet is able to wrap most most legacy taglets because * the standard doclet is the only known doclet to use legacy taglets. * * This code is not part of an API. * It is implementation that is subject to change. * Do not use it as an API * * @since 1.5 * @author Jamie Ho */ public class LegacyTaglet implements Taglet { private com.sun.tools.doclets.Taglet legacyTaglet; public LegacyTaglet(com.sun.tools.doclets.Taglet t) { legacyTaglet = t; } /** * {@inheritDoc} */ public boolean inField() { return legacyTaglet.isInlineTag() || legacyTaglet.inField(); } /** * {@inheritDoc} */ public boolean inConstructor() { return legacyTaglet.isInlineTag() || legacyTaglet.inConstructor(); } /** * {@inheritDoc} */ public boolean inMethod() { return legacyTaglet.isInlineTag() || legacyTaglet.inMethod(); } /** * {@inheritDoc} */ public boolean inOverview() { return legacyTaglet.isInlineTag() || legacyTaglet.inOverview(); } /** * {@inheritDoc} */ public boolean inPackage() { return legacyTaglet.isInlineTag() || legacyTaglet.inPackage(); } /** * {@inheritDoc} */ public boolean inType() { return legacyTaglet.isInlineTag() || legacyTaglet.inType(); } /** * Return true if this <code>Taglet</code> * is an inline tag. * @return true if this <code>Taglet</code> * is an inline tag and false otherwise. */ public boolean isInlineTag() { return legacyTaglet.isInlineTag(); } /** * {@inheritDoc} */ public String getName() { return legacyTaglet.getName(); } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException { TagletOutput output = writer.getOutputInstance(); output.setOutput(legacyTaglet.toString(tag)); return output; } /** * {@inheritDoc} */ public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException { TagletOutput output = writer.getOutputInstance(); output.setOutput(legacyTaglet.toString(holder.tags(getName()))); return output; } }
3,920
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Standard.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/standard/Standard.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.standard; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.*; public class Standard { public static int optionLength(String option) { return HtmlDoclet.optionLength(option); } public static boolean start(RootDoc root) { return HtmlDoclet.start(root); } public static boolean validOptions(String[][] options, DocErrorReporter reporter) { return HtmlDoclet.validOptions(options, reporter); } public static LanguageVersion languageVersion() { return HtmlDoclet.languageVersion(); } }
1,851
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DeprecatedListWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
/* * Copyright (c) 1997, 2011, 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.formats.html; import java.io.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Generate File to list all the deprecated classes and class members with the * appropriate links. * * @see java.util.List * @author Atul M Dambalkar * @author Bhavesh Patel (Modified) */ public class DeprecatedListWriter extends SubWriterHolderWriter { private static final String[] ANCHORS = new String[] { "package", "interface", "class", "enum", "exception", "error", "annotation_type", "field", "method", "constructor", "enum_constant", "annotation_type_member" }; private static final String[] HEADING_KEYS = new String[] { "doclet.Deprecated_Packages", "doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes", "doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors", "doclet.Deprecated_Annotation_Types", "doclet.Deprecated_Fields", "doclet.Deprecated_Methods", "doclet.Deprecated_Constructors", "doclet.Deprecated_Enum_Constants", "doclet.Deprecated_Annotation_Type_Members" }; private static final String[] SUMMARY_KEYS = new String[] { "doclet.deprecated_packages", "doclet.deprecated_interfaces", "doclet.deprecated_classes", "doclet.deprecated_enums", "doclet.deprecated_exceptions", "doclet.deprecated_errors", "doclet.deprecated_annotation_types", "doclet.deprecated_fields", "doclet.deprecated_methods", "doclet.deprecated_constructors", "doclet.deprecated_enum_constants", "doclet.deprecated_annotation_type_members" }; private static final String[] HEADER_KEYS = new String[] { "doclet.Package", "doclet.Interface", "doclet.Class", "doclet.Enum", "doclet.Exceptions", "doclet.Errors", "doclet.AnnotationType", "doclet.Field", "doclet.Method", "doclet.Constructor", "doclet.Enum_Constant", "doclet.Annotation_Type_Member" }; private AbstractMemberWriter[] writers; private ConfigurationImpl configuration; /** * Constructor. * * @param filename the file to be generated. */ public DeprecatedListWriter(ConfigurationImpl configuration, String filename) throws IOException { super(configuration, filename); this.configuration = configuration; NestedClassWriterImpl classW = new NestedClassWriterImpl(this); writers = new AbstractMemberWriter[] {classW, classW, classW, classW, classW, classW, new FieldWriterImpl(this), new MethodWriterImpl(this), new ConstructorWriterImpl(this), new EnumConstantWriterImpl(this), new AnnotationTypeOptionalMemberWriterImpl(this, null)}; } /** * Get list of all the deprecated classes and members in all the Packages * specified on the Command Line. * Then instantiate DeprecatedListWriter and generate File. * * @param configuration the current configuration of the doclet. */ public static void generate(ConfigurationImpl configuration) { String filename = "deprecated-list.html"; try { DeprecatedListWriter depr = new DeprecatedListWriter(configuration, filename); depr.generateDeprecatedListFile( new DeprecatedAPIListBuilder(configuration)); depr.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Generate the deprecated API list. * * @param deprapi list of deprecated API built already. */ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) throws IOException { Content body = getHeader(); body.addContent(getContentsList(deprapi)); String memberTableSummary; String[] memberTableHeader = new String[1]; HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { if (deprapi.hasDocumentation(i)) { addAnchor(deprapi, i, div); memberTableSummary = configuration.getText("doclet.Member_Table_Summary", configuration.getText(HEADING_KEYS[i]), configuration.getText(SUMMARY_KEYS[i])); memberTableHeader[0] = configuration.getText("doclet.0_and_1", configuration.getText(HEADER_KEYS[i]), configuration.getText("doclet.Description")); // DeprecatedAPIListBuilder.PACKAGE == 0, so if i == 0, it is // a PackageDoc. if (i == DeprecatedAPIListBuilder.PACKAGE) addPackageDeprecatedAPI(deprapi.getList(i), HEADING_KEYS[i], memberTableSummary, memberTableHeader, div); else writers[i - 1].addDeprecatedAPI(deprapi.getList(i), HEADING_KEYS[i], memberTableSummary, memberTableHeader, div); } } body.addContent(div); addNavLinks(false, body); addBottom(body); printHtmlDocument(null, true, body); } /** * Add the index link. * * @param builder the deprecated list builder * @param type the type of list being documented * @param contentTree the content tree to which the index link will be added */ private void addIndexLink(DeprecatedAPIListBuilder builder, int type, Content contentTree) { if (builder.hasDocumentation(type)) { Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type], getResource(HEADING_KEYS[type]))); contentTree.addContent(li); } } /** * Get the contents list. * * @param deprapi the deprecated list builder * @return a content tree for the contents list */ public Content getContentsList(DeprecatedAPIListBuilder deprapi) { Content headContent = getResource("doclet.Deprecated_API"); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content headingContent = getResource("doclet.Contents"); div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent)); Content ul = new HtmlTree(HtmlTag.UL); for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { addIndexLink(deprapi, i, ul); } div.addContent(ul); return div; } /** * Add the anchor. * * @param builder the deprecated list builder * @param type the type of list being documented * @param contentTree the content tree to which the anchor will be added */ private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) { if (builder.hasDocumentation(type)) { htmlTree.addContent(getMarkerAnchor(ANCHORS[type])); } } /** * Get the header for the deprecated API Listing. * * @return a content tree for the header */ public Content getHeader() { String title = configuration.getText("doclet.Window_Deprecated_List"); Content bodyTree = getBody(true, getWindowTitle(title)); addTop(bodyTree); addNavLinks(true, bodyTree); return bodyTree; } /** * Get the deprecated label. * * @return a content tree for the deprecated label */ protected Content getNavLinkDeprecated() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel); return li; } }
9,535
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageFrameWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
/* * Copyright (c) 1998, 2011, 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.formats.html; import java.io.*; import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Class to generate file for each package contents in the left-hand bottom * frame. This will list all the Class Kinds in the package. A click on any * class-kind will update the right-hand frame with the clicked class-kind page. * * @author Atul M Dambalkar * @author Bhavesh Patel (Modified) */ public class PackageFrameWriter extends HtmlDocletWriter { /** * The package being documented. */ private PackageDoc packageDoc; /** * The classes to be documented. Use this to filter out classes * that will not be documented. */ private Set<ClassDoc> documentedClasses; /** * The name of the output file. */ public static final String OUTPUT_FILE_NAME = "package-frame.html"; /** * Constructor to construct PackageFrameWriter object and to generate * "package-frame.html" file in the respective package directory. * For example for package "java.lang" this will generate file * "package-frame.html" file in the "java/lang" directory. It will also * create "java/lang" directory in the current or the destination directory * if it doesen't exist. * * @param configuration the configuration of the doclet. * @param packageDoc PackageDoc under consideration. */ public PackageFrameWriter(ConfigurationImpl configuration, PackageDoc packageDoc) throws IOException { super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc)); this.packageDoc = packageDoc; if (configuration.root.specifiedPackages().length == 0) { documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes())); } } /** * Generate a package summary page for the left-hand bottom frame. Construct * the PackageFrameWriter object and then uses it generate the file. * * @param configuration the current configuration of the doclet. * @param packageDoc The package for which "pacakge-frame.html" is to be generated. */ public static void generate(ConfigurationImpl configuration, PackageDoc packageDoc) { PackageFrameWriter packgen; try { packgen = new PackageFrameWriter(configuration, packageDoc); String pkgName = Util.getPackageName(packageDoc); Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); Content pkgNameContent = new RawHtml(pkgName); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent)); body.addContent(heading); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.indexContainer); packgen.addClassListing(div); body.addContent(div); packgen.printHtmlDocument( configuration.metakeywords.getMetaKeywords(packageDoc), false, body); packgen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), OUTPUT_FILE_NAME); throw new DocletAbortException(); } } /** * Add class listing for all the classes in this package. Divide class * listing as per the class kind and generate separate listing for * Classes, Interfaces, Exceptions and Errors. * * @param contentTree the content tree to which the listing will be added */ protected void addClassListing(Content contentTree) { Configuration config = configuration(); if (packageDoc.isIncluded()) { addClassKindListing(packageDoc.interfaces(), getResource("doclet.Interfaces"), contentTree); addClassKindListing(packageDoc.ordinaryClasses(), getResource("doclet.Classes"), contentTree); addClassKindListing(packageDoc.enums(), getResource("doclet.Enums"), contentTree); addClassKindListing(packageDoc.exceptions(), getResource("doclet.Exceptions"), contentTree); addClassKindListing(packageDoc.errors(), getResource("doclet.Errors"), contentTree); addClassKindListing(packageDoc.annotationTypes(), getResource("doclet.AnnotationTypes"), contentTree); } else { String name = Util.getPackageName(packageDoc); addClassKindListing(config.classDocCatalog.interfaces(name), getResource("doclet.Interfaces"), contentTree); addClassKindListing(config.classDocCatalog.ordinaryClasses(name), getResource("doclet.Classes"), contentTree); addClassKindListing(config.classDocCatalog.enums(name), getResource("doclet.Enums"), contentTree); addClassKindListing(config.classDocCatalog.exceptions(name), getResource("doclet.Exceptions"), contentTree); addClassKindListing(config.classDocCatalog.errors(name), getResource("doclet.Errors"), contentTree); addClassKindListing(config.classDocCatalog.annotationTypes(name), getResource("doclet.AnnotationTypes"), contentTree); } } /** * Add specific class kind listing. Also add label to the listing. * * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error * @param labelContent content tree of the label to be added * @param contentTree the content tree to which the class kind listing will be added */ protected void addClassKindListing(ClassDoc[] arr, Content labelContent, Content contentTree) { if(arr.length > 0) { Arrays.sort(arr); boolean printedHeader = false; HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addAttr(HtmlAttr.TITLE, labelContent.toString()); for (int i = 0; i < arr.length; i++) { if (documentedClasses != null && !documentedClasses.contains(arr[i])) { continue; } if (!Util.isCoreClass(arr[i]) || ! configuration.isGeneratedDoc(arr[i])) { continue; } if (!printedHeader) { Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, labelContent); contentTree.addContent(heading); printedHeader = true; } Content link = new RawHtml (getLink(new LinkInfoImpl( LinkInfoImpl.PACKAGE_FRAME, arr[i], (arr[i].isInterface() ? italicsText(arr[i].name()) : arr[i].name()),"classFrame"))); Content li = HtmlTree.LI(link); ul.addContent(li); } contentTree.addContent(ul); } } }
8,705
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumConstantWriterImpl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
/* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.formats.html; import java.io.*; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; /** * Writes enum constant documentation in HTML format. * * @author Jamie Ho * @author Bhavesh Patel (Modified) */ public class EnumConstantWriterImpl extends AbstractMemberWriter implements EnumConstantWriter, MemberSummaryWriter { public EnumConstantWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { super(writer, classdoc); } public EnumConstantWriterImpl(SubWriterHolderWriter writer) { super(writer); } /** * {@inheritDoc} */ public Content getMemberSummaryHeader(ClassDoc classDoc, Content memberSummaryTree) { memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, classDoc, memberTree); return memberTree; } /** * {@inheritDoc} */ public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree) { memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS); Content enumConstantsDetailsTree = writer.getMemberTreeHeader(); enumConstantsDetailsTree.addContent(writer.getMarkerAnchor("enum_constant_detail")); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, writer.enumConstantsDetailsLabel); enumConstantsDetailsTree.addContent(heading); return enumConstantsDetailsTree; } /** * {@inheritDoc} */ public Content getEnumConstantsTreeHeader(FieldDoc enumConstant, Content enumConstantsDetailsTree) { enumConstantsDetailsTree.addContent( writer.getMarkerAnchor(enumConstant.name())); Content enumConstantsTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); heading.addContent(enumConstant.name()); enumConstantsTree.addContent(heading); return enumConstantsTree; } /** * {@inheritDoc} */ public Content getSignature(FieldDoc enumConstant) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(enumConstant, pre); addModifiers(enumConstant, pre); Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, enumConstant.type()))); pre.addContent(enumConstantLink); pre.addContent(" "); if (configuration().linksource) { Content enumConstantName = new StringContent(enumConstant.name()); writer.addSrcLink(enumConstant, enumConstantName, pre); } else { addName(enumConstant.name(), pre); } return pre; } /** * {@inheritDoc} */ public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) { addDeprecatedInfo(enumConstant, enumConstantsTree); } /** * {@inheritDoc} */ public void addComments(FieldDoc enumConstant, Content enumConstantsTree) { addComment(enumConstant, enumConstantsTree); } /** * {@inheritDoc} */ public void addTags(FieldDoc enumConstant, Content enumConstantsTree) { writer.addTagsInfo(enumConstant, enumConstantsTree); } /** * {@inheritDoc} */ public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) { return getMemberTree(enumConstantsDetailsTree); } /** * {@inheritDoc} */ public Content getEnumConstants(Content enumConstantsTree, boolean isLastContent) { return getMemberTree(enumConstantsTree, isLastContent); } /** * {@inheritDoc} */ public void close() throws IOException { writer.close(); } public int getMemberKind() { return VisibleMemberMap.ENUM_CONSTANTS; } /** * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, writer.getResource("doclet.Enum_Constant_Summary")); memberTree.addContent(label); } /** * {@inheritDoc} */ public String getTableSummary() { return configuration().getText("doclet.Member_Table_Summary", configuration().getText("doclet.Enum_Constant_Summary"), configuration().getText("doclet.enum_constants")); } /** * {@inheritDoc} */ public String getCaption() { return configuration().getText("doclet.Enum_Constants"); } /** * {@inheritDoc} */ public String[] getSummaryTableHeader(ProgramElementDoc member) { String[] header = new String[] { configuration().getText("doclet.0_and_1", configuration().getText("doclet.Enum_Constant"), configuration().getText("doclet.Description")) }; return header; } /** * {@inheritDoc} */ public void addSummaryAnchor(ClassDoc cd, Content memberTree) { memberTree.addContent(writer.getMarkerAnchor("enum_constant_summary")); } /** * {@inheritDoc} */ public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { } /** * {@inheritDoc} */ public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { } /** * {@inheritDoc} */ protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, Content tdSummary) { Content strong = HtmlTree.STRONG(new RawHtml( writer.getDocLink(context, (MemberDoc) member, member.name(), false))); Content code = HtmlTree.CODE(strong); tdSummary.addContent(code); } /** * {@inheritDoc} */ @Override public void setSummaryColumnStyle(HtmlTree tdTree) { tdTree.addStyle(HtmlStyle.colOne); } /** * {@inheritDoc} */ protected void addInheritedSummaryLink(ClassDoc cd, ProgramElementDoc member, Content linksTree) { } /** * {@inheritDoc} */ protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { //Not applicable. } /** * {@inheritDoc} */ protected Content getDeprecatedLink(ProgramElementDoc member) { return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) member, ((FieldDoc)member).qualifiedName()); } /** * {@inheritDoc} */ protected Content getNavSummaryLink(ClassDoc cd, boolean link) { if (link) { return writer.getHyperLink("", (cd == null)? "enum_constant_summary": "enum_constants_inherited_from_class_" + configuration().getClassName(cd), writer.getResource("doclet.navEnum")); } else { return writer.getResource("doclet.navEnum"); } } /** * {@inheritDoc} */ protected void addNavDetailLink(boolean link, Content liNav) { if (link) { liNav.addContent(writer.getHyperLink("", "enum_constant_detail", writer.getResource("doclet.navEnum"))); } else { liNav.addContent(writer.getResource("doclet.navEnum")); } } }
8,825
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AllClassesFrameWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
/* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.formats.html; 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.doclets.formats.html.markup.*; /** * Generate the file with list of all the classes in this run. This page will be * used in the left-hand bottom frame, when "All Classes" link is clicked in * the left-hand top frame. The name of the generated file is * "allclasses-frame.html". * * @author Atul M Dambalkar * @author Doug Kramer * @author Bhavesh Patel (Modified) */ public class AllClassesFrameWriter extends HtmlDocletWriter { /** * The name of the output file with frames */ public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html"; /** * The name of the output file without frames */ public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html"; /** * Index of all the classes. */ protected IndexBuilder indexbuilder; /** * BR tag to be used within a document tree. */ final HtmlTree BR = new HtmlTree(HtmlTag.BR); /** * Construct AllClassesFrameWriter object. Also initilises the indexbuilder * variable in this class. * @throws IOException * @throws DocletAbortException */ public AllClassesFrameWriter(ConfigurationImpl configuration, String filename, IndexBuilder indexbuilder) throws IOException { super(configuration, filename); this.indexbuilder = indexbuilder; } /** * Create AllClassesFrameWriter object. Then use it to generate the * "allclasses-frame.html" file. Generate the file in the current or the * destination directory. * * @param indexbuilder IndexBuilder object for all classes index. * @throws DocletAbortException */ public static void generate(ConfigurationImpl configuration, IndexBuilder indexbuilder) { AllClassesFrameWriter allclassgen; String filename = OUTPUT_FILE_NAME_FRAMES; try { allclassgen = new AllClassesFrameWriter(configuration, filename, indexbuilder); allclassgen.buildAllClassesFile(true); allclassgen.close(); filename = OUTPUT_FILE_NAME_NOFRAMES; allclassgen = new AllClassesFrameWriter(configuration, filename, indexbuilder); allclassgen.buildAllClassesFile(false); allclassgen.close(); } catch (IOException exc) { configuration.standardmessage. error("doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Print all the classes in the file. * @param wantFrames True if we want frames. */ protected void buildAllClassesFile(boolean wantFrames) throws IOException { String label = configuration.getText("doclet.All_Classes"); Content body = getBody(false, getWindowTitle(label)); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, allclassesLabel); body.addContent(heading); Content ul = new HtmlTree(HtmlTag.UL); // Generate the class links and add it to the tdFont tree. addAllClasses(ul, wantFrames); Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul); body.addContent(div); printHtmlDocument(null, false, body); } /** * Use the sorted index of all the classes and add all the classes to the * content list. * * @param content HtmlTree content to which all classes information will be added * @param wantFrames True if we want frames. */ protected void addAllClasses(Content content, boolean wantFrames) { for (int i = 0; i < indexbuilder.elements().length; i++) { Character unicode = (Character)((indexbuilder.elements())[i]); addContents(indexbuilder.getMemberList(unicode), wantFrames, content); } } /** * Given a list of classes, generate links for each class or interface. * If the class kind is interface, print it in the italics font. Also all * links should target the right-hand frame. If clicked on any class name * in this page, appropriate class page should get opened in the right-hand * frame. * * @param classlist Sorted list of classes. * @param wantFrames True if we want frames. * @param content HtmlTree content to which the links will be added */ protected void addContents(List<Doc> classlist, boolean wantFrames, Content content) { for (int i = 0; i < classlist.size(); i++) { ClassDoc cd = (ClassDoc)classlist.get(i); if (!Util.isCoreClass(cd)) { continue; } String label = italicsClassName(cd, false); Content linkContent; if(wantFrames){ linkContent = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame"))); } else { linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label))); } Content li = HtmlTree.LI(linkContent); content.addContent(li); } } }
6,816
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HtmlSerialFieldWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
/* * Copyright (c) 1998, 2011, 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.formats.html; import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Generate serialized form for serializable fields. * Documentation denoted by the tags <code>serial</code> and * <code>serialField</code> is processed. * * @author Joe Fialli * @author Bhavesh Patel (Modified) */ public class HtmlSerialFieldWriter extends FieldWriterImpl implements SerializedFormWriter.SerialFieldWriter { ProgramElementDoc[] members = null; private boolean printedOverallAnchor = false; public HtmlSerialFieldWriter(SubWriterHolderWriter writer, ClassDoc classdoc) { super(writer, classdoc); } public List<FieldDoc> members(ClassDoc cd) { return Arrays.asList(cd.serializableFields()); } protected void printTypeLinkNoDimension(Type type) { ClassDoc cd = type.asClassDoc(); //Linking to package private classes in serialized for causes //broken links. Don't link to them. if (type.isPrimitive() || cd.isPackagePrivate()) { print(type.typeName()); } else { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type)); } } /** * Return the header for serializable fields section. * * @return a content tree for the header */ public Content getSerializableFieldsHeader() { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); return ul; } /** * Return the header for serializable fields content section. * * @param isLastContent true if the cotent being documented is the last content. * @return a content tree for the header */ public Content getFieldsContentHeader(boolean isLastContent) { HtmlTree li = new HtmlTree(HtmlTag.LI); if (isLastContent) li.addStyle(HtmlStyle.blockListLast); else li.addStyle(HtmlStyle.blockList); return li; } /** * Add serializable fields. * * @param heading the heading for the section * @param serializableFieldsTree the tree to be added to the serializable fileds * content tree * @return a content tree for the serializable fields content */ public Content getSerializableFields(String heading, Content serializableFieldsTree) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); if (serializableFieldsTree.isValid()) { if (!printedOverallAnchor) { li.addContent(writer.getMarkerAnchor("serializedForm")); printedOverallAnchor = true; } Content headingContent = new StringContent(heading); Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, headingContent); li.addContent(serialHeading); li.addContent(serializableFieldsTree); } return li; } /** * Add the member header. * * @param fieldsType the class document to be listed * @param fieldTypeStr the string for the filed type to be documented * @param fieldDimensions the dimensions of the field string to be added * @param firldName name of the field to be added * @param contentTree the content tree to which the member header will be added */ public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr, String fieldDimensions, String fieldName, Content contentTree) { Content nameContent = new RawHtml(fieldName); Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent); contentTree.addContent(heading); Content pre = new HtmlTree(HtmlTag.PRE); if (fieldType == null) { pre.addContent(fieldTypeStr); } else { Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType))); pre.addContent(fieldContent); } pre.addContent(fieldDimensions + " "); pre.addContent(fieldName); contentTree.addContent(pre); } /** * Add the deprecated information for this member. * * @param field the field to document. * @param contentTree the tree to which the deprecated info will be added */ public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree) { addDeprecatedInfo(field, contentTree); } /** * Add the description text for this member. * * @param field the field to document. * @param contentTree the tree to which the deprecated info will be added */ public void addMemberDescription(FieldDoc field, Content contentTree) { if (field.inlineTags().length > 0) { writer.addInlineComment(field, contentTree); } Tag[] tags = field.tags("serial"); if (tags.length > 0) { writer.addInlineComment(field, tags[0], contentTree); } } /** * Add the description text for this member represented by the tag. * * @param serialFieldTag the field to document (represented by tag) * @param contentTree the tree to which the deprecated info will be added */ public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree) { String serialFieldTagDesc = serialFieldTag.description().trim(); if (!serialFieldTagDesc.isEmpty()) { Content serialFieldContent = new RawHtml(serialFieldTagDesc); Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent); contentTree.addContent(div); } } /** * Add the tag information for this member. * * @param field the field to document. * @param contentTree the tree to which the member tags info will be added */ public void addMemberTags(FieldDoc field, Content contentTree) { TagletOutputImpl output = new TagletOutputImpl(""); TagletWriter.genTagOuput(configuration().tagletManager, field, configuration().tagletManager.getCustomTags(field), writer.getTagletWriterInstance(false), output); String outputString = output.toString().trim(); Content dlTags = new HtmlTree(HtmlTag.DL); if (!outputString.isEmpty()) { Content tagContent = new RawHtml(outputString); dlTags.addContent(tagContent); } contentTree.addContent(dlTags); } /** * Check to see if overview details should be printed. If * nocomment option set or if there is no text to be printed * for deprecation info, comment or tags, do not print overview details. * * @param field the field to check overview details for. * @return true if overview details need to be printed */ public boolean shouldPrintOverview(FieldDoc field) { if (!configuration().nocomment) { if(!field.commentText().isEmpty() || writer.hasSerializationOverviewTags(field)) return true; } if (field.tags("deprecated").length > 0) return true; return false; } }
8,682
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageIndexWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
/* * Copyright (c) 1997, 2011, 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.formats.html; 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.doclets.formats.html.markup.*; /** * Generate the package index page "overview-summary.html" for the right-hand * frame. A click on the package name on this page will update the same frame * with the "pacakge-summary.html" file for the clicked package. * * @author Atul M Dambalkar * @author Bhavesh Patel (Modified) */ public class PackageIndexWriter extends AbstractPackageIndexWriter { /** * Root of the program structure. Used for "overview" documentation. */ private RootDoc root; /** * Map representing the group of packages as specified on the command line. * * @see Group */ private Map<String,List<PackageDoc>> groupPackageMap; /** * List to store the order groups as specified on the command line. */ private List<String> groupList; /** * Construct the PackageIndexWriter. Also constructs the grouping * information as provided on the command line by "-group" option. Stores * the order of groups specified by the user. * * @see Group */ public PackageIndexWriter(ConfigurationImpl configuration, String filename) throws IOException { super(configuration, filename); this.root = configuration.root; groupPackageMap = configuration.group.groupPackages(packages); groupList = configuration.group.getGroupList(); } /** * Generate the package index page for the right-hand frame. * * @param configuration the current configuration of the doclet. */ public static void generate(ConfigurationImpl configuration) { PackageIndexWriter packgen; String filename = "overview-summary.html"; try { packgen = new PackageIndexWriter(configuration, filename); packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); packgen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Depending upon the grouping information and their titles, add * separate table indices for each package group. * * @param body the documentation tree to which the index will be added */ protected void addIndex(Content body) { for (int i = 0; i < groupList.size(); i++) { String groupname = groupList.get(i); List<PackageDoc> list = groupPackageMap.get(groupname); if (list != null && list.size() > 0) { addIndexContents(list.toArray(new PackageDoc[list.size()]), groupname, configuration.getText("doclet.Member_Table_Summary", groupname, configuration.getText("doclet.packages")), body); } } } /** * {@inheritDoc} */ protected void addPackagesList(PackageDoc[] packages, String text, String tableSummary, Content body) { Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary, getTableCaption(text)); table.addContent(getSummaryTableHeader(packageTableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); addPackagesList(packages, tbody); table.addContent(tbody); Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table); body.addContent(div); } /** * Adds list of packages in the index table. Generate link to each package. * * @param packages Packages to which link is to be generated * @param tbody the documentation tree to which the list will be added */ protected void addPackagesList(PackageDoc[] packages, Content tbody) { for (int i = 0; i < packages.length; i++) { if (packages[i] != null && packages[i].name().length() > 0) { if (configuration.nodeprecated && Util.isDeprecated(packages[i])) continue; Content packageLinkContent = getPackageLink(packages[i], getPackageName(packages[i])); Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent); HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); tdSummary.addStyle(HtmlStyle.colLast); addSummaryComment(packages[i], tdSummary); HtmlTree tr = HtmlTree.TR(tdPackage); tr.addContent(tdSummary); if (i%2 == 0) tr.addStyle(HtmlStyle.altColor); else tr.addStyle(HtmlStyle.rowColor); tbody.addContent(tr); } } } /** * Adds the overview summary comment for this documentation. Add one line * summary at the top of the page and generate a link to the description, * which is added at the end of this page. * * @param body the documentation tree to which the overview header will be added */ protected void addOverviewHeader(Content body) { if (root.inlineTags().length > 0) { HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV); subTitleDiv.addStyle(HtmlStyle.subTitle); addSummaryComment(root, subTitleDiv); Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv); Content see = seeLabel; see.addContent(" "); Content descPara = HtmlTree.P(see); Content descLink = getHyperLink("", "overview_description", descriptionLabel, "", ""); descPara.addContent(descLink); div.addContent(descPara); body.addContent(div); } } /** * Adds the overview comment as provided in the file specified by the * "-overview" option on the command line. * * @param htmltree the documentation tree to which the overview comment will * be added */ protected void addOverviewComment(Content htmltree) { if (root.inlineTags().length > 0) { htmltree.addContent(getMarkerAnchor("overview_description")); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.subTitle); addInlineComment(root, div); htmltree.addContent(div); } } /** * Adds the tag information as provided in the file specified by the * "-overview" option on the command line. * * @param body the documentation tree to which the overview will be added */ protected void addOverview(Content body) throws IOException { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.footer); addOverviewComment(div); addTagsInfo(root, div); body.addContent(div); } /** * Adds the top text (from the -top option), the upper * navigation bar, and then the title (from the"-title" * option), at the top of page. * * @body the documentation tree to which the navigation bar header will be added */ protected void addNavigationBarHeader(Content body) { addTop(body); addNavLinks(true, body); addConfigurationTitle(body); } /** * Adds the lower navigation bar and the bottom text * (from the -bottom option) at the bottom of page. * * @param the documentation tree to which the navigation bar footer will be added */ protected void addNavigationBarFooter(Content body) { addNavLinks(false, body); addBottom(body); } }
9,147
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LinkOutputImpl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkOutputImpl.java
/* * Copyright (c) 2003, 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.formats.html; import com.sun.tools.doclets.internal.toolkit.util.links.*; /** * Stores output of a link. * * @author Jamie Ho * @since 1.5 */ public class LinkOutputImpl implements LinkOutput { /** * The output of the link. */ public StringBuffer output; /** * Construct a new LinkOutputImpl. */ public LinkOutputImpl() { output = new StringBuffer(); } /** * {@inheritDoc} */ public void append(Object o) { output.append(o instanceof String ? (String) o : ((LinkOutputImpl)o).toString()); } /** * {@inheritDoc} */ public String toString() { return output.toString(); } }
1,941
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HtmlSerialMethodWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
/* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.formats.html; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Generate serialized form for Serializable/Externalizable methods. * Documentation denoted by the <code>serialData</code> tag is processed. * * @author Joe Fialli * @author Bhavesh Patel (Modified) */ public class HtmlSerialMethodWriter extends MethodWriterImpl implements SerializedFormWriter.SerialMethodWriter{ public HtmlSerialMethodWriter(SubWriterHolderWriter writer, ClassDoc classdoc) { super(writer, classdoc); } /** * Return the header for serializable methods section. * * @return a content tree for the header */ public Content getSerializableMethodsHeader() { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); return ul; } /** * Return the header for serializable methods content section. * * @param isLastContent true if the cotent being documented is the last content. * @return a content tree for the header */ public Content getMethodsContentHeader(boolean isLastContent) { HtmlTree li = new HtmlTree(HtmlTag.LI); if (isLastContent) li.addStyle(HtmlStyle.blockListLast); else li.addStyle(HtmlStyle.blockList); return li; } /** * Add serializable methods. * * @param heading the heading for the section * @param serializableMethodContent the tree to be added to the serializable methods * content tree * @return a content tree for the serializable methods content */ public Content getSerializableMethods(String heading, Content serializableMethodContent) { Content li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor( "serialized_methods")); Content headingContent = new StringContent(heading); Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, headingContent); li.addContent(serialHeading); li.addContent(serializableMethodContent); return li; } /** * Return the no customization message. * * @param msg the message to be displayed * @return no customization message content */ public Content getNoCustomizationMsg(String msg) { Content noCustomizationMsg = new StringContent(msg); return noCustomizationMsg; } /** * Add the member header. * * @param member the method document to be listed * @param methodsContentTree the content tree to which the member header will be added */ public void addMemberHeader(MethodDoc member, Content methodsContentTree) { methodsContentTree.addContent(writer.getMarkerAnchor( writer.getAnchor(member))); methodsContentTree.addContent(getHead(member)); methodsContentTree.addContent(getSignature(member)); } /** * Add the deprecated information for this member. * * @param member the method to document. * @param methodsContentTree the tree to which the deprecated info will be added */ public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) { addDeprecatedInfo(member, methodsContentTree); } /** * Add the description text for this member. * * @param member the method to document. * @param methodsContentTree the tree to which the deprecated info will be added */ public void addMemberDescription(MethodDoc member, Content methodsContentTree) { addComment(member, methodsContentTree); } /** * Add the tag information for this member. * * @param member the method to document. * @param methodsContentTree the tree to which the member tags info will be added */ public void addMemberTags(MethodDoc member, Content methodsContentTree) { TagletOutputImpl output = new TagletOutputImpl(""); TagletManager tagletManager = ConfigurationImpl.getInstance().tagletManager; TagletWriter.genTagOuput(tagletManager, member, tagletManager.getSerializedFormTags(), writer.getTagletWriterInstance(false), output); String outputString = output.toString().trim(); Content dlTags = new HtmlTree(HtmlTag.DL); if (!outputString.isEmpty()) { Content tagContent = new RawHtml(outputString); dlTags.addContent(tagContent); } methodsContentTree.addContent(dlTags); MethodDoc method = member; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { serialWarning(member.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } } protected void printTypeLinkNoDimension(Type type) { ClassDoc cd = type.asClassDoc(); if (type.isPrimitive() || cd.isPackagePrivate()) { print(type.typeName()); } else { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type)); } } }
6,599
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConfigurationImpl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
/* * Copyright (c) 1998, 2011, 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.formats.html; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.javadoc.*; import java.util.*; import java.io.*; import java.net.*; /** * Configure the output based on the command line options. * <p> * Also determine the length of the command line option. For example, * for a option "-header" there will be a string argument associated, then the * the length of option "-header" is two. But for option "-nohelp" no argument * is needed so it's length is 1. * </p> * <p> * Also do the error checking on the options used. For example it is illegal to * use "-helpfile" option when already "-nohelp" option is used. * </p> * * @author Robert Field. * @author Atul Dambalkar. * @author Jamie Ho * @author Bhavesh Patel (Modified) */ public class ConfigurationImpl extends Configuration { private static ConfigurationImpl instance = new ConfigurationImpl(); /** * The build date. Note: For now, we will use * a version number instead of a date. */ public static final String BUILD_DATE = System.getProperty("java.version"); /** * The name of the constant values file. */ public static final String CONSTANTS_FILE_NAME = "constant-values.html"; /** * Argument for command line option "-header". */ public String header = ""; /** * Argument for command line option "-packagesheader". */ public String packagesheader = ""; /** * Argument for command line option "-footer". */ public String footer = ""; /** * Argument for command line option "-doctitle". */ public String doctitle = ""; /** * Argument for command line option "-windowtitle". */ public String windowtitle = ""; /** * Argument for command line option "-top". */ public String top = ""; /** * Argument for command line option "-bottom". */ public String bottom = ""; /** * Argument for command line option "-helpfile". */ public String helpfile = ""; /** * Argument for command line option "-stylesheetfile". */ public String stylesheetfile = ""; /** * Argument for command line option "-Xdocrootparent". */ public String docrootparent = ""; /** * True if command line option "-nohelp" is used. Default value is false. */ public boolean nohelp = false; /** * True if command line option "-splitindex" is used. Default value is * false. */ public boolean splitindex = false; /** * False if command line option "-noindex" is used. Default value is true. */ public boolean createindex = true; /** * True if command line option "-use" is used. Default value is false. */ public boolean classuse = false; /** * False if command line option "-notree" is used. Default value is true. */ public boolean createtree = true; /** * True if command line option "-nodeprecated" is used. Default value is * false. */ public boolean nodeprecatedlist = false; /** * True if command line option "-nonavbar" is used. Default value is false. */ public boolean nonavbar = false; /** * True if command line option "-nooverview" is used. Default value is * false */ private boolean nooverview = false; /** * True if command line option "-overview" is used. Default value is false. */ public boolean overview = false; /** * This is true if option "-overview" is used or option "-overview" is not * used and number of packages is more than one. */ public boolean createoverview = false; /** * Unique Resource Handler for this package. */ public final MessageRetriever standardmessage; /** * First file to appear in the right-hand frame in the generated * documentation. */ public String topFile = ""; /** * The classdoc for the class file getting generated. */ public ClassDoc currentcd = null; // Set this classdoc in the // ClassWriter. /** * Constructor. Initialises resource for the * {@link com.sun.tools.doclets.MessageRetriever}. */ private ConfigurationImpl() { standardmessage = new MessageRetriever(this, "com.sun.tools.doclets.formats.html.resources.standard"); } /** * Reset to a fresh new ConfigurationImpl, to allow multiple invocations * of javadoc within a single VM. It would be better not to be using * static fields at all, but .... (sigh). */ public static void reset() { instance = new ConfigurationImpl(); } public static ConfigurationImpl getInstance() { return instance; } /** * Return the build date for the doclet. */ public String getDocletSpecificBuildDate() { return BUILD_DATE; } /** * Depending upon the command line options provided by the user, set * configure the output generation environment. * * @param options The array of option names and values. */ public void setSpecificDocletOptions(String[][] options) { for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-footer")) { footer = os[1]; } else if (opt.equals("-header")) { header = os[1]; } else if (opt.equals("-packagesheader")) { packagesheader = os[1]; } else if (opt.equals("-doctitle")) { doctitle = os[1]; } else if (opt.equals("-windowtitle")) { windowtitle = os[1]; } else if (opt.equals("-top")) { top = os[1]; } else if (opt.equals("-bottom")) { bottom = os[1]; } else if (opt.equals("-helpfile")) { helpfile = os[1]; } else if (opt.equals("-stylesheetfile")) { stylesheetfile = os[1]; } else if (opt.equals("-charset")) { charset = os[1]; } else if (opt.equals("-xdocrootparent")) { docrootparent = os[1]; } else if (opt.equals("-nohelp")) { nohelp = true; } else if (opt.equals("-splitindex")) { splitindex = true; } else if (opt.equals("-noindex")) { createindex = false; } else if (opt.equals("-use")) { classuse = true; } else if (opt.equals("-notree")) { createtree = false; } else if (opt.equals("-nodeprecatedlist")) { nodeprecatedlist = true; } else if (opt.equals("-nosince")) { nosince = true; } else if (opt.equals("-nonavbar")) { nonavbar = true; } else if (opt.equals("-nooverview")) { nooverview = true; } else if (opt.equals("-overview")) { overview = true; } } if (root.specifiedClasses().length > 0) { Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); PackageDoc pd; ClassDoc[] classes = root.classes(); for (int i = 0; i < classes.length; i++) { pd = classes[i].containingPackage(); if(! map.containsKey(pd.name())) { map.put(pd.name(), pd); } } } setCreateOverview(); setTopFile(root); } /** * Returns the "length" of a given option. If an option takes no * arguments, its length is one. If it takes one argument, it's * length is two, and so on. This method is called by JavaDoc to * parse the options it does not recognize. It then calls * {@link #validOptions(String[][], DocErrorReporter)} to * validate them. * <b>Note:</b><br> * The options arrive as case-sensitive strings. For options that * are not case-sensitive, use toLowerCase() on the option string * before comparing it. * </blockquote> * * @return number of arguments + 1 for a option. Zero return means * option not known. Negative value means error occurred. */ public int optionLength(String option) { int result = -1; if ((result = super.optionLength(option)) > 0) { return result; } // otherwise look for the options we have added option = option.toLowerCase(); if (option.equals("-nodeprecatedlist") || option.equals("-noindex") || option.equals("-notree") || option.equals("-nohelp") || option.equals("-splitindex") || option.equals("-serialwarn") || option.equals("-use") || option.equals("-nonavbar") || option.equals("-nooverview")) { return 1; } else if (option.equals("-help")) { System.out.println(getText("doclet.usage")); return 1; } else if (option.equals("-footer") || option.equals("-header") || option.equals("-packagesheader") || option.equals("-doctitle") || option.equals("-windowtitle") || option.equals("-top") || option.equals("-bottom") || option.equals("-helpfile") || option.equals("-stylesheetfile") || option.equals("-charset") || option.equals("-overview") || option.equals("-xdocrootparent")) { return 2; } else { return 0; } } /** * {@inheritDoc} */ public boolean validOptions(String options[][], DocErrorReporter reporter) { boolean helpfile = false; boolean nohelp = false; boolean overview = false; boolean nooverview = false; boolean splitindex = false; boolean noindex = false; // check shared options if (!generalValidOptions(options, reporter)) { return false; } // otherwise look at our options for (int oi = 0; oi < options.length; ++oi) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-helpfile")) { if (nohelp == true) { reporter.printError(getText("doclet.Option_conflict", "-helpfile", "-nohelp")); return false; } if (helpfile == true) { reporter.printError(getText("doclet.Option_reuse", "-helpfile")); return false; } File help = new File(os[1]); if (!help.exists()) { reporter.printError(getText("doclet.File_not_found", os[1])); return false; } helpfile = true; } else if (opt.equals("-nohelp")) { if (helpfile == true) { reporter.printError(getText("doclet.Option_conflict", "-nohelp", "-helpfile")); return false; } nohelp = true; } else if (opt.equals("-xdocrootparent")) { try { new URL(os[1]); } catch (MalformedURLException e) { reporter.printError(getText("doclet.MalformedURL", os[1])); return false; } } else if (opt.equals("-overview")) { if (nooverview == true) { reporter.printError(getText("doclet.Option_conflict", "-overview", "-nooverview")); return false; } if (overview == true) { reporter.printError(getText("doclet.Option_reuse", "-overview")); return false; } overview = true; } else if (opt.equals("-nooverview")) { if (overview == true) { reporter.printError(getText("doclet.Option_conflict", "-nooverview", "-overview")); return false; } nooverview = true; } else if (opt.equals("-splitindex")) { if (noindex == true) { reporter.printError(getText("doclet.Option_conflict", "-splitindex", "-noindex")); return false; } splitindex = true; } else if (opt.equals("-noindex")) { if (splitindex == true) { reporter.printError(getText("doclet.Option_conflict", "-noindex", "-splitindex")); return false; } noindex = true; } } return true; } /** * {@inheritDoc} */ public MessageRetriever getDocletSpecificMsg() { return standardmessage; } /** * Decide the page which will appear first in the right-hand frame. It will * be "overview-summary.html" if "-overview" option is used or no * "-overview" but the number of packages is more than one. It will be * "package-summary.html" of the respective package if there is only one * package to document. It will be a class page(first in the sorted order), * if only classes are provided on the command line. * * @param root Root of the program structure. */ protected void setTopFile(RootDoc root) { if (!checkForDeprecation(root)) { return; } if (createoverview) { topFile = "overview-summary.html"; } else { if (packages.length == 1 && packages[0].name().equals("")) { if (root.classes().length > 0) { ClassDoc[] classarr = root.classes(); Arrays.sort(classarr); ClassDoc cd = getValidClass(classarr); topFile = DirectoryManager.getPathToClass(cd); } } else { topFile = DirectoryManager.getPathToPackage(packages[0], "package-summary.html"); } } } protected ClassDoc getValidClass(ClassDoc[] classarr) { if (!nodeprecated) { return classarr[0]; } for (int i = 0; i < classarr.length; i++) { if (classarr[i].tags("deprecated").length == 0) { return classarr[i]; } } return null; } protected boolean checkForDeprecation(RootDoc root) { ClassDoc[] classarr = root.classes(); for (int i = 0; i < classarr.length; i++) { if (isGeneratedDoc(classarr[i])) { return true; } } return false; } /** * Generate "overview.html" page if option "-overview" is used or number of * packages is more than one. Sets {@link #createoverview} field to true. */ protected void setCreateOverview() { if ((overview || packages.length > 1) && !nooverview) { createoverview = true; } } /** * {@inheritDoc} */ public WriterFactory getWriterFactory() { return new WriterFactoryImpl(this); } /** * {@inheritDoc} */ public Comparator<ProgramElementDoc> getMemberComparator() { return null; } /** * {@inheritDoc} */ public Locale getLocale() { if (root instanceof com.sun.tools.javadoc.RootDocImpl) return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale(); else return Locale.getDefault(); } }
17,489
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SubWriterHolderWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
/* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.formats.html; import java.io.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.formats.html.markup.*; /** * This abstract class exists to provide functionality needed in the * the formatting of member information. Since AbstractSubWriter and its * subclasses control this, they would be the logical place to put this. * However, because each member type has its own subclass, subclassing * can not be used effectively to change formatting. The concrete * class subclass of this class can be subclassed to change formatting. * * @see AbstractMemberWriter * @see ClassWriterImpl * * @author Robert Field * @author Atul M Dambalkar * @author Bhavesh Patel (Modified) */ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { public SubWriterHolderWriter(ConfigurationImpl configuration, String filename) throws IOException { super(configuration, filename); } public SubWriterHolderWriter(ConfigurationImpl configuration, String path, String filename, String relpath) throws IOException { super(configuration, path, filename, relpath); } public void printTypeSummaryHeader() { tdIndex(); font("-1"); code(); } public void printTypeSummaryFooter() { codeEnd(); fontEnd(); tdEnd(); } /** * Add the summary header. * * @param mw the writer for the member being documented * @param cd the classdoc to be documented * @param memberTree the content tree to which the summary header will be added */ public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, Content memberTree) { mw.addSummaryAnchor(cd, memberTree); mw.addSummaryLabel(memberTree); } /** * Get the summary table. * * @param mw the writer for the member being documented * @param cd the classdoc to be documented * @return the content tree for the summary table */ public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) { Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, mw.getTableSummary(), getTableCaption(mw.getCaption())); table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col")); return table; } public void printTableHeadingBackground(String str) { tableIndexDetail(); tableHeaderStart("#CCCCFF", 1); strong(str); tableHeaderEnd(); tableEnd(); } /** * Add the inherited summary header. * * @param mw the writer for the member being documented * @param cd the classdoc to be documented * @param inheritedTree the content tree to which the inherited summary header will be added */ public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, Content inheritedTree) { mw.addInheritedSummaryAnchor(cd, inheritedTree); mw.addInheritedSummaryLabel(cd, inheritedTree); } public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { tableEnd(); space(); } public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { codeEnd(); summaryRowEnd(); trEnd(); tableEnd(); space(); } /** * Add the index comment. * * @param member the member being documented * @param contentTree the content tree to which the comment will be added */ protected void addIndexComment(Doc member, Content contentTree) { addIndexComment(member, member.firstSentenceTags(), contentTree); } protected void printIndexComment(Doc member, Tag[] firstSentenceTags) { Tag[] deprs = member.tags("deprecated"); if (Util.isDeprecated((ProgramElementDoc) member)) { strongText("doclet.Deprecated"); space(); if (deprs.length > 0) { printInlineDeprecatedComment(member, deprs[0]); } return; } else { ClassDoc cd = ((ProgramElementDoc)member).containingClass(); if (cd != null && Util.isDeprecated(cd)) { strongText("doclet.Deprecated"); space(); } } printSummaryComment(member, firstSentenceTags); } /** * Add the index comment. * * @param member the member being documented * @param firstSentenceTags the first sentence tags for the member to be documented * @param tdSummary the content tree to which the comment will be added */ protected void addIndexComment(Doc member, Tag[] firstSentenceTags, Content tdSummary) { Tag[] deprs = member.tags("deprecated"); Content div; if (Util.isDeprecated((ProgramElementDoc) member)) { Content strong = HtmlTree.STRONG(deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, strong); div.addContent(getSpace()); if (deprs.length > 0) { addInlineDeprecatedComment(member, deprs[0], div); } tdSummary.addContent(div); return; } else { ClassDoc cd = ((ProgramElementDoc)member).containingClass(); if (cd != null && Util.isDeprecated(cd)) { Content strong = HtmlTree.STRONG(deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, strong); div.addContent(getSpace()); tdSummary.addContent(div); } } addSummaryComment(member, firstSentenceTags, tdSummary); } /** * Add the summary type for the member. * * @param mw the writer for the member being documented * @param member the member to be documented * @param tdSummaryType the content tree to which the type will be added */ public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member, Content tdSummaryType) { mw.addSummaryType(member, tdSummaryType); } /** * Add the summary link for the member. * * @param mw the writer for the member being documented * @param member the member to be documented * @param contentTree the content tree to which the link will be added */ public void addSummaryLinkComment(AbstractMemberWriter mw, ProgramElementDoc member, Content contentTree) { addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree); } public void printSummaryLinkComment(AbstractMemberWriter mw, ProgramElementDoc member, Tag[] firstSentenceTags) { codeEnd(); println(); br(); printNbsps(); printIndexComment(member, firstSentenceTags); summaryRowEnd(); trEnd(); } /** * Add the summary link comment. * * @param mw the writer for the member being documented * @param member the member being documented * @param firstSentenceTags the first sentence tags for the member to be documented * @param tdSummary the content tree to which the comment will be added */ public void addSummaryLinkComment(AbstractMemberWriter mw, ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) { addIndexComment(member, firstSentenceTags, tdSummary); } /** * Add the inherited member summary. * * @param mw the writer for the member being documented * @param cd the class being documented * @param member the member being documented * @param isFirst true if its the first link being documented * @param linksTree the content tree to which the summary will be added */ public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd, ProgramElementDoc member, boolean isFirst, Content linksTree) { if (! isFirst) { linksTree.addContent(", "); } mw.addInheritedSummaryLink(cd, member, linksTree); } public void printMemberHeader() { hr(); } public void printMemberFooter() { } /** * Get the document content header tree * * @return a content tree the document content header */ public Content getContentHeader() { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); return div; } /** * Get the member header tree * * @return a content tree the member header */ public Content getMemberTreeHeader() { HtmlTree li = new HtmlTree(HtmlTag.LI); li.addStyle(HtmlStyle.blockList); return li; } /** * Get the member tree * * @param contentTree the tree used to generate the complete member tree * @return a content tree for the member */ public Content getMemberTree(Content contentTree) { Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree); return ul; } /** * Get the member summary tree * * @param contentTree the tree used to generate the member summary tree * @return a content tree for the member summary */ public Content getMemberSummaryTree(Content contentTree) { return getMemberTree(HtmlStyle.summary, contentTree); } /** * Get the member details tree * * @param contentTree the tree used to generate the member details tree * @return a content tree for the member details */ public Content getMemberDetailsTree(Content contentTree) { return getMemberTree(HtmlStyle.details, contentTree); } /** * Get the member tree * * @param style the style class to be added to the content tree * @param contentTree the tree used to generate the complete member tree */ public Content getMemberTree(HtmlStyle style, Content contentTree) { Content div = HtmlTree.DIV(style, getMemberTree(contentTree)); return div; } }
11,545
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassWriterImpl.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
/* * Copyright (c) 1997, 2011, 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.formats.html; 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.doclets.internal.toolkit.builders.*; import com.sun.tools.doclets.internal.toolkit.taglets.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Generate the Class Information Page. * @see com.sun.javadoc.ClassDoc * @see java.util.Collections * @see java.util.List * @see java.util.ArrayList * @see java.util.HashMap * * @author Atul M Dambalkar * @author Robert Field * @author Bhavesh Patel (Modified) */ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter { protected ClassDoc classDoc; protected ClassTree classtree; protected ClassDoc prev; protected ClassDoc next; /** * @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 for the given class. */ public ClassWriterImpl (ClassDoc classDoc, ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree) throws Exception { super(ConfigurationImpl.getInstance(), DirectoryManager.getDirectoryPath(classDoc.containingPackage()), classDoc.name() + ".html", DirectoryManager.getRelativePath(classDoc.containingPackage().name())); this.classDoc = classDoc; configuration.currentcd = classDoc; this.classtree = classTree; this.prev = prevClass; this.next = nextClass; } /** * Get this package link. * * @return a content tree for the package link */ protected Content getNavLinkPackage() { Content linkContent = getHyperLink("package-summary.html", "", packageLabel); Content li = HtmlTree.LI(linkContent); return li; } /** * Get the class link. * * @return a content tree for the class link */ protected Content getNavLinkClass() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel); return li; } /** * Get the class use link. * * @return a content tree for the class use link */ protected Content getNavLinkClassUse() { Content linkContent = getHyperLink("class-use/" + filename, "", useLabel); Content li = HtmlTree.LI(linkContent); return li; } /** * Get link to previous class. * * @return a content tree for the previous class link */ public Content getNavLinkPrevious() { Content li; if (prev != null) { Content prevLink = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS, prev, "", configuration.getText("doclet.Prev_Class"), true))); li = HtmlTree.LI(prevLink); } else li = HtmlTree.LI(prevclassLabel); return li; } /** * Get link to next class. * * @return a content tree for the next class link */ public Content getNavLinkNext() { Content li; if (next != null) { Content nextLink = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS, next, "", configuration.getText("doclet.Next_Class"), true))); li = HtmlTree.LI(nextLink); } else li = HtmlTree.LI(nextclassLabel); return li; } /** * {@inheritDoc} */ public Content getHeader(String header) { String pkgname = (classDoc.containingPackage() != null)? classDoc.containingPackage().name(): ""; String clname = classDoc.name(); Content bodyTree = getBody(true, getWindowTitle(clname)); addTop(bodyTree); addNavLinks(true, bodyTree); bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.header); if (pkgname.length() > 0) { Content pkgNameContent = new StringContent(pkgname); Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent); div.addContent(pkgNameDiv); } LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false); //Let's not link to ourselves in the header. linkInfo.linkToSelf = false; Content headerContent = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headerContent); heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo))); div.addContent(heading); bodyTree.addContent(div); return bodyTree; } /** * {@inheritDoc} */ public Content getClassContentHeader() { return getContentHeader(); } /** * {@inheritDoc} */ public void addFooter(Content contentTree) { contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); addNavLinks(false, contentTree); addBottom(contentTree); } /** * {@inheritDoc} */ public void printDocument(Content contentTree) { printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc), true, contentTree); } /** * {@inheritDoc} */ public Content getClassInfoTreeHeader() { return getMemberTreeHeader(); } /** * {@inheritDoc} */ public Content getClassInfo(Content classInfoTree) { return getMemberTree(HtmlStyle.description, classInfoTree); } /** * {@inheritDoc} */ public void addClassSignature(String modifiers, Content classInfoTree) { boolean isInterface = classDoc.isInterface(); classInfoTree.addContent(new HtmlTree(HtmlTag.BR)); Content pre = new HtmlTree(HtmlTag.PRE); addAnnotationInfo(classDoc, pre); pre.addContent(modifiers); LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); //Let's not link to ourselves in the signature. linkInfo.linkToSelf = false; Content className = new StringContent(classDoc.name()); Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo)); if (configuration().linksource) { addSrcLink(classDoc, className, pre); pre.addContent(parameterLinks); } else { Content span = HtmlTree.SPAN(HtmlStyle.strong, className); span.addContent(parameterLinks); pre.addContent(span); } if (!isInterface) { Type superclass = Util.getFirstVisibleSuperClass(classDoc, configuration()); if (superclass != null) { pre.addContent(DocletConstants.NL); pre.addContent("extends "); Content link = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, superclass))); pre.addContent(link); } } Type[] implIntfacs = classDoc.interfaceTypes(); if (implIntfacs != null && implIntfacs.length > 0) { int counter = 0; for (int i = 0; i < implIntfacs.length; i++) { ClassDoc classDoc = implIntfacs[i].asClassDoc(); if (! (classDoc.isPublic() || Util.isLinkable(classDoc, configuration()))) { continue; } if (counter == 0) { pre.addContent(DocletConstants.NL); pre.addContent(isInterface? "extends " : "implements "); } else { pre.addContent(", "); } Content link = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, implIntfacs[i]))); pre.addContent(link); counter++; } } classInfoTree.addContent(pre); } /** * {@inheritDoc} */ public void addClassDescription(Content classInfoTree) { if(!configuration.nocomment) { // generate documentation for the class. if (classDoc.inlineTags().length > 0) { addInlineComment(classDoc, classInfoTree); } } } /** * {@inheritDoc} */ public void addClassTagInfo(Content classInfoTree) { if(!configuration.nocomment) { // Print Information about all the tags here addTagsInfo(classDoc, classInfoTree); } } /** * Get the class hierarchy tree for the given class. * * @param type the class to print the hierarchy for * @return a content tree for class inheritence */ private Content getClassInheritenceTree(Type type) { Type sup; HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL); classTreeUl.addStyle(HtmlStyle.inheritance); Content liTree = null; do { sup = Util.getFirstVisibleSuperClass( type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), configuration()); if (sup != null) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.inheritance); ul.addContent(getTreeForClassHelper(type)); if (liTree != null) ul.addContent(liTree); Content li = HtmlTree.LI(ul); liTree = li; type = sup; } else classTreeUl.addContent(getTreeForClassHelper(type)); } while (sup != null); if (liTree != null) classTreeUl.addContent(liTree); return classTreeUl; } /** * Get the class helper tree for the given class. * * @param type the class to print the helper for * @return a content tree for class helper */ private Content getTreeForClassHelper(Type type) { Content li = new HtmlTree(HtmlTag.LI); if (type.equals(classDoc)) { String typeParameters = getTypeParameterLinks( new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE, classDoc, false)); if (configuration.shouldExcludeQualifier( classDoc.containingPackage().name())) { li.addContent(type.asClassDoc().name()); li.addContent(new RawHtml(typeParameters)); } else { li.addContent(type.asClassDoc().qualifiedName()); li.addContent(new RawHtml(typeParameters)); } } else { Content link = new RawHtml(getLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT, type instanceof ClassDoc ? (ClassDoc) type : type, configuration.getClassName(type.asClassDoc()), false))); li.addContent(link); } return li; } /** * {@inheritDoc} */ public void addClassTree(Content classContentTree) { if (!classDoc.isClass()) { return; } classContentTree.addContent(getClassInheritenceTree(classDoc)); } /** * {@inheritDoc} */ public void addTypeParamInfo(Content classInfoTree) { if (classDoc.typeParamTags().length > 0) { TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc, getTagletWriterInstance(false)); Content typeParam = new RawHtml(output.toString()); Content dl = HtmlTree.DL(typeParam); classInfoTree.addContent(dl); } } /** * {@inheritDoc} */ public void addSubClassInfo(Content classInfoTree) { if (classDoc.isClass()) { if (classDoc.qualifiedName().equals("java.lang.Object") || classDoc.qualifiedName().equals("org.omg.CORBA.Object")) { return; // Don't generate the list, too huge } List<ClassDoc> subclasses = classtree.subs(classDoc, false); if (subclasses.size() > 0) { Content label = getResource( "doclet.Subclasses"); Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES, subclasses)); classInfoTree.addContent(dl); } } } /** * {@inheritDoc} */ public void addSubInterfacesInfo(Content classInfoTree) { if (classDoc.isInterface()) { List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false); if (subInterfaces.size() > 0) { Content label = getResource( "doclet.Subinterfaces"); Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES, subInterfaces)); classInfoTree.addContent(dl); } } } /** * {@inheritDoc} */ public void addInterfaceUsageInfo (Content classInfoTree) { if (! classDoc.isInterface()) { return; } if (classDoc.qualifiedName().equals("java.lang.Cloneable") || classDoc.qualifiedName().equals("java.io.Serializable")) { return; // Don't generate the list, too big } List<ClassDoc> implcl = classtree.implementingclasses(classDoc); if (implcl.size() > 0) { Content label = getResource( "doclet.Implementing_Classes"); Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES, implcl)); classInfoTree.addContent(dl); } } /** * {@inheritDoc} */ public void addImplementedInterfacesInfo(Content classInfoTree) { //NOTE: we really should be using ClassDoc.interfaceTypes() here, but // it doesn't walk up the tree like we want it to. List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration); if (classDoc.isClass() && interfaceArray.size() > 0) { Content label = getResource( "doclet.All_Implemented_Interfaces"); Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES, interfaceArray)); classInfoTree.addContent(dl); } } /** * {@inheritDoc} */ public void addSuperInterfacesInfo(Content classInfoTree) { //NOTE: we really should be using ClassDoc.interfaceTypes() here, but // it doesn't walk up the tree like we want it to. List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration); if (classDoc.isInterface() && interfaceArray.size() > 0) { Content label = getResource( "doclet.All_Superinterfaces"); Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES, interfaceArray)); classInfoTree.addContent(dl); } } /** * {@inheritDoc} */ public void addNestedClassInfo(Content classInfoTree) { ClassDoc outerClass = classDoc.containingClass(); if (outerClass != null) { Content label; if (outerClass.isInterface()) { label = getResource( "doclet.Enclosing_Interface"); } else { label = getResource( "doclet.Enclosing_Class"); } Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass, false)))); dl.addContent(dd); classInfoTree.addContent(dl); } } /** * {@inheritDoc} */ public void addClassDeprecationInfo(Content classInfoTree) { Content hr = new HtmlTree(HtmlTag.HR); classInfoTree.addContent(hr); Tag[] deprs = classDoc.tags("deprecated"); if (Util.isDeprecated(classDoc)) { Content strong = HtmlTree.STRONG(deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, strong); if (deprs.length > 0) { Tag[] commentTags = deprs[0].inlineTags(); if (commentTags.length > 0) { div.addContent(getSpace()); addInlineDeprecatedComment(classDoc, deprs[0], div); } } classInfoTree.addContent(div); } } /** * Get links to the given classes. * * @param context the id of the context where the link will be printed * @param list the list of classes * @return a content tree for the class list */ private Content getClassLinks(int context, List<?> list) { Object[] typeList = list.toArray(); Content dd = new HtmlTree(HtmlTag.DD); for (int i = 0; i < list.size(); i++) { if (i > 0) { Content separator = new StringContent(", "); dd.addContent(separator); } if (typeList[i] instanceof ClassDoc) { Content link = new RawHtml(getLink( new LinkInfoImpl(context, (ClassDoc)(typeList[i])))); dd.addContent(link); } else { Content link = new RawHtml(getLink( new LinkInfoImpl(context, (Type)(typeList[i])))); dd.addContent(link); } } return dd; } /** * {@inheritDoc} */ protected Content getNavLinkTree() { Content treeLinkContent = getHyperLink("package-tree.html", "", treeLabel, "", ""); Content li = HtmlTree.LI(treeLinkContent); return li; } /** * Add summary details to the navigation bar. * * @param subDiv the content tree to which the summary detail links will be added */ protected void addSummaryDetailLinks(Content subDiv) { try { Content div = HtmlTree.DIV(getNavSummaryLinks()); div.addContent(getNavDetailLinks()); subDiv.addContent(div); } catch (Exception e) { e.printStackTrace(); throw new DocletAbortException(); } } /** * Get summary links for navigation bar. * * @return the content tree for the navigation summary links */ protected Content getNavSummaryLinks() throws Exception { Content li = HtmlTree.LI(summaryLabel); li.addContent(getSpace()); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); String[] navLinkLabels = new String[] { "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", "doclet.navMethod" }; for (int i = 0; i < navLinkLabels.length; i++ ) { Content liNav = new HtmlTree(HtmlTag.LI); if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { continue; } if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) { continue; } AbstractMemberWriter writer = ((AbstractMemberWriter) memberSummaryBuilder. getMemberSummaryWriter(i)); if (writer == null) { liNav.addContent(getResource(navLinkLabels[i])); } else { writer.addNavSummaryLink( memberSummaryBuilder.members(i), memberSummaryBuilder.getVisibleMemberMap(i), liNav); } if (i < navLinkLabels.length-1) { addNavGap(liNav); } ulNav.addContent(liNav); } return ulNav; } /** * Get detail links for the navigation bar. * * @return the content tree for the detail links */ protected Content getNavDetailLinks() throws Exception { Content li = HtmlTree.LI(detailLabel); li.addContent(getSpace()); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) configuration.getBuilderFactory().getMemberSummaryBuilder(this); String[] navLinkLabels = new String[] { "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", "doclet.navMethod" }; for (int i = 1; i < navLinkLabels.length; i++ ) { Content liNav = new HtmlTree(HtmlTag.LI); AbstractMemberWriter writer = ((AbstractMemberWriter) memberSummaryBuilder. getMemberSummaryWriter(i)); if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { continue; } if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) { continue; } if (writer == null) { liNav.addContent(getResource(navLinkLabels[i])); } else { writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav); } if (i < navLinkLabels.length - 1) { addNavGap(liNav); } ulNav.addContent(liNav); } return ulNav; } /** * Add gap between navigation bar elements. * * @param liNav the content tree to which the gap will be added */ protected void addNavGap(Content liNav) { liNav.addContent(getSpace()); liNav.addContent("|"); liNav.addContent(getSpace()); } /** * Return the classDoc being documented. * * @return the classDoc being documented. */ public ClassDoc getClassDoc() { return classDoc; } }
24,259
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AbstractTreeWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
/* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.tools.doclets.formats.html; import java.io.*; import java.util.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.formats.html.markup.*; import com.sun.javadoc.*; /** * Abstract class to print the class hierarchy page for all the Classes. This * is sub-classed by {@link PackageTreeWriter} and {@link TreeWriter} to * generate the Package Tree and global Tree(for all the classes and packages) * pages. * * @author Atul M Dambalkar */ public abstract class AbstractTreeWriter extends HtmlDocletWriter { /** * The class and interface tree built by using {@link ClassTree} */ protected final ClassTree classtree; private static final String LI_CIRCLE = "circle"; /** * Constructor initilises classtree variable. This constructor will be used * while generating global tree file "overview-tree.html". * * @param filename File to be generated. * @param classtree Tree built by {@link ClassTree}. * @throws IOException * @throws DocletAbortException */ protected AbstractTreeWriter(ConfigurationImpl configuration, String filename, ClassTree classtree) throws IOException { super(configuration, filename); this.classtree = classtree; } /** * Create appropriate directory for the package and also initilise the * relative path from this generated file to the current or * the destination directory. This constructor will be used while * generating "package tree" file. * * @param path Directories in this path will be created if they are not * already there. * @param filename Name of the package tree file to be generated. * @param classtree The tree built using {@link ClassTree}. * for the package pkg. * @param pkg PackageDoc for which tree file will be generated. * @throws IOException * @throws DocletAbortException */ protected AbstractTreeWriter(ConfigurationImpl configuration, String path, String filename, ClassTree classtree, PackageDoc pkg) throws IOException { super(configuration, path, filename, DirectoryManager.getRelativePath(pkg.name())); this.classtree = classtree; } /** * Add each level of the class tree. For each sub-class or * sub-interface indents the next level information. * Recurses itself to add subclasses info. * * @param parent the superclass or superinterface of the list * @param list list of the sub-classes at this level * @param isEnum true if we are generating a tree for enums * @param contentTree the content tree to which the level information will be added */ protected void addLevelInfo(ClassDoc parent, List<ClassDoc> list, boolean isEnum, Content contentTree) { int size = list.size(); if (size > 0) { Content ul = new HtmlTree(HtmlTag.UL); for (int i = 0; i < size; i++) { ClassDoc local = list.get(i); HtmlTree li = new HtmlTree(HtmlTag.LI); li.addAttr(HtmlAttr.TYPE, LI_CIRCLE); addPartialInfo(local, li); addExtendsImplements(parent, local, li); addLevelInfo(local, classtree.subs(local, isEnum), isEnum, li); // Recurse ul.addContent(li); } contentTree.addContent(ul); } } /** * Add the heading for the tree depending upon tree type if it's a * Class Tree or Interface tree. * * @param list List of classes which are at the most base level, all the * other classes in this run will derive from these classes * @param heading heading for the tree * @param div the content tree to which the tree will be added */ protected void addTree(List<ClassDoc> list, String heading, Content div) { if (list.size() > 0) { ClassDoc firstClassDoc = list.get(0); Content headingContent = getResource(heading); div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent)); addLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null, list, list == classtree.baseEnums(), div); } } /** * Add information regarding the classes which this class extends or * implements. * * @param parent the parent class of the class being documented * @param cd the classdoc under consideration * @param contentTree the content tree to which the information will be added */ protected void addExtendsImplements(ClassDoc parent, ClassDoc cd, Content contentTree) { ClassDoc[] interfaces = cd.interfaces(); if (interfaces.length > (cd.isInterface()? 1 : 0)) { Arrays.sort(interfaces); int counter = 0; for (int i = 0; i < interfaces.length; i++) { if (parent != interfaces[i]) { if (! (interfaces[i].isPublic() || Util.isLinkable(interfaces[i], configuration()))) { continue; } if (counter == 0) { if (cd.isInterface()) { contentTree.addContent(" ("); contentTree.addContent(getResource("doclet.also")); contentTree.addContent(" extends "); } else { contentTree.addContent(" (implements "); } } else { contentTree.addContent(", "); } addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE, interfaces[i], contentTree); counter++; } } if (counter > 0) { contentTree.addContent(")"); } } } /** * Add information about the class kind, if it's a "class" or "interface". * * @param cd the class being documented * @param contentTree the content tree to which the information will be added */ protected void addPartialInfo(ClassDoc cd, Content contentTree) { addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree); } /** * Get the tree label for the navigation bar. * * @return a content tree for the tree label */ protected Content getNavLinkTree() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel); return li; } }
8,141
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
HelpWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
/* * Copyright (c) 1998, 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.formats.html; import java.io.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.formats.html.markup.*; /** * Generate the Help File for the generated API documentation. The help file * contents are helpful for browsing the generated documentation. * * @author Atul M Dambalkar */ public class HelpWriter extends HtmlDocletWriter { /** * Constructor to construct HelpWriter object. * @param filename File to be generated. */ public HelpWriter(ConfigurationImpl configuration, String filename) throws IOException { super(configuration, filename); } /** * Construct the HelpWriter object and then use it to generate the help * file. The name of the generated file is "help-doc.html". The help file * will get generated if and only if "-helpfile" and "-nohelp" is not used * on the command line. * @throws DocletAbortException */ public static void generate(ConfigurationImpl configuration) { HelpWriter helpgen; String filename = ""; try { filename = "help-doc.html"; helpgen = new HelpWriter(configuration, filename); helpgen.generateHelpFile(); helpgen.close(); } catch (IOException exc) { configuration.standardmessage.error( "doclet.exception_encountered", exc.toString(), filename); throw new DocletAbortException(); } } /** * Generate the help file contents. */ protected void generateHelpFile() { String title = configuration.getText("doclet.Window_Help_title"); Content body = getBody(true, getWindowTitle(title)); addTop(body); addNavLinks(true, body); addHelpFileContents(body); addNavLinks(false, body); addBottom(body); printHtmlDocument(null, true, body); } /** * Add the help file contents from the resource file to the content tree. While adding the * help file contents it also keeps track of user options. If "-notree" * is used, then the "overview-tree.html" will not get added and hence * help information also will not get added. * * @param contentTree the content tree to which the help file contents will be added */ protected void addHelpFileContents(Content contentTree) { Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, getResource("doclet.Help_line_1")); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content line2 = HtmlTree.DIV(HtmlStyle.subTitle, getResource("doclet.Help_line_2")); div.addContent(line2); contentTree.addContent(div); HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); if (configuration.createoverview) { Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Overview")); Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading); Content line3 = getResource("doclet.Help_line_3", getHyperLinkString("overview-summary.html", configuration.getText("doclet.Overview"))); Content overviewPara = HtmlTree.P(line3); liOverview.addContent(overviewPara); ul.addContent(liOverview); } Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Package")); Content liPackage = HtmlTree.LI(HtmlStyle.blockList, packageHead); Content line4 = getResource("doclet.Help_line_4"); Content packagePara = HtmlTree.P(line4); liPackage.addContent(packagePara); HtmlTree ulPackage = new HtmlTree(HtmlTag.UL); ulPackage.addContent(HtmlTree.LI( getResource("doclet.Interfaces_Italic"))); ulPackage.addContent(HtmlTree.LI( getResource("doclet.Classes"))); ulPackage.addContent(HtmlTree.LI( getResource("doclet.Enums"))); ulPackage.addContent(HtmlTree.LI( getResource("doclet.Exceptions"))); ulPackage.addContent(HtmlTree.LI( getResource("doclet.Errors"))); ulPackage.addContent(HtmlTree.LI( getResource("doclet.AnnotationTypes"))); liPackage.addContent(ulPackage); ul.addContent(liPackage); Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_5")); Content liClass = HtmlTree.LI(HtmlStyle.blockList, classHead); Content line6 = getResource("doclet.Help_line_6"); Content classPara = HtmlTree.P(line6); liClass.addContent(classPara); HtmlTree ul1 = new HtmlTree(HtmlTag.UL); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_7"))); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_8"))); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_9"))); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_10"))); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_11"))); ul1.addContent(HtmlTree.LI( getResource("doclet.Help_line_12"))); liClass.addContent(ul1); HtmlTree ul2 = new HtmlTree(HtmlTag.UL); ul2.addContent(HtmlTree.LI( getResource("doclet.Nested_Class_Summary"))); ul2.addContent(HtmlTree.LI( getResource("doclet.Field_Summary"))); ul2.addContent(HtmlTree.LI( getResource("doclet.Constructor_Summary"))); ul2.addContent(HtmlTree.LI( getResource("doclet.Method_Summary"))); liClass.addContent(ul2); HtmlTree ul3 = new HtmlTree(HtmlTag.UL); ul3.addContent(HtmlTree.LI( getResource("doclet.Field_Detail"))); ul3.addContent(HtmlTree.LI( getResource("doclet.Constructor_Detail"))); ul3.addContent(HtmlTree.LI( getResource("doclet.Method_Detail"))); liClass.addContent(ul3); Content line13 = getResource("doclet.Help_line_13"); Content para = HtmlTree.P(line13); liClass.addContent(para); ul.addContent(liClass); //Annotation Types Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.AnnotationType")); Content liAnnotation = HtmlTree.LI(HtmlStyle.blockList, aHead); Content aline1 = getResource("doclet.Help_annotation_type_line_1"); Content aPara = HtmlTree.P(aline1); liAnnotation.addContent(aPara); HtmlTree aul = new HtmlTree(HtmlTag.UL); aul.addContent(HtmlTree.LI( getResource("doclet.Help_annotation_type_line_2"))); aul.addContent(HtmlTree.LI( getResource("doclet.Help_annotation_type_line_3"))); aul.addContent(HtmlTree.LI( getResource("doclet.Annotation_Type_Required_Member_Summary"))); aul.addContent(HtmlTree.LI( getResource("doclet.Annotation_Type_Optional_Member_Summary"))); aul.addContent(HtmlTree.LI( getResource("doclet.Annotation_Type_Member_Detail"))); liAnnotation.addContent(aul); ul.addContent(liAnnotation); //Enums Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Enum")); Content liEnum = HtmlTree.LI(HtmlStyle.blockList, enumHead); Content eline1 = getResource("doclet.Help_enum_line_1"); Content enumPara = HtmlTree.P(eline1); liEnum.addContent(enumPara); HtmlTree eul = new HtmlTree(HtmlTag.UL); eul.addContent(HtmlTree.LI( getResource("doclet.Help_enum_line_2"))); eul.addContent(HtmlTree.LI( getResource("doclet.Help_enum_line_3"))); eul.addContent(HtmlTree.LI( getResource("doclet.Enum_Constant_Summary"))); eul.addContent(HtmlTree.LI( getResource("doclet.Enum_Constant_Detail"))); liEnum.addContent(eul); ul.addContent(liEnum); if (configuration.classuse) { Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_14")); Content liUse = HtmlTree.LI(HtmlStyle.blockList, useHead); Content line15 = getResource("doclet.Help_line_15"); Content usePara = HtmlTree.P(line15); liUse.addContent(usePara); ul.addContent(liUse); } if (configuration.createtree) { Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_16")); Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead); Content line17 = getResource("doclet.Help_line_17_with_tree_link", getHyperLinkString("overview-tree.html", configuration.getText("doclet.Class_Hierarchy"))); Content treePara = HtmlTree.P(line17); liTree.addContent(treePara); HtmlTree tul = new HtmlTree(HtmlTag.UL); tul.addContent(HtmlTree.LI( getResource("doclet.Help_line_18"))); tul.addContent(HtmlTree.LI( getResource("doclet.Help_line_19"))); liTree.addContent(tul); ul.addContent(liTree); } if (!(configuration.nodeprecatedlist || configuration.nodeprecated)) { Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Deprecated_API")); Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead); Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link", getHyperLinkString("deprecated-list.html", configuration.getText("doclet.Deprecated_API"))); Content dPara = HtmlTree.P(line20); liDeprecated.addContent(dPara); ul.addContent(liDeprecated); } if (configuration.createindex) { String indexlink; if (configuration.splitindex) { indexlink = getHyperLinkString("index-files/index-1.html", configuration.getText("doclet.Index")); } else { indexlink = getHyperLinkString("index-all.html", configuration.getText("doclet.Index")); } Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_21")); Content liIndex = HtmlTree.LI(HtmlStyle.blockList, indexHead); Content line22 = getResource("doclet.Help_line_22", indexlink); Content indexPara = HtmlTree.P(line22); liIndex.addContent(indexPara); ul.addContent(liIndex); } Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_23")); Content liPrev = HtmlTree.LI(HtmlStyle.blockList, prevHead); Content line24 = getResource("doclet.Help_line_24"); Content prevPara = HtmlTree.P(line24); liPrev.addContent(prevPara); ul.addContent(liPrev); Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Help_line_25")); Content liFrame = HtmlTree.LI(HtmlStyle.blockList, frameHead); Content line26 = getResource("doclet.Help_line_26"); Content framePara = HtmlTree.P(line26); liFrame.addContent(framePara); ul.addContent(liFrame); Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.All_Classes")); Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead); Content line27 = getResource("doclet.Help_line_27", getHyperLinkString("allclasses-noframe.html", configuration.getText("doclet.All_Classes"))); Content allclassesPara = HtmlTree.P(line27); liAllClasses.addContent(allclassesPara); ul.addContent(liAllClasses); Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Serialized_Form")); Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead); Content line28 = getResource("doclet.Help_line_28"); Content serialPara = HtmlTree.P(line28); liSerial.addContent(serialPara); ul.addContent(liSerial); Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, getResource("doclet.Constants_Summary")); Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead); Content line29 = getResource("doclet.Help_line_29", getHyperLinkString("constant-values.html", configuration.getText("doclet.Constants_Summary"))); Content constPara = HtmlTree.P(line29); liConst.addContent(constPara); ul.addContent(liConst); Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul); Content line30 = HtmlTree.EM(getResource("doclet.Help_line_30")); divContent.addContent(line30); contentTree.addContent(divContent); } /** * Get the help label. * * @return a content tree for the help label */ protected Content getNavLinkHelp() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel); return li; } }
15,218
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z