Package org.javlo.xml
Class NodeXML
- java.lang.Object
-
- org.javlo.xml.NodeXML
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String name)Method addAttribute adds an attribute to a node with all attributes value to null, so you still have to do a setAttribute to add value.NodeXMLaddChild(String name)booleanattributeExist(String attribute)get a attribute value (pvdm)Objectclone()protected voiderror(String message)print error message on the screen (pvdm)Collection<NodeXML>getAllChildren()StringgetAttributeValue(String attribute)get a attribute value (pvdm)StringgetAttributeValue(String attribute, String standardValue)get a attribute value, with a standard value if the attribute is not found.NodeXMLgetChild()get the first child node (pvdm)NodeXMLgetChild(String name)get the first child node with a specific name (gh)Collection<NodeXML>getChildren()StringgetContent()get the first text content of the node, if any (grh)StringgetContentPrefix()StringgetContentSuffix()StringgetName()NodeXMLgetNext()get the next node (pvdm)NodeXMLgetNext(String name)get the next node (pvdm)NodegetNode()DocumentgetOwnerDocument()NodeXMLgetParent()get the first child node (pvdm)intgetParentDistance(NodeXML inParent)return the distance in node count form a prentstatic voidmain(String[] args)StringnodeToString()voidremoveChild(NodeXML n)NodeXMLsearchChild(String inXpath)NodeXMLsearchChild(String name, String paramName, String paramValue)search a node with a specific value for a parameter (pvdm)Collection<NodeXML>searchChildren(String inXpath)StringsearchValue(String inXpath)voidsetAttribute(String name, String value)Method setAttribute sets an attrinute to its value, if the attribute does not exist it will be added.voidsetCDATAContent(String content)setCDATAContent: Set a CDATA content in a DOM, Will add a new CDATA node if there is none.voidsetContent(String content)
-
-
-
Method Detail
-
getChild
public NodeXML getChild()
get the first child node (pvdm)
-
getChild
public NodeXML getChild(String name)
get the first child node with a specific name (gh)- Parameters:
name- name of the node needed (gh)- Returns:
- the node as a NodeXML if matching name, null otherwise (gh)
-
getParent
public NodeXML getParent()
get the first child node (pvdm)
-
getNext
public NodeXML getNext()
get the next node (pvdm)
-
getNext
public NodeXML getNext(String name)
get the next node (pvdm)- Parameters:
name- return the next node with this name (pvdm)
-
getName
public String getName()
- Returns:
- the name of the node (pvdm)
-
getAttributeValue
public String getAttributeValue(String attribute, String standardValue)
get a attribute value, with a standard value if the attribute is not found.- Parameters:
attribute- the name of the attributestandardValue- the standard value if attribute not found.- Returns:
- the attribute value if exist else the standard value.
-
attributeExist
public boolean attributeExist(String attribute)
get a attribute value (pvdm)
-
error
protected void error(String message)
print error message on the screen (pvdm)
-
searchChild
public NodeXML searchChild(String name, String paramName, String paramValue)
search a node with a specific value for a parameter (pvdm)- Parameters:
name- the name of the node (pvdm)paramName- the name of the attribute of the node (pvdm)paramValue- the value of the attribute (pvdm)- Returns:
- renturn the node fund with this specification (pvdm)
-
searchChild
public NodeXML searchChild(String inXpath) throws XPathExpressionException
- Throws:
XPathExpressionException
-
searchChildren
public Collection<NodeXML> searchChildren(String inXpath) throws XPathExpressionException
- Throws:
XPathExpressionException
-
getChildren
public Collection<NodeXML> getChildren()
-
getAllChildren
public Collection<NodeXML> getAllChildren()
-
searchValue
public String searchValue(String inXpath) throws XPathExpressionException
- Throws:
XPathExpressionException
-
getContent
public String getContent()
get the first text content of the node, if any (grh)
-
getContentPrefix
public String getContentPrefix()
-
getContentSuffix
public String getContentSuffix()
-
getOwnerDocument
public Document getOwnerDocument()
-
getNode
public Node getNode()
-
addAttribute
public void addAttribute(String name)
Method addAttribute adds an attribute to a node with all attributes value to null, so you still have to do a setAttribute to add value.- Parameters:
name- name of the new attribute.
-
setAttribute
public void setAttribute(String name, String value)
Method setAttribute sets an attrinute to its value, if the attribute does not exist it will be added. @see- Parameters:
name- of the attribute.value- of the attribute.
-
setContent
public void setContent(String content)
-
setCDATAContent
public void setCDATAContent(String content)
setCDATAContent: Set a CDATA content in a DOM, Will add a new CDATA node if there is none. (xcosyns)- Parameters:
content- The content to have as a CDATA section in your node.
-
removeChild
public void removeChild(NodeXML n)
-
clone
public Object clone()
- Overrides:
clonein classObject- See Also:
Clones this XMLNode with the 'deep' attribute set. So it clones this node and the whole subtree of nodes.
-
nodeToString
public String nodeToString()
-
getParentDistance
public int getParentDistance(NodeXML inParent)
return the distance in node count form a prent- Parameters:
inParent-- Returns:
- -1 if not found.
-
main
public static void main(String[] args)
-
-