public class QueryString extends Object
QueryString
is a utility class used to construct Pivotal GemFire OQL query statements.Pattern
,
Sort
,
OqlKeyword
,
Region
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
HINT_PATTERN |
protected static Pattern |
IMPORT_PATTERN |
protected static Pattern |
LIMIT_PATTERN |
protected static Pattern |
TRACE_PATTERN |
Constructor and Description |
---|
QueryString(Class<?> domainType)
Constructs a new instance of
QueryString initialized from the given domain type ,
which is used to construct an OQL SELECT query statement. |
QueryString(Class<?> domainType,
boolean asCountQuery)
Constructs a new instance of
QueryString initialized from the given domain type ,
which is used to construct an OQL SELECT query statement. |
QueryString(String query)
Constructs a new instance of
QueryString initialized with the given OQL query . |
Modifier and Type | Method and Description |
---|---|
QueryString |
asDistinct()
Replaces the SELECT query with a SELECT DISTINCT query if the
query
is not already distinct; i.e. does not contain the DISTINCT keyword. |
QueryString |
bindIn(Collection<?> values)
Binds the given
Collection of values into the IN parameters of the OQL Query by expanding
the given values into a comma-separated String . |
static QueryString |
count(Class<?> domainType)
Factory method used to construct an instance of
QueryString initialized with
the given domain type for which a count query will be created. |
static QueryString |
from(Class<?> domainType)
Factory method used to construct an instance of
QueryString initialized with
the given domain type for which the query will be created. |
QueryString |
fromRegion(Class<?> domainClass,
org.apache.geode.cache.Region<?,?> region)
|
Iterable<Integer> |
getInParameterIndexes()
Returns the parameter indexes used in this query.
|
static QueryString |
of(String query)
Factory method used to construct an instance of
QueryString initialized with the given query . |
QueryString |
orderBy(Sort sort)
Appends the
Sort order to this Pivotal GemFire OQL Query string. |
String |
toString()
Returns a
String representation of this QueryString . |
QueryString |
withHints(String... hints)
Applies HINTS to the OQL Query.
|
QueryString |
withImport(String importExpression)
Applies an IMPORT to the OQL Query.
|
QueryString |
withLimit(Integer limit)
Applies a LIMIT to the OQL Query.
|
QueryString |
withTrace()
Applies TRACE logging to the OQL Query.
|
protected static final Pattern HINT_PATTERN
protected static final Pattern IMPORT_PATTERN
protected static final Pattern LIMIT_PATTERN
protected static final Pattern TRACE_PATTERN
public QueryString(String query)
QueryString
initialized with the given OQL query
.query
- String
containing the OQL query.IllegalArgumentException
- if query
is null or empty.validateQuery(String)
,
String
public QueryString(Class<?> domainType)
QueryString
initialized from the given domain type
,
which is used to construct an OQL SELECT query statement.domainType
- application domain type
to query; must not be null.IllegalArgumentException
- if domain type
is null.QueryString(Class, boolean)
public QueryString(Class<?> domainType, boolean asCountQuery)
QueryString
initialized from the given domain type
,
which is used to construct an OQL SELECT query statement.
asCountQuery
is a Boolean
flag indicating whether to select a count or select the contents
of the objects for the given domain type
.domainType
- application domain type
to query; must not be null.asCountQuery
- boolean value to indicate if this is a count query.IllegalArgumentException
- if domain type
is null.asQuery(Class, boolean)
,
QueryString(String)
public static QueryString of(String query)
QueryString
initialized with the given query
.query
- String
containing the OQL query.QueryString
initialized with the given query
.IllegalArgumentException
- if query
is not specified.QueryString(String)
public static QueryString from(Class<?> domainType)
QueryString
initialized with
the given domain type
for which the query will be created.domainType
- domain object type
for which the query will be created.QueryString
initialized with the given query
.IllegalArgumentException
- if domain type
is null.QueryString(Class)
public static QueryString count(Class<?> domainType)
QueryString
initialized with
the given domain type
for which a count query will be created.domainType
- domain object type
for which the query will be created.QueryString
initialized with the given query
.IllegalArgumentException
- if domain type
is null.QueryString(Class)
public QueryString asDistinct()
query
is not already distinct; i.e. does not contain the DISTINCT keyword.query
does not contain
the DISTINCT keyword.String.replaceFirst(String, String)
,
asDistinct(String)
public QueryString bindIn(Collection<?> values)
Collection
of values into the IN parameters of the OQL Query by expanding
the given values into a comma-separated String
.values
- the values to bind, returns the QueryString
as is if null is given.public QueryString fromRegion(Class<?> domainClass, org.apache.geode.cache.Region<?,?> region)
domainClass
- type
of the persistent entity to query; must not be null.region
- Region
to query; must not be null.QueryString
with an OQL SELECT statement having a FROM clause
based on the selected Region
.Region
,
Class
public Iterable<Integer> getInParameterIndexes()
public QueryString orderBy(Sort sort)
Sort
order to this Pivotal GemFire OQL Query string.sort
- Sort
indicating the order of the query results.QueryString
with an ORDER BY clause if Sort
is not null,
or this QueryString
as-is if Sort
is null.Sort
,
QueryString
public QueryString withHints(String... hints)
hints
- array of Strings
containing query hints.QueryString
if hints are not null or empty, or return this QueryString
.public QueryString withImport(String importExpression)
importExpression
- String
containing the import clause.QueryString
if an import was declared, or return this QueryString
.public QueryString withLimit(Integer limit)
limit
- Integer
indicating the number of results to return from the query.QueryString
if a limit was specified, or return this QueryString
.public QueryString withTrace()
QueryString
with tracing enabled.public String toString()
String
representation of this QueryString
.toString
in class Object
String
representation of this QueryString
.Object.toString()
,
String
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.