org.htmlparser.nodes
public class TagNode extends AbstractNode implements Tag
Field Summary | |
---|---|
protected static Hashtable | breakTags
Set of tags that breaks the flow. |
protected Vector | mAttributes
The tag attributes.
|
protected static Scanner | mDefaultScanner
The default scanner for non-composite tags. |
Constructor Summary | |
---|---|
TagNode()
Create an empty tag. | |
TagNode(Page page, int start, int end, Vector attributes)
Create a tag with the location and attributes provided | |
TagNode(TagNode tag, TagScanner scanner)
Create a tag like the one provided. |
Method Summary | |
---|---|
void | accept(NodeVisitor visitor)
Default tag visiting code.
|
boolean | breaksFlow()
Determines if the given tag breaks the flow of text. |
String | getAttribute(String name)
Returns the value of an attribute. |
Attribute | getAttributeEx(String name)
Returns the attribute with the given name. |
Vector | getAttributesEx()
Gets the attributes in the tag. |
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.
|
String[] | getEndTagEnders()
Return the set of end tag names that cause this tag to finish.
|
String[] | getIds()
Return the set of names handled by this tag.
|
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. |
String | getTagName()
Return the name of this tag.
|
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(String key)
Remove the attribute with the given key, if it exists. |
void | setAttribute(String key, String value)
Set attribute with given key, value pair.
|
void | setAttribute(String key, String value, char quote)
Set attribute with given key, value pair where the value is quoted by quote. |
void | setAttribute(Attribute attribute)
Set an attribute.
|
void | setAttributeEx(Attribute attribute)
Set an attribute. |
void | setAttributesEx(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(String name)
Set the name of this tag.
|
void | setText(String text)
Parses the given text to create the tag contents. |
void | setThisScanner(Scanner scanner)
Set the scanner associated with this tag. |
String | toHtml(boolean verbatim)
Render the tag as HTML.
|
String | toPlainTextString()
Get the plain text from this node. |
String | toString()
Print the contents of the tag. |
Parameters: 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.
See Also: Attribute
Parameters: tag The tag to emulate. scanner The scanner for this tag.
isEndTag()
, calls either visitTag()
or
visitEndTag()
.Parameters: visitor The visitor that is visiting this node.
Returns: true
if following text would start on a new line,
false
otherwise.
Parameters: name Name of attribute, case insensitive.
Returns: The value associated with the attribute or null if it does not exist, or is a stand-alone or
Parameters: name Name of attribute, case insensitive.
Returns: The attribute or null if it does not exist.
Returns: Returns the list of Attributes
in the tag.
The first element is the tag name, subsequent elements being either
whitespace or real attributes.
Returns: The names of following tags that stop further scanning.
Returns: The (zero based) line number in the page where this tag ends.
null
.Returns: The tag that terminates this composite tag, i.e. </HTML>.
Returns: The names of following end tags that stop further scanning.
Returns: The names to be matched that create tags of this type.
Returns: The tag name or null if this tag contains nothing or only whitespace.
Returns: The (zero based) line number in the page where this tag starts.
Returns: The nodeBegin value.
Returns: The nodeEnd value.
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.
Returns: The tag name.
Returns: The complete contents of the tag (within the angle brackets).
Returns: The scanner associated with this tag.
Returns: true if the last character of the last attribute is a '/'.
Returns: true
if this tag is an end tag.
Parameters: key The name of the attribute.
Parameters: key The name of the attribute. value The value of the attribute.
Parameters: key 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.
Parameters: attribute The attribute to set.
Parameters: attribute The attribute to set.
See Also: setAttribute
Parameters: attribs The attribute collection to set.
Parameters: emptyXmlTag If true, ensures there is an ending slash in the node, i.e. <tag/>, otherwise removes it.
Parameters: end The tag that terminates this composite tag, i.e. </HTML>.
Parameters: tagBegin The nodeBegin to set
Parameters: tagEnd The nodeEnd to set
Parameters: name The tag name.
Parameters: text A string of the form <TAGNAME xx="yy">.
Parameters: scanner The scanner for this tag.
toHtml()
method will render it in HTML.Parameters: verbatim If true
return as close to the original
page text as possible.
Returns: The tag as an HTML fragment.
See Also: toHtml
Returns: An empty string (tag contents do not display in a browser).
If you want this tags HTML equivalent, use toHtml()
.
Returns: An string describing the tag. For text that looks like HTML use #toHtml().
HTML Parser is an open source library released under LGPL. | |