public interface QueryStatement extends Cloneable
Sample code:
Calendar cal = ... Folder folder = ... QueryStatement qs = session.createQueryStatement("SELECT ?, ? FROM ? WHERE ? > TIMESTAMP ? AND IN_FOLDER(?) OR ? IN (?)"); qs.setProperty(1, "cmis:document", "cmis:name"); qs.setProperty(2, "cmis:document", "cmis:objectId"); qs.setType(3, "cmis:document"); qs.setProperty(4, "cmis:document", "cmis:creationDate"); qs.setDateTime(5, cal); qs.setId(6, folder); qs.setProperty(7, "cmis:document", "cmis:createdBy"); qs.setString(8, "bob", "tom", "lisa"); String statement = qs.toQueryString();
Modifier and Type | Method and Description |
---|---|
ItemIterable<QueryResult> |
query()
Executes the query with
searchAllVersions set to false . |
ItemIterable<QueryResult> |
query(boolean searchAllVersions)
Executes the query.
|
ItemIterable<QueryResult> |
query(boolean searchAllVersions,
OperationContext context)
Executes the query.
|
void |
setBoolean(int parameterIndex,
boolean... bool)
Sets the designated parameter to the given boolean.
|
void |
setDateTime(int parameterIndex,
Calendar... cal)
Sets the designated parameter to the given DateTime value.
|
void |
setDateTime(int parameterIndex,
Date... date)
Sets the designated parameter to the given DateTime value.
|
void |
setDateTime(int parameterIndex,
long... ms)
Sets the designated parameter to the given DateTime value.
|
void |
setDateTimeTimestamp(int parameterIndex,
Calendar... cal)
Sets the designated parameter to the given DateTime value with the prefix
'TIMESTAMP '.
|
void |
setDateTimeTimestamp(int parameterIndex,
Date... date)
Sets the designated parameter to the given DateTime value with the prefix
'TIMESTAMP '.
|
void |
setDateTimeTimestamp(int parameterIndex,
long... ms)
Sets the designated parameter to the given DateTime value with the prefix
'TIMESTAMP '.
|
void |
setId(int parameterIndex,
ObjectId... id)
Sets the designated parameter to the given object ID.
|
void |
setNumber(int parameterIndex,
Number... num)
Sets the designated parameter to the given number.
|
void |
setProperty(int parameterIndex,
PropertyDefinition<?> propertyDefinition)
Sets the designated parameter to the query name of the given property.
|
void |
setProperty(int parameterIndex,
String typeId,
String propertyId)
Sets the designated parameter to the query name of the given property.
|
void |
setString(int parameterIndex,
String... str)
Sets the designated parameter to the given string.
|
void |
setStringContains(int parameterIndex,
String str)
Sets the designated parameter to the given string in a CMIS contains
statement.
|
void |
setStringLike(int parameterIndex,
String str)
Sets the designated parameter to the given string.
|
void |
setType(int parameterIndex,
ObjectType type)
Sets the designated parameter to the query name of the given type.
|
void |
setType(int parameterIndex,
String typeId)
Sets the designated parameter to the query name of the given type ID.
|
void |
setUri(int parameterIndex,
URI... uri)
Sets the designated parameter to the given URI.
|
void |
setUrl(int parameterIndex,
URL... url)
Sets the designated parameter to the given URL.
|
String |
toQueryString()
Returns the query statement.
|
void setType(int parameterIndex, String typeId)
parameterIndex
- the parameter index (one-based)typeId
- the type IDvoid setType(int parameterIndex, ObjectType type)
parameterIndex
- the parameter index (one-based)type
- the object typevoid setProperty(int parameterIndex, String typeId, String propertyId)
parameterIndex
- the parameter index (one-based)propertyId
- the property IDvoid setProperty(int parameterIndex, PropertyDefinition<?> propertyDefinition)
parameterIndex
- the parameter index (one-based)propertyDefinition
- the property definitionvoid setNumber(int parameterIndex, Number... num)
parameterIndex
- the parameter index (one-based)num
- the numbervoid setString(int parameterIndex, String... str)
parameterIndex
- the parameter index (one-based)str
- the stringvoid setStringLike(int parameterIndex, String str)
parameterIndex
- the parameter index (one-based)str
- the LIKE stringvoid setStringContains(int parameterIndex, String str)
Note that the CMIS specification requires two levels of escaping. The first level escapes ', ", \ characters to \', \" and \\. The characters *, ? and - are interpreted as text search operators and are not escaped on first level. If *, ?, - shall be used as literals, they must be passed escaped with \*, \? and \- to this method.
For all statements in a CONTAINS() clause it is required to isolate those from a query statement. Therefore a second level escaping is performed. On the second level grammar ", ', - and \ are escaped with a \. See the spec for further details.
Summary:
input | first level escaping | second level escaping |
---|---|---|
* | * | * |
? | ? | ? |
- | - | - |
\ | \\ | \\\\ (for any other character following other than * ? -) |
\* | \* | \\* |
\? | \? | \\? |
\- | \- | \\-+ |
' | \' | \\\' |
" | \" | \\\" |
parameterIndex
- the parameter index (one-based)str
- the CONTAINS stringvoid setId(int parameterIndex, ObjectId... id)
parameterIndex
- the parameter index (one-based)id
- the object IDvoid setUri(int parameterIndex, URI... uri)
parameterIndex
- the parameter index (one-based)uri
- the URIvoid setUrl(int parameterIndex, URL... url)
parameterIndex
- the parameter index (one-based)url
- the URLvoid setBoolean(int parameterIndex, boolean... bool)
parameterIndex
- the parameter index (one-based)bool
- the booleanvoid setDateTime(int parameterIndex, Calendar... cal)
parameterIndex
- the parameter index (one-based)cal
- the DateTime value as Calendar objectvoid setDateTime(int parameterIndex, Date... date)
parameterIndex
- the parameter index (one-based)date
- the DateTime value as Date objectvoid setDateTime(int parameterIndex, long... ms)
parameterIndex
- the parameter index (one-based)ms
- the DateTime value in milliseconds from midnight, January 1,
1970 UTC.void setDateTimeTimestamp(int parameterIndex, Calendar... cal)
parameterIndex
- the parameter index (one-based)cal
- the DateTime value as Calendar objectvoid setDateTimeTimestamp(int parameterIndex, Date... date)
parameterIndex
- the parameter index (one-based)date
- the DateTime value as Date objectvoid setDateTimeTimestamp(int parameterIndex, long... ms)
parameterIndex
- the parameter index (one-based)ms
- the DateTime value in milliseconds from midnight, January 1,
1970 UTC.String toQueryString()
null
ItemIterable<QueryResult> query()
searchAllVersions
set to false
.Session.query(String, boolean)
ItemIterable<QueryResult> query(boolean searchAllVersions)
searchAllVersions
- true
if all document versions should be included in
the search results, false
if only the latest document
versions should be included in the search resultsSession.query(String, boolean)
ItemIterable<QueryResult> query(boolean searchAllVersions, OperationContext context)
searchAllVersions
- true
if all document versions should be included in
the search results, false
if only the latest document
versions should be included in the search resultscontext
- the operation context to useSession.query(String, boolean, OperationContext)
Copyright © 2009–2017 The Apache Software Foundation. All rights reserved.