Source Code Cross Referenced for FormatDefUtil.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » mdl » util » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.common.mdl.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify 
008:         * it under the terms of the GNU General Public License as published by 
009:         * the Free Software Foundation; either version 2 of the License, or 
010:         * (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
015:         * General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License 
018:         * along with this program; if not, write to the Free Software 
019:         * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307 
020:         * USA
021:         *
022:         * $Id: FormatDefUtil.java 6617 2007-04-11 01:04:44Z zjin $
023:         *
024:         */
025:        package com.bostechcorp.cbesb.common.mdl.util;
026:
027:        import java.io.File;
028:        import java.io.IOException;
029:
030:        import com.bostechcorp.cbesb.common.mdl.DefaultDocLocationResolver;
031:        import com.bostechcorp.cbesb.common.mdl.IDocLocationResolver;
032:        import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
033:        import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
034:        import com.bostechcorp.cbesb.common.mdl.MDLDocumentFactory;
035:        import com.bostechcorp.cbesb.common.mdl.hl7.Hl7DocLocationResolver;
036:        import com.bostechcorp.cbesb.common.mdl.x12.X12DocLocationResolver;
037:
038:        public class FormatDefUtil {
039:
040:            public static IMDLDocument getMdlDocFromFormatSpec(String format,
041:                    String formatSpec) {
042:                IDocLocationResolver docLocResolver;
043:                if (format.equals("x12")) {
044:                    docLocResolver = new X12DocLocationResolver();
045:                } else if (format.equals("hl7")) {
046:                    docLocResolver = new Hl7DocLocationResolver();
047:                } else {
048:                    docLocResolver = new DefaultDocLocationResolver();
049:                }
050:
051:                MDLDocumentFactory mdlFactory = new MDLDocumentFactory(
052:                        docLocResolver);
053:
054:                return mdlFactory.getMDLDocumentFromFormatSpec(formatSpec);
055:            }
056:
057:            public static IMDLDocument getMdlDocFromPath(String path) {
058:                return getMdlDocFromPath(path, false);
059:            }
060:
061:            public static IMDLDocument getMdlDocFromPath(String path,
062:                    boolean useDefaultMdlResolver) {
063:                File absPath = new File(path);
064:                //Figure out the details of the format from the path
065:                String project = null;
066:                String format = null;
067:                String version = null;
068:                String variant = null;
069:                int srcIndex = -1;
070:                try {
071:                    String pathStr = absPath.getCanonicalPath();
072:
073:                    /**
074:                     * If the File.separator="\". it can't be used as a parameter for split method,
075:                     * because it can't be as regular expression. 
076:                     */
077:                    String tempStr = pathStr.replace(File.separator, ";");
078:
079:                    String[] pathArr = tempStr.split(";");
080:                    for (int i = 0; i < pathArr.length; i++) {
081:                        if (pathArr[i].equals("src")) {
082:                            srcIndex = i;
083:                            break;
084:                        }
085:                    }
086:
087:                    if (srcIndex > 1) {
088:                        project = pathArr[srcIndex - 1];
089:                    }
090:                    if (pathArr.length > srcIndex + 2) {
091:                        format = pathArr[srcIndex + 2];
092:                        if (format.equals("x12") || format.equals("hl7")) {
093:                            if (pathArr.length > srcIndex + 4) {
094:                                version = pathArr[srcIndex + 3];
095:                                variant = pathArr[srcIndex + 4];
096:                            }
097:                        } else {
098:                            format = "mdl";
099:                        }
100:                    }
101:
102:                } catch (IOException e) {
103:                    //Shouldn't happen
104:                }
105:
106:                // This is a special case which used by the migration project. It always falls back to use tge deafult resolver 
107:                //  even if the x12 or hl7 is in the path.
108:                if (useDefaultMdlResolver)
109:                    format = "mdl";
110:
111:                IDocLocationResolver docLocResolver;
112:                if (format.equals("x12")) {
113:                    docLocResolver = new X12DocLocationResolver();
114:                    ((X12DocLocationResolver) docLocResolver)
115:                            .setProject(project);
116:                    ((X12DocLocationResolver) docLocResolver)
117:                            .setVersion(version);
118:                    ((X12DocLocationResolver) docLocResolver)
119:                            .setVariant(variant);
120:                } else if (format.equals("hl7")) {
121:                    docLocResolver = new Hl7DocLocationResolver();
122:                    ((Hl7DocLocationResolver) docLocResolver)
123:                            .setProject(project);
124:                    ((Hl7DocLocationResolver) docLocResolver)
125:                            .setVersion(version);
126:                    ((Hl7DocLocationResolver) docLocResolver)
127:                            .setVariant(variant);
128:                } else {
129:                    docLocResolver = new DefaultDocLocationResolver();
130:                }
131:
132:                MDLDocumentFactory mdlFactory = new MDLDocumentFactory(
133:                        docLocResolver);
134:
135:                return mdlFactory.getMDLDocument(absPath.getAbsolutePath(),
136:                        null);
137:            }
138:
139:            public static IMessageDefinition getMdlMessageDefFromFormatSpec(
140:                    String format, String formatSpec, String rootName) {
141:                IMDLDocument mdlDoc = getMdlDocFromFormatSpec(format,
142:                        formatSpec);
143:                return mdlDoc.getMessageDefinition(mdlDoc.getTargetNamespace(),
144:                        rootName);
145:            }
146:
147:            public static IMessageDefinition getMdlMessageDefFromPath(
148:                    String path, String rootName) {
149:                IMDLDocument mdlDoc = getMdlDocFromPath(path);
150:                return mdlDoc.getMessageDefinition(mdlDoc.getTargetNamespace(),
151:                        rootName);
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.