Source Code Cross Referenced for VariableElementParser.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » runtime » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.runtime.parser 
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 it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * 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 MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id: VariableElementParser.java 3622 2006-12-12 03:04:08Z lzheng $
023:         */
024:        package com.bostechcorp.cbesb.runtime.parser;
025:
026:        import java.io.InputStream;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.w3c.dom.Element;
031:
032:        import com.bostechcorp.cbesb.common.mdl.IElementDefinition;
033:        import com.bostechcorp.cbesb.common.mdl.IVariableFormatDefinition;
034:
035:        /**
036:         * The VariableElementParser class implements ElementParser. It is used to parse
037:         * elements defined as variable format.
038:         * 
039:         * Basic flow of the parse method: 1. Set the variable format attributes in the
040:         * VariableDataScanner (delimiter, escape character, etc). 2. If the
041:         * VariableFormatDefinition specifies an IDMethod = tag, call parseTag, if the
042:         * IDMethod = position, call parsePosition.
043:         * 
044:         * Basic flow of parseTag method: 1. Create a new Element with the name and
045:         * namespace provided in the ElementDefinition. 2. Initialize Finite State
046:         * Machine with content model defined by tags in ElementDefinition. 3. Call
047:         * getNextElement in the VariableDataScanner to retrieve the next piece of data
048:         * from the InputStream. 4. Repeatedly feed in the element data to the FSM until
049:         * the end of the InputStream is reached. 5. If the FSM matches all elements
050:         * successfully, then do the following for each successfully matched element: a.
051:         * Create a new InputStream containing this data only. b. Get the
052:         * ElementDefinition from the ContentElement that defines the child. c. Get an
053:         * instance of ElementParser from ElementParserFactory using the child
054:         * ElementDefinition as input. d. Call the parse method of this ElementParser
055:         * passing in the new InputStream and child ElementDefinition. e. Append the
056:         * returned DOM Element to the Element created in step 1.
057:         * 
058:         * Basic flow of parsePosition method: 1. Create a new Element with the name and
059:         * namespace provided in the ElementDefinition. 2. Loop over all of the child
060:         * ContentElement nodes defined in the ElementDefinition. For each child, do the
061:         * following: a. Call getNextElement in the VariableDataScanner to retrieve the
062:         * next piece of data from the InputStream. b. If the getNextElement method
063:         * returned multiple strings, then there were multiple occurrences of this
064:         * element in the data. For each Occurrence, do the following: i. Create a new
065:         * InputStream containing this data only. ii. Get the ElementDefinition from the
066:         * ContentElement that defines the child. iii. Get an instance of ElementParser
067:         * from ElementParserFactory using the child ElementDefinition as input. iv.
068:         * Call the parse method of this ElementParser passing in the new InputStream
069:         * and child ElementDefinition. v. Append the returned DOM Element to the
070:         * Element created in step 1.
071:         * 
072:         */
073:        public abstract class VariableElementParser implements  IElementParser {
074:
075:            private static final Log logger = LogFactory
076:                    .getLog(VariableElementParser.class);
077:
078:            protected VariableDataScanner scanner = new VariableDataScanner();
079:
080:            protected void setupScanner(IElementDefinition elementDefinition) {
081:                IVariableFormatDefinition varDef = (IVariableFormatDefinition) elementDefinition
082:                        .getFormatDefinition();
083:                scanner.setDelimiter(varDef.getResolvedDelimiter());
084:                scanner.setRepeatDelimiter(varDef.getResolvedRepeatDelimiter());
085:                scanner.setEscapeChar(varDef.getResolvedEscapeChar());
086:                scanner.setQuoteChar(varDef.getResolvedQuoteChar());
087:                scanner.setTagLength(varDef.getResolvedTagLength());
088:                scanner.setTagDelimiter(varDef.getResolvedTagDelimiter());
089:
090:                if (logger.isDebugEnabled()) {
091:                    logger.debug("VariableElementParser scanner settings:");
092:                    logger.debug("Delimiter = ["
093:                            + getHexString(scanner.getDelimiter()) + "]");
094:                    logger.debug("RepeatDelimiter = ["
095:                            + getHexString(scanner.getRepeatDelimiter()) + "]");
096:                    logger.debug("EscapeChar = ["
097:                            + getHexString(scanner.getEscapeChar()) + "]");
098:                    logger.debug("QuoteChar = ["
099:                            + getHexString(scanner.getQuoteChar()) + "]");
100:                    logger.debug("Tag Length = [" + scanner.getTagLength()
101:                            + "]");
102:                    logger.debug("Tag Delimiter = ["
103:                            + getHexString(scanner.getTagDelimiter()) + "]");
104:                }
105:            }
106:
107:            protected String getHexString(String data) {
108:                StringBuffer sb = new StringBuffer();
109:                if (data != null) {
110:                    for (int i = 0; i < data.length(); i++) {
111:                        char c = data.charAt(i);
112:                        String hex = Integer.toHexString(c);
113:                        sb.append(hex);
114:                    }
115:                }
116:                return sb.toString();
117:            }
118:
119:            protected String getHexString(char c) {
120:                return Integer.toHexString(c);
121:            }
122:
123:            public abstract Element parse(InputStream is,
124:                    IElementDefinition elementDefinition)
125:                    throws ParserException;
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.