Package ch.usi.si.seart.treesitter
Class QueryCursor
- java.lang.Object
-
- ch.usi.si.seart.treesitter.QueryCursor
-
- All Implemented Interfaces:
AutoCloseable,Iterable<QueryMatch>
public class QueryCursor extends Object implements Iterable<QueryMatch>
Cursor used for executing queries, carrying the state needed to process them.The query cursor should not be shared between threads, but can be reused for many query executions.
- Since:
- 1.0.0
- Author:
- Ozren Dabić
-
-
Constructor Summary
Constructors Constructor Description QueryCursor(@NotNull Node node, @NotNull Query query)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Delete the query cursor, freeing all the memory that it used.booleanequals(Object obj)voidexecute()Start running a given query on a given node.inthashCode()booleanisNull()@NotNull Iterator<QueryMatch>iterator()QueryMatchnextMatch()Advance to the next match of the currently running query.StringtoString()-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
close
public void close()
Delete the query cursor, freeing all the memory that it used.- Specified by:
closein interfaceAutoCloseable
-
execute
public void execute()
Start running a given query on a given node. Successive calls to this method are ignored.
-
nextMatch
public QueryMatch nextMatch()
Advance to the next match of the currently running query.- Returns:
- A match if there is one, null otherwise
- Throws:
IllegalStateException- ifqueryExec()was not called beforehand
-
iterator
@NotNull public @NotNull Iterator<QueryMatch> iterator()
- Specified by:
iteratorin interfaceIterable<QueryMatch>- Returns:
- An iterator over the query cursor matches, starting from the first match
-
isNull
public final boolean isNull()
-
-