|
HTML Parser Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.htmlparser.nodes.AbstractNode org.htmlparser.nodes.TagNode
public class TagNode
TagNode represents a generic tag. If no scanner is registered for a given tag name, this is what you get. This is also the base class for all tags created by the parser.
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. |
Fields inherited from class org.htmlparser.nodes.AbstractNode |
---|
children, mPage, nodeBegin, nodeEnd, parent |
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(Attribute attribute)
Set an attribute. |
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 |
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. |
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 Detail |
---|
protected static final Scanner mDefaultScanner
protected Vector mAttributes
Attribute
.
The first element is the tag name, subsequent elements being either
whitespace or real attributes.
protected static Hashtable breakTags
Constructor Detail |
---|
public TagNode()
public TagNode(Page page, int start, int end, 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.Attribute
public TagNode(TagNode tag, TagScanner scanner)
tag
- The tag to emulate.scanner
- The scanner for this tag.Method Detail |
---|
public String getAttribute(String name)
getAttribute
in interface Tag
name
- Name of attribute, case insensitive.
Tag.setAttribute(java.lang.String, java.lang.String)
public void setAttribute(String key, String value)
setAttribute
in interface Tag
key
- The name of the attribute.value
- The value of the attribute.Tag.getAttribute(java.lang.String)
,
Tag.setAttribute(String,String,char)
public void removeAttribute(String key)
removeAttribute
in interface Tag
key
- The name of the attribute.public void setAttribute(String key, String value, char quote)
setAttribute
in interface Tag
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.Tag.getAttribute(java.lang.String)
public Attribute getAttributeEx(String name)
getAttributeEx
in interface Tag
name
- Name of attribute, case insensitive.
Tag.setAttributeEx(org.htmlparser.Attribute)
public void setAttributeEx(Attribute attribute)
setAttributeEx
in interface Tag
attribute
- The attribute to set.setAttribute(Attribute)
public void setAttribute(Attribute attribute)
attribute
- The attribute to set.public Vector getAttributesEx()
getAttributesEx
in interface Tag
Attributes
in the tag.
The first element is the tag name, subsequent elements being either
whitespace or real attributes.Tag.setAttributesEx(java.util.Vector)
public 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
in interface Tag
Tag.setTagName(java.lang.String)
public String getRawTagName()
getRawTagName
in interface Tag
public void setTagName(String name)
setTagName
in interface Tag
name
- The tag name.Tag.getTagName()
public String getText()
getText
in interface Node
getText
in class AbstractNode
Node.setText(java.lang.String)
public void setAttributesEx(Vector attribs)
setAttributesEx
in interface Tag
attribs
- 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(String text)
setText
in interface Node
setText
in class AbstractNode
text
- A string of the form <TAGNAME xx="yy">.Node.getText()
public String toPlainTextString()
toPlainTextString
in interface Node
toPlainTextString
in class AbstractNode
toHtml()
.public String toHtml(boolean verbatim)
toHtml()
method will render it in HTML.
toHtml
in interface Node
toHtml
in class AbstractNode
verbatim
- If true
return as close to the original
page text as possible.
Node.toHtml()
public String toString()
toString
in interface Node
toString
in class AbstractNode
public boolean breaksFlow()
breaksFlow
in interface Tag
true
if following text would start on a new line,
false
otherwise.public void accept(NodeVisitor visitor)
isEndTag()
, calls either visitTag()
or
visitEndTag()
.
accept
in interface Node
accept
in class AbstractNode
visitor
- The visitor that is visiting this node.public boolean isEmptyXmlTag()
isEmptyXmlTag
in interface Tag
public void setEmptyXmlTag(boolean emptyXmlTag)
setEmptyXmlTag
in interface Tag
emptyXmlTag
- If true, ensures there is an ending slash in the node,
i.e. <tag/>, otherwise removes it.public boolean isEndTag()
isEndTag
in interface Tag
true
if this tag is an end tag.public int getStartingLineNumber()
getStartingLineNumber
in interface Tag
public int getEndingLineNumber()
getEndingLineNumber
in interface Tag
public String[] getIds()
getIds
in interface Tag
public String[] getEnders()
getEnders
in interface Tag
public String[] getEndTagEnders()
getEndTagEnders
in interface Tag
public Scanner getThisScanner()
getThisScanner
in interface Tag
Tag.setThisScanner(org.htmlparser.scanners.Scanner)
public void setThisScanner(Scanner scanner)
setThisScanner
in interface Tag
scanner
- The scanner for this tag.Tag.getThisScanner()
public Tag getEndTag()
null
.
getEndTag
in interface Tag
Tag.setEndTag(org.htmlparser.Tag)
public void setEndTag(Tag end)
setEndTag
in interface Tag
end
- The tag that terminates this composite tag, i.e. </HTML>.Tag.getEndTag()
|
© 2006 Derrick Oswald Sep 17, 2006
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
HTML Parser is an open source library released under Common Public License. |