org.apache.any23.validator
Class DefaultDOMDocument

java.lang.Object
  extended by 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
DefaultDOMDocument(URI documentURI, Document document)
           
 
Method Summary
 void addAttribute(String xPath, String attrName, String attrValue)
          Adds an attribute to a node addressed by the given XPath.
 URI getDocumentURI()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDOMDocument

public DefaultDOMDocument(URI documentURI,
                          Document document)
Method Detail

getDocumentURI

public URI getDocumentURI()
Specified by:
getDocumentURI in interface DOMDocument
Returns:
the original document URI.

getOriginalDocument

public Document getOriginalDocument()
Description copied from interface: DOMDocument
Returns the original document.

Specified by:
getOriginalDocument in interface DOMDocument
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 interface DOMDocument
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 interface DOMDocument
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 interface DOMDocument
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 interface DOMDocument
Parameters:
attrName - name of attribute to use for filtering.
Returns:
a list of nodes. null if no matches found.


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.