org.jsoup.nodes
Class TextNode

java.lang.Object
  extended by org.jsoup.nodes.Node
      extended by org.jsoup.nodes.TextNode

public class TextNode
extends Node

A text node.

Author:
Jonathan Hedley, [email protected]

Constructor Summary
TextNode(String text, String baseUri)
          Create a new TextNode representing the supplied (unencoded) text).
 
Method Summary
static TextNode createFromEncoded(String encodedText, String baseUri)
          Create a new TextNode from HTML encoded (aka escaped) data.
 String getWholeText()
          Get the (unencoded) text of this text node, including any newlines and spaces present in the original.
 boolean isBlank()
          Test if this text node is blank -- that is, empty or only whitespace (including newlines).
 String nodeName()
          Get the node name of this node.
 String text()
          Get the text content of this text node.
 TextNode text(String text)
          Set the text content of this text node.
 String toString()
           
 
Methods inherited from class org.jsoup.nodes.Node
absUrl, addChildren, addChildren, attr, attr, attributes, baseUri, childNode, childNodes, childNodesAsArray, equals, hasAttr, hashCode, indent, nextSibling, nodeDepth, outerHtml, outerHtml, parent, previousSibling, remove, removeAttr, removeChild, replaceChild, replaceWith, setBaseUri, setParentNode, setSiblingIndex, siblingIndex, siblingNodes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextNode

public TextNode(String text,
                String baseUri)
Create a new TextNode representing the supplied (unencoded) text).

Parameters:
text - raw text
baseUri - base uri
See Also:
createFromEncoded(String, String)
Method Detail

nodeName

public String nodeName()
Description copied from class: Node
Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof).

Specified by:
nodeName in class Node
Returns:
node name

text

public String text()
Get the text content of this text node.

Returns:
Unencoded, normalised text.
See Also:
getWholeText()

text

public TextNode text(String text)
Set the text content of this text node.

Parameters:
text - unencoded text
Returns:
this, for chaining

getWholeText

public String getWholeText()
Get the (unencoded) text of this text node, including any newlines and spaces present in the original.

Returns:
text

isBlank

public boolean isBlank()
Test if this text node is blank -- that is, empty or only whitespace (including newlines).

Returns:
true if this document is empty or only whitespace, false if it contains any text content.

toString

public String toString()
Overrides:
toString in class Node

createFromEncoded

public static TextNode createFromEncoded(String encodedText,
                                         String baseUri)
Create a new TextNode from HTML encoded (aka escaped) data.

Parameters:
encodedText - Text containing encoded HTML (e.g. <)
Returns:
TextNode containing unencoded data (e.g. <)


Copyright © 2009-2010 Jonathan Hedley. All Rights Reserved.