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