Source Code Cross Referenced for SourceObject.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.SourceObject
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 javax.xml.parsers.*;
022:        import org.w3c.dom.*;
023:        import java.io.*;
024:        import java.util.*;
025:
026:        /**
027:         * This is the common super-class of all classes in this package which represent Java source code element declarations.
028:         *  
029:         * @author  Jens Gulden
030:         * @version  1.0
031:         */
032:        public abstract class SourceObject implements  Named, Serializable,
033:                ParserTreeConstants {
034:
035:            // ------------------------------------------------------------------------
036:            // --- static field                                                     ---
037:            // ------------------------------------------------------------------------
038:
039:            /**
040:             * The nl.
041:             */
042:            public static String nl = System.getProperty("line.separator");
043:
044:            // ------------------------------------------------------------------------
045:            // --- fields                                                           ---
046:            // ------------------------------------------------------------------------
047:
048:            /**
049:             * The my package.
050:             */
051:            public Package myPackage;
052:
053:            /**
054:             * The name.
055:             */
056:            protected String name;
057:
058:            // ------------------------------------------------------------------------
059:            // --- methods                                                          ---
060:            // ------------------------------------------------------------------------
061:
062:            /**
063:             * Returns the name.
064:             */
065:            public String getName() {
066:                return name;
067:            }
068:
069:            /**
070:             * Sets the name.
071:             */
072:            public void setName(String n) {
073:                name = n;
074:            }
075:
076:            /**
077:             * Gets the unqualified name of this, that means the name without any leading package information.
078:             */
079:            public String getUnqualifiedName() {
080:                return unqualify(getName());
081:            }
082:
083:            /**
084:             * Returns the package of which this is a member.
085:             */
086:            public Package getPackage() {
087:                return myPackage;
088:            }
089:
090:            /**
091:             * Initialize this object from XML.
092:             *  
093:             * @param element The corresponding XML tag.
094:             * @throws IOException if an i/o error occurs
095:             */
096:            public void initFromXML(Element element) throws IOException {
097:                name = element.getAttribute("name");
098:                // to be extended (not overwritten) by subclasses
099:            }
100:
101:            /**
102:             * Output this object as XML.
103:             *  
104:             * @return  The XML tag.
105:             * @see  #initFromXML
106:             */
107:            public Element buildXML(Document d) {
108:                // must be extended by subclasses (i.e. overwritten starting with ...=super.buildXML(..))
109:                String tagName = getXMLName();
110:                Element e = d.createElement(tagName);
111:                e.setAttribute("name", getName());
112:                return e;
113:            }
114:
115:            /**
116:             * Returns the full signature of this SourceObject. This is the fully
117:             * qualified name and, depending on the type of the SourceObject,
118:             * the (return-)type, and the parameters' signatures
119:             */
120:            public String getSignature() {
121:                // will be extended by subclasses
122:                return getUnqualifiedName();
123:            }
124:
125:            /**
126:             * Tests if two source objects represent the same source code element.
127:             * The test is performed based on the fully referenced signature strings.
128:             * Executing this is quite expensive, so consider testing for reference identity (a==b) where possible.
129:             *  
130:             * @return  <code>true</code> if equal.
131:             */
132:            public boolean equals(Object o) {
133:                return o.getClass().equals(this .getClass())
134:                        && ((SourceObject) o).getSignature().equals(
135:                                this .getSignature());
136:            }
137:
138:            public String toString() {
139:                return getXMLName() + " " + getSignature();
140:            }
141:
142:            /**
143:             * Returns the name of the XML tag representing this SourceObject.
144:             */
145:            protected String getXMLName() {
146:                return SourceObjectDeclaredVisible.unqualify(
147:                        this .getClass().getName()).toLowerCase(); // dynamically get tag name from class name (!)
148:            }
149:
150:            /**
151:             * Initialize this object with values from parsed Java code.
152:             *  
153:             * @param rootnode The corresponding node in the abstract syntax tree (AST).
154:             */
155:            void initFromAST(Node rootnode) {
156:                // get name
157:                name = rootnode.getName();
158:                // to be extended (not overwritten) by subclasses
159:            }
160:
161:            // ------------------------------------------------------------------------
162:            // --- static methods                                                   ---
163:            // ------------------------------------------------------------------------
164:
165:            /**
166:             * Returns the unqualified name part of the string.
167:             *  
168:             * @param n The qualified name.
169:             * @return  The name's part after the last occurrence of '.', or the unchanged name if no '.' is contained.
170:             */
171:            static String unqualify(String n) {
172:                int pos = n.lastIndexOf('.');
173:                if (pos != -1) {
174:                    return n.substring(pos + 1);
175:                } else {
176:                    return n;
177:                }
178:            }
179:
180:            /**
181:             * Returns a less qualified name part of the string, including withParents parents, too.
182:             *  
183:             * @param n The qualified name.
184:             * @return  The name's part after the withParent's-last occurrence of '.', or the unchanged name if no '.' is contained.
185:             */
186:            static String unqualify(String n, int withParents) {
187:                int pos = n.lastIndexOf('.');
188:                while ((pos > 0) && (withParents > 0)) {
189:                    pos = n.lastIndexOf('.', pos - 1);
190:                    withParents--;
191:                }
192:                if (pos != -1) {
193:                    return n.substring(pos + 1);
194:                } else {
195:                    return n;
196:                }
197:            }
198:
199:            /**
200:             * Tool method for outputting a string to an OutputStream.
201:             *  
202:             * @throws IOException if an i/o error occurs
203:             */
204:            static void write(OutputStream out, String s) throws IOException {
205:                out.write(s.getBytes());
206:            }
207:
208:            /**
209:             * Tool method for converting an array to a Vector.
210:             */
211:            static void stringsIntoVector(Object[] s, Vector v) {
212:                v.removeAllElements();
213:                for (int i = 0; i < s.length; i++) {
214:                    v.addElement(s[i]);
215:                }
216:            }
217:
218:        } // end SourceObject
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.