001: /*
002: * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.javadoc;
027:
028: import com.sun.javadoc.*;
029:
030: import com.sun.tools.javac.code.Symbol.ClassSymbol;
031: import com.sun.tools.javac.code.Symbol.MethodSymbol;
032: import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
033: import com.sun.tools.javac.util.Position;
034:
035: /**
036: * Represents a constructor of a java class.
037: *
038: * @since 1.2
039: * @author Robert Field
040: * @author Neal Gafter (rewrite)
041: */
042:
043: public class ConstructorDocImpl extends ExecutableMemberDocImpl
044: implements ConstructorDoc {
045:
046: /**
047: * constructor.
048: */
049: public ConstructorDocImpl(DocEnv env, MethodSymbol sym) {
050: super (env, sym);
051: }
052:
053: /**
054: * constructor.
055: */
056: public ConstructorDocImpl(DocEnv env, MethodSymbol sym,
057: String docComment, JCMethodDecl tree,
058: Position.LineMap lineMap) {
059: super (env, sym, docComment, tree, lineMap);
060: }
061:
062: /**
063: * Return true if it is a constructor, which it is.
064: *
065: * @return true
066: */
067: public boolean isConstructor() {
068: return true;
069: }
070:
071: /**
072: * Get the name.
073: *
074: * @return the name of the member qualified by class (but not package)
075: */
076: public String name() {
077: ClassSymbol c = sym.enclClass();
078: String n = c.name.toString();
079: for (c = c.owner.enclClass(); c != null; c = c.owner
080: .enclClass()) {
081: n = c.name.toString() + "." + n;
082: }
083: return n;
084: }
085:
086: /**
087: * Get the name.
088: *
089: * @return the qualified name of the member.
090: */
091: public String qualifiedName() {
092: return sym.enclClass().getQualifiedName().toString();
093: }
094:
095: /**
096: * Returns a string representation of this constructor. Includes the
097: * qualified signature and any type parameters.
098: * Type parameters precede the class name, as they do in the syntax
099: * for invoking constructors with explicit type parameters using "new".
100: * (This is unlike the syntax for invoking methods with explicit type
101: * parameters.)
102: */
103: public String toString() {
104: return typeParametersString() + qualifiedName() + signature();
105: }
106: }
|