Package org.htmlparser.nodes
Class TextNode
- java.lang.Object
-
- org.htmlparser.nodes.AbstractNode
-
- org.htmlparser.nodes.TextNode
-
public class TextNode extends AbstractNode implements Text
Normal text in the HTML document is represented by this class.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(NodeVisitor visitor)String visiting code.java.lang.StringgetText()Returns the text of the node.booleanisWhiteSpace()Returns if the node consists of only white space.voidsetText(java.lang.String text)Sets the string contents of the node.java.lang.StringtoHtml(boolean verbatim)Returns the text of the node.java.lang.StringtoPlainTextString()Returns the text of the node.java.lang.StringtoString()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
-
-
-
-
Constructor Detail
-
TextNode
public TextNode(java.lang.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 java.lang.String getText()
Returns the text of the node. This is the same astoHtml(boolean)for this type of node.- Specified by:
getTextin interfaceNode- Specified by:
getTextin interfaceText- Overrides:
getTextin classAbstractNode- Returns:
- The contents of this text node.
- See Also:
Node.setText(java.lang.String)
-
setText
public void setText(java.lang.String text)
Sets the string contents of the node.- Specified by:
setTextin interfaceNode- Specified by:
setTextin interfaceText- Overrides:
setTextin classAbstractNode- Parameters:
text- The new text for the node.- See Also:
Node.getText()
-
toPlainTextString
public java.lang.String toPlainTextString()
Returns the text of the node. This is the same astoHtml(boolean)for this type of node.- Specified by:
toPlainTextStringin interfaceNode- Specified by:
toPlainTextStringin classAbstractNode- Returns:
- The contents of this text node.
-
toHtml
public java.lang.String toHtml(boolean verbatim)
Returns the text of the node.- Specified by:
toHtmlin interfaceNode- Specified by:
toHtmlin classAbstractNode- Parameters:
verbatim- Iftruereturn as close to the original page text as possible.- Returns:
- The contents of this text node.
-
toString
public java.lang.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:
toStringin interfaceNode- Specified by:
toStringin 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
public void accept(NodeVisitor visitor)
String visiting code.- Specified by:
acceptin interfaceNode- Specified by:
acceptin classAbstractNode- Parameters:
visitor- TheNodeVisitorobject to invokevisitStringNode()on.
-
-