public class Predicates
extends java.lang.Object
Predicate
interface, designed for use when navigating streams of XDM items.Constructor and Description |
---|
Predicates() |
Modifier and Type | Method and Description |
---|---|
static java.util.function.Predicate<XdmNode> |
attributeEq(java.lang.String local,
java.lang.String value)
Obtain a predicate that tests whether an item is an element node with a given attribute (whose
name is in no namespace) whose string value is equal to a given value
|
static <T extends XdmItem> |
empty(Step<T> step)
Obtain a predicate that tests whether a supplied
Step delivers an empty result |
static <T extends XdmItem> |
eq(Step<T> step,
java.lang.String value)
Obtain a predicate that tests whether there is some item in the result of applying a step,
whose string value is equal to a given string.
|
static java.util.function.Predicate<XdmItem> |
eq(java.lang.String value)
Obtain a predicate that tests whether the result of applying the XPath string() function to an item
is equal to a given string
|
static java.util.function.Predicate<XdmAtomicValue> |
eq(XdmAtomicValue value)
Obtain a predicate that tests whether an atomic value compares equal to a supplied atomic value of
a comparable type
|
static <T extends XdmItem> |
every(Step<T> step,
java.util.function.Predicate<? super XdmItem> condition)
Obtain a predicate that tests whether every item in the result of applying a step
satisfies the supplied condition.
|
static <T extends XdmItem> |
exists(Step<T> step)
Obtain a predicate that tests whether a supplied Step delivers a non-empty result
|
static java.util.function.Predicate<XdmNode> |
hasAttribute(java.lang.String local)
Obtain a predicate that tests whether an item is an element node with a given attribute (whose
name is in no namespace)
|
static java.util.function.Predicate<XdmNode> |
hasLocalName(java.lang.String localName)
Obtain a predicate that tests whether an item is a node with a given local name,
irrespective of the namespace
|
static java.util.function.Predicate<? super XdmNode> |
hasName(java.lang.String uri,
java.lang.String localName)
Obtain a predicate that tests whether an item is a node with a given namespace URI and local name
|
static java.util.function.Predicate<XdmNode> |
hasNamespace(java.lang.String uri)
Obtain a predicate that tests whether an item is a node with a given namespace URI
|
static java.util.function.Predicate<XdmItem> |
hasType(ItemType type)
Obtain a predicate that tests whether an item matches a given item type
|
static java.util.function.Predicate<XdmItem> |
isArray()
A predicate to test whether an item is an XDM array
|
static java.util.function.Predicate<XdmItem> |
isAtomic()
A predicate to test whether an item is an atomic value
|
static java.util.function.Predicate<XdmItem> |
isAttribute()
A predicate to test whether an item is an attribute node
|
static java.util.function.Predicate<XdmItem> |
isComment()
A predicate to test whether an item is a comment node
|
static java.util.function.Predicate<XdmItem> |
isDocument()
A predicate to test whether an item is a document node
|
static java.util.function.Predicate<XdmItem> |
isElement()
A predicate to test whether an item is an element node
|
static java.util.function.Predicate<XdmItem> |
isFunction()
A predicate to test whether an item is a function value (this includes maps and arrays)
|
static java.util.function.Predicate<XdmItem> |
isMap()
A predicate to test whether an item is an XDM map
|
static java.util.function.Predicate<XdmItem> |
isNamespace()
A predicate to test whether an item is a namespace node
|
static java.util.function.Predicate<XdmItem> |
isNode()
A predicate to test whether an item is a node
|
static java.util.function.Predicate<XdmItem> |
isProcessingInstruction()
A predicate to test whether an item is a processing instruction node
|
static java.util.function.Predicate<XdmItem> |
isText()
A predicate to test whether an item is a text node
|
static java.util.function.Predicate<XdmItem> |
matchesRegex(java.lang.String regex)
Obtain a predicate that tests whether the result of applying the XPath string() function to an item
matches a given regular expression
|
static <T> java.util.function.Predicate<T> |
not(java.util.function.Predicate<T> condition)
Return a
Predicate that is the negation of a supplied Predicate |
static <T extends XdmItem> |
some(Step<T> step,
java.util.function.Predicate<? super T> condition)
Obtain a predicate that tests whether there is some item in the result of applying a step that
satisfies the supplied condition.
|
public static java.util.function.Predicate<XdmItem> isNode()
public static java.util.function.Predicate<XdmItem> isElement()
public static java.util.function.Predicate<XdmItem> isAttribute()
public static java.util.function.Predicate<XdmItem> isText()
public static java.util.function.Predicate<XdmItem> isComment()
public static java.util.function.Predicate<XdmItem> isProcessingInstruction()
public static java.util.function.Predicate<XdmItem> isDocument()
public static java.util.function.Predicate<XdmItem> isNamespace()
public static java.util.function.Predicate<XdmItem> isAtomic()
Note: to test for a specific type of atomic value, use a predicate such as
hasType(ItemType.XS_INTEGER)
public static java.util.function.Predicate<XdmItem> isFunction()
public static java.util.function.Predicate<XdmItem> isMap()
public static java.util.function.Predicate<XdmItem> isArray()
public static <T extends XdmItem> java.util.function.Predicate<XdmItem> empty(Step<T> step)
Step
delivers an empty resultstep
- a step to be applied to the item being testedempty(attribute("id")
is a predicate that returns true for a node that
has no "id" attribute. Similarly CHILD.where(empty(child(IS_ELEMENT)))
is a step
that selects child elements having no element children.public static <T> java.util.function.Predicate<T> not(java.util.function.Predicate<T> condition)
Predicate
that is the negation of a supplied Predicate
T
- The type of object to which the predicate is applicablecondition
- the supplied predicatepublic static <T extends XdmItem> java.util.function.Predicate<XdmItem> exists(Step<T> step)
step
- a step to be applied to the item being testedexists(attribute("id")
is a
predicate that returns true for a node that has an "id" attribute. So
CHILD.where(exists(attribute("id"))
is a step that selects child elements
having an "id" attribute.public static java.util.function.Predicate<? super XdmNode> hasName(java.lang.String uri, java.lang.String localName)
uri
- the required namespace URI: supply a zero-length string to indicate the null namespacelocalName
- the required local namepublic static java.util.function.Predicate<XdmNode> hasLocalName(java.lang.String localName)
localName
- the required local name. If a zero-length string is supplied, the predicate
will match nodes having no name (for example, comments and text nodes)public static java.util.function.Predicate<XdmNode> hasNamespace(java.lang.String uri)
uri
- the required namespace URI: supply a zero-length string to identify the null namespacepublic static java.util.function.Predicate<XdmNode> hasAttribute(java.lang.String local)
local
- the required attribute namepublic static java.util.function.Predicate<XdmNode> attributeEq(java.lang.String local, java.lang.String value)
local
- the required attribute namevalue
- the required attribute valuepublic static java.util.function.Predicate<XdmItem> hasType(ItemType type)
type
- the required item typehasType(ItemType.DATE_TIME)
matches atomic values of type
xs:dateTime
.public static <T extends XdmItem> java.util.function.Predicate<XdmItem> some(Step<T> step, java.util.function.Predicate<? super T> condition)
For example, some(CHILD, exists(attribute("foo"))
matches an element if it has a child
element with an attribute whose local name is "foo".
If the step returns an empty sequence the result will always be false.
step
- the step to be evaluatedcondition
- the predicate to be applied to the items returned by the steppublic static <T extends XdmItem> java.util.function.Predicate<XdmItem> every(Step<T> step, java.util.function.Predicate<? super XdmItem> condition)
For example, every(CHILD, exists(attribute("foo"))
matches an element if each of its child
elements has an attribute whose local name is "foo".
If the step returns an empty sequence the result will always be true.
step
- the step to be evaluatedcondition
- the predicate to be applied to the items returned by the steppublic static java.util.function.Predicate<XdmAtomicValue> eq(XdmAtomicValue value)
value
- the atomic value to be compared withpublic static java.util.function.Predicate<XdmItem> eq(java.lang.String value)
value
- the string being testedpublic static java.util.function.Predicate<XdmItem> matchesRegex(java.lang.String regex)
regex
- the regular expression (this is a Java regular expression, not an XPath regular expression)public static <T extends XdmItem> java.util.function.Predicate<XdmItem> eq(Step<T> step, java.lang.String value)
For example, eq(attribute("id"), "foo")
matches an element if it has an "id"
attribute whose value is "foo".
step
- the step to be evaluatedvalue
- the string to be compared against the items returned by the stepCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.