com.topcoder.shared.problem
Class TextElement

java.lang.Object
  |
  +--com.topcoder.shared.problem.BaseElement
        |
        +--com.topcoder.shared.problem.TextElement
All Implemented Interfaces:
java.lang.Cloneable, com.topcoder.shared.netCommon.CustomSerializable, Element, java.io.Serializable

public class TextElement
extends com.topcoder.shared.problem.BaseElement
implements Element

The simplest element is a TextElement, which corresponds to CDATA (plain, unstructured text).

Author:
Logan Hanks
See Also:
Element, Serialized Form

Constructor Summary
TextElement()
          Empty constructor required by custom serialization.
TextElement(java.lang.String text)
          Constructs the text element with the given text.
 
Method Summary
 void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
          Custom serialization
 void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
          Custom serialization
static java.lang.String encodeHTML(java.lang.String text)
          Utility function for encoding HTML entities in text.
 java.lang.String getEditableText()
          Get's the text within the element.
 ElementRenderer getRenderer()
          Returns this elements renderer.
 void setEditableText(java.lang.String text)
          Set's the text within the element.
 void setRenderer(ElementRenderer renderer)
          Sets the renderer for this element.
 java.lang.String toString()
          Returns the string represenetation of this object.
 java.lang.String toXML()
          Returns the XML representation of this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.topcoder.shared.problem.Element
getRenderer, setRenderer
 

Constructor Detail

TextElement

public TextElement()
Empty constructor required by custom serialization.


TextElement

public TextElement(java.lang.String text)
Constructs the text element with the given text.

Parameters:
text - the text for the element.
Method Detail

customWriteObject

public void customWriteObject(com.topcoder.shared.netCommon.CSWriter writer)
                       throws java.io.IOException
Custom serialization

Specified by:
customWriteObject in interface Element
Parameters:
writer - the writer to write to.
Throws:
java.io.IOException - if an I/O error has occurred in the stream that backs the writer.

customReadObject

public void customReadObject(com.topcoder.shared.netCommon.CSReader reader)
                      throws java.io.IOException,
                             java.io.ObjectStreamException
Custom serialization

Specified by:
customReadObject in interface Element
Parameters:
reader - the reader to read from.
Throws:
java.io.ObjectStreamException - if the information that is read is inconsistent (stream corrupted or incompatibility between writers and readers)
java.io.IOException - if an I/O error has occurred in the stream that backs the reader.

getEditableText

public java.lang.String getEditableText()
Get's the text within the element.

Returns:
the text.

setEditableText

public void setEditableText(java.lang.String text)
Set's the text within the element.

Parameters:
text - the text.

toXML

public java.lang.String toXML()
Returns the XML representation of this element. Simply a wrapper call to BaseElement.encodeHTML(text).

Specified by:
toXML in interface Element
Returns:
the XML representation of this element.
See Also:
BaseElement#encodeHTML(string)

toString

public java.lang.String toString()
Returns the string represenetation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the string represenetation of this object.

setRenderer

public void setRenderer(ElementRenderer renderer)
Sets the renderer for this element.

Specified by:
setRenderer in interface Element
Parameters:
renderer - the element renderer.
See Also:
ElementRenderer

getRenderer

public ElementRenderer getRenderer()
Returns this elements renderer.

Specified by:
getRenderer in interface Element
Returns:
this elements renderer.
See Also:
ElementRenderer

encodeHTML

public static java.lang.String encodeHTML(java.lang.String text)
Utility function for encoding HTML entities in text. All occurrences of the <, >, and & characters are converted to &lt;, &gt;, and &amp;, respectively.

Parameters:
text - the text to encode.
Returns:
the encoded text.