Package com.couchbase.lite
Class From
- java.lang.Object
-
- com.couchbase.lite.From
-
- All Implemented Interfaces:
Query
public final class From extends java.lang.Object
A From represents a FROM clause for specifying the data source of the query.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListenerToken
addChangeListener(QueryChangeListener listener)
Adds a query change listener.ListenerToken
addChangeListener(java.util.concurrent.Executor executor, QueryChangeListener listener)
Adds a query change listener with the dispatch queue on which changes will be posted.ResultSet
execute()
Executes the query.java.lang.String
explain()
Returns a string describing the implementation of the compiled query.Parameters
getParameters()
Returns a copies of the current parameters.GroupBy
groupBy(Expression... expressions)
Creates and chains a GroupBy object to group the query result.Joins
join(Join... joins)
Creates and chains a Joins object for specifying the JOIN clause of the query.Limit
limit(Expression limit)
Creates and chains a Limit object to limit the number query results.Limit
limit(Expression limit, Expression offset)
Creates and chains a Limit object to skip the returned results for the given offset position and to limit the number of results to not more than the given limit value.OrderBy
orderBy(Ordering... orderings)
Create and chain an ORDER BY component for specifying the ORDER BY clause of the query.void
removeChangeListener(ListenerToken token)
Removes a change listener wih the given listener token.void
setParameters(Parameters parameters)
Set parameters should copy the given parameters.java.lang.String
toString()
Where
where(Expression expression)
Create and chain a WHERE component for specifying the WHERE clause of the query.
-
-
-
Method Detail
-
join
@NonNull public Joins join(@NonNull Join... joins)
Creates and chains a Joins object for specifying the JOIN clause of the query.- Parameters:
joins
- The Join objects.- Returns:
- The Joins object that represents the JOIN clause of the query.
-
where
@NonNull public Where where(@NonNull Expression expression)
Create and chain a WHERE component for specifying the WHERE clause of the query.- Parameters:
expression
- the WHERE clause expression.- Returns:
- the WHERE component.
-
groupBy
@NonNull public GroupBy groupBy(@NonNull Expression... expressions)
Creates and chains a GroupBy object to group the query result.- Parameters:
expressions
- The group by expression.- Returns:
- The GroupBy object that represents the GROUP BY clause of the query.
-
orderBy
@NonNull public OrderBy orderBy(@NonNull Ordering... orderings)
Create and chain an ORDER BY component for specifying the ORDER BY clause of the query.- Parameters:
orderings
- an array of the ORDER BY expressions.- Returns:
- the ORDER BY component.
-
limit
@NonNull public Limit limit(@NonNull Expression limit)
Creates and chains a Limit object to limit the number query results.- Parameters:
limit
- The limit expression.- Returns:
- The Limit object that represents the LIMIT clause of the query.
-
limit
@NonNull public Limit limit(@NonNull Expression limit, @Nullable Expression offset)
Creates and chains a Limit object to skip the returned results for the given offset position and to limit the number of results to not more than the given limit value.- Parameters:
limit
- The limit expression.offset
- The offset expression.- Returns:
- The Limit object that represents the LIMIT clause of the query.
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getParameters
@Nullable public Parameters getParameters()
Returns a copies of the current parameters.- Specified by:
getParameters
in interfaceQuery
-
setParameters
public void setParameters(@Nullable Parameters parameters)
Set parameters should copy the given parameters. Set a new parameter will also re-execute the query if there is at least one listener listening for changes.- Specified by:
setParameters
in interfaceQuery
-
execute
@NonNull public ResultSet execute() throws CouchbaseLiteException
Executes the query. The returning a result set that enumerates result rows one at a time. You can run the query any number of times, and you can even have multiple ResultSet active at once.The results come from a snapshot of the database taken at the moment the run() method is called, so they will not reflect any changes made to the database afterwards.
- Specified by:
execute
in interfaceQuery
- Returns:
- the ResultSet for the query result.
- Throws:
CouchbaseLiteException
- if there is an error when running the query.
-
explain
@NonNull public java.lang.String explain() throws CouchbaseLiteException
Returns a string describing the implementation of the compiled query. This is intended to be read by a developer for purposes of optimizing the query, especially to add database indexes. It's not machine-readable and its format may change. As currently implemented, the result is two or more lines separated by newline characters: * The first line is the SQLite SELECT statement. * The subsequent lines are the output of SQLite's "EXPLAIN QUERY PLAN" command applied to that statement; for help interpreting this, see https://www.sqlite.org/eqp.html . The most important thing to know is that if you see "SCAN TABLE", it means that SQLite is doing a slow linear scan of the documents instead of using an index.- Specified by:
explain
in interfaceQuery
- Returns:
- a string describing the implementation of the compiled query.
- Throws:
CouchbaseLiteException
- if an error occurs
-
addChangeListener
@NonNull public ListenerToken addChangeListener(@NonNull QueryChangeListener listener)
Adds a query change listener. Changes will be posted on the main queue.- Specified by:
addChangeListener
in interfaceQuery
- Parameters:
listener
- The listener to post changes.- Returns:
- An opaque listener token object for removing the listener.
-
addChangeListener
@NonNull public ListenerToken addChangeListener(@Nullable java.util.concurrent.Executor executor, @NonNull QueryChangeListener listener)
Adds a query change listener with the dispatch queue on which changes will be posted. If the dispatch queue is not specified, the changes will be posted on the main queue.- Specified by:
addChangeListener
in interfaceQuery
- Parameters:
executor
- The executor object that calls listener. If null, use default executor.listener
- The listener to post changes.- Returns:
- An opaque listener token object for removing the listener.
-
removeChangeListener
public void removeChangeListener(@NonNull ListenerToken token)
Removes a change listener wih the given listener token.- Specified by:
removeChangeListener
in interfaceQuery
- Parameters:
token
- The listener token.
-
-