Package org.apache.any23.validator
Class DefaultDOMDocument
- java.lang.Object
-
- org.apache.any23.validator.DefaultDOMDocument
-
- All Implemented Interfaces:
DOMDocument
public class DefaultDOMDocument extends Object implements DOMDocument
This class wraps the DOM document.- Author:
- Michele Mostarda (mostarda@fbk.eu), Davide Palmisano (palmisano@fbk.eu)
-
-
Constructor Summary
Constructors Constructor Description DefaultDOMDocument(URI documentIRI, Document document)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(String xPath, String attrName, String attrValue)
Adds an attribute to a node addressed by the given XPath.URI
getDocumentIRI()
Node
getNode(String xPath)
Returns the node addressed by the given XPath, if more then one an exception will be raised.List<Node>
getNodes(String xPath)
Returns the list of nodes addressed by the given XPath.List<Node>
getNodesWithAttribute(String attrName)
Returns all the nodes declaring an attribute with the specified name.Document
getOriginalDocument()
Returns the original document.
-
-
-
Method Detail
-
getDocumentIRI
public URI getDocumentIRI()
- Specified by:
getDocumentIRI
in interfaceDOMDocument
- Returns:
- the original document IRI.
-
getOriginalDocument
public Document getOriginalDocument()
Description copied from interface:DOMDocument
Returns the original document.- Specified by:
getOriginalDocument
in interfaceDOMDocument
- Returns:
- the original document.
-
getNodes
public List<Node> getNodes(String xPath)
Description copied from interface:DOMDocument
Returns the list of nodes addressed by the given XPath.- Specified by:
getNodes
in interfaceDOMDocument
- Parameters:
xPath
- a valid XPath- Returns:
- a not null list of nodes.
-
getNode
public Node getNode(String xPath)
Description copied from interface:DOMDocument
Returns the node addressed by the given XPath, if more then one an exception will be raised.- Specified by:
getNode
in interfaceDOMDocument
- Parameters:
xPath
- a valid XPath.- Returns:
- a node or
null
if nothing found.
-
addAttribute
public void addAttribute(String xPath, String attrName, String attrValue)
Description copied from interface:DOMDocument
Adds an attribute to a node addressed by the given XPath.- Specified by:
addAttribute
in interfaceDOMDocument
- Parameters:
xPath
- the XPath pointing the node.attrName
- the name of the attribute.attrValue
- the value of the attribute.
-
getNodesWithAttribute
public List<Node> getNodesWithAttribute(String attrName)
Description copied from interface:DOMDocument
Returns all the nodes declaring an attribute with the specified name.- Specified by:
getNodesWithAttribute
in interfaceDOMDocument
- Parameters:
attrName
- name of attribute to use for filtering.- Returns:
- a list of nodes. null if no matches found.
-
-