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 voidaddAttribute(String xPath, String attrName, String attrValue)Adds an attribute to a node addressed by the given XPath.URIgetDocumentIRI()NodegetNode(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.DocumentgetOriginalDocument()Returns the original document.
-
-
-
Method Detail
-
getDocumentIRI
public URI getDocumentIRI()
- Specified by:
getDocumentIRIin interfaceDOMDocument- Returns:
- the original document IRI.
-
getOriginalDocument
public Document getOriginalDocument()
Description copied from interface:DOMDocumentReturns the original document.- Specified by:
getOriginalDocumentin interfaceDOMDocument- Returns:
- the original document.
-
getNodes
public List<Node> getNodes(String xPath)
Description copied from interface:DOMDocumentReturns the list of nodes addressed by the given XPath.- Specified by:
getNodesin interfaceDOMDocument- Parameters:
xPath- a valid XPath- Returns:
- a not null list of nodes.
-
getNode
public Node getNode(String xPath)
Description copied from interface:DOMDocumentReturns the node addressed by the given XPath, if more then one an exception will be raised.- Specified by:
getNodein interfaceDOMDocument- Parameters:
xPath- a valid XPath.- Returns:
- a node or
nullif nothing found.
-
addAttribute
public void addAttribute(String xPath, String attrName, String attrValue)
Description copied from interface:DOMDocumentAdds an attribute to a node addressed by the given XPath.- Specified by:
addAttributein 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:DOMDocumentReturns all the nodes declaring an attribute with the specified name.- Specified by:
getNodesWithAttributein interfaceDOMDocument- Parameters:
attrName- name of attribute to use for filtering.- Returns:
- a list of nodes. null if no matches found.
-
-