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:
16: package org.griphyn.vdl.directive;
17:
18: import java.io.*;
19: import java.util.MissingResourceException;
20: import org.griphyn.common.util.Currently;
21: import org.griphyn.vdl.classes.*;
22: import org.griphyn.vdl.parser.*;
23: import org.griphyn.vdl.classes.Definitions;
24: import org.griphyn.vdl.util.Logging;
25: import org.xml.sax.InputSource;
26:
27: /**
28: * This class uses the <code>VDLxParser</code> to parse VDL XML
29: * specification and output VDL textual specification.
30: *
31: * @author Jens-S. Vöckler
32: * @author Yong Zhao
33: * @version $Revision: 50 $
34: *
35: * @see org.griphyn.vdl.parser.VDLxParser
36: * @see org.griphyn.vdl.parser.DefinitionHandler
37: */
38: public class VDLxConvert extends Directive implements DefinitionHandler {
39:
40: private Writer m_writer;
41:
42: /**
43: * Constructor
44: */
45: public VDLxConvert() throws IOException, MissingResourceException {
46: super ();
47: }
48:
49: /**
50: * Reads VDLx specification and outputs vdlt specification
51: * @param reader the source vdlx reader
52: * @param writer the target vdlt writer
53: */
54: public void VDLx2VDLt(Reader reader, Writer writer) {
55: m_writer = writer;
56:
57: org.griphyn.vdl.parser.VDLxParser parser = new org.griphyn.vdl.parser.VDLxParser(
58: m_props.getVDLSchemaLocation());
59:
60: parser.parse(new InputSource(reader), this );
61: }
62:
63: /**
64: * This method implements the interface defined in DefinitionHandler
65: * to output the vdlt specification.
66: *
67: * @param d is the Definition that is ready to be stored.
68: * @return always true, if the write was successful.
69: */
70: public boolean store(Definition d) {
71: boolean result = true;
72: try {
73: if (m_verbose)
74: m_logger.log("directive", 3, d.shortID());
75: d.toString(m_writer);
76: } catch (IOException ioe) {
77: m_logger.log("default", 0, "IO Error: " + ioe.getMessage());
78: result = false;
79: }
80: return result;
81: }
82: }
|