Source Code Cross Referenced for VariantParser.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » runtime » parser » impl » 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.runtime.parser.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package com.bostechcorp.cbesb.runtime.parser.impl;
004:
005:        import java.io.ByteArrayInputStream;
006:        import java.io.ByteArrayOutputStream;
007:        import java.io.IOException;
008:        import java.io.InputStream;
009:
010:        import org.w3c.dom.Document;
011:
012:        import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
013:        import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
014:        import com.bostechcorp.cbesb.common.mdl.IProperty;
015:        import com.bostechcorp.cbesb.common.mdl.impl.PropertyImpl;
016:        import com.bostechcorp.cbesb.common.util.ErrorUtil;
017:        import com.bostechcorp.cbesb.runtime.parser.ParserException;
018:
019:        public abstract class VariantParser extends LegacyDataParser {
020:
021:            private String projectName;
022:            private String version;
023:            private String variant = null;
024:            private IMDLDocument mdlDoc;
025:
026:            /**
027:             * @return the mdlDoc
028:             */
029:            public IMDLDocument getMdlDoc() {
030:                return mdlDoc;
031:            }
032:
033:            /**
034:             * @param mdlDoc the mdlDoc to set
035:             */
036:            public void setMdlDoc(IMDLDocument mdlDoc) {
037:                this .mdlDoc = mdlDoc;
038:            }
039:
040:            /**
041:             * @return the projectName
042:             */
043:            public String getProjectName() {
044:                return projectName;
045:            }
046:
047:            /**
048:             * @param projectName the projectName to set
049:             */
050:            public void setProjectName(String projectName) {
051:                this .projectName = projectName;
052:            }
053:
054:            /**
055:             * @return the variant
056:             */
057:            public String getVariant() {
058:                return variant;
059:            }
060:
061:            /**
062:             * @param variant the variant to set
063:             */
064:            public void setVariant(String variant) {
065:                this .variant = variant;
066:            }
067:
068:            /**
069:             * @return the version
070:             */
071:            public String getVersion() {
072:                return version;
073:            }
074:
075:            /**
076:             * @param version the version to set
077:             */
078:            public void setVersion(String version) {
079:                this .version = version;
080:            }
081:
082:            protected abstract void preProcessMessage(StringBuffer msgData)
083:                    throws ParserException;
084:
085:            protected abstract String getFsmClassName(String messageName);
086:
087:            public Document parse(InputStream is, IMessageDefinition msgDef)
088:                    throws IOException, ParserException {
089:                StringBuffer msgData;
090:
091:                //		Get message data into a StringBuffer
092:                msgData = getMsgDataFromInputStream(is);
093:
094:                //Do any format specific pre-processing
095:                preProcessMessage(msgData);
096:
097:                try {
098:
099:                    //Get the FSM class name
100:                    this .setFsmClassName(getFsmClassName(msgDef.getName()));
101:
102:                    //Convert back into an InputStream and call the LegacyDataParser
103:                    ByteArrayInputStream bais = new ByteArrayInputStream(
104:                            msgData.toString().getBytes("utf-8"));
105:                    return super .parse(bais, msgDef);
106:                } catch (ParserException pe) {
107:
108:                    // can't find FSM class in the variant; use the default base and try again;
109:
110:                    this .setVariant("");
111:                    //			Get the FSM class name
112:                    this .setFsmClassName(getFsmClassName(msgDef.getName()));
113:
114:                    //Convert back into an InputStream and call the LegacyDataParser
115:                    ByteArrayInputStream bais = new ByteArrayInputStream(
116:                            msgData.toString().getBytes("utf-8"));
117:                    return super .parse(bais, msgDef);
118:
119:                }
120:                //		catch (IOException e) {
121:                //
122:                //			ErrorUtil.printError("VariantParser caught IOException",e);
123:                //			throw new ParserException("VariantParser caught IOException", e);
124:                //		}
125:            }
126:
127:            private StringBuffer getMsgDataFromInputStream(InputStream is)
128:                    throws IOException {
129:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
130:                int i = is.read();
131:                while (i != -1) {
132:                    baos.write(i);
133:                    i = is.read();
134:                }
135:                return new StringBuffer(baos.toString("utf-8"));
136:            }
137:
138:            protected void overrideMsgDefProperty(String propertyName,
139:                    String propertyValue) {
140:
141:                String namespaceURI = mdlDoc.getTargetNamespace();
142:                IProperty prop = mdlDoc.getProperty(namespaceURI, propertyName);
143:                if (prop == null) {
144:                    prop = new PropertyImpl();
145:                    mdlDoc.addProperty(prop);
146:                    prop.setNamespaceURI(namespaceURI);
147:                    prop.setName(propertyName);
148:                }
149:                prop.setValue(propertyValue);
150:
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.