public class DocumentConfigurationHelper extends Object implements ConfigurationHelper<Document>
Document using
XPath.| Constructor and Description |
|---|
DocumentConfigurationHelper(Document document)
Creates a new helper for the given XML
Document. |
| Modifier and Type | Method and Description |
|---|---|
static XPathExpression |
compileXPath(String expression)
Compiles the given XPath expression.
|
ConfigurationMerger<Document> |
configurationMerger()
Creates the applicable
ConfigurationMerger object for the type associated with
this ConfigurationHelper. |
NodeList |
get(String xpath)
Returns the
NodeList object associated with the specified @{code XPath} in the
XML document in context. |
Document |
getBean()
Returns the configuration bean used by this data retriever, typically for manual
handling and/or troubleshooting purposes.
|
Boolean |
getBoolean(String xpath)
Returns the
Boolean object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to boolean. |
Double |
getDouble(String xpath)
Returns the
Double object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to double. |
Integer |
getInteger(String xpath)
Returns the
Integer object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to int. |
Long |
getLong(String xpath)
Returns the
Long object associated with the specified XPath expression
in the XML document in context, provided that the expression returns a single element
that can be converted to long. |
Boolean |
getMandatoryBoolean(String xpath)
Returns the
Boolean object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to boolean. |
Double |
getMandatoryDouble(String xpath)
Returns the
Double object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to double. |
Integer |
getMandatoryInteger(String xpath)
Returns the
Integer object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to int. |
Long |
getMandatoryLong(String xpath)
Returns the
Long object associated with the specified XPath expression
in the XML document in context, provided that the expression returns a single element
that can be converted to long. |
String |
getMandatoryString(String xpath)
Returns the
String object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element. |
String |
getString(String xpath)
Returns the
String object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewInstancepublic Document getBean()
ConfigurationDataRetrievergetBean in interface ConfigurationDataRetriever<Document>Document in contextpublic Boolean getBoolean(String xpath)
Boolean object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to boolean.
Note: If the evaluation result is a valid string it will parsed
according to Boolean.parseBoolean(String), it will return false for any
string different than "true" (ignoring case).
getBoolean in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateBoolean object from the evaluation result of the specified
XPath expression; null if the expression is not foundNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, or it
evaluates to more than a single elementpublic Boolean getMandatoryBoolean(String xpath)
Boolean object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to boolean.
If no value is found for the given expression, then an exception will be thrown.
Note: If the evaluation result is a valid string it will parsed
according to Boolean.parseBoolean(String), it will return false for any
string different than "true" (ignoring case).
getMandatoryBoolean in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateBoolean object from the evaluation result of the the specified
XPath expression; never nullNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, not
found, or it evaluates to more than a single elementpublic Integer getInteger(String xpath)
Integer object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to int.getInteger in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateInteger object from the evaluation result of the specified
XPath expression; null if the expression is not foundNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, or it
evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
intpublic Integer getMandatoryInteger(String xpath)
Integer object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to int.
If no value is found for the given expression, then an exception will be thrown.
getMandatoryInteger in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateInteger object from the evaluation result of the the specified
XPath expression; never nullNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, not
found, or it evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
intpublic Long getLong(String xpath)
Long object associated with the specified XPath expression
in the XML document in context, provided that the expression returns a single element
that can be converted to long.getLong in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateLong object from the evaluation result of the specified
XPath expression; null if the expression is not foundNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, or it
evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
longpublic Long getMandatoryLong(String xpath)
Long object associated with the specified XPath expression
in the XML document in context, provided that the expression returns a single element
that can be converted to long.
If no value is found for the given expression, then an exception will be thrown.
getMandatoryLong in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateLong object from the evaluation result of the the specified
XPath expression; never nullNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, not
found, or it evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
longpublic Double getDouble(String xpath)
Double object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to double.getDouble in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateDouble object from the evaluation result of the specified
XPath expression; null if the expression is not foundNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, or it
evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
doublepublic Double getMandatoryDouble(String xpath)
Double object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element that can be converted to double.
If no value is found for the given expression, then an exception will be thrown.
getMandatoryDouble in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateDouble object from the evaluation result of the the specified
XPath expression; never nullNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, not
found, or it evaluates to more than a single elementNumberFormatException - if the XPath result cannot be assigned to
doublepublic String getString(String xpath)
String object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element.getString in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateString value associated with the specified XPath
expression; null if the expression is not foundNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, or it
evaluates to more than a single elementpublic String getMandatoryString(String xpath)
String object associated with the specified XPath
expression in the XML document in context, provided that the expression returns a
single element.
If no value is found for the given expression, then an exception will be thrown.
getMandatoryString in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to evaluateString value associated with the specified XPath
expression; never nullNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is either invalid, not
found, or it evaluates to more than a single elementpublic NodeList get(String xpath)
NodeList object associated with the specified @{code XPath} in the
XML document in context.get in interface ConfigurationDataRetriever<Document>xpath - the XPath expression to readNodeList object associated with the specified XPathNullPointerException - if the XPath expression is nullConfigurationException - if the XPath expression is not validpublic static XPathExpression compileXPath(String expression) throws XPathExpressionException
expression - the XPath expression to be compiledXPathExpression object that can be used for further evaluationXPathExpressionException - if the expression cannot be compiledpublic ConfigurationMerger<Document> configurationMerger()
ConfigurationHelperConfigurationMerger object for the type associated with
this ConfigurationHelper.configurationMerger in interface ConfigurationHelper<Document>ConfigurationMerger instanceCopyright © 2023. All rights reserved.