Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| HTML Parser Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.htmlparser.nodes
Class TextNode

    java.lang.Object
      org.htmlparser.nodes.AbstractNode
          org.htmlparser.nodes.TextNode

All Implemented Interfaces:
  Serializable, Cloneable, Node, Text

    public class TextNode

extends AbstractNode
implements Text

Normal text in the HTML document is represented by this class.

See Also:
  Serialized Form

Field Summary
`protected String` | `mText` The contents of the string node, or override text.

Fields inherited from class org.htmlparser.nodes.AbstractNode
`children, mPage, nodeBegin, nodeEnd, parent`

Constructor Summary
`TextNode(Page page, int start, int end)` Constructor takes in the page and beginning and ending posns.
`TextNode(String text)` Constructor takes in the text string.

Method Summary
`void` | `accept(NodeVisitor visitor)` String visiting code.
`String` | `getText()` Returns the text of the node.
`boolean` | `isWhiteSpace()` Returns if the node consists of only white space.
`void` | `setText(String text)` Sets the string contents of the node.
`String` | `toHtml(boolean verbatim)` Returns the text of the node.
`String` | `toPlainTextString()` Returns the text of the node.
`String` | `toString()` Express this string node as a printable string This is suitable for display in a debugger or output to a printout.

Methods inherited from class org.htmlparser.nodes.AbstractNode
`clone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtml`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.htmlparser.Node
`clone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtml`

Field Detail

### mText

    protected String mText

  The contents of the string node, or override text.

Constructor Detail

### TextNode

    public TextNode(String text)

  Constructor takes in the text string.

  Parameters:
    `text` - The string node text. For correct generation of HTML, this should not contain representations of tags (unless they are balanced).

### TextNode

    public TextNode(Page page,
                    int start,
                    int end)

  Constructor takes in the page and beginning and ending posns.

  Parameters:
    `page` - The page this string is on.
    `start` - The beginning position of the string.
    `end` - The ending positiong of the string.

Method Detail

### getText

    public String getText()

  Returns the text of the node. This is the same as `toHtml(boolean)` for this type of node.

  Specified by:
    `getText` in interface `Node`
  Specified by:
    `getText` in interface `Text`
  Overrides:
    `getText` in class `AbstractNode`
  Returns:
    The contents of this text node.
  See Also:
    `Node.setText(java.lang.String)`

### setText

    public void setText(String text)

  Sets the string contents of the node.

  Specified by:
    `setText` in interface `Node`
  Specified by:
    `setText` in interface `Text`
  Overrides:
    `setText` in class `AbstractNode`
  Parameters:
    `text` - The new text for the node.
  See Also:
    `Node.getText()`

### toPlainTextString

    public String toPlainTextString()

  Returns the text of the node. This is the same as `toHtml(boolean)` for this type of node.

  Specified by:
    `toPlainTextString` in interface `Node`
  Specified by:
    `toPlainTextString` in class `AbstractNode`
  Returns:
    The contents of this text node.

### toHtml

    public String toHtml(boolean verbatim)

  Returns the text of the node.

  Specified by:
    `toHtml` in interface `Node`
  Specified by:
    `toHtml` in class `AbstractNode`
  Parameters:
    `verbatim` - If `true` return as close to the original page text as possible.
  Returns:
    The contents of this text node.

### toString

    public String toString()

  Express this string node as a printable string This is suitable for display in a debugger or output to a printout. Control characters are replaced by their equivalent escape sequence and contents is truncated to 80 characters.

  Specified by:
    `toString` in interface `Node`
  Specified by:
    `toString` in class `AbstractNode`
  Returns:
    A string representation of the string node.

### isWhiteSpace

    public boolean isWhiteSpace()

  Returns if the node consists of only white space. White space can be spaces, new lines, etc.

### accept

    public void accept(NodeVisitor visitor)

  String visiting code.

  Specified by:
    `accept` in interface `Node`
  Specified by:
    `accept` in class `AbstractNode`
  Parameters:
    `visitor` - The `NodeVisitor` object to invoke `visitStringNode()` on.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| © 2005 Derrick Oswald Jun 10, 2006
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

HTML Parser is an open source library released under LGPL. |