Source code: org/enhydra/kelp/common/bridge/ParserV2.java
1 /*
2 * Enhydra Java Application Server Project
3 *
4 * The contents of this file are subject to the Enhydra Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License on
7 * the Enhydra web site ( http://www.enhydra.org/ ).
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific terms governing rights and limitations
12 * under the License.
13 *
14 * The Initial Developer of the Enhydra Application Server is Lutris
15 * Technologies, Inc. The Enhydra Application Server and portions created
16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17 * All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22 package org.enhydra.kelp.common.bridge;
23
24 // Kelp imports
25 import org.enhydra.kelp.common.wizard.xmlc.Reporter;
26
27 // XMLC imports
28 import org.enhydra.xml.xmlc.XMLCError;
29 import org.enhydra.xml.xmlc.XMLCException;
30 import org.enhydra.xml.xmlc.dom.XMLCDocument;
31 import org.enhydra.xml.xmlc.compiler.Parse;
32 import org.enhydra.xml.xmlc.metadata.MetaData;
33
34 // Standard imports
35 import java.io.PrintWriter;
36 import java.io.IOException;
37
38 //
39 public class ParserV2 implements Parser {
40 private PrintWriter traceWriter = null;
41 private MetaDataHandler handler = null;
42 private Parse parser = null;
43
44 public ParserV2(PrintWriter trace, MetaDataHandler metaData) {
45 traceWriter = trace;
46 handler = metaData;
47 Reporter reporter = null;
48
49 reporter = new Reporter(trace);
50 parser = new Parse(reporter, trace);
51 }
52
53 public XMLCDocument parse() throws XMLCException {
54 XMLCDocument doc = null;
55 MetaData metaData = null;
56
57 metaData = (MetaData) handler.getMetaData();
58 try {
59 doc = parser.parse(metaData);
60 } catch (XMLCException xe) {
61 throw xe;
62 } catch (Exception e) {
63 e.printStackTrace();
64 throw new XMLCException(e);
65 } catch (XMLCError e) {
66 e.printStackTrace();
67 throw new XMLCException(e);
68 } catch (Error e) {
69 e.printStackTrace();
70 throw new XMLCException(e);
71 }
72 return doc;
73 }
74
75 public MetaDataHandler getMetaDataHandler() {
76 return handler;
77 }
78
79 public void setMetaDataHandler(MetaDataHandler h) {
80 handler = h;
81 }
82
83 public PrintWriter getTraceWriter() {
84 return traceWriter;
85 }
86
87 }