org.newsml.toolkit
Interface Text

All Superinterfaces:
BaseNode
All Known Subinterfaces:
AssignedOriginText, AssignedText, BasisForChoice, Comment, Description, FormalNameDecl, IdText, Origin, OriginNode, OriginText, RevisionId, TransmissionId

public interface Text
extends BaseNode

Basic interface for a node containing text.

Most of the leaf data in a NewsML document occurs in nodes that implement this interface, whether the nodes represent XML elements or XML attributes. The normal way to get text is to use the toString() method on a Text node, and the normal way to change text is to use the setString(java.lang.String) method. There are also convenience methods for working with boolean and integer values.

Version:
2.0
Author:
Reuters PLC

Method Summary
 void setBoolean(boolean value)
          Set a boolean value as text.
 void setInt(int value)
          Set an integer as text.
 void setString(String value)
          Set the text contents of the node.
 boolean toBoolean()
          Convert the text to a boolean.
 int toInt()
          Convert the text to an integer.
 String toString()
          Get the text contents of the node.
 
Methods inherited from interface org.newsml.toolkit.BaseNode
getAttr, getChild, getChild, getChild, getChild, getChildCount, getChildCount, getParent, getPath, getSession, getXMLName, getXPath, insertAfter, insertAfter, insertAfter, insertAfter, insertAfterDuid, insertAfterDuid, insertBefore, insertBefore, insertBefore, insertBefore, insertBeforeDuid, insertBeforeDuid, insertChild, insertChild, insertFirst, insertFirst, insertLast, insertLast, removeChild, removeChild, removeSelf, replaceChild, replaceChild, replaceChild, replaceChild, replaceChild, replaceChild, setAttr, setAttr, toXML, toXML, unsetAttr, unsetAttr, writeXML, writeXML
 

Method Detail

toBoolean

public boolean toBoolean()
Convert the text to a boolean.

This method returns true if the string value is "yes", and false otherwise. It is particularly useful for the Essential and EquivalentsList attributes.

Returns:
The text as a boolean.
See Also:
setInt(int), setString(java.lang.String)

setBoolean

public void setBoolean(boolean value)
Set a boolean value as text.

The resulting text will be "yes" for true or "no" for false.

Parameters:
value - The boolean value to set.
See Also:
setInt(int), setString(java.lang.String)

toInt

public int toInt()
Convert the text to an integer.
Returns:
The text as an integer, or -1 if the text could not be parsed as a number.
See Also:
toBoolean(), toString()

setInt

public void setInt(int value)
Set an integer as text.

The result will always be displayed as base 10.

Parameters:
value - The integer value to set.
See Also:
setBoolean(boolean), setString(java.lang.String)

toString

public String toString()
Get the text contents of the node.

This method is the normal way to get leaf data from a NewsML document; leaf nodes (elements or attributes) usually implement the Text interface, and their data is available through toString. toBoolean() and toInt() are also available as special convenience methods.

Overrides:
toString in class Object
Returns:
The text value (content) as a string.
See Also:
toBoolean(), toInt()

setString

public void setString(String value)
Set the text contents of the node.

This method is the normal way to add leaf data to a NewsML document; leaf nodes (elements or attributes) usually implement the Text interface, and their data can be set through setString. setBoolean(boolean) and setInt(int) are also available as special convenience methods.

Parameters:
value - The string value to set, replacing any current text in the node.
See Also:
setBoolean(boolean), setInt(int)