Package org.htmlparser.nodes
Class TextNode
java.lang.Object
org.htmlparser.nodes.AbstractNode
org.htmlparser.nodes.TextNode
- All Implemented Interfaces:
Serializable
,Cloneable
,Node
,Text
Normal text in the HTML document is represented by this class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The contents of the string node, or override text. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(NodeVisitor visitor) String visiting code.getText()
Returns the text of the node.boolean
Returns if the node consists of only white space.void
Sets the string contents of the node.toHtml
(boolean verbatim) Returns the text of the node.Returns the text of the node.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 Details
-
mText
The contents of the string node, or override text.
-
-
Constructor Details
-
TextNode
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
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 Details
-
getText
Returns the text of the node. This is the same astoHtml(boolean)
for this type of node. -
setText
Sets the string contents of the node. -
toPlainTextString
Returns the text of the node. This is the same astoHtml(boolean)
for this type of node.- Specified by:
toPlainTextString
in interfaceNode
- Specified by:
toPlainTextString
in classAbstractNode
- Returns:
- The contents of this text node.
-
toHtml
Returns the text of the node.- Specified by:
toHtml
in interfaceNode
- Specified by:
toHtml
in classAbstractNode
- Parameters:
verbatim
- Iftrue
return as close to the original page text as possible.- Returns:
- The contents of this text node.
-
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 interfaceNode
- Specified by:
toString
in classAbstractNode
- 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
String visiting code.- Specified by:
accept
in interfaceNode
- Specified by:
accept
in classAbstractNode
- Parameters:
visitor
- TheNodeVisitor
object to invokevisitStringNode()
on.
-