public class TagNode extends AbstractNode implements Tag
| 构造器和说明 |
|---|
TagNode()
Create an empty tag.
|
TagNode(Page page,
int start,
int end,
java.util.Vector attributes)
Create a tag with the location and attributes provided
|
TagNode(TagNode tag,
TagScanner scanner)
Create a tag like the one provided.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
accept(NodeVisitor visitor)
Default tag visiting code.
|
boolean |
breaksFlow()
Determines if the given tag breaks the flow of text.
|
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of an attribute.
|
Attribute |
getAttributeEx(java.lang.String name)
Returns the attribute with the given name.
|
java.util.Vector |
getAttributesEx()
Gets the attributes in the tag.
|
java.lang.String[] |
getEnders()
Return the set of tag names that cause this tag to finish.
|
int |
getEndingLineNumber()
Get the line number where this tag ends.
|
Tag |
getEndTag()
Get the end tag for this (composite) tag.
|
java.lang.String[] |
getEndTagEnders()
Return the set of end tag names that cause this tag to finish.
|
java.lang.String[] |
getIds()
Return the set of names handled by this tag.
|
java.lang.String |
getRawTagName()
Return the name of this tag.
|
int |
getStartingLineNumber()
Get the line number where this tag starts.
|
int |
getTagBegin()
Gets the nodeBegin.
|
int |
getTagEnd()
Gets the nodeEnd.
|
java.lang.String |
getTagName()
Return the name of this tag.
|
java.lang.String |
getText()
Return the text contained in this tag.
|
Scanner |
getThisScanner()
Return the scanner associated with this tag.
|
boolean |
isEmptyXmlTag()
Is this an empty xml tag of the form <tag/>.
|
boolean |
isEndTag()
Predicate to determine if this tag is an end tag (i.e.
|
void |
removeAttribute(java.lang.String key)
Remove the attribute with the given key, if it exists.
|
void |
setAttribute(Attribute attribute)
Set an attribute.
|
void |
setAttribute(java.lang.String key,
java.lang.String value)
Set attribute with given key, value pair.
|
void |
setAttribute(java.lang.String key,
java.lang.String value,
char quote)
Set attribute with given key, value pair where the value is quoted by quote.
|
void |
setAttributeEx(Attribute attribute)
Set an attribute.
|
void |
setAttributesEx(java.util.Vector attribs)
Sets the attributes.
|
void |
setEmptyXmlTag(boolean emptyXmlTag)
Set this tag to be an empty xml node, or not.
|
void |
setEndTag(Tag end)
Set the end tag for this (composite) tag.
|
void |
setTagBegin(int tagBegin)
Sets the nodeBegin.
|
void |
setTagEnd(int tagEnd)
Sets the nodeEnd.
|
void |
setTagName(java.lang.String name)
Set the name of this tag.
|
void |
setText(java.lang.String text)
Parses the given text to create the tag contents.
|
void |
setThisScanner(Scanner scanner)
Set the scanner associated with this tag.
|
java.lang.String |
toHtml(boolean verbatim)
Render the tag as HTML.
|
java.lang.String |
toPlainTextString()
Get the plain text from this node.
|
java.lang.String |
toString()
Print the contents of the tag.
|
clone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtmlclone, collectInto, doSemanticAction, getChildren, getEndPosition, getFirstChild, getLastChild, getNextSibling, getPage, getParent, getPreviousSibling, getStartPosition, setChildren, setEndPosition, setPage, setParent, setStartPosition, toHtmlpublic TagNode()
public TagNode(Page page, int start, int end, java.util.Vector attributes)
page - The page this tag was read from.start - The starting offset of this node within the page.end - The ending offset of this node within the page.attributes - The list of attributes that were parsed in this tag.Attributepublic TagNode(TagNode tag, TagScanner scanner)
tag - The tag to emulate.scanner - The scanner for this tag.public java.lang.String getAttribute(java.lang.String name)
getAttribute 在接口中 Tagname - Name of attribute, case insensitive.Tag.setAttribute(java.lang.String, java.lang.String)public void setAttribute(java.lang.String key,
java.lang.String value)
setAttribute 在接口中 Tagkey - The name of the attribute.value - The value of the attribute.Tag.getAttribute(java.lang.String),
Tag.setAttribute(String,String,char)public void removeAttribute(java.lang.String key)
removeAttribute 在接口中 Tagkey - The name of the attribute.public void setAttribute(java.lang.String key,
java.lang.String value,
char quote)
setAttribute 在接口中 Tagkey - The name of the attribute.value - The value of the attribute.quote - The quote character to be used around value.
If zero, it is an unquoted value.Tag.getAttribute(java.lang.String)public Attribute getAttributeEx(java.lang.String name)
getAttributeEx 在接口中 Tagname - Name of attribute, case insensitive.Tag.setAttributeEx(org.htmlparser.Attribute)public void setAttributeEx(Attribute attribute)
setAttributeEx 在接口中 Tagattribute - The attribute to set.setAttribute(Attribute)public void setAttribute(Attribute attribute)
attribute - The attribute to set.public java.util.Vector getAttributesEx()
getAttributesEx 在接口中 TagAttributes in the tag.
The first element is the tag name, subsequent elements being either
whitespace or real attributes.Tag.setAttributesEx(java.util.Vector)public java.lang.String getTagName()
Note: This value is converted to uppercase and does not
begin with "/" if it is an end tag. Nor does it end with
a slash in the case of an XML type tag.
To get at the original text of the tag name use
getRawTagName().
The conversion to uppercase is performed with an ENGLISH locale.
getTagName 在接口中 TagTag.setTagName(java.lang.String)public java.lang.String getRawTagName()
getRawTagName 在接口中 Tagpublic void setTagName(java.lang.String name)
setTagName 在接口中 Tagname - The tag name.Tag.getTagName()public java.lang.String getText()
getText 在接口中 NodegetText 在类中 AbstractNodeNode.setText(java.lang.String)public void setAttributesEx(java.util.Vector attribs)
setAttributesEx 在接口中 Tagattribs - The attribute collection to set.Tag.getAttributesEx()public void setTagBegin(int tagBegin)
tagBegin - The nodeBegin to setpublic int getTagBegin()
public void setTagEnd(int tagEnd)
tagEnd - The nodeEnd to setpublic int getTagEnd()
public void setText(java.lang.String text)
setText 在接口中 NodesetText 在类中 AbstractNodetext - A string of the form <TAGNAME xx="yy">.Node.getText()public java.lang.String toPlainTextString()
toPlainTextString 在接口中 NodetoPlainTextString 在类中 AbstractNodetoHtml().public java.lang.String toHtml(boolean verbatim)
toHtml() method will render it in HTML.toHtml 在接口中 NodetoHtml 在类中 AbstractNodeverbatim - If true return as close to the original
page text as possible.Node.toHtml()public java.lang.String toString()
toString 在接口中 NodetoString 在类中 AbstractNodepublic boolean breaksFlow()
breaksFlow 在接口中 Tagtrue if following text would start on a new line,
false otherwise.public void accept(NodeVisitor visitor)
isEndTag(), calls either visitTag() or
visitEndTag().accept 在接口中 Nodeaccept 在类中 AbstractNodevisitor - The visitor that is visiting this node.public boolean isEmptyXmlTag()
isEmptyXmlTag 在接口中 Tagpublic void setEmptyXmlTag(boolean emptyXmlTag)
setEmptyXmlTag 在接口中 TagemptyXmlTag - If true, ensures there is an ending slash in the node,
i.e. <tag/>, otherwise removes it.public boolean isEndTag()
public int getStartingLineNumber()
getStartingLineNumber 在接口中 Tagpublic int getEndingLineNumber()
getEndingLineNumber 在接口中 Tagpublic java.lang.String[] getIds()
public java.lang.String[] getEnders()
public java.lang.String[] getEndTagEnders()
getEndTagEnders 在接口中 Tagpublic Scanner getThisScanner()
getThisScanner 在接口中 TagTag.setThisScanner(org.htmlparser.scanners.Scanner)public void setThisScanner(Scanner scanner)
setThisScanner 在接口中 Tagscanner - The scanner for this tag.Tag.getThisScanner()public Tag getEndTag()
null.getEndTag 在接口中 TagTag.setEndTag(org.htmlparser.Tag)public void setEndTag(Tag end)
setEndTag 在接口中 Tagend - The tag that terminates this composite tag, i.e. </HTML>.Tag.getEndTag()