Source Code Cross Referenced for MakumbaDataDefinitionFactory.java in  » Web-Framework » makumba » org » makumba » providers » datadefinition » makumba » 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 » Web Framework » makumba » org.makumba.providers.datadefinition.makumba 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.makumba.providers.datadefinition.makumba;
002:
003:        import java.io.File;
004:        import java.net.URISyntaxException;
005:        import java.util.Vector;
006:
007:        import org.makumba.DataDefinition;
008:        import org.makumba.FieldDefinition;
009:        import org.makumba.providers.DataDefinitionProviderInterface;
010:
011:        /**
012:         * This class is the Makumba implementation of a data definition provider, based on MDD files. TODO refactor together
013:         * with RecordInfo to build objects (and not use static methods)
014:         * 
015:         * @author Manuel Gay
016:         * @version $Id: MakumbaDataDefinitionFactory.java 2035 2007-11-07 20:32:24Z manuel_gay $
017:         */
018:        public class MakumbaDataDefinitionFactory implements 
019:                DataDefinitionProviderInterface {
020:
021:            /**
022:             * {@inheritdoc} The type a.b.C will generate a lookup for the file CLASSPATH/a/b/C.mdd and then for
023:             * CLASSPATH/dataDefinitions/a/b/C.mdd
024:             */
025:            public DataDefinition getDataDefinition(String typeName) {
026:                return RecordInfo
027:                        .getRecordInfo(typeName.replaceAll("__", "->"));
028:            }
029:
030:            /**
031:             * {@inheritdoc}
032:             */
033:            public DataDefinition getVirtualDataDefinition(String name) {
034:                return new RecordInfo(name.replaceAll("__", "->"));
035:            }
036:
037:            /**
038:             * {@inheritdoc}
039:             */
040:            public FieldDefinition makeFieldDefinition(String name,
041:                    String definition) {
042:                return FieldInfo.getFieldInfo(name.replaceAll("__", "->"),
043:                        definition.replaceAll("__", "->"), true);
044:            }
045:
046:            /**
047:             * {@inheritdoc}
048:             */
049:            public FieldDefinition makeFieldOfType(String name, String type) {
050:                return FieldInfo.getFieldInfo(name.replaceAll("__", "->"), type
051:                        .replaceAll("__", "->"), false);
052:            }
053:
054:            /**
055:             * {@inheritdoc}
056:             */
057:            public FieldDefinition makeFieldOfType(String name, String type,
058:                    String description) {
059:                return FieldInfo.getFieldInfo(name.replaceAll("__", "->"), type
060:                        .replaceAll("__", "->"), false, description);
061:            }
062:
063:            /**
064:             * {@inheritdoc}
065:             */
066:            public FieldDefinition makeFieldWithName(String name,
067:                    FieldDefinition type) {
068:                return FieldInfo.getFieldInfo(name, type, false);
069:            }
070:
071:            /**
072:             * {@inheritdoc}
073:             */
074:            public FieldDefinition makeFieldWithName(String name,
075:                    FieldDefinition type, String description) {
076:                return FieldInfo.getFieldInfo(name, type, false, description);
077:            }
078:
079:            public Vector getDataDefinitionsInLocation(String location) {
080:                return mddsInDirectory(location);
081:            }
082:
083:            /**
084:             * Discover mdds in a directory in classpath.
085:             * 
086:             * @return filenames as Vector of Strings.
087:             */
088:            private java.util.Vector mddsInDirectory(String dirInClasspath) {
089:                java.util.Vector mdds = new java.util.Vector();
090:                try {
091:                    java.net.URL u = org.makumba.commons.ClassResource
092:                            .get(dirInClasspath);
093:                    // we need to create the file path with this methode. rather than u.getFile(), as that method would keep
094:                    // e.g. %20 for spaces in the path, which fails on windows.
095:                    java.io.File dir = new File(u.toURI());
096:                    fillMdds(dir.toString().length() + 1, dir, mdds);
097:                } catch (URISyntaxException e) {
098:                    e.printStackTrace();
099:                }
100:                return mdds;
101:            }
102:
103:            private void fillMdds(int baselength, java.io.File dir,
104:                    java.util.Vector<String> mdds) {
105:                if (dir.isDirectory()) {
106:                    String[] list = dir.list();
107:                    for (int i = 0; i < list.length; i++) {
108:                        String s = list[i];
109:                        if (s.endsWith(".mdd")) {
110:                            s = dir.toString() + java.io.File.separatorChar + s;
111:                            s = s.substring(baselength, s.length() - 4); // cut off the ".mdd"
112:                            s = s.replace(java.io.File.separatorChar, '.');
113:                            mdds.add(s);
114:                        } else {
115:                            java.io.File f = new java.io.File(dir, s);
116:                            if (f.isDirectory())
117:                                fillMdds(baselength, f, mdds);
118:                        }
119:                    }
120:                }
121:            }
122:
123:            public MakumbaDataDefinitionFactory() {
124:
125:            }
126:
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.