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.
|
AbstractXJdfType |
evaluate(String xPath,
Class 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.
|
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 Exception
xmlBytes - XML Document as Byte Array.Exceptionpublic XmlNavigator(byte[] xmlBytes,
boolean namespaceAware)
throws Exception
xmlBytes - XML Document as Byte Array.namespaceAware - True if navigator should be XML Namespace aware.Exceptionpublic XmlNavigator(InputStream xmlStream) throws Exception
xmlStream - XML Document as Input Stream.Exceptionpublic XmlNavigator(InputStream xmlStream, boolean namespaceAware) throws Exception
xmlStream - XML Document as Input Stream.namespaceAware - True if navigator should be XML Namespace aware.Exceptionpublic 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, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
xPath - XPath expression to evaluate.xJdfType - Target JDF Data Type of attribute.XPathExpressionExceptionSecurityExceptionNoSuchMethodExceptionInvocationTargetExceptionIllegalArgumentExceptionIllegalAccessExceptionInstantiationExceptionpublic 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 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 AbstractXJdfType evaluate(String xPath, Class xJdfType) throws XPathExpressionException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
xPath - XPath expression to execute to.xJdfType - The desired result data type.XPathExpressionExceptionNoSuchMethodExceptionSecurityExceptionInstantiationExceptionIllegalAccessExceptionIllegalArgumentExceptionInvocationTargetExceptionprotected 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 Exception
xPath - XPath expression of attribute to read.Exception - Is being thrown in case an exception occurs.public void updateAttribute(String xPath, String value) throws Exception
xPath - XPath expression of attribute to read.Exception - Is being thrown in case an exception occurs.public InputStream getXmlStream() throws Exception
ExceptionCopyright © 2014. All Rights Reserved.