Source Code Cross Referenced for SourceObjectDeclared.java in  » Code-Analyzer » beautyJ » de » gulden » util » javasource » 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 » Code Analyzer » beautyJ » de.gulden.util.javasource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Project: BeautyJ - Customizable Java Source Code Transformer
003:         * Class:   de.gulden.util.javasource.SourceObjectDeclared
004:         * Version: 1.1
005:         *
006:         * Date:    2004-09-29
007:         *
008:         * Note:    Contains auto-generated Javadoc comments created by BeautyJ.
009:         *  
010:         * This is licensed under the GNU General Public License (GPL)
011:         * and comes with NO WARRANTY. See file license.txt for details.
012:         *
013:         * Author:  Jens Gulden
014:         * Email:   beautyj@jensgulden.de
015:         */
016:
017:        package de.gulden.util.javasource;
018:
019:        import de.gulden.util.javasource.jjt.Node;
020:        import de.gulden.util.javasource.jjt.*;
021:        import de.gulden.util.xml.XMLToolbox;
022:        import javax.xml.parsers.*;
023:        import org.w3c.dom.*;
024:        import java.io.*;
025:        import java.util.*;
026:
027:        /**
028:         * Class SourceObjectDeclared.
029:         *  
030:         * @author  Jens Gulden
031:         * @version  1.0
032:         */
033:        public abstract class SourceObjectDeclared extends SourceObject {
034:
035:            // ------------------------------------------------------------------------
036:            // --- fields                                                           ---
037:            // ------------------------------------------------------------------------
038:
039:            /**
040:             */
041:            public Class declaringClass;
042:
043:            /**
044:             */
045:            public Documentation myDocumentation;
046:
047:            /**
048:             * The modifier.
049:             */
050:            protected int modifier = 0;
051:
052:            /**
053:             * The source.
054:             */
055:            protected String source;
056:
057:            /**
058:             * The source position array.
059:             */
060:            protected int[] sourcePosition;
061:
062:            // ------------------------------------------------------------------------
063:            // --- methods                                                          ---
064:            // ------------------------------------------------------------------------
065:
066:            /**
067:             * Returns the modifier.
068:             */
069:            public int getModifier() {
070:                return modifier;
071:            }
072:
073:            /**
074:             * Returns the modifier string.
075:             */
076:            public String getModifierString() {
077:                return java.lang.reflect.Modifier.toString(getModifier());
078:            }
079:
080:            /**
081:             * Sets the modifier.
082:             */
083:            public void setModifier(int m) {
084:                modifier = m;
085:            }
086:
087:            /**
088:             * Returns the class within which this SourceObjectDeclared is declared.
089:             */
090:            public Class getDeclaringClass() {
091:                return declaringClass;
092:            }
093:
094:            /**
095:             * Sets the class within which this SourceObjectDeclared is declared.
096:             */
097:            public void setDeclaringClass(Class c) {
098:                declaringClass = c;
099:            }
100:
101:            /**
102:             * Returns the documentation.
103:             */
104:            public Documentation getDocumentation() {
105:                return myDocumentation;
106:            }
107:
108:            /**
109:             * Sets the documentation.
110:             */
111:            public void setDocumentation(Documentation d) {
112:                myDocumentation = d;
113:            }
114:
115:            /**
116:             * Initialize this object from XML.
117:             *  
118:             * @param element The XML tag.
119:             * @throws IOException if an i/o error occurs
120:             */
121:            public void initFromXML(Element element) throws IOException {
122:                // to be extended (not overwritten) by subclasses
123:                super .initFromXML(element);
124:
125:                // get modifier 'final'
126:                this .modifier = 0;
127:                if (XMLToolbox.isYesAttribute(element, "final")) {
128:                    this .modifier |= java.lang.reflect.Modifier.FINAL;
129:                }
130:
131:                // get javadoc comment
132:                Element doc = XMLToolbox.getChild(element, "documentation");
133:                if (doc != null) {
134:                    DocumentationDeclared d = new DocumentationDeclared();
135:                    d.initFromXML(doc);
136:                    myDocumentation = d;
137:                } else {
138:                    myDocumentation = null;
139:                }
140:
141:                if (this  instanceof  Typed) {
142:                    Typed typed = (Typed) this ;
143:                    Type t = null;
144:                    if (this  instanceof  Member) {
145:                        t = new Type((Member) this );
146:                    } else if (this  instanceof  Parameter) {
147:                        t = new Type(((Parameter) this ).myMemberExecutable);
148:                    } else if (this  instanceof  Exception) {
149:                        t = new Type(((Exception) this ).myMemberExecutable);
150:                    }
151:                    t.initFromXML(XMLToolbox.getChildRequired(element, "type"));
152:                    typed.setType(t);
153:                }
154:            }
155:
156:            /**
157:             * Output this object as XML.
158:             *  
159:             * @return  The XML tag.
160:             * @see  #initFromXML
161:             */
162:            public Element buildXML(Document d) {
163:                Element e = super .buildXML(d);
164:
165:                if (java.lang.reflect.Modifier.isFinal(modifier)) {
166:                    e.setAttribute("final", "yes");
167:                }
168:                if (java.lang.reflect.Modifier.isStrict(modifier)) {
169:                    e.setAttribute("strictfp", "yes");
170:                }
171:
172:                // javadoc
173:                Documentation doc = getDocumentation();
174:                if (doc != null) {
175:                    e.appendChild(doc.buildXML(d));
176:                }
177:
178:                return e;
179:            }
180:
181:            /**
182:             * Returns the full signature of this SourceObject. This is the fully
183:             * qualified name and, depending on the type of the SourceObject,
184:             * the (return-)type, and the parameters' signatures
185:             */
186:            public String getSignature() {
187:                String type;
188:                if (this  instanceof  Typed) {
189:                    Typed tt = (Typed) this ;
190:                    Type t = tt.getType();
191:                    type = t.getFullTypeName() + " ";
192:                } else {
193:                    type = "";
194:                }
195:                return type + super .getSignature();
196:            }
197:
198:            /**
199:             * Returns the source.
200:             */
201:            public String getSource() {
202:                return source;
203:            }
204:
205:            /**
206:             * Sets the source.
207:             */
208:            public void setSource(String source) {
209:                this .source = source;
210:            }
211:
212:            /**
213:             * Returns the source position.
214:             */
215:            public int[] getSourcePosition() {
216:                return sourcePosition;
217:            }
218:
219:            /**
220:             * Returns the source position string.
221:             */
222:            public String getSourcePositionString() {
223:                return "[" + getSourcePosition()[0] + ":"
224:                        + getSourcePosition()[1] + "]";
225:            }
226:
227:            public String toString() {
228:                if (getSource() != null) {
229:                    return super .toString() + " " + getSource() + " "
230:                            + getSourcePositionString();
231:                } else {
232:                    return super .toString();
233:                }
234:            }
235:
236:            /**
237:             * Initialize this object with values from parsed Java code.
238:             *  
239:             * @param rootnode The corresponding node in the abstract syntax tree (AST).
240:             */
241:            void initFromAST(Node rootnode) {
242:                super .initFromAST(rootnode);
243:
244:                source = rootnode.getSource();
245:                sourcePosition = rootnode.getSourcePosition();
246:
247:                // get modifier 'final'
248:                this .modifier = 0;
249:                Node mod = rootnode.getChild(JJT_MODIFIER);
250:                if (mod != null) {
251:                    if (mod.hasChild(JJT_FINAL)) {
252:                        this .modifier |= java.lang.reflect.Modifier.FINAL;
253:                    }
254:                    if (mod.hasChild(JJT_STRICTFP)) {
255:                        this .modifier |= java.lang.reflect.Modifier.STRICT;
256:                    }
257:                }
258:
259:                // get javadoc comment
260:                Token t = rootnode.getStartToken();
261:                t = t.specialToken;
262:                if (t != null) {
263:                    String doc = t.image;
264:                    if (doc.startsWith("/**")) // could be an 'ordinary'-comment (then ignore)
265:                    {
266:                        DocumentationDeclared d = new DocumentationDeclared();
267:                        d.setSourceObjectDeclared(this );
268:                        doc = doc.replace('\r', ' '); // workaround: avoid problems with crlf-linefeeds
269:                        d.setRaw(doc);
270:                        myDocumentation = d;
271:                    } else {
272:                        myDocumentation = null;
273:                    }
274:                } else {
275:                    myDocumentation = null;
276:                }
277:            }
278:
279:        } // end SourceObjectDeclared
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.