public class XmlNavigator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected NamespaceManager |
nsManager |
protected org.w3c.dom.Document |
xmlDocument |
protected javax.xml.xpath.XPath |
xPath |
| Constructor and Description |
|---|
XmlNavigator(byte[] xmlBytes)
Custom constructor.
|
XmlNavigator(byte[] xmlBytes,
boolean namespaceAware)
Custom constructor.
|
XmlNavigator(java.io.InputStream xmlStream)
Custom constructor.
|
XmlNavigator(java.io.InputStream xmlStream,
boolean namespaceAware)
Custom constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNamespace(java.lang.String prefix,
java.lang.String uri)
Add XML Namespace if navigator works namespace aware.
|
<T extends AbstractXJdfType> |
evaluate(java.lang.String xPath,
java.lang.Class<T> xJdfType)
Evaluates an XPath expression on XML Document and returns the result as XJDF DataType.
|
boolean |
evaluateBoolean(java.lang.String xPath)
Evaluate an XPath expression on XML Document and returns an Boolean value as result.
|
double |
evaluateDouble(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns a Double object as result.
|
java.lang.Integer |
evaluateInt(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns an Integer value as result.
|
java.lang.Long |
evaluateLong(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns an Long value as result.
|
org.w3c.dom.Node |
evaluateNode(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns a Node object as result.
|
org.w3c.dom.NodeList |
evaluateNodeList(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns a NodeList object as result.
|
java.lang.String |
evaluateString(java.lang.String xPath)
Evaluates an XPath expression on XML Document and returns a String object as result.
|
protected java.lang.Object |
extractNode(java.lang.String xPath,
AbstractXmlParser parser)
Extract an XML Node from XML Document and return parsed result.
|
byte[] |
getXmlBytes()
Return the XML Document as Byte Array.
|
org.w3c.dom.Document |
getXmlDocument()
Getter for xmlDocument attribute.
|
java.io.InputStream |
getXmlStream()
Return the XML Document as input stream.
|
java.lang.String |
readAttribute(java.lang.String xPath)
Read attribute from XML Document using XPath.
|
java.lang.Object |
readAttribute(java.lang.String xPath,
java.lang.Class xJdfType)
Read attribute from XML Document using XPath and convert to JDF Datatype.
|
void |
removeNode(java.lang.String xPath)
Remove a node from XML Document locaed by the XPath expression.
|
protected void |
replaceNode(java.lang.String xPath,
java.lang.Object replacement,
AbstractXmlParser parser)
Replace a node in XML Document located by the XPath expression.
|
void |
updateAttribute(java.lang.String xPath,
AbstractXJdfType value)
Update attribute in XML Document.
|
void |
updateAttribute(java.lang.String xPath,
java.lang.String value)
Update attribute in XML Document.
|
protected final javax.xml.xpath.XPath xPath
protected final org.w3c.dom.Document xmlDocument
protected final NamespaceManager nsManager
public XmlNavigator(byte[] xmlBytes)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
xmlBytes - XML Document as Byte Array.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created
which satisfies the configuration requested.org.xml.sax.SAXException - - If any parse errors occur.java.io.IOException - - If any IO errors occur.public XmlNavigator(byte[] xmlBytes,
boolean namespaceAware)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
xmlBytes - XML Document as Byte Array.namespaceAware - True if navigator should be XML Namespace aware.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created
which satisfies the configuration requested.org.xml.sax.SAXException - - If any parse errors occur.java.io.IOException - - If any IO errors occur.public XmlNavigator(java.io.InputStream xmlStream)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
xmlStream - XML Document as Input Stream.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created
which satisfies the configuration requested.org.xml.sax.SAXException - - If any parse errors occur.java.io.IOException - - If any IO errors occur.public XmlNavigator(java.io.InputStream xmlStream,
boolean namespaceAware)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException,
org.xml.sax.SAXException
xmlStream - XML Document as Input Stream.namespaceAware - True if navigator should be XML Namespace aware.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created
which satisfies the configuration requested.org.xml.sax.SAXException - - If any parse errors occur.java.io.IOException - - If any IO errors occur.public org.w3c.dom.Document getXmlDocument()
public void addNamespace(java.lang.String prefix,
java.lang.String uri)
prefix - Prefix of Namespace.uri - Namespace URI.public java.lang.String readAttribute(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression of attribute to read.javax.xml.xpath.XPathExpressionException - Is being thrown in case an exception occurs.public java.lang.Object readAttribute(java.lang.String xPath,
java.lang.Class xJdfType)
throws javax.xml.xpath.XPathExpressionException,
java.lang.ReflectiveOperationException
xPath - XPath expression to evaluate.xJdfType - Target JDF Data Type of attribute.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.java.lang.ReflectiveOperationException - Is thrown in case reflection fails.public double evaluateDouble(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public java.lang.Integer evaluateInt(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public java.lang.Long evaluateLong(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public java.lang.String evaluateString(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public org.w3c.dom.Node evaluateNode(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public org.w3c.dom.NodeList evaluateNodeList(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public final <T extends AbstractXJdfType> T evaluate(java.lang.String xPath, java.lang.Class<T> xJdfType) throws javax.xml.xpath.XPathExpressionException, java.lang.ReflectiveOperationException
T - Type of the desired value object.xPath - XPath expression to execute to.xJdfType - The desired result data type.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.java.lang.ReflectiveOperationException - Is thrown in case reflection fails.protected java.lang.Object extractNode(java.lang.String xPath,
AbstractXmlParser parser)
throws javax.xml.xpath.XPathExpressionException,
javax.xml.bind.JAXBException
xPath - XPath expression in order to locate the node.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.javax.xml.bind.JAXBExceptionpublic void removeNode(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - Location of the node to be removed.javax.xml.xpath.XPathExpressionExceptionprotected void replaceNode(java.lang.String xPath,
java.lang.Object replacement,
AbstractXmlParser parser)
throws javax.xml.xpath.XPathExpressionException,
javax.xml.bind.JAXBException,
javax.xml.parsers.ParserConfigurationException
xPath - Location of the node to be replaced.replacement - The new node.parser - XML Parser.javax.xml.xpath.XPathExpressionExceptionjavax.xml.bind.JAXBExceptionjavax.xml.parsers.ParserConfigurationExceptionpublic boolean evaluateBoolean(java.lang.String xPath)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression to execute to.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public void updateAttribute(java.lang.String xPath,
AbstractXJdfType value)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression of attribute to read.value - New value of attribute defined by xPath.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public void updateAttribute(java.lang.String xPath,
java.lang.String value)
throws javax.xml.xpath.XPathExpressionException
xPath - XPath expression of attribute to read.value - New value of attribute defined by xPath.javax.xml.xpath.XPathExpressionException - Is thrown in case an XPath Exception occurs.public java.io.InputStream getXmlStream()
throws javax.xml.transform.TransformerException,
java.io.IOException
javax.xml.transform.TransformerException - If this document could not be transformed.java.io.IOException - If any IO errors occur.public byte[] getXmlBytes()
throws javax.xml.transform.TransformerException,
java.io.IOException
javax.xml.transform.TransformerException - If this document could not be transformed.java.io.IOException - - If any IO errors occur.