com.twicom.qdparser
Class Element

java.lang.Object
  extended by com.twicom.qdparser.Element
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TaggedElement, TextElement

public abstract class Element
extends java.lang.Object
implements java.io.Serializable

This is the base class for the XML Elements.

Version:
$Id$
Author:
Kevin Twidle
See Also:
Serialized Form

Constructor Summary
Element()
          Class constructor.
 
Method Summary
 java.lang.Object clone()
           
static Element newElement(java.lang.String value)
          Creates a new TaggedElement or TextElement depending on the argument
static java.lang.String quote(java.lang.String string)
          quotes a string according to XML rules.
 java.lang.String toString(boolean formatted)
          Returns formatted or unformatted XML source.
protected abstract  java.lang.StringBuffer toString(java.lang.StringBuffer sb, boolean formatted, int level)
          Internal method used recursively to format XML with appropriate indentation.
static java.lang.String unquote(java.lang.String string)
          quotes a string according to XML rules.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

public Element()
Class constructor.

Method Detail

newElement

public static Element newElement(java.lang.String value)
Creates a new TaggedElement or TextElement depending on the argument

Parameters:
value - the string to be turned into an element
Returns:
a new TaggedElement or TextElement

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

toString

public java.lang.String toString(boolean formatted)
Returns formatted or unformatted XML source.

Parameters:
formatted - whether to return formatted XML source. If true, the source is pretty-printed with new lines and indentation. If false, the XML string is returned as one lone, unformatted line.
Returns:
a String containing the XML source

toString

protected abstract java.lang.StringBuffer toString(java.lang.StringBuffer sb,
                                                   boolean formatted,
                                                   int level)
Internal method used recursively to format XML with appropriate indentation.

Parameters:
sb - TODO
formatted - whether to return formatted XML source. If true, the source is pretty-printed with new lines and indentation. If false, the XML string is returned as one long, unformatted line.
level - the indentation level used to write leading spaces
Returns:
a String containing th XML source

quote

public static java.lang.String quote(java.lang.String string)
quotes a string according to XML rules. When attributes and text elements are written out special characters have to be quoted.

Parameters:
string - the string to process
Returns:
the string with quoted special characters

unquote

public static java.lang.String unquote(java.lang.String string)
quotes a string according to XML rules. When attributes and text elements are written out special characters have to be quoted.

Parameters:
string - the string to process
Returns:
the string with quoted special characters