org.griphyn.vdl
Class Chimera

java.lang.Object
  extended by org.griphyn.vdl.Chimera
Direct Known Subclasses:
DAX, Invocation, VDL

public abstract class Chimera
extends Object

This abstract class defines a common base for all JAPI Chimera objects. All VDL-related classes must conform to this interface, in order to make various instances available as a reference to this class.

Version:
$Revision: 50 $
Author:
Jens-S. V??ckler, Yong Zhao

Constructor Summary
Chimera()
           
 
Method Summary
static String escape(String original)
          Escapes certain characters inappropriate for textual output.
static String quote(String original, boolean isAttribute)
          Escapes certain characters inappropriate for XML content output.
 String toString()
          Dumps content of the given element into a string.
abstract  void toString(Writer s)
          Dumps the content of the given element into a stream.
 String toXML(String indent, String namespace)
          Dumps the state of the current element as XML output.
 void toXML(Writer stream, String indent)
          Provides backward compatibility.
abstract  void toXML(Writer stream, String indent, String namespace)
          Dump the state of the current element as XML output.
 void writeAttribute(Writer stream, String key, String value)
          XML write helper method writes a quoted attribute onto a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Chimera

public Chimera()
Method Detail

escape

public static String escape(String original)
Escapes certain characters inappropriate for textual output.

Parameters:
original - is a string that needs to be quoted
Returns:
a string that is "safe" to print.

quote

public static String quote(String original,
                           boolean isAttribute)
Escapes certain characters inappropriate for XML content output. FIXME: Quotes within attribute values are still not handled correctly.

Parameters:
original - is a string that needs to be quoted
isAttribute - denotes an attributes value, if set to true. If false, it denotes regular XML content outside of attributes.
Returns:
a string that is "safe" to print as XML.

toString

public String toString()
Dumps content of the given element into a string. This function traverses all sibling classes as necessary and converts the data into textual output.

Sibling classes which represent small leaf objects, and can return the necessary data more efficiently, are encouraged to overwrite this method.

Overrides:
toString in class Object
Returns:
a textual description of the element and its sub-classes. Be advised that these strings might become large.

toString

public abstract void toString(Writer s)
                       throws IOException
Dumps the content of the given element into a stream. This function traverses all sibling classes as necessary and converts the data into textual output.

Parameters:
s - is a stream opened and ready for writing. This can also be a string stream for efficient output. The stream interface should be able to handle large elements efficiently.
Throws:
IOException - if something fishy happens to the stream.

writeAttribute

public void writeAttribute(Writer stream,
                           String key,
                           String value)
                    throws IOException
XML write helper method writes a quoted attribute onto a stream. The terminating quote will be appended automatically. Values will be XML-escaped. No action will be taken, if the value is null.

Parameters:
stream - is the stream to append to
key - is the attribute including initial space, attribute name, equals sign, and opening quote.
value - is a string value, which will be put within the quotes and which will be escaped. If the value is null, no action will be taken
Throws:
IOException - for stream errors.

toXML

public String toXML(String indent,
                    String namespace)
Dumps the state of the current element as XML output. This function traverses all sibling classes as necessary, and converts the data into pretty-printed XML output.

Sibling classes which represent small leaf objects, and can return the necessary data more efficiently, are encouraged to overwrite this method.

Parameters:
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal. If null, avoidable whitespaces in the output will be avoided.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Returns:
a String which contains the state of the current class and its siblings using XML. Note that these strings might become large.

toXML

public void toXML(Writer stream,
                  String indent)
           throws IOException
Provides backward compatibility.
 toXML( stream, indent, (String) null );
 

Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal. If a null value is specified, no indentation nor linefeeds will be generated.
Throws:
IOException - if something fishy happens to the stream.
See Also:
toXML( Writer, String, String )

toXML

public abstract void toXML(Writer stream,
                           String indent,
                           String namespace)
                    throws IOException
Dump the state of the current element as XML output. This function traverses all sibling classes as necessary, and converts the data into pretty-printed XML output. The stream interface should be able to handle large output efficiently, if you used a buffered writer.

Parameters:
stream - is a stream opened and ready for writing. This can also be a string stream for efficient output.
indent - is a String of spaces used for pretty printing. The initial amount of spaces should be an empty string. The parameter is used internally for the recursive traversal. If a null value is specified, no indentation nor linefeeds will be generated.
namespace - is the XML schema namespace prefix. If neither empty nor null, each element will be prefixed with this prefix, and the root element will map the XML namespace.
Throws:
IOException - if something fishy happens to the stream.
See Also:
BufferedWriter


Copyright © 2007 The University of Southern California. All Rights Reserved.