Class NodeQueryImpl
- All Implemented Interfaces:
NodeQuery
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfrom
(Collection<javafx.scene.Node> parentNodes) Stores all givenparentNodes
within this NodeQuery.from
(javafx.scene.Node... parentNodes) Stores all givenparentNodes
within this NodeQuery.private static boolean
isCssSelector
(String query) Sifts through stored nodes by their id ("#id"), their class (".class"), or the text it has ("text"), depending on the query used, and keeps only thoseNode
s that meet the query.Sifts through stored nodes and usesfunction
to determine which nodes to keep and which to remove.<T extends javafx.scene.Node>
NodeQuerySifts through stored nodes and keeps only thoseNode
s that pass the givenpredicate
.<T> NodeQuery
lookup
(org.hamcrest.Matcher<T> matcher) Sifts through stored nodes and keeps only thoseNode
s that match the given matcher.<T extends javafx.scene.Node>
NodeQuerySifts through stored nodes and keeps only thoseNode
s that pass the given predicate.<T> NodeQuery
match
(org.hamcrest.Matcher<T> matcher) Sifts through stored nodes and keeps only thoseNode
s that match the given matcher.nth
(int index) Keeps the nthNode
in stored nodes and removes all others.private static String
ordinal
(int i) https://stackoverflow.com/a/6810409/3634630<T extends javafx.scene.Node>
Tquery()
Executes thisNodeQuery
and returns the firstNode
found that matches this query.<T extends javafx.scene.Node>
Set<T> queryAll()
Executes thisNodeQuery
and returns theSet
of all theNode
s that match this query.<T extends javafx.scene.Node>
Set<T> queryAllAs
(Class<T> clazz) Type-safe version ofNodeQuery.queryAll()
that executes thisNodeQuery
and returns theSet
of all theNode
s that match this query.<T extends javafx.scene.Node>
TType-safe version ofNodeQuery.query()
that executes thisNodeQuery
and returns the firstNode
found that matches this query.toString()
<T extends javafx.scene.Node>
Optional<T> tryQuery()
Executes thisNodeQuery
and returns anOptional
that either contains the firstNode
found that matches this query or nothing (e.g.<T extends javafx.scene.Node>
Optional<T> tryQueryAs
(Class<T> clazz) Type-safe version ofNodeQuery.tryQuery()
that executes thisNodeQuery
and returns anOptional
that either contains the firstNode
found that matches this query or nothing (e.g.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.testfx.service.query.NodeQuery
queryButton, queryComboBox, queryLabeled, queryListView, queryParent, queryTableView, queryText, queryTextFlow, queryTextInputControl
-
Field Details
-
CSS_ID_SELECTOR_PREFIX
- See Also:
-
CSS_CLASS_SELECTOR_PREFIX
- See Also:
-
parentNodes
-
queryDescriptors
-
-
Constructor Details
-
NodeQueryImpl
public NodeQueryImpl()
-
-
Method Details
-
from
Description copied from interface:NodeQuery
Stores all givenparentNodes
within this NodeQuery. -
from
Description copied from interface:NodeQuery
Stores all givenparentNodes
within this NodeQuery. -
lookup
Description copied from interface:NodeQuery
Sifts through stored nodes by their id ("#id"), their class (".class"), or the text it has ("text"), depending on the query used, and keeps only thoseNode
s that meet the query. -
lookup
Description copied from interface:NodeQuery
Sifts through stored nodes and keeps only thoseNode
s that match the given matcher. -
lookup
Description copied from interface:NodeQuery
Sifts through stored nodes and keeps only thoseNode
s that pass the givenpredicate
. -
lookup
Description copied from interface:NodeQuery
Sifts through stored nodes and usesfunction
to determine which nodes to keep and which to remove. -
match
Description copied from interface:NodeQuery
Sifts through stored nodes and keeps only thoseNode
s that match the given matcher. -
match
Description copied from interface:NodeQuery
Sifts through stored nodes and keeps only thoseNode
s that pass the given predicate. -
nth
Description copied from interface:NodeQuery
Keeps the nthNode
in stored nodes and removes all others. -
query
public <T extends javafx.scene.Node> T query()Description copied from interface:NodeQuery
Executes thisNodeQuery
and returns the firstNode
found that matches this query. If no nodes match this query then anEmptyNodeQueryException
is thrown.The determinism of this method relies on the determinism of
Node.lookupAll(String)
, for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched. -
queryAs
Description copied from interface:NodeQuery
Type-safe version ofNodeQuery.query()
that executes thisNodeQuery
and returns the firstNode
found that matches this query. If no nodes match this query then anEmptyNodeQueryException
is thrown.The determinism of this method relies on the determinism of
Node.lookupAll(String)
, for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.- Specified by:
queryAs
in interfaceNodeQuery
- Type Parameters:
T
- the type that extendsNode
- Parameters:
clazz
- the concrete sub-type ofNode
that should be returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the first node found that matches this query, if any
-
tryQuery
Description copied from interface:NodeQuery
Executes thisNodeQuery
and returns anOptional
that either contains the firstNode
found that matches this query or nothing (e.g.Optional.empty()
returns true) if no nodes match this query.The determinism of this method relies on the determinism of
Node.lookupAll(String)
, for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched. -
tryQueryAs
Description copied from interface:NodeQuery
Type-safe version ofNodeQuery.tryQuery()
that executes thisNodeQuery
and returns anOptional
that either contains the firstNode
found that matches this query or nothing (e.g.Optional.empty()
returns true) if no nodes match this query.The determinism of this method relies on the determinism of
Node.lookupAll(String)
, for which the JavaDocs specifically state that the result is unordered. The current (9.0.4) version of JavaFX happens to return the nodes in the order in which they are encountered whilst traversing the scene graph but this could change in future versions of JavaFX. Thus if there are multiple nodes matched by this query and you want a specific one it is advised not to use this method and instead narrow the query so that only one node is matched.- Specified by:
tryQueryAs
in interfaceNodeQuery
- Type Parameters:
T
- the type that extendsNode
- Parameters:
clazz
- the concrete sub-type ofNode
that should be contained in theOptional
returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the first node found or an empty
Optional
if the query does not match any nodes
-
queryAll
Description copied from interface:NodeQuery
Executes thisNodeQuery
and returns theSet
of all theNode
s that match this query. If no nodes match this query, the empty set is returned. -
queryAllAs
Description copied from interface:NodeQuery
Type-safe version ofNodeQuery.queryAll()
that executes thisNodeQuery
and returns theSet
of all theNode
s that match this query. If no nodes match this query, the empty set is returned.- Specified by:
queryAllAs
in interfaceNodeQuery
- Type Parameters:
T
- the type that extendsNode
- Parameters:
clazz
- the concrete sub-type ofNode
the set of which should be returned by this query so as to avoid extraneous casting when used inside an "assertThat" assertion- Returns:
- the set of nodes that match this query
-
toString
-
isCssSelector
-
ordinal
https://stackoverflow.com/a/6810409/3634630
-