Source Code Cross Referenced for Project.java in  » Ajax » dwr » org » directwebremoting » drapgen » ast » 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 » Ajax » dwr » org.directwebremoting.drapgen.ast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.directwebremoting.drapgen.ast;
017:
018:        import java.io.File;
019:        import java.io.IOException;
020:        import java.util.Collection;
021:        import java.util.Collections;
022:        import java.util.HashMap;
023:        import java.util.HashSet;
024:        import java.util.Map;
025:        import java.util.Set;
026:        import java.util.SortedSet;
027:        import java.util.TreeSet;
028:
029:        import org.directwebremoting.drapgen.loader.gi.GiLoader;
030:        import org.directwebremoting.util.Logger;
031:
032:        /**
033:         * A Project is a collection of {@link Type}s that we will convert to reverse
034:         * ajax proxies.
035:         * @author Joe Walker [joe at getahead dot ltd dot uk]
036:         */
037:        public class Project {
038:            /**
039:             * Save the types in the current project into XML files in the given
040:             * directory.
041:             * This helps us separate the process of creating the AST (from the
042:             * Javascript) from the process of generating the Java from the AST
043:             * @param directory The place to write to
044:             * @throws IOException If the save process fails
045:             */
046:            public void save(File directory) throws IOException {
047:                SortedSet<String> keys = new TreeSet<String>(types.keySet());
048:                for (String className : keys) {
049:                    Type type = types.get(className);
050:                    type.save(directory);
051:                }
052:            }
053:
054:            /**
055:             * Load the types in the given directory into this Project.
056:             * This method does *not* call clear before it loads Types
057:             * @param directory The place to read from
058:             * @throws IOException If the read fails.
059:             */
060:            public void load(File directory) throws IOException {
061:                for (File file : directory.listFiles()) {
062:                    if (file.getName().endsWith(".xml")) {
063:                        Type type = new Type(this , file);
064:                        add(type);
065:                    }
066:                }
067:            }
068:
069:            /**
070:             * Allow users to dig into the code in a project
071:             * @param visitor The object to pass around the code in a project
072:             */
073:            public void visit(Visitor visitor) {
074:                boolean dig = visitor.visitEnter(this );
075:                if (dig) {
076:                    for (Type type : types.values()) {
077:                        type.visit(visitor);
078:                    }
079:                    visitor.visitLeave(this );
080:                }
081:            }
082:
083:            /**
084:             * Useful if we have a classname that we know must be defined somewhere,
085:             * but might not have been defined yet.
086:             * @param className The potentially existing class name
087:             * @return A newly created or existing Type
088:             */
089:            public Type getType(String className) {
090:                Type type = types.get(className);
091:
092:                if (className.indexOf(" ") != -1) {
093:                    log.warn("Creating class called: " + className);
094:                }
095:
096:                if (type == null) {
097:                    type = new Type(this , className);
098:                    add(type);
099:                }
100:
101:                return type;
102:            }
103:
104:            /**
105:             * Is the given (full) class name one that another class claims as it's
106:             * ancestor?
107:             * @param name The class name to search for
108:             * @return true iff the class has children
109:             */
110:            public boolean isSuperClass(String name) {
111:                if (super Classes == null) {
112:                    super Classes = new HashSet<String>();
113:                    for (Type type : types.values()) {
114:                        Type super Class = type.getSuperClass();
115:                        if (super Class != null) {
116:                            super Classes.add(super Class.getFullName());
117:                        }
118:
119:                        for (Type iface : type.getInterfaces()) {
120:                            super Classes.add(iface.getFullName());
121:                        }
122:                    }
123:                }
124:
125:                return super Classes.contains(name);
126:            }
127:
128:            /**
129:             * @return An class name with native types replaced by Object types
130:             */
131:            public String asObject(String maybeNative) {
132:                if (maybeNative.equals("int")) {
133:                    return "Integer";
134:                } else if (maybeNative.equals("char")) {
135:                    return "Character";
136:                } else if (maybeNative.equals("boolean")) {
137:                    return "Boolean";
138:                } else if (maybeNative.equals("long")) {
139:                    return "Long";
140:                } else if (maybeNative.equals("float")) {
141:                    return "Float";
142:                } else if (maybeNative.equals("double")) {
143:                    return "Double";
144:                } else if (maybeNative.equals("short")) {
145:                    return "Short";
146:                } else if (maybeNative.equals("byte")) {
147:                    return "Byte";
148:                }
149:                return maybeNative;
150:            }
151:
152:            /**
153:             * @see java.util.Set#clear()
154:             */
155:            public void clear() {
156:                types.clear();
157:            }
158:
159:            /**
160:             * @see java.util.Set#contains(java.lang.Object)
161:             */
162:            public boolean contains(String className) {
163:                return types.containsKey(className);
164:            }
165:
166:            /**
167:             * @see java.util.Set#isEmpty()
168:             */
169:            public boolean isEmpty() {
170:                return types.isEmpty();
171:            }
172:
173:            /**
174:             * @return Read-only collection of all our types
175:             */
176:            public Collection<Type> getTypes() {
177:                return Collections.unmodifiableCollection(types.values());
178:            }
179:
180:            /**
181:             * @see java.util.Set#remove(java.lang.Object)
182:             */
183:            public void remove(Type type) {
184:                types.remove(type.getFullName());
185:            }
186:
187:            /**
188:             * @see java.util.Set#size()
189:             */
190:            public int size() {
191:                return types.size();
192:            }
193:
194:            /**
195:             * @see java.util.Set#add(java.lang.Object)
196:             */
197:            private void add(Type type) {
198:                types.put(type.getFullName(), type);
199:            }
200:
201:            /* (non-Javadoc)
202:             * @see java.lang.Object#equals(java.lang.Object)
203:             */
204:            @Override
205:            public boolean equals(Object o) {
206:                return types.equals(o);
207:            }
208:
209:            /* (non-Javadoc)
210:             * @see java.lang.Object#hashCode()
211:             */
212:            @Override
213:            public int hashCode() {
214:                return types.hashCode();
215:            }
216:
217:            /**
218:             * The store of the types we are about to generate from
219:             */
220:            private Map<String, Type> types = new HashMap<String, Type>();
221:
222:            /**
223:             * We cache the names of the super classes that we've found
224:             */
225:            private Set<String> super Classes;
226:
227:            /**
228:             * The log stream
229:             */
230:            private static final Logger log = Logger.getLogger(GiLoader.class);
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.