Source Code Cross Referenced for ProjectInfoParser.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » util » project » 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.util.project 
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:         *
023:         *
024:         */
025:        package com.bostechcorp.cbesb.common.util.project;
026:
027:        import java.io.File;
028:        import java.util.Stack;
029:
030:        import javax.xml.parsers.SAXParser;
031:        import javax.xml.parsers.SAXParserFactory;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:        import org.xml.sax.Attributes;
036:        import org.xml.sax.SAXException;
037:        import org.xml.sax.helpers.DefaultHandler;
038:
039:        import com.bostechcorp.cbesb.common.util.ErrorUtil;
040:
041:        public class ProjectInfoParser extends DefaultHandler {
042:
043:            private Stack<Object> loadStack;
044:
045:            private ProjectInfoDocument mdlDoc;
046:
047:            protected static transient Log logger = LogFactory
048:                    .getLog(ProjectInfoParser.class);
049:
050:            public ProjectInfoParser() {
051:                loadStack = new Stack<Object>();
052:                mdlDoc = new ProjectInfoDocument();
053:            }
054:
055:            /**
056:             * Static method to instantiate an MDLDocument object from a File.
057:             * 
058:             * @param filename The File to load
059:             * @return The loaded MDLDocument
060:             * @throws MDLException If any errors occur.
061:             */
062:            public static ProjectInfoDocument load(File filename) {
063:                ProjectInfoParser parserInstance = new ProjectInfoParser();
064:                return parserInstance.parse(filename);
065:            }
066:
067:            /**
068:             * Perform cleanup so GC can free up some memory
069:             */
070:            public void finalize() {
071:                loadStack.clear();
072:                loadStack = null;
073:                mdlDoc = null;
074:            }
075:
076:            /* (non-Javadoc)
077:             * SAX Handler Methods
078:             * @see org.xml.sax.helpers.DefaultHandler#startDocument()
079:             */
080:            public void startDocument() throws SAXException {
081:                super .startDocument();
082:            }
083:
084:            /* (non-Javadoc)
085:             * SAX Handler Methods
086:             * @see org.xml.sax.helpers.DefaultHandler#endDocument()
087:             */
088:            public void endDocument() throws SAXException {
089:                super .endDocument();
090:            }
091:
092:            /* (non-Javadoc)
093:             * SAX Handler Methods
094:             * @see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String, java.lang.String)
095:             */
096:            public void startPrefixMapping(String prefix, String uri)
097:                    throws SAXException {
098:                super .startPrefixMapping(prefix, uri);
099:            }
100:
101:            /* (non-Javadoc)
102:             * SAX Handler Methods
103:             * @see org.xml.sax.helpers.DefaultHandler#endPrefixMapping(java.lang.String)
104:             */
105:            public void endPrefixMapping(String prefix) throws SAXException {
106:                super .endPrefixMapping(prefix);
107:            }
108:
109:            /* (non-Javadoc)
110:             * SAX Handler Methods
111:             * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
112:             */
113:            public void startElement(String uri, String localName,
114:                    String qName, Attributes attributes) throws SAXException {
115:                super .startElement(uri, localName, qName, attributes);
116:                // Ignore elements that do not belong to the MDL Namespace
117:                //		if (uri.equals(MDL_NAMESPACE)) {
118:                try {
119:                    if (localName.equals("project")) {
120:                        startProjectNode(attributes);
121:                    } else if (localName.equals("subproject")
122:                            || localName.equals("superproject")) {
123:                        startSubProjectNode(attributes);
124:                    }
125:
126:                } catch (Exception e) {
127:                    ErrorUtil.printError("Exception in startElement(): ", e);
128:                    // SAX API forces us to wrap the exception in SAXException
129:                    throw new SAXException(e);
130:                }
131:            }
132:
133:            /* (non-Javadoc)
134:             * SAX Handler Methods
135:             * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
136:             */
137:            public void endElement(String uri, String localName, String qName)
138:                    throws SAXException {
139:                super .endElement(uri, localName, qName);
140:                // Ignore elements that do not belong to the MDL Namespace
141:            }
142:
143:            private ProjectInfoDocument parse(File filename) {
144:                try {
145:                    SAXParserFactory factory = SAXParserFactory.newInstance();
146:                    //    		System.out.println(filename.getAbsolutePath());
147:                    factory.setNamespaceAware(true);
148:                    SAXParser saxParser = factory.newSAXParser();
149:                    saxParser.parse(filename, this );
150:                    //            resolveRefs();
151:                } catch (Exception e) {
152:                    logger.error("Exception in parse(): " + e.getMessage());
153:                    if (logger.isDebugEnabled()) {
154:                        logger.debug("Exception in parse():", e);
155:                    }
156:                }
157:                return mdlDoc;
158:
159:            }
160:
161:            /**
162:             * MDL Specific Methods
163:             *
164:             * @param attributes Attributes
165:             * @throws MDLException MDLException
166:             */
167:            private void startProjectNode(Attributes attributes) {
168:                String projectName = attributes.getValue("", "name");
169:                String projectType = attributes.getValue("", "type");
170:                ProjectBean projectBean = new ProjectBean();
171:                if (projectName != null) {
172:                    projectBean.setName(projectName);
173:                    projectBean.setType(projectType);
174:                }
175:                mdlDoc.setProject(projectBean);
176:
177:                loadStack.push(mdlDoc);
178:            }
179:
180:            private void startSubProjectNode(Attributes attributes) {
181:                String projectName = attributes.getValue("", "name");
182:                String projectType = attributes.getValue("", "type");
183:                SubProjectBean subProjectBean = new SubProjectBean();
184:                if (projectName != null) {
185:                    subProjectBean.setName(projectName);
186:                    subProjectBean.setType(projectType);
187:                }
188:                mdlDoc.getProject().addNewSubProject(subProjectBean);
189:
190:                loadStack.push(mdlDoc);
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.