Interface QueryLanguageProvider<T>
-
@ConsumerType public interface QueryLanguageProvider<T>
The JCR query provider supports querying based on the JCR spec. Calls fromResourceResolver.findResources(String, String)
andResourceResolver.queryResources(String, String)
are passed on to this object.- Since:
- 1.0.0 (Sling API Bundle 2.11.0)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Iterator<Resource>
findResources(@NotNull ResolveContext<T> ctx, java.lang.String query, java.lang.String language)
Searches for resources using the given query formulated in the given language.java.lang.String[]
getSupportedLanguages(@NotNull ResolveContext<T> ctx)
The supported languages of the resource provider.java.util.Iterator<ValueMap>
queryResources(@NotNull ResolveContext<T> ctx, java.lang.String query, java.lang.String language)
Queries the storage using the given query formulated in the given language.
-
-
-
Method Detail
-
getSupportedLanguages
java.lang.String[] getSupportedLanguages(@NotNull @NotNull ResolveContext<T> ctx)
The supported languages of the resource provider.- Parameters:
ctx
- The resolve context- Returns:
- The array of supported languages
-
findResources
java.util.Iterator<Resource> findResources(@NotNull @NotNull ResolveContext<T> ctx, java.lang.String query, java.lang.String language)
Searches for resources using the given query formulated in the given language.The semantic meaning of the query and language depend on the actual implementation and storage used for the resources. For JCR repository being used as storage, the query and language parameters are used to create a JCR
Query
through theQueryManager
. The result returned is then based on theNodeIterator
provided by the query result.- Parameters:
ctx
- The resolve contextquery
- The query string to use to find the resources.language
- The language in which the query is formulated.- Returns:
- An
Iterator
ofResource
objects matching the query. If no resources match,null
might be returned instead of an empty iterator. - Throws:
QuerySyntaxException
- If the query is not syntactically correct according to the query language indicator or if the query language is not supported as specified ingetSupportedLanguages(ResolveContext)
.SlingException
- If an error occurs querying for the resources.java.lang.IllegalStateException
- if this resource provider has already been closed.
-
queryResources
java.util.Iterator<ValueMap> queryResources(@NotNull @NotNull ResolveContext<T> ctx, java.lang.String query, java.lang.String language)
Queries the storage using the given query formulated in the given language.The semantic meaning of the query and language depend on the actual implementation and storage used for the resources. For JCR repository being used as storage, the query and language parameters are used to create a JCR
Query
through theQueryManager
. The result returned is then based on theRowIterator
provided by the query result. The map returned for each row is indexed by the column name and the column value is the JCRValue
object converted into the respective Java object, such asBoolean
for a value of property type Boolean.- Parameters:
ctx
- The resolve contextquery
- The query string to use to find the resources.language
- The language in which the query is formulated.- Returns:
- An
Iterator
ofMap
instances providing access to the query result. If no resources match,null
might be returned instead of an empty iterator. - Throws:
QuerySyntaxException
- If the query is not syntactically correct according to the query language indicator or if the query language is not supported as specified ingetSupportedLanguages(ResolveContext)
.SlingException
- If an error occurs querying for the resources.java.lang.IllegalStateException
- if this resource provider has already been closed.
-
-