Source Code Cross Referenced for Jaxor.java in  » Database-ORM » jaxor-3.5 » net » sourceforge » jaxor » parser » 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 » Database ORM » jaxor 3.5 » net.sourceforge.jaxor.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.jaxor.parser;
002:
003:        import com.thoughtworks.qdox.model.JavaClass;
004:        import net.sourceforge.jaxor.util.SystemException;
005:
006:        import java.io.File;
007:        import java.util.Collections;
008:        import java.util.Iterator;
009:        import java.util.List;
010:        import java.util.Properties;
011:
012:        import org.apache.velocity.runtime.log.LogSystem;
013:
014:        /*
015:         * User: Mike
016:         * Date: Oct 22, 2002
017:         * Time: 12:39:56 AM
018:         */
019:
020:        public class Jaxor {
021:            private Entity _entity;
022:            private ImportSet _imports = new ImportSet();
023:            private String _package;
024:            private Generator _config;
025:            private File _destDir;
026:            private Properties _mapperProps;
027:            private SourceMap _javaDocBuilder;
028:            private String _source;
029:            private net.sourceforge.jaxor.api.MapperRegistry _mapperRegistry = new net.sourceforge.jaxor.impl.MapperRegistryImpl();
030:
031:            public void addImport(Import imp) {
032:                _imports.add(imp);
033:            }
034:
035:            public java.util.Set getImports() {
036:                ImportSet set = getImportsSet();
037:                return set.getSet();
038:            }
039:
040:            private ImportSet getImportsSet() {
041:                ImportSet set = new ImportSet();
042:                set.add(_imports);
043:                return set;
044:            }
045:
046:            public ImportSet getImportsWithPackage() {
047:                ImportSet set = getImportsSet();
048:                set.add(_package + ".*");
049:                return set;
050:            }
051:
052:            public void setPackage(String aPackage) {
053:                _package = aPackage;
054:            }
055:
056:            public void addEntity(Entity entity) {
057:                if (_entity != null)
058:                    throw new SystemException(
059:                            "Only one entity allowed per jaxor file");
060:                _entity = entity;
061:            }
062:
063:            public String getPackageNameAsDir() {
064:                return _package.replace('.', File.separatorChar);
065:            }
066:
067:            public String getPackageName() {
068:                return _package;
069:            }
070:
071:            public void setConfig(Generator config) {
072:                _config = config;
073:            }
074:
075:            public void setDestDir(File dir) {
076:                _destDir = dir;
077:            }
078:
079:            public void execute(EntityCollection coll, LogSystem logger) {
080:                Entity entity = getEntity();
081:                Iterator it = _config.getAttributes().iterator();
082:                while (it.hasNext()) {
083:                    entity.addAttribute((Attribute) it.next());
084:                }
085:                File destdir = new File(_destDir.getPath() + File.separator
086:                        + getPackageNameAsDir());
087:                long timestamp = getLastModified();
088:                SourceGenerator gen = new SourceGenerator(this , destdir,
089:                        timestamp, logger);
090:                gen.addToContext("entityCollection", coll);
091:                gen.add("Finder.vm", getEntity().getFinderName());
092:                gen.add("Impl.vm", getEntity().getImplName());
093:                gen.add("Interface.vm", getEntity().getInterfaceName());
094:                gen.add("List.vm", getEntity().getGeneratedListName());
095:                gen.add("Iterator.vm", getEntity().getIteratorName());
096:                gen.add("FinderImpl.vm", getEntity().getFinderImpl());
097:                gen.add("Meta.vm", getEntity().getMetaName());
098:                gen.add("EntityRow.vm", getEntity().getEntityRowName());
099:                gen.add("ResultSet.vm", getEntity().getEntityResultSetClass());
100:                gen.add("QueryResult.vm", getEntity()
101:                        .getEntityQueryResultClass());
102:                gen.generate();
103:            }
104:
105:            private long getLastModified() {
106:                String impl = getEntity().getImpl();
107:                long metaModified = new File(_source).lastModified();
108:                if (impl == null)
109:                    return metaModified;
110:                else {
111:                    long timestamp = _javaDocBuilder.getTimestamp(impl);
112:                    return timestamp > metaModified ? timestamp : metaModified;
113:                }
114:            }
115:
116:            public SourceClass getImplClass() {
117:                String impl = getEntity().getImpl();
118:                if (impl == null)
119:                    return null;
120:                JavaClass daClass = _javaDocBuilder.get(impl);
121:                if (daClass != null)
122:                    return new SourceClass(daClass);
123:                throw new SystemException("Unable to find 'impl' class for "
124:                        + getEntity().getTableName() + " class " + impl);
125:            }
126:
127:            public List getImplMethods() {
128:                SourceClass daClass = getImplClass();
129:                if (daClass == null)
130:                    return Collections.EMPTY_LIST;
131:                return daClass.getImplMethods();
132:            }
133:
134:            public void setMapperProps(Properties mapperProps) {
135:                _mapperProps = mapperProps;
136:            }
137:
138:            public Entity getEntity() {
139:                return _entity;
140:            }
141:
142:            public List getFields(EntityCollection coll) {
143:                return getEntity().getFields(coll, this );
144:            }
145:
146:            public List getForeignFields(EntityCollection coll) {
147:                return getEntity().getForeignFields(coll, this );
148:            }
149:
150:            public String getMapperName(String type) {
151:                String map = (String) _mapperProps.get(type);
152:                if (map == null)
153:                    map = _mapperRegistry.getName(type);
154:                if (map == null)
155:                    throw new SystemException(
156:                            "Mapper not specified and mapper not found in registry for: "
157:                                    + type);
158:                return map;
159:            }
160:
161:            public String getExtends() {
162:                return _config.getExtends(_entity);
163:            }
164:
165:            public String getImplements() {
166:                return _config.getImplements(_entity);
167:            }
168:
169:            public List getQueries() {
170:                return getEntity().getQueries(this );
171:            }
172:
173:            public void setJavaDocBuilders(SourceMap javaDocBuilders) {
174:                _javaDocBuilder = javaDocBuilders;
175:            }
176:
177:            public void setSource(String src) {
178:                _source = src;
179:            }
180:
181:            public String getFullName() {
182:                return getPackageName() + "." + getEntity().getTableName();
183:            }
184:
185:            public Attribute findAttribute(String key) {
186:                return getEntity().findAttribute(key);
187:            }
188:
189:            public String getListClassFull() {
190:                return getPackageName() + "." + getEntity().getListClass();
191:            }
192:
193:            public String getEntityClassFull() {
194:                return getPackageName() + "." + getEntity().getInterfaceName();
195:            }
196:
197:            public String getFinderImplFull() {
198:                return getPackageName() + "." + getEntity().getFinderImpl();
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.