Source Code Cross Referenced for ConstructorDeclaration.java in  » UML » jrefactory » org » acm » seguin » pretty » jdi » 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 » UML » jrefactory » org.acm.seguin.pretty.jdi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Author:  Mike Atkinson
003:         *
004:         *  This software has been developed under the copyleft
005:         *  rules of the GNU General Public License.  Please
006:         *  consult the GNU General Public License for more
007:         *  details about use and distribution of this software.
008:         */
009:        package org.acm.seguin.pretty.jdi;
010:
011:        import java.text.MessageFormat;
012:        import net.sourceforge.jrefactory.ast.ASTConstructorDeclaration;
013:        import net.sourceforge.jrefactory.ast.ASTFormalParameters;
014:        import net.sourceforge.jrefactory.ast.ASTFormalParameter;
015:        import net.sourceforge.jrefactory.ast.ASTAnnotation;
016:        import net.sourceforge.jrefactory.ast.ASTType;
017:        import net.sourceforge.jrefactory.ast.ASTClassOrInterfaceType;
018:        import net.sourceforge.jrefactory.ast.ASTClassBodyDeclaration;
019:        import net.sourceforge.jrefactory.ast.ASTVariableDeclaratorId;
020:        import net.sourceforge.jrefactory.ast.ASTNameList;
021:        import net.sourceforge.jrefactory.ast.ASTName;
022:        import net.sourceforge.jrefactory.ast.ASTClassBody;
023:        import net.sourceforge.jrefactory.ast.ASTReferenceType;
024:        import net.sourceforge.jrefactory.ast.SimpleNode;
025:        import net.sourceforge.jrefactory.ast.Node;
026:        import org.acm.seguin.pretty.ForceJavadocComments;
027:        import org.acm.seguin.pretty.JavadocTags;
028:        import org.acm.seguin.pretty.PrintData;
029:        import org.acm.seguin.pretty.ai.RequiredTags;
030:        import org.acm.seguin.util.FileSettings;
031:
032:        /**
033:         *  Description of the Class
034:         *
035:         * @author    Mike Atkinson
036:         * @since     jRefactory 2.9.0, created October 16, 2003
037:         */
038:        public class ConstructorDeclaration extends BaseJDI {
039:            private ASTConstructorDeclaration constructor;
040:
041:            /**
042:             *  Constructor for the ConstructorDeclaration JavaDoc creator.
043:             *
044:             * @param  constructor Create JavaDoc for this node.
045:             */
046:            public ConstructorDeclaration(ASTConstructorDeclaration constructor) {
047:                super ();
048:                this .constructor = constructor;
049:            }
050:
051:            /**
052:             *  Checks to see if it was printed
053:             *
054:             * @return    true if it still needs to be printed
055:             */
056:            public boolean isRequired() {
057:                return jdi.isRequired()
058:                        && (new ForceJavadocComments()).isJavaDocRequired(
059:                                "method", constructor);
060:            }
061:
062:            /**
063:             *  Prints all the java doc components
064:             *
065:             * @param  printData  the print data
066:             */
067:            public void printJavaDocComponents(PrintData printData) {
068:                jdi.printJavaDocComponents(printData, bundle
069:                        .getString("method.tags"));
070:            }
071:
072:            /**
073:             *  Makes sure all the java doc components are present. For methods and constructors we need to do more work -
074:             *  checking parameters, return types, and exceptions.
075:             */
076:            public void finish() {
077:                //  Local Variables
078:                int ndx;
079:                int childCount;
080:
081:                //  Get the tags
082:                JavadocTags tags = JavadocTags.get();
083:
084:                //  Description of the constructor
085:                Object[] nameArray = new Object[1];
086:                nameArray[0] = constructor.getName();
087:                String descr = tags.getConstructorDescr();
088:                if (isCopyConstructor()) {
089:                    descr = bundle
090:                            .getProperty(
091:                                    "copyconstructor.descr",
092:                                    "Copy constructor for the {0} object. Creates a copy of the {0} object parameter.");
093:                }
094:                String msg = MessageFormat.format(descr, nameArray);
095:                jdi.require("", msg);
096:
097:                //  Check for parameters
098:                int childNo = constructor.skipAnnotations();
099:                ASTFormalParameters params = (ASTFormalParameters) constructor
100:                        .jjtGetChild(childNo);
101:                childCount = params.jjtGetNumChildren();
102:                String[] constructorParams = new String[childCount];
103:                for (ndx = 0; ndx < childCount; ndx++) {
104:                    ASTFormalParameter nextParam = (ASTFormalParameter) params
105:                            .jjtGetChild(ndx);
106:                    childNo = nextParam.skipAnnotations();
107:                    ASTVariableDeclaratorId varID = (ASTVariableDeclaratorId) nextParam
108:                            .jjtGetChild(childNo + 1);
109:                    jdi.require("@param", varID.getName(),
110:                            getParameterDescription(bundle, tags, varID
111:                                    .getName(), "class"));
112:
113:                    constructorParams[ndx] = varID.getName();
114:                }
115:                // sort @param tags into order of constructor parameters
116:                jdi.sort("@param", constructorParams);
117:
118:                //  Check for exceptions
119:                if ((constructor.jjtGetNumChildren() > childNo + 1)
120:                        && (constructor.jjtGetChild(childNo + 1) instanceof  ASTNameList)) {
121:                    ASTNameList exceptions = (ASTNameList) constructor
122:                            .jjtGetChild(childNo + 1);
123:                    childCount = exceptions.jjtGetNumChildren();
124:                    for (ndx = 0; ndx < childCount; ndx++) {
125:                        ASTName name = (ASTName) exceptions.jjtGetChild(ndx);
126:                        if (!(jdi.contains("@exception", name.getName())
127:                                || jdi.contains("@throws", name.getName()) || jdi
128:                                .contains(tags.getExceptionTag(), name
129:                                        .getName()))) {
130:                            jdi.require(tags.getExceptionTag(), name.getName(),
131:                                    tags.getExceptionDescr());
132:                        }
133:                    }
134:                }
135:
136:                RequiredTags.getTagger().addTags(bundle, "method",
137:                        constructor.getName(), jdi);
138:            }
139:
140:            /**
141:             *  Gets the parameterDescription attribute of the ASTConstructorDeclaration node.
142:             *
143:             * @param  bundle     Description of Parameter
144:             * @param  tags       Description of Parameter
145:             * @param  param      Description of Parameter
146:             * @param  className  Description of Parameter
147:             * @return            The parameterDescription value
148:             */
149:            private String getParameterDescription(FileSettings bundle,
150:                    JavadocTags tags, String param, String className) {
151:                String pattern = "";
152:                Object[] nameArray = new Object[6];
153:                nameArray[0] = param;
154:                nameArray[1] = className;
155:
156:                if (isCopyConstructor()) {
157:                    pattern = bundle.getProperty("copyconstructor.param.descr",
158:                            "Object to copy.");
159:                } else {
160:                    pattern = tags.getParamDescr();
161:                }
162:
163:                if (pattern == null || pattern.equals("")) {
164:                    return null;
165:                }
166:
167:                return MessageFormat.format(pattern, nameArray);
168:            }
169:
170:            /**
171:             *  Gets the copyConstructor attribute of the ASTConstructorDeclaration node.
172:             *
173:             * @return    The copyConstructor value
174:             */
175:            private boolean isCopyConstructor() {
176:                for (int childNo1 = 0; childNo1 < constructor
177:                        .jjtGetNumChildren(); childNo1++) {
178:                    Node child = constructor.jjtGetChild(childNo1);
179:                    if (child instanceof  ASTFormalParameters) {
180:                        ASTFormalParameters params = (ASTFormalParameters) child;
181:                        if (params.jjtGetNumChildren() == 1) {
182:                            ASTFormalParameter param = (ASTFormalParameter) params
183:                                    .jjtGetChild(0);
184:                            int childNo = param.skipAnnotations();
185:                            ASTType type = (ASTType) param.jjtGetChild(childNo);
186:                            if (type.jjtGetChild(0) instanceof  ASTReferenceType) {
187:                                ASTReferenceType refType = (ASTReferenceType) type
188:                                        .jjtGetChild(0);
189:                                if (refType.getArrayCount() == 0) {
190:                                    ASTClassOrInterfaceType clazz = (ASTClassOrInterfaceType) refType
191:                                            .jjtGetChild(0);
192:                                    //System.out.println("isCopyConstructor refType name=" + refType.getName());
193:                                    //System.out.println("isCopyConstructor type name=" + clazz.getName());
194:                                    ASTClassBodyDeclaration classBodyDec = (ASTClassBodyDeclaration) constructor
195:                                            .jjtGetParent();
196:                                    if (classBodyDec.jjtGetParent() instanceof  ASTClassBody) {
197:                                        ASTClassBody classBody = (ASTClassBody) classBodyDec
198:                                                .jjtGetParent();
199:                                        //System.out.println("isCopyConstructor clazz name="+ clazz.getName() + ", compare with name="+ ((SimpleNode)classBody.jjtGetParent()).getName());
200:                                        boolean flag = (clazz.getName()
201:                                                .equals(((SimpleNode) classBody
202:                                                        .jjtGetParent())
203:                                                        .getName()));
204:                                        //System.out.println("  -> "+flag);
205:                                        return flag;
206:                                    } else {
207:                                        return false;
208:                                    }
209:                                } else {
210:                                    return false;
211:                                }
212:                            } else {
213:                                return false;
214:                            }
215:                        } else {
216:                            return false;
217:                        }
218:                    }
219:                }
220:                return false;
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.