|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.htmlcleaner.BaseTokenImpl
org.htmlcleaner.TagToken
org.htmlcleaner.TagNode
public class TagNode
XML node tag - basic node of the cleaned HTML tree. At the same time, it represents start tag token after HTML parsing phase and before cleaning phase. After cleaning process, tree structure remains containing tag nodes (TagNode class), content (text nodes - ContentNode), comments (CommentNode) and optionally doctype node (DoctypeToken).
| Field Summary |
|---|
| Fields inherited from class org.htmlcleaner.TagToken |
|---|
name |
| Constructor Summary | |
|---|---|
TagNode(String name)
|
|
| Method Summary | |
|---|---|
void |
addAttribute(String attName,
String attValue)
Adds specified attribute to this tag or overrides existing one. |
void |
addChild(Object child)
|
void |
addChildren(List newChildren)
Add all elements from specified list to this node. |
void |
addNamespaceDeclaration(String nsPrefix,
String nsURI)
Adds namespace declaration to the node |
Object[] |
evaluateXPath(String xPathExpression)
Evaluates XPath expression on give node. |
TagNode |
findElementByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
|
TagNode |
findElementByName(String findName,
boolean isRecursive)
|
TagNode |
findElementHavingAttribute(String attName,
boolean isRecursive)
|
List |
getAllChildren()
|
TagNode[] |
getAllElements(boolean isRecursive)
|
List |
getAllElementsList(boolean isRecursive)
|
String |
getAttributeByName(String attName)
|
Map<String,String> |
getAttributes()
|
int |
getChildIndex(HtmlNode child)
|
List<TagNode> |
getChildren()
Deprecated. use getChildTagList(), will be refactored and possibly removed in
future versions. TODO This method should be refactored because is does not
properly match the commonly used Java's getter/setter strategy. |
List<TagNode> |
getChildTagList()
|
TagNode[] |
getChildTags()
|
DoctypeToken |
getDocType()
|
List |
getElementList(ITagNodeCondition condition,
boolean isRecursive)
Get all elements in the tree that satisfy specified condition. |
List |
getElementListByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
|
List |
getElementListByName(String findName,
boolean isRecursive)
|
List |
getElementListHavingAttribute(String attName,
boolean isRecursive)
|
TagNode[] |
getElementsByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
|
TagNode[] |
getElementsByName(String findName,
boolean isRecursive)
|
TagNode[] |
getElementsHavingAttribute(String attName,
boolean isRecursive)
|
Map<String,String> |
getNamespaceDeclarations()
|
TagNode |
getParent()
|
CharSequence |
getText()
|
boolean |
hasAttribute(String attName)
Checks existence of specified attribute. |
boolean |
hasChildren()
|
void |
insertChild(int index,
HtmlNode childToAdd)
Inserts specified node at specified position in array of children |
void |
insertChildAfter(HtmlNode node,
HtmlNode nodeToInsert)
Inserts specified node in the list of children after specified child |
void |
insertChildBefore(HtmlNode node,
HtmlNode nodeToInsert)
Inserts specified node in the list of children before specified child |
boolean |
isAutoGenerated()
|
boolean |
isEmpty()
|
boolean |
isPruned()
|
TagNode |
makeCopy()
|
void |
removeAllChildren()
Removes all children (subelements and text content). |
void |
removeAttribute(String attName)
Removes specified attribute from this tag. |
boolean |
removeChild(Object child)
Remove specified child element from this node. |
boolean |
removeFromTree()
Remove this node from the tree. |
void |
serialize(Serializer serializer,
Writer writer)
|
void |
setAttributes(Map<String,String> attributes)
|
void |
setAutoGenerated(boolean autoGenerated)
|
void |
setDocType(DoctypeToken docType)
|
void |
setPruned(boolean pruned)
|
void |
traverse(TagNodeVisitor visitor)
Traverses the tree and performs visitor's action on each node. |
| Methods inherited from class org.htmlcleaner.TagToken |
|---|
getName, toString |
| Methods inherited from class org.htmlcleaner.BaseTokenImpl |
|---|
getCol, getRow, setCol, setRow |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TagNode(String name)
| Method Detail |
|---|
public String getAttributeByName(String attName)
attName -
public Map<String,String> getAttributes()
public void setAttributes(Map<String,String> attributes)
public boolean hasAttribute(String attName)
attName -
public void addAttribute(String attName,
String attValue)
attName - attValue - public void removeAttribute(String attName)
attName - @Deprecated public List<TagNode> getChildren()
getChildTagList(), will be refactored and possibly removed in
future versions. TODO This method should be refactored because is does not
properly match the commonly used Java's getter/setter strategy.
public List getAllChildren()
public List<TagNode> getChildTagList()
public boolean hasChildren()
public TagNode[] getChildTags()
public CharSequence getText()
public int getChildIndex(HtmlNode child)
child - Child to find index of
public void insertChild(int index,
HtmlNode childToAdd)
index - childToAdd -
public void insertChildBefore(HtmlNode node,
HtmlNode nodeToInsert)
node - Child before which to insert new nodenodeToInsert - Node to be inserted at specified position
public void insertChildAfter(HtmlNode node,
HtmlNode nodeToInsert)
node - Child after which to insert new nodenodeToInsert - Node to be inserted at specified positionpublic TagNode getParent()
public DoctypeToken getDocType()
public void setDocType(DoctypeToken docType)
public void addChild(Object child)
public void addChildren(List newChildren)
newChildren -
public List getElementList(ITagNodeCondition condition,
boolean isRecursive)
condition - isRecursive -
public List getAllElementsList(boolean isRecursive)
public TagNode[] getAllElements(boolean isRecursive)
public TagNode findElementByName(String findName,
boolean isRecursive)
public List getElementListByName(String findName,
boolean isRecursive)
public TagNode[] getElementsByName(String findName,
boolean isRecursive)
public TagNode findElementHavingAttribute(String attName,
boolean isRecursive)
public List getElementListHavingAttribute(String attName,
boolean isRecursive)
public TagNode[] getElementsHavingAttribute(String attName,
boolean isRecursive)
public TagNode findElementByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
public List getElementListByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
public TagNode[] getElementsByAttValue(String attName,
String attValue,
boolean isRecursive,
boolean isCaseSensitive)
public Object[] evaluateXPath(String xPathExpression)
throws XPatherException
- //div//a
- //div//a[@id][@class]
- /body/*[1]/@type
- //div[3]//a[@id][@href='r/n4']
- //div[last() >= 4]//./div[position() = last()])[position() > 22]//li[2]//a
- //div[2]/@*[2]
- data(//div//a[@id][@class])
- //p/last()
- //body//div[3][@class]//span[12.2
- data(//a['v' < @id])
xPathExpression -
XPatherExceptionpublic boolean removeFromTree()
public boolean removeChild(Object child)
child -
public void removeAllChildren()
public void setAutoGenerated(boolean autoGenerated)
autoGenerated - the autoGenerated to setpublic boolean isAutoGenerated()
public boolean isPruned()
public void setPruned(boolean pruned)
public boolean isEmpty()
public void addNamespaceDeclaration(String nsPrefix,
String nsURI)
nsPrefix - Namespace prefixnsURI - Namespace URIpublic Map<String,String> getNamespaceDeclarations()
public void serialize(Serializer serializer,
Writer writer)
throws IOException
serialize in interface BaseTokenIOExceptionpublic TagNode makeCopy()
public void traverse(TagNodeVisitor visitor)
visitor - TagNodeVisitor implementation
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||