Source Code Cross Referenced for QDoxParser.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » expression » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.expression 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package org.codehaus.aspectwerkz.expression;
008:
009:        import com.thoughtworks.qdox.JavaDocBuilder;
010:        import com.thoughtworks.qdox.model.JavaClass;
011:        import com.thoughtworks.qdox.model.JavaField;
012:        import com.thoughtworks.qdox.model.JavaMethod;
013:        import com.thoughtworks.qdox.model.JavaParameter;
014:        import com.thoughtworks.qdox.model.Type;
015:
016:        import org.codehaus.aspectwerkz.exception.DefinitionException;
017:
018:        import java.io.File;
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.Iterator;
022:
023:        /**
024:         * Parses a src tree with <code>QDox</code>.
025:         *
026:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
027:         */
028:        public class QDoxParser {
029:            /**
030:             * The QDox builder.
031:             */
032:            private JavaDocBuilder m_builder = new JavaDocBuilder();
033:
034:            /**
035:             * The parsed java class.
036:             */
037:            private JavaClass m_class;
038:
039:            /**
040:             * The name of the class.
041:             */
042:            private String m_className;
043:
044:            /**
045:             * Transforms the QDox JavaMethod parameters to a String array with the types represented as strings.
046:             *
047:             * @param method the JavaMethod
048:             * @return an array with the types as strings
049:             */
050:            public static String[] getJavaMethodParametersAsStringArray(
051:                    final JavaMethod method) {
052:                JavaParameter[] javaParameters = method.getParameters();
053:                String[] parameters = new String[javaParameters.length];
054:                for (int i = 0; i < javaParameters.length; i++) {
055:                    Type type = javaParameters[i].getType();
056:                    int dimensions = type.getDimensions();
057:                    StringBuffer parameter = new StringBuffer(type.getValue());
058:                    for (int j = 0; j < dimensions; j++) {
059:                        parameter.append("[]");
060:                    }
061:                    parameters[i] = parameter.toString();
062:                }
063:                return parameters;
064:            }
065:
066:            /**
067:             * Adds a source tree to the builder.
068:             *
069:             * @param srcDir the source tree
070:             */
071:            public QDoxParser(final String srcDir) {
072:                m_builder.addSourceTree(new File(srcDir));
073:            }
074:
075:            /**
076:             * Parses a specific class.
077:             *
078:             * @param className the name of the class to compile
079:             * @return true if class was found and false otherwise
080:             * @todo QDox seems to have a problem retrieving inner classes => null
081:             */
082:            public boolean parse(final String className) {
083:                m_class = m_builder.getClassByName(className);
084:                if (m_class == null) {
085:                    return false;
086:                }
087:                m_className = m_class.getFullyQualifiedName();
088:                return true;
089:            }
090:
091:            /**
092:             * Returns the QDox JavaClass.
093:             *
094:             * @return the QDox JavaClass
095:             */
096:            public JavaClass getJavaClass() {
097:                if ((m_class == null) && (m_className == null)) {
098:                    throw new DefinitionException(
099:                            "no class has been parsed, call parse(..) first");
100:                }
101:                if (m_class == null) {
102:                    throw new DefinitionException(
103:                            "could not find source file for "
104:                                    + m_className
105:                                    + " (have you specified the correct srcDir)");
106:                }
107:                return m_class;
108:            }
109:
110:            /**
111:             * Returns all classes.
112:             *
113:             * @return a collections with all classes
114:             */
115:            public String[] getAllClassNames() {
116:                Collection classes = m_builder.getClassLibrary().all();
117:                Collection classNames = new ArrayList();
118:                String className = null;
119:                for (Iterator it = classes.iterator(); it.hasNext();) {
120:                    className = (String) it.next();
121:                    if ("java.lang.Object".equals(className)) {
122:                        continue;
123:                    }
124:                    classNames.add(className);
125:                }
126:                return (String[]) classNames.toArray(new String[] {});
127:            }
128:
129:            /**
130:             * Parses a specific class A returns an array with the methods.
131:             *
132:             * @return an array with the methods
133:             */
134:            public JavaMethod[] getJavaMethods() {
135:                if ((m_class == null) && (m_className == null)) {
136:                    throw new DefinitionException(
137:                            "no class has been parsed, call parse(..) first");
138:                }
139:                if (m_class == null) {
140:                    throw new DefinitionException(
141:                            "could not find source file for "
142:                                    + m_className
143:                                    + " (have you specified the correct srcDir)");
144:                }
145:                return m_class.getMethods();
146:            }
147:
148:            /**
149:             * Parses a specific class A returns an array with the methods.
150:             *
151:             * @return an array with the methods
152:             */
153:            public JavaField[] getJavaFields() {
154:                if ((m_class == null) && (m_className == null)) {
155:                    throw new DefinitionException(
156:                            "no class has been parsed, call parse(..) first");
157:                }
158:                if (m_class == null) {
159:                    throw new DefinitionException(
160:                            "could not find source file for "
161:                                    + m_className
162:                                    + " (have you specified the correct srcDir)");
163:                }
164:                return m_class.getFields();
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.