com.twicom.qdparser
Class TextElement

java.lang.Object
  extended by com.twicom.qdparser.Element
      extended by com.twicom.qdparser.TextElement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class TextElement
extends Element
implements java.lang.Cloneable

An XML element that simply contains text. This is normally a child element of TaggedElement.

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

Field Summary
(package private)  java.lang.Integer integer
           
(package private)  java.lang.String string
          The value of the TextElement.
 
Constructor Summary
TextElement(int value)
          Constructs a TextElement using an integer.
TextElement(java.lang.String string)
          Constructs a TextElement using a string
 
Method Summary
 java.lang.Object clone()
           
 boolean getCData()
          Gets the value of the CDATA boolean
 int getInteger()
          Gets the value of this TextElement as an integer.
 boolean isNumber()
          checks to see if this TextElement contains a numeric value
 void setCData(boolean cdata)
          Sets this element to print as a CDATA element
 void setValue(int value)
          Sets the value of this TextElement using an integer
 void setValue(java.lang.String value)
          Sets the value of this TextElement using a String
 java.lang.String toString()
           
protected  java.lang.StringBuffer toString(java.lang.StringBuffer sb, boolean formatted, int level)
          Internal method used recursively to format XML with appropriate indentation.
 
Methods inherited from class com.twicom.qdparser.Element
newElement, quote, toString, unquote
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

string

java.lang.String string
The value of the TextElement.


integer

java.lang.Integer integer
Constructor Detail

TextElement

public TextElement(java.lang.String string)
Constructs a TextElement using a string

Parameters:
string -

TextElement

public TextElement(int value)
Constructs a TextElement using an integer.

Parameters:
value -
Method Detail

clone

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

setValue

public void setValue(java.lang.String value)
Sets the value of this TextElement using a String

Parameters:
value - the value to store in this TextElement

setValue

public void setValue(int value)
Sets the value of this TextElement using an integer

Parameters:
value - the value to store in this TextElement

setCData

public void setCData(boolean cdata)
Sets this element to print as a CDATA element

Parameters:
cdata - true if it should be printed as a CDATA element

getCData

public boolean getCData()
Gets the value of the CDATA boolean

Returns:
the CDATA value

isNumber

public boolean isNumber()
checks to see if this TextElement contains a numeric value

Returns:
true if this TextElement contains a numeric value

getInteger

public int getInteger()
Gets the value of this TextElement as an integer.

Returns:
the value of this TextElement as an integer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

protected java.lang.StringBuffer toString(java.lang.StringBuffer sb,
                                          boolean formatted,
                                          int level)
Description copied from class: Element
Internal method used recursively to format XML with appropriate indentation.

Specified by:
toString in class Element
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