Package org.javlo.xml
Class NodeXML
- java.lang.Object
-
- org.javlo.xml.NodeXML
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.NodeXML
addChild(String name)
boolean
attributeExist(String attribute)
get a attribute value (pvdm)Object
clone()
protected void
error(String message)
print error message on the screen (pvdm)Collection<NodeXML>
getAllChildren()
String
getAttributeValue(String attribute)
get a attribute value (pvdm)String
getAttributeValue(String attribute, String standardValue)
get a attribute value, with a standard value if the attribute is not found.NodeXML
getChild()
get the first child node (pvdm)NodeXML
getChild(String name)
get the first child node with a specific name (gh)Collection<NodeXML>
getChildren()
String
getContent()
get the first text content of the node, if any (grh)String
getContentPrefix()
String
getContentSuffix()
String
getName()
NodeXML
getNext()
get the next node (pvdm)NodeXML
getNext(String name)
get the next node (pvdm)Node
getNode()
Document
getOwnerDocument()
NodeXML
getParent()
get the first child node (pvdm)int
getParentDistance(NodeXML inParent)
return the distance in node count form a prentstatic void
main(String[] args)
String
nodeToString()
void
removeChild(NodeXML n)
NodeXML
searchChild(String inXpath)
NodeXML
searchChild(String name, String paramName, String paramValue)
search a node with a specific value for a parameter (pvdm)Collection<NodeXML>
searchChildren(String inXpath)
String
searchValue(String inXpath)
void
setAttribute(String name, String value)
Method setAttribute sets an attrinute to its value, if the attribute does not exist it will be added.void
setCDATAContent(String content)
setCDATAContent: Set a CDATA content in a DOM, Will add a new CDATA node if there is none.void
setContent(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:
clone
in 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)
-
-