Source Code Cross Referenced for MethodDocImpl.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » javadoc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules com.sun » tools » com.sun.tools.javadoc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.*;
031:        import com.sun.tools.javac.code.Symbol.*;
032:        import com.sun.tools.javac.code.Type;
033:        import com.sun.tools.javac.code.TypeTags;
034:        import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
035:        import com.sun.tools.javac.util.Position;
036:
037:        import java.lang.reflect.Modifier;
038:
039:        /**
040:         * Represents a method of a java class.
041:         *
042:         * @since 1.2
043:         * @author Robert Field
044:         * @author Neal Gafter (rewrite)
045:         */
046:
047:        public class MethodDocImpl extends ExecutableMemberDocImpl implements 
048:                MethodDoc {
049:
050:            /**
051:             * constructor.
052:             */
053:            public MethodDocImpl(DocEnv env, MethodSymbol sym) {
054:                super (env, sym);
055:            }
056:
057:            /**
058:             * constructor.
059:             */
060:            public MethodDocImpl(DocEnv env, MethodSymbol sym,
061:                    String docComment, JCMethodDecl tree,
062:                    Position.LineMap lineMap) {
063:                super (env, sym, docComment, tree, lineMap);
064:            }
065:
066:            /** 
067:             * Return true if it is a method, which it is. 
068:             * Note: constructors are not methods.
069:             * This method is overridden by AnnotationTypeElementDocImpl.
070:             *
071:             * @return true
072:             */
073:            public boolean isMethod() {
074:                return true;
075:            }
076:
077:            /** 
078:             * Return true if this method is abstract 
079:             */
080:            public boolean isAbstract() {
081:                //### This is dubious, but old 'javadoc' apparently does it.
082:                //### I regard this as a bug and an obstacle to treating the
083:                //### doclet API as a proper compile-time reflection facility.
084:                //### (maddox 09/26/2000)
085:                if (containingClass().isInterface()) {
086:                    //### Don't force creation of ClassDocImpl for super here.
087:                    // Abstract modifier is implicit.  Strip/canonicalize it.
088:                    return false;
089:                }
090:                return Modifier.isAbstract(getModifiers());
091:            }
092:
093:            /**
094:             * Get return type. 
095:             *
096:             * @return the return type of this method, null if it
097:             * is a constructor.
098:             */
099:            public com.sun.javadoc.Type returnType() {
100:                return TypeMaker.getType(env, sym.type.getReturnType(), false);
101:            }
102:
103:            /** 
104:             * Return the class that originally defined the method that
105:             * is overridden by the current definition, or null if no
106:             * such class exists.
107:             *
108:             * @return a ClassDocImpl representing the superclass that
109:             * originally defined this method, null if this method does
110:             * not override a definition in a superclass.
111:             */
112:            public ClassDoc overriddenClass() {
113:                com.sun.javadoc.Type t = overriddenType();
114:                return (t != null) ? t.asClassDoc() : null;
115:            }
116:
117:            /**
118:             * Return the type containing the method that this method overrides.
119:             * It may be a <code>ClassDoc</code> or a <code>ParameterizedType</code>.
120:             */
121:            public com.sun.javadoc.Type overriddenType() {
122:
123:                if ((sym.flags() & Flags.STATIC) != 0) {
124:                    return null;
125:                }
126:
127:                ClassSymbol origin = (ClassSymbol) sym.owner;
128:                for (Type t = env.types.super type(origin.type); t.tag == TypeTags.CLASS; t = env.types
129:                        .super type(t)) {
130:                    ClassSymbol c = (ClassSymbol) t.tsym;
131:                    for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e
132:                            .next()) {
133:                        if (sym.overrides(e.sym, origin, env.types, true)) {
134:                            return TypeMaker.getType(env, t);
135:                        }
136:                    }
137:                }
138:                return null;
139:            }
140:
141:            /**
142:             * Return the method that this method overrides.
143:             *
144:             * @return a MethodDoc representing a method definition
145:             * in a superclass this method overrides, null if
146:             * this method does not override.
147:             */
148:            public MethodDoc overriddenMethod() {
149:
150:                // Real overriding only.  Static members are simply hidden.
151:                // Likewise for constructors, but the MethodSymbol.overrides
152:                // method takes this into account.
153:                if ((sym.flags() & Flags.STATIC) != 0) {
154:                    return null;
155:                }
156:
157:                // Derived from  com.sun.tools.javac.comp.Check.checkOverride .
158:
159:                ClassSymbol origin = (ClassSymbol) sym.owner;
160:                for (Type t = env.types.super type(origin.type); t.tag == TypeTags.CLASS; t = env.types
161:                        .super type(t)) {
162:                    ClassSymbol c = (ClassSymbol) t.tsym;
163:                    for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e
164:                            .next()) {
165:                        if (sym.overrides(e.sym, origin, env.types, true)) {
166:                            return env.getMethodDoc((MethodSymbol) e.sym);
167:                        }
168:                    }
169:                }
170:                return null;
171:            }
172:
173:            /**
174:             * Tests whether this method overrides another.
175:             * The overridden method may be one declared in a superclass or
176:             * a superinterface (unlike {@link #overriddenMethod()}).
177:             *
178:             * <p> When a non-abstract method overrides an abstract one, it is
179:             * also said to <i>implement</i> the other.
180:             *
181:             * @param meth  the other method to examine
182:             * @return <tt>true</tt> if this method overrides the other
183:             */
184:            public boolean overrides(MethodDoc meth) {
185:                MethodSymbol overridee = ((MethodDocImpl) meth).sym;
186:                ClassSymbol origin = (ClassSymbol) sym.owner;
187:
188:                return sym.name == overridee.name
189:                        &&
190:
191:                        // not reflexive as per JLS
192:                        sym != overridee
193:                        &&
194:
195:                        // we don't care if overridee is static, though that wouldn't
196:                        // compile
197:                        !sym.isStatic()
198:                        &&
199:
200:                        // sym, whose declaring type is the origin, must be
201:                        // in a subtype of overridee's type
202:                        env.types.asSuper(origin.type, overridee.owner) != null
203:                        &&
204:
205:                        // check access and signatures; don't check return types
206:                        sym.overrides(overridee, origin, env.types, false);
207:            }
208:
209:            public String name() {
210:                return sym.name.toString();
211:            }
212:
213:            public String qualifiedName() {
214:                return sym.enclClass().getQualifiedName() + "." + sym.name;
215:            }
216:
217:            /**
218:             * Returns a string representation of this method.  Includes the
219:             * qualified signature, the qualified method name, and any type
220:             * parameters.  Type parameters follow the class name, as they do
221:             * in the syntax for invoking methods with explicit type parameters.
222:             */
223:            public String toString() {
224:                return sym.enclClass().getQualifiedName() + "."
225:                        + typeParametersString() + name() + signature();
226:            }
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.