KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > bridge > ParserV2


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 // 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 JavaDoc;
33 import java.io.IOException JavaDoc;
34
35 //
36
public class ParserV2 implements Parser {
37     private PrintWriter JavaDoc traceWriter = null;
38     private MetaDataHandler handler = null;
39     private Parse parser = null;
40
41     public ParserV2(PrintWriter JavaDoc trace, MetaDataHandler metaData) {
42         traceWriter = trace;
43         handler = metaData;
44         Reporter reporter = null;
45
46         reporter = new Reporter(trace);
47         parser = new Parse(reporter, trace);
48     }
49
50     public XMLCDocument parse() throws XMLCException {
51         XMLCDocument doc = null;
52         MetaData metaData = null;
53
54         metaData = (MetaData) handler.getMetaData();
55         try {
56             doc = parser.parse(metaData);
57         } catch (XMLCException xe) {
58             throw xe;
59         } catch (Exception JavaDoc e) {
60             e.printStackTrace();
61             throw new XMLCException(e);
62         } catch (XMLCError e) {
63             e.printStackTrace();
64             throw new XMLCException(e);
65         } catch (Error JavaDoc e) {
66             e.printStackTrace();
67             throw new XMLCException(e);
68         }
69         return doc;
70     }
71
72     public MetaDataHandler getMetaDataHandler() {
73         return handler;
74     }
75
76     public void setMetaDataHandler(MetaDataHandler h) {
77         handler = h;
78     }
79
80     public PrintWriter JavaDoc getTraceWriter() {
81         return traceWriter;
82     }
83
84 }
85
Popular Tags