01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * 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: // XMLC imports
25: import org.enhydra.xml.xmlc.XMLCError;
26: import org.enhydra.xml.xmlc.XMLCException;
27: import org.enhydra.xml.xmlc.dom.XMLCDocument;
28: import org.enhydra.xml.xmlc.compiler.Parse;
29: import org.enhydra.xml.xmlc.metadata.MetaData;
30:
31: // Standard imports
32: import java.io.PrintWriter;
33:
34: //
35: public class ParserV2 implements Parser {
36: private PrintWriter traceWriter = null;
37: private MetaDataHandler handler = null;
38: private Parse parser = null;
39:
40: public ParserV2(PrintWriter trace, MetaDataHandler metaData) {
41: traceWriter = trace;
42: handler = metaData;
43: Reporter reporter = null;
44:
45: reporter = new Reporter(trace);
46: parser = new Parse(reporter, trace);
47: }
48:
49: public XMLCDocument parse() throws XMLCException {
50: XMLCDocument doc = null;
51: MetaData metaData = null;
52:
53: metaData = (MetaData) handler.getMetaData();
54: try {
55: doc = parser.parse(metaData);
56: } catch (XMLCException xe) {
57: throw xe;
58: } catch (Exception e) {
59: e.printStackTrace();
60: throw new XMLCException(e);
61: } catch (XMLCError e) {
62: e.printStackTrace();
63: throw new XMLCException(e);
64: } catch (Error e) {
65: e.printStackTrace();
66: throw new XMLCException(e);
67: }
68: return doc;
69: }
70:
71: public MetaDataHandler getMetaDataHandler() {
72: return handler;
73: }
74:
75: public void setMetaDataHandler(MetaDataHandler h) {
76: handler = h;
77: }
78:
79: public PrintWriter getTraceWriter() {
80: return traceWriter;
81: }
82:
83: }
|