01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.vdl.directive;
16:
17: import org.griphyn.common.util.Currently;
18: import org.griphyn.vdl.parser.*;
19: import org.griphyn.vdl.classes.*;
20: import org.griphyn.vdl.util.Logging;
21:
22: import java.io.Reader;
23: import java.io.Writer;
24: import java.io.IOException;
25: import java.util.MissingResourceException;
26:
27: /**
28: * The class converts VDLt syntax into VDLx syntax.
29: *
30: * @author Jens-S. Vöckler
31: * @author Yong Zhao
32: * @version $Revision: 50 $
33: *
34: * @see org.griphyn.vdl.parser.VDLtParser
35: */
36: public class VDLtConvert extends Directive {
37: /**
38: * Constructor
39: */
40: public VDLtConvert() throws IOException, MissingResourceException {
41: super ();
42: }
43:
44: /**
45: * Reads VDLt specification and outputs VDLx specification
46: *
47: * @param reader the vdlt source reader
48: * @param writer the vdlx taget writer
49: */
50: public void VDLt2VDLx(Reader reader, Writer writer)
51: throws VDLtParserException, VDLtScannerException,
52: IOException {
53: VDLt2VDLx(reader, writer, null, null);
54: }
55:
56: /**
57: * Reads VDLt specification and outputs VDLx specification
58: *
59: * @param reader the vdlt source reader
60: * @param writer the vdlx taget writer
61: * @param namespace the common vdl namespace for all the definitions included
62: * @param version the common version number for all the definitions included
63: */
64: public void VDLt2VDLx(Reader reader, Writer writer,
65: String namespace, String version)
66: throws VDLtParserException, VDLtScannerException,
67: IOException {
68: VDLtParser parser = new VDLtParser(reader);
69:
70: String newline = System.getProperty("line.separator", "\r\n");
71:
72: Definitions def = new Definitions();
73: def.setVdlns(namespace);
74: def.setVersion(version);
75: def.writeXMLHeader(writer, "", null);
76:
77: do {
78: Definition d = parser.parseDefinition();
79: d.toXML(writer, " ");
80: if (m_verbose)
81: m_logger.log("directive", 1, d.shortID());
82: } while (parser.hasMoreTokens());
83:
84: writer.write("</definitions>");
85: writer.write(newline);
86: writer.flush();
87: }
88: }
|