XPathExpression instances without having
to manage your own Namespace and Variable contexts.
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final Filter | |
| private Map | |
| private Map |
| Access | Constructor and Description |
|---|---|
| public | XPathBuilder(String
The XPath expression. expression, Filter<T> The Filter to perform the coercion with. filter)Create a skeleton XPathBuilder with the given expression and result filter. |
| Modifier and Type | Method and Description |
|---|---|
| public XPathExpression | Returns: The compiled XPath expressionThe XPath factory to use for compiling. factory)Compile an XPathExpression using the details currently stored in the XPathBuilder. |
| public String | |
| public Filter | |
| public Namespace | Returns: the Namespace with that prefix, or null if that prefix was never defined.The Namespace prefix to get the Namespace for. prefix)Get the Namespace associated with the given prefix. |
| public Object | Returns: the variable value, or null if the variable was not defined.The variable name to get the variable value for. qname)Get the variable value associated with the given name. |
| public boolean | Returns: true if the Namespace prefix was newly defined, false if the prefix was previously defined and has now been redefined.The namespace prefix to define. prefix, String The namespace URI to define. uri)Define a Namespace to be available for the XPath expression. |
| public boolean | Returns: true if this Namespace prefix was newly defined, false if the prefix was previously defined and has now been redefined.The namespace to define. namespace)Define a Namespace to be available for the XPath expression. |
| public boolean | Returns: true if any of the Namespace prefixes are new to the XPathBuilderThe namespaces to set. namespaces)Add a number of namespaces to this XPathBuilder |
| public boolean | Returns: true if this variable was defined, false if it was previously defined and has now been redefined.The variable name to define. qname, Object The variable value to set. value)Define or redefine an XPath expression variable value. |
| expression | back to summary |
|---|---|
| private final String expression | |
| filter | back to summary |
|---|---|
| private final Filter<T> filter | |
| namespaces | back to summary |
|---|---|
| private Map<String, Namespace> namespaces | |
| variables | back to summary |
|---|---|
| private Map<String, Object> variables | |
| XPathBuilder | back to summary |
|---|---|
| public XPathBuilder(String expression, Filter<T> filter) Create a skeleton XPathBuilder with the given expression and result filter. | |
| compileWith | back to summary |
|---|---|
| public XPathExpression Compile an XPathExpression using the details currently stored in the XPathBuilder.
| |
| getExpression | back to summary |
|---|---|
| public String getExpression() Get the XPath expression.
| |
| getFilter | back to summary |
|---|---|
| public Filter Get the Filter instance used for coercion.
| |
| getNamespace | back to summary |
|---|---|
| public Namespace getNamespace(String prefix) Get the Namespace associated with the given prefix. | |
| getVariable | back to summary |
|---|---|
| public Object getVariable(String qname) Get the variable value associated with the given name. See
| |
| setNamespace | back to summary |
|---|---|
| public boolean setNamespace(String prefix, String uri) Define a Namespace to be available for the XPath expression. If a Namespace with the same prefix was previously defined then the prefix will be re-defined. | |
| setNamespace | back to summary |
|---|---|
| public boolean setNamespace(Namespace namespace) Define a Namespace to be available for the XPath expression.
| |
| setNamespaces | back to summary |
|---|---|
| public boolean setNamespaces(Collection<Namespace> namespaces) Add a number of namespaces to this XPathBuilder
| |
| setVariable | back to summary |
|---|---|
| public boolean setVariable(String qname, Object value) Define or redefine an XPath expression variable value. In XPath, variable names can be in a namespace, and thus the variable name is in a QName form: prefix:name Variables without a prefix are in the "" Namespace.
Variables can have a null value. The
In order to validate that a Variable is unique you have to know the
namespace associated with the prefix. This class is designed to make it
possible to make the namespace associations after the variables have been
added. As a result it is not possible to validate the uniqueness of a
variable name until the
As a consequence of the above, this class assumes that each unique prefix
is for a unique Namespace URI (thus calling this method with different
QNames is assumed to be setting different variables). This may lead to an
IllegalArgumentException when the This method does not validate the format of the variable name either, it instead postpones the validation until the expression is compiled. As a result you may encounter IllegalArgumentExceptions at compile time if the variable names are not valid XPath QNames ("name" or "prefix:name").
| |