Source Code Cross Referenced for ApplicationVerificationReportReader.java in  » ESB » open-esb » com » sun » esb » management » common » data » helper » 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 » open esb » com.sun.esb.management.common.data.helper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)ApplicationVerificationReportReader.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:
030:        package com.sun.esb.management.common.data.helper;
031:
032:        import java.io.File;
033:        import java.io.FileInputStream;
034:        import java.io.IOException;
035:        import java.io.InputStream;
036:        import java.io.Reader;
037:        import java.io.Serializable;
038:        import java.io.StringReader;
039:        import java.net.MalformedURLException;
040:        import java.net.URI;
041:        import java.net.URISyntaxException;
042:        import java.util.ArrayList;
043:        import java.util.List;
044:        import java.util.Stack;
045:
046:        import javax.xml.parsers.ParserConfigurationException;
047:        import javax.xml.parsers.SAXParser;
048:        import javax.xml.parsers.SAXParserFactory;
049:
050:        import org.xml.sax.Attributes;
051:        import org.xml.sax.InputSource;
052:        import org.xml.sax.SAXException;
053:        import org.xml.sax.helpers.DefaultHandler;
054:
055:        import com.sun.esb.management.common.data.ApplicationVerificationReport;
056:        import com.sun.esb.management.common.data.EndpointInformation;
057:        import com.sun.esb.management.common.data.JavaEEVerifierReport;
058:
059:        /**
060:         * Parses Application Verification Report from an XML String or file
061:         * 
062:         * @author graj
063:         * 
064:         */
065:        public class ApplicationVerificationReportReader extends DefaultHandler
066:                implements  ApplicationVerificationReportXMLConstants,
067:                Serializable {
068:
069:            static final long serialVersionUID = -1L;
070:
071:            // Private members needed to parse the XML document
072:
073:            // keep track of parsing
074:            private boolean parsingInProgress;
075:
076:            // keep track of QName
077:            private Stack<String> qNameStack = new Stack<String>();
078:
079:            private EndpointInformation endpointInformation;
080:
081:            private List<EndpointInformation> endpointInformationList;
082:
083:            /** java ee verifier report list */
084:            private List<JavaEEVerifierReport> javaEEVerifierReportList;
085:
086:            /** java ee verifier report */
087:            private JavaEEVerifierReport javaEEVerifierReport;
088:
089:            /** jave ee verifier report table item type */
090:            private JavaEEVerifierReport.JavaEEReportItem javaEEVerifierTableItem;
091:
092:            private List<String /* ComponentName */> missingComponentsList;
093:
094:            private ApplicationVerificationReport report;
095:
096:            private String applicationVerificationReportVersion;
097:
098:            private List<String> missingAppVars;
099:
100:            private List<String> missingAppConfigs;
101:
102:            /**
103:             * Constructor - creates a new instance of
104:             * ApplicationVerificationReportReader
105:             */
106:            public ApplicationVerificationReportReader() {
107:            }
108:
109:            /**
110:             * @return the Application Verification Report
111:             */
112:            public ApplicationVerificationReport getApplicationVerificationReport() {
113:                return this .report;
114:            }
115:
116:            /**
117:             * Start of document processing.
118:             * 
119:             * @throws org.xml.sax.SAXException
120:             *             is any SAX exception, possibly wrapping another exception.
121:             */
122:            public void startDocument() throws SAXException {
123:                parsingInProgress = true;
124:                qNameStack.removeAllElements();
125:            }
126:
127:            /**
128:             * End of document processing.
129:             * 
130:             * @throws org.xml.sax.SAXException
131:             *             is any SAX exception, possibly wrapping another exception.
132:             */
133:            public void endDocument() throws SAXException {
134:                parsingInProgress = false;
135:                // We have encountered the end of the document. Do any processing that
136:                // is desired, for example dump all collected element2 values.
137:
138:            }
139:
140:            /**
141:             * Process the new element.
142:             * 
143:             * @param uri
144:             *            is the Namespace URI, or the empty string if the element has
145:             *            no Namespace URI or if Namespace processing is not being
146:             *            performed.
147:             * @param localName
148:             *            is the The local name (without prefix), or the empty string if
149:             *            Namespace processing is not being performed.
150:             * @param qName
151:             *            is the qualified name (with prefix), or the empty string if
152:             *            qualified names are not available.
153:             * @param attributes
154:             *            is the attributes attached to the element. If there are no
155:             *            attributes, it shall be an empty Attributes object.
156:             * @throws org.xml.sax.SAXException
157:             *             is any SAX exception, possibly wrapping another exception.
158:             */
159:            public void startElement(String uri, String localName,
160:                    String qName, Attributes attributes) throws SAXException {
161:                if (qName != null) {
162:                    if (qName.endsWith(APPLICATION_VERIFICATION_REPORT_KEY)) {
163:                        // ELEMENT1 has an attribute, get it by name
164:                        // Do something with the attribute
165:                        if ((attributes != null)
166:                                && (attributes.getLength() > 0)) {
167:                            String namespace = attributes
168:                                    .getValue(NAMESPACE_KEY);
169:                            // //////////////////////////////////////////////////////
170:                            // Read performanceDataListVersion attribute and ensure you
171:                            // store the right
172:                            // performanceDataListVersion of the report map list
173:                            // //////////////////////////////////////////////////////
174:                            this .applicationVerificationReportVersion = attributes
175:                                    .getValue(VERSION_KEY);
176:                            if ((applicationVerificationReportVersion != null)
177:                                    && (VERSION_VALUE
178:                                            .equals(applicationVerificationReportVersion))) {
179:                                this .report = new ApplicationVerificationReport();
180:                            } else {
181:                                // Invalid applicationVerificationReportVersion.
182:                                // Not storing it
183:                            }
184:                        }
185:                    } else if (qName.endsWith(MISSING_COMPONENTS_LIST_KEY)) {
186:                        // ELEMENT1 has an attribute, get it by name
187:                        // Do something with the attribute
188:                        if (this .report != null) {
189:                            this .missingComponentsList = new ArrayList<String /* ComponentName */>();
190:                        }
191:                    } else if (qName.endsWith(ENDPOINT_INFORMATION_LIST_KEY)) {
192:                        // ELEMENT1 has an attribute, get it by name
193:                        // Do something with the attribute
194:                        if (this .report != null) {
195:                            this .endpointInformationList = new ArrayList<EndpointInformation>();
196:                        }
197:                    } else if (qName.endsWith(ENDPOINT_KEY)) {
198:                        // ELEMENT1 has an attribute, get it by name
199:                        // Do something with the attribute
200:                        if ((this .report != null)
201:                                && (this .endpointInformationList != null)) {
202:                            this .endpointInformation = new EndpointInformation();
203:                        }
204:                    } else if (qName.endsWith(MISSING_APPVARS_KEY)) {
205:                        // ELEMENT1 has an attribute, get it by name
206:                        // Do something with the attribute
207:                        if ((this .report != null)
208:                                && (this .endpointInformationList != null)) {
209:                            this .missingAppVars = new ArrayList<String>();
210:                        }
211:                    } else if (qName.endsWith(MISSING_APPCONFIGS_KEY)) {
212:                        // ELEMENT1 has an attribute, get it by name
213:                        // Do something with the attribute
214:                        if ((this .report != null)
215:                                && (this .endpointInformationList != null)) {
216:                            this .missingAppConfigs = new ArrayList<String>();
217:                        }
218:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORTS_LIST_KEY)) {
219:                        if (this .report != null) {
220:                            this .javaEEVerifierReportList = new ArrayList<JavaEEVerifierReport>();
221:                        }
222:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORT_KEY)) {
223:                        if ((this .report != null)
224:                                && (this .javaEEVerifierReportList != null)) {
225:                            this .javaEEVerifierReport = new JavaEEVerifierReport();
226:                        }
227:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORT_ITEM_KEY)) {
228:                        if ((this .report != null)
229:                                && (this .javaEEVerifierReport != null)) {
230:                            this .javaEEVerifierTableItem = javaEEVerifierReport.new JavaEEReportItem();
231:                        }
232:                    }
233:                    // Keep track of QNames
234:                    qNameStack.push(qName);
235:                }
236:            }
237:
238:            /**
239:             * Process the character report for current tag.
240:             * 
241:             * @param ch
242:             *            are the element's characters.
243:             * @param start
244:             *            is the start position in the character array.
245:             * @param length
246:             *            is the number of characters to use from the character array.
247:             * @throws org.xml.sax.SAXException
248:             *             is any SAX exception, possibly wrapping another exception.
249:             */
250:            public void characters(char[] ch, int start, int length)
251:                    throws SAXException {
252:                String qName;
253:                String chars = new String(ch, start, length);
254:                // Get current QName
255:                qName = (String) qNameStack.peek();
256:                if (qName.endsWith(SERVICE_ASSEMBLY_NAME_KEY)) {
257:                    if (this .report != null) {
258:                        this .report.setServiceAssemblyName(chars);
259:                    }
260:                } else if (qName.endsWith(SERVICE_ASSEMBLY_DESCRIPTION_KEY)) {
261:                    if (this .report != null) {
262:                        this .report.setServiceAssemblyDescription(chars);
263:                    }
264:                } else if (qName.endsWith(NUMBER_OF_SERVICE_UNITS_KEY)) {
265:                    if (this .report != null) {
266:                        int numberOfServiceUnits = Integer.valueOf(chars)
267:                                .intValue();
268:                        this .report
269:                                .setNumberOfServiceUnits(numberOfServiceUnits);
270:                    }
271:                } else if (qName.endsWith(ALL_COMPONENTS_INSTALLED_KEY)) {
272:                    if (this .report != null) {
273:                        boolean allComponentsInstalled = Boolean.valueOf(chars)
274:                                .booleanValue();
275:                        this .report
276:                                .setAllComponentsInstalled(allComponentsInstalled);
277:                    }
278:                } else if (qName.endsWith(TEMPLATE_ZIPID_KEY)) {
279:                    if (this .report != null) {
280:                        this .report.setTemplateZipId(chars);
281:                    }
282:                } else if (qName.endsWith(MISSING_COMPONENT_NAME_KEY)) {
283:                    if ((this .report != null)
284:                            && (this .missingComponentsList != null)) {
285:                        this .missingComponentsList.add(chars);
286:                    }
287:                } else if (qName.endsWith(ENDPOINT_NAME_KEY)) {
288:                    if ((this .report != null)
289:                            && (this .endpointInformationList != null)
290:                            && (this .endpointInformation != null)) {
291:                        this .endpointInformation.setEndpointName(chars);
292:                    }
293:                } else if (qName.endsWith(SERVICE_UNIT_NAME_KEY)) {
294:                    if ((this .report != null)
295:                            && (this .endpointInformationList != null)
296:                            && (this .endpointInformation != null)) {
297:                        this .endpointInformation.setServiceUnitName(chars);
298:                    }
299:                } else if (qName.endsWith(COMPONENT_NAME_KEY)) {
300:                    if ((this .report != null)
301:                            && (this .endpointInformationList != null)
302:                            && (this .endpointInformation != null)) {
303:                        this .endpointInformation.setComponentName(chars);
304:                    }
305:                } else if (qName.endsWith(STATUS_KEY)) {
306:                    if ((this .report != null)
307:                            && (this .endpointInformationList != null)
308:                            && (this .endpointInformation != null)) {
309:                        this .endpointInformation.setStatus(chars);
310:                    }
311:                } else if (qName.endsWith(MISSING_APPVAR_NAME_KEY)) {
312:                    if ((this .report != null) && (this .missingAppVars != null)) {
313:                        this .missingAppVars.add(chars);
314:                    }
315:                } else if (qName.endsWith(MISSING_APPCONFIG_NAME_KEY)) {
316:                    if ((this .report != null)
317:                            && (this .missingAppConfigs != null)) {
318:                        this .missingAppConfigs.add(chars);
319:                    }
320:                } else if (qName.endsWith(JAVAEE_VERIFIER_SERVICE_UNIT_NAME)) {
321:                    if ((this .report != null)
322:                            && (this .javaEEVerifierReportList != null)
323:                            && (this .javaEEVerifierReport != null)) {
324:                        this .javaEEVerifierReport.setServiceUnitName(chars);
325:                    }
326:                } else if (qName
327:                        .endsWith(JAVAEE_VERIFIER_EAR_FILE_NAME_ITEM_KEY)) {
328:                    if ((this .report != null)
329:                            && (this .javaEEVerifierReportList != null)
330:                            && (this .javaEEVerifierReport != null)
331:                            && (this .javaEEVerifierTableItem != null)) {
332:                        this .javaEEVerifierTableItem.setEarFileName(chars);
333:                    }
334:                } else if (qName
335:                        .endsWith(JAVAEE_VERIFIER_REFERENCE_BY_ITEM_KEY)) {
336:                    if ((this .report != null)
337:                            && (this .javaEEVerifierReportList != null)
338:                            && (this .javaEEVerifierReport != null)
339:                            && (this .javaEEVerifierTableItem != null)) {
340:                        this .javaEEVerifierTableItem.setReferenceBy(chars);
341:                    }
342:                } else if (qName
343:                        .endsWith(JAVAEE_VERIFIER_REFERENCE_CLASS_ITEM_KEY)) {
344:                    if ((this .report != null)
345:                            && (this .javaEEVerifierReportList != null)
346:                            && (this .javaEEVerifierReport != null)
347:                            && (this .javaEEVerifierTableItem != null)) {
348:                        this .javaEEVerifierTableItem.setReferenceClass(chars);
349:                    }
350:                } else if (qName.endsWith(JAVAEE_VERIFIER_JNDI_NAME_ITEM_KEY)) {
351:                    if ((this .report != null)
352:                            && (this .javaEEVerifierReportList != null)
353:                            && (this .javaEEVerifierReport != null)
354:                            && (this .javaEEVerifierTableItem != null)) {
355:                        this .javaEEVerifierTableItem.setJndiName(chars);
356:                    }
357:                } else if (qName.endsWith(JAVAEE_VERIFIER_JNDI_CLASS_ITEM_KEY)) {
358:                    if ((this .report != null)
359:                            && (this .javaEEVerifierReportList != null)
360:                            && (this .javaEEVerifierReport != null)
361:                            && (this .javaEEVerifierTableItem != null)) {
362:                        this .javaEEVerifierTableItem.setJndiClass(chars);
363:                    }
364:                } else if (qName.endsWith(JAVAEE_VERIFIER_MESSAGE_ITEM_KEY)) {
365:                    if ((this .report != null)
366:                            && (this .javaEEVerifierReportList != null)
367:                            && (this .javaEEVerifierReport != null)
368:                            && (this .javaEEVerifierTableItem != null)) {
369:                        this .javaEEVerifierTableItem.setMessage(chars);
370:                    }
371:                } else if (qName.endsWith(JAVAEE_VERIFIER_STATUS_ITEM_KEY)) {
372:                    if ((this .report != null)
373:                            && (this .javaEEVerifierReportList != null)
374:                            && (this .javaEEVerifierReport != null)
375:                            && (this .javaEEVerifierTableItem != null)) {
376:                        this .javaEEVerifierTableItem.setStatus(Integer
377:                                .parseInt(chars));
378:                    }
379:                }
380:
381:            }
382:
383:            /**
384:             * Process the end element tag.
385:             * 
386:             * @param uri
387:             *            is the Namespace URI, or the empty string if the element has
388:             *            no Namespace URI or if Namespace processing is not being
389:             *            performed.
390:             * @param localName
391:             *            is the The local name (without prefix), or the empty string if
392:             *            Namespace processing is not being performed.
393:             * @param qName
394:             *            is the qualified name (with prefix), or the empty string if
395:             *            qualified names are not available.
396:             * @throws org.xml.sax.SAXException
397:             *             is any SAX exception, possibly wrapping another exception.
398:             */
399:            public void endElement(String uri, String localName, String qName)
400:                    throws SAXException {
401:                // Pop QName, since we are done with it
402:                qNameStack.pop();
403:                if (qName != null) {
404:                    if (qName.endsWith(MISSING_COMPONENTS_LIST_KEY)) {
405:                        // We have encountered the end of ELEMENT1
406:                        // ...
407:                        if ((this .report != null)
408:                                && (this .missingComponentsList != null)) {
409:                            this .report
410:                                    .setMissingComponentsList(this .missingComponentsList);
411:                            this .missingComponentsList = null;
412:                        }
413:                    } else if (qName.endsWith(ENDPOINT_INFORMATION_LIST_KEY)) {
414:                        // We have encountered the end of ELEMENT1
415:                        // ...
416:                        if ((this .report != null)
417:                                && (this .endpointInformationList != null)) {
418:                            this .report
419:                                    .setEndpointInformationList(this .endpointInformationList);
420:                            this .endpointInformationList = null;
421:                        }
422:                    } else if (qName.endsWith(ENDPOINT_KEY)) {
423:                        // We have encountered the end of ELEMENT1
424:                        // ...
425:                        if ((this .report != null)
426:                                && (this .endpointInformationList != null)) {
427:                            this .endpointInformationList
428:                                    .add(this .endpointInformation);
429:                            this .endpointInformation = null;
430:                        }
431:                    } else if (qName.endsWith(MISSING_APPVARS_KEY)) {
432:                        // We have encountered the end of ELEMENT1
433:                        // ...
434:                        if ((this .report != null)
435:                                && (this .missingAppVars != null)) {
436:                            this .endpointInformation
437:                                    .setMissingApplicationVariables((String[]) this .missingAppVars
438:                                            .toArray(new String[] {}));
439:                            this .missingAppVars = null;
440:                        }
441:                    } else if (qName.endsWith(MISSING_APPCONFIGS_KEY)) {
442:                        // We have encountered the end of ELEMENT1
443:                        // ...
444:                        if ((this .report != null)
445:                                && (this .missingAppConfigs != null)) {
446:                            this .endpointInformation
447:                                    .setMissingApplicationConfigurations((String[]) this .missingAppConfigs
448:                                            .toArray(new String[] {}));
449:                            this .missingAppConfigs = null;
450:                        }
451:
452:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORT_ITEM_KEY)) {
453:                        // We have encountered the end of JAVAEE_VERIFIER_REPORT_ITEM_KEY
454:                        if (this .report != null
455:                                && this .javaEEVerifierReportList != null
456:                                && javaEEVerifierReport != null) {
457:                            this .javaEEVerifierReport
458:                                    .addJavaEEVerifierReportItem(this .javaEEVerifierTableItem);
459:                            this .javaEEVerifierTableItem = null;
460:                        }
461:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORT_KEY)) {
462:                        if (this .report != null
463:                                && this .javaEEVerifierReportList != null
464:                                && javaEEVerifierReport != null) {
465:                            this .javaEEVerifierReportList
466:                                    .add(javaEEVerifierReport);
467:                            this .javaEEVerifierReport = null;
468:                        }
469:                    } else if (qName.endsWith(JAVAEE_VERIFIER_REPORTS_LIST_KEY)) {
470:                        if ((this .report != null)
471:                                && (this .javaEEVerifierReportList != null)) {
472:                            this .report
473:                                    .setJavaEEVerifierReports(this .javaEEVerifierReportList);
474:                            this .javaEEVerifierReportList = null;
475:                        }
476:                    }
477:                }
478:            }
479:
480:            /**
481:             * 
482:             * @param rawXMLData
483:             * @return
484:             * @throws MalformedURLException
485:             * @throws ParserConfigurationException
486:             * @throws SAXException
487:             * @throws URISyntaxException
488:             * @throws IOException
489:             */
490:            public static ApplicationVerificationReport parseFromXMLData(
491:                    String rawXMLData) throws MalformedURLException,
492:                    ParserConfigurationException, SAXException,
493:                    URISyntaxException, IOException {
494:                // System.out.println("Parsing file: "+uriString);
495:                // Get an instance of the SAX parser factory
496:                SAXParserFactory factory = SAXParserFactory.newInstance();
497:
498:                // Get an instance of the SAX parser
499:                SAXParser saxParser = factory.newSAXParser();
500:
501:                // Initialize the XML Document InputStream
502:                Reader reader = new StringReader(rawXMLData);
503:
504:                // Create an InputSource from the InputStream
505:                InputSource inputSource = new InputSource(reader);
506:
507:                // Parse the aspectInput XML document stream, using my event handler
508:                ApplicationVerificationReportReader parser = new ApplicationVerificationReportReader();
509:                saxParser.parse(inputSource, parser);
510:
511:                return parser.getApplicationVerificationReport();
512:
513:            }
514:
515:            /**
516:             * 
517:             * @param fileName
518:             * @return
519:             * @throws MalformedURLException
520:             * @throws ParserConfigurationException
521:             * @throws SAXException
522:             * @throws URISyntaxException
523:             * @throws IOException
524:             */
525:            public static ApplicationVerificationReport parseFromFile(
526:                    String fileName) throws MalformedURLException,
527:                    ParserConfigurationException, SAXException,
528:                    URISyntaxException, IOException {
529:                File file = new File(fileName);
530:                return parseFromFile(file);
531:            }
532:
533:            /**
534:             * 
535:             * @param fileName
536:             * @return
537:             * @throws MalformedURLException
538:             * @throws ParserConfigurationException
539:             * @throws SAXException
540:             * @throws URISyntaxException
541:             * @throws IOException
542:             */
543:            public static ApplicationVerificationReport parseFromFile(File file)
544:                    throws MalformedURLException, ParserConfigurationException,
545:                    SAXException, URISyntaxException, IOException {
546:
547:                // Get an instance of the SAX parser factory
548:                SAXParserFactory factory = SAXParserFactory.newInstance();
549:
550:                // Get an instance of the SAX parser
551:                SAXParser saxParser = factory.newSAXParser();
552:
553:                // Initialize the URI and XML Document InputStream
554:                InputStream inputStream = new FileInputStream(file);
555:
556:                // Create an InputSource from the InputStream
557:                InputSource inputSource = new InputSource(inputStream);
558:
559:                // Parse the aspectInput XML document stream, using my event handler
560:                ApplicationVerificationReportReader parser = new ApplicationVerificationReportReader();
561:                saxParser.parse(inputSource, parser);
562:
563:                return parser.getApplicationVerificationReport();
564:            }
565:
566:            /**
567:             * 
568:             * @param uriString
569:             * @return
570:             * @throws MalformedURLException
571:             * @throws ParserConfigurationException
572:             * @throws SAXException
573:             * @throws URISyntaxException
574:             * @throws IOException
575:             */
576:            public static ApplicationVerificationReport parseFromURI(
577:                    String uriString) throws MalformedURLException,
578:                    ParserConfigurationException, SAXException,
579:                    URISyntaxException, IOException {
580:                URI uri = new URI(uriString);
581:                return parseFromURI(uri);
582:            }
583:
584:            /**
585:             * 
586:             * @param uri
587:             * @return
588:             * @throws MalformedURLException
589:             * @throws ParserConfigurationException
590:             * @throws SAXException
591:             * @throws URISyntaxException
592:             * @throws IOException
593:             */
594:            public static ApplicationVerificationReport parseFromURI(URI uri)
595:                    throws MalformedURLException, ParserConfigurationException,
596:                    SAXException, URISyntaxException, IOException {
597:
598:                // Get an instance of the SAX parser factory
599:                SAXParserFactory factory = SAXParserFactory.newInstance();
600:
601:                // Get an instance of the SAX parser
602:                SAXParser saxParser = factory.newSAXParser();
603:
604:                // Initialize the URI and XML Document InputStream
605:                InputStream inputStream = uri.toURL().openStream();
606:
607:                // Create an InputSource from the InputStream
608:                InputSource inputSource = new InputSource(inputStream);
609:
610:                // Parse the aspectInput XML document stream, using my event handler
611:                ApplicationVerificationReportReader parser = new ApplicationVerificationReportReader();
612:                saxParser.parse(inputSource, parser);
613:
614:                return parser.getApplicationVerificationReport();
615:            }
616:
617:            /**
618:             * @param args
619:             */
620:            public static void main(String[] args) {
621:                // String uri = "C:/test/schema/verification/instance.xml";
622:                String uri = "C:/test/schema/verification/ApplicationVerificationReport.xml";
623:                try {
624:                    ApplicationVerificationReport report = ApplicationVerificationReportReader
625:                            .parseFromFile(uri);
626:                    System.out.println(report.getDisplayString());
627:                } catch (MalformedURLException e) {
628:                    // TODO Auto-generated catch block
629:                    e.printStackTrace();
630:                } catch (ParserConfigurationException e) {
631:                    // TODO Auto-generated catch block
632:                    e.printStackTrace();
633:                } catch (SAXException e) {
634:                    // TODO Auto-generated catch block
635:                    e.printStackTrace();
636:                } catch (URISyntaxException e) {
637:                    // TODO Auto-generated catch block
638:                    e.printStackTrace();
639:                } catch (IOException e) {
640:                    // TODO Auto-generated catch block
641:                    e.printStackTrace();
642:                }
643:            }
644:
645:        }
w_w_w___.___j_a_v__a__2__s___.__c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.