Package org.restlet.ext.odata
Class Query<T>
- java.lang.Object
-
- org.restlet.ext.odata.Query<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
java.lang.Iterable<T>
public class Query<T> extends java.lang.Object implements java.lang.Iterable<T>
Specific query to a OData service, represents a particular HTTP request to a data service. This Java class is more or less equivalent to the WCF DataServiceQuery class.
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_COMPLEX_TYPE_OR_PROPERTY
Type of query: complex type or property.static int
TYPE_COMPLEX_TYPE_PROPERTY
Type of query: property.static int
TYPE_COMPLEX_TYPE_PROPERTY5
Type of query: property bis??static int
TYPE_ENTITY
Type of query: entity.static int
TYPE_ENTITY_SET
Type of query: entity set.static int
TYPE_LINKS
Type of query: links.static int
TYPE_PROPERTY_VALUE
Type of query: property value.static int
TYPE_UNKNOWN
Type of query: unknown.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Query<T>
addParameter(java.lang.String name, java.lang.String value)
Creates a new Query with the query parameter set in the URI generated by the returned query.Query<T>
addParameters(org.restlet.util.Series<org.restlet.data.Parameter> params)
Creates a new Query with the query parameter set in the URI generated by the returned query.protected java.lang.String
createTargetUri()
Returns the complete target URI reference for this query.void
execute()
Executes the query.Query<T>
expand(java.lang.String path)
Creates a new Query with the $expand option set in the URI generated by the returned query.Query<T>
filter(java.lang.String predicate)
Creates a new Query with the $filter option set in the URI generated by the returned query.int
getCount()
Returns the total number of elements in the entity set, or -1 if it is available.org.restlet.data.Reference
getNextPage()
Return the reference to the next page (used in server-paging mode).Service
getService()
Returns the parent client service.java.lang.String
getSubpath()
Returns the path of the targeted entity relatively to the data service URI.Query<T>
inlineCount(boolean inlineCount)
Creates a new Query with the $inlinecount option set in the URI generated by the returned query.java.util.Iterator<T>
iterator()
Returns an iterator over a set of elements of type T.Query<T>
orderBy(java.lang.String criteria)
Creates a new Query with the $orderby option set in the URI generated by the returned query.Query<T>
select(java.lang.String select)
Creates a new Query with the $select option set in the URI generated by the returned query.void
setNextPage(org.restlet.data.Reference nextPage)
Sets the reference to the next page (used in server-paging mode).void
setQuery(java.lang.String query)
Sets the query string of the request.Query<T>
skip(int rowsCount)
Creates a new Query with the $skip option set in the URI generated by the returned query.Query<T>
skipToken(java.lang.String token)
Creates a new Query with the $skiptoken option set in the URI generated by the returned query.Query<T>
top(int rowsCount)
Creates a new Query with the $top option set in the URI generated by the returned query.
-
-
-
Field Detail
-
TYPE_COMPLEX_TYPE_OR_PROPERTY
public static final int TYPE_COMPLEX_TYPE_OR_PROPERTY
Type of query: complex type or property.- See Also:
- Constant Field Values
-
TYPE_COMPLEX_TYPE_PROPERTY
public static final int TYPE_COMPLEX_TYPE_PROPERTY
Type of query: property.- See Also:
- Constant Field Values
-
TYPE_COMPLEX_TYPE_PROPERTY5
public static final int TYPE_COMPLEX_TYPE_PROPERTY5
Type of query: property bis??- See Also:
- Constant Field Values
-
TYPE_ENTITY
public static final int TYPE_ENTITY
Type of query: entity.- See Also:
- Constant Field Values
-
TYPE_ENTITY_SET
public static final int TYPE_ENTITY_SET
Type of query: entity set.- See Also:
- Constant Field Values
-
TYPE_LINKS
public static final int TYPE_LINKS
Type of query: links.- See Also:
- Constant Field Values
-
TYPE_PROPERTY_VALUE
public static final int TYPE_PROPERTY_VALUE
Type of query: property value.- See Also:
- Constant Field Values
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
Type of query: unknown.- See Also:
- Constant Field Values
-
-
Method Detail
-
addParameter
public Query<T> addParameter(java.lang.String name, java.lang.String value)
Creates a new Query with the query parameter set in the URI generated by the returned query.- Parameters:
name
- The string value that contains the name of the query string option to add.value
- The value of the query string option.- Returns:
- A new Query with the query parameter set in the URI generated by the returned query.
-
addParameters
public Query<T> addParameters(org.restlet.util.Series<org.restlet.data.Parameter> params)
Creates a new Query with the query parameter set in the URI generated by the returned query.- Parameters:
params
- the set of name/value pairs to add to the query string- Returns:
- A new Query with the query parameter set in the URI generated by the returned query.
-
createTargetUri
protected java.lang.String createTargetUri()
Returns the complete target URI reference for this query. It is composed of the data service base URI, the subpath and the query string.- Returns:
- The complete target URI reference.
-
execute
public void execute() throws java.lang.Exception
Executes the query.- Throws:
java.lang.Exception
-
expand
public Query<T> expand(java.lang.String path)
Creates a new Query with the $expand option set in the URI generated by the returned query.- Parameters:
path
- A string value that contains the requesting URI.- Returns:
- A new Query with the $expand option set in the URI generated by the returned query.
-
filter
public Query<T> filter(java.lang.String predicate)
Creates a new Query with the $filter option set in the URI generated by the returned query.- Parameters:
predicate
- A string value that contains the predicate used to filter the data.- Returns:
- A new Query with the $filter option set in the URI generated by the returned query.
-
getCount
public int getCount()
Returns the total number of elements in the entity set, or -1 if it is available.- Returns:
- The total number of elements in the entity set.
- Throws:
java.lang.Exception
-
getNextPage
public org.restlet.data.Reference getNextPage()
Return the reference to the next page (used in server-paging mode).- Returns:
- The reference to the next page (used in server-paging mode).
-
getService
public Service getService()
Returns the parent client service.- Returns:
- The parent client service.
-
getSubpath
public java.lang.String getSubpath()
Returns the path of the targeted entity relatively to the data service URI.- Returns:
- The path of the targeted entity relatively to the data service URI.
-
inlineCount
public Query<T> inlineCount(boolean inlineCount)
Creates a new Query with the $inlinecount option set in the URI generated by the returned query.- Parameters:
inlineCount
- True if the total number of entities in the entity set must be returned.- Returns:
- A new Query with the $inlinecount option set in the URI generated by the returned query.
-
iterator
public java.util.Iterator<T> iterator()
Returns an iterator over a set of elements of type T. It returns null if the query does not retrieve elements.- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- an Iterator or null if the query does not retrieve elements.
-
orderBy
public Query<T> orderBy(java.lang.String criteria)
Creates a new Query with the $orderby option set in the URI generated by the returned query.- Parameters:
criteria
- A string value that contains the criteria used to order the results.- Returns:
- A new Query with the $orderby option set in the URI generated by the returned query.
-
select
public Query<T> select(java.lang.String select)
Creates a new Query with the $select option set in the URI generated by the returned query.- Parameters:
select
- A string value that contains the requesting URI.- Returns:
- A new Query with the $select option set in the URI generated by the returned query.
-
setNextPage
public void setNextPage(org.restlet.data.Reference nextPage)
Sets the reference to the next page (used in server-paging mode).- Parameters:
nextPage
- The reference to the next page.
-
setQuery
public void setQuery(java.lang.String query)
Sets the query string of the request.- Parameters:
query
- The query string of the request.
-
skip
public Query<T> skip(int rowsCount)
Creates a new Query with the $skip option set in the URI generated by the returned query.- Parameters:
rowsCount
- A number of rows to skip.- Returns:
- A new Query with the $skip option set in the URI generated by the returned query.
-
skipToken
public Query<T> skipToken(java.lang.String token)
Creates a new Query with the $skiptoken option set in the URI generated by the returned query.- Parameters:
token
- A string value that contains the requesting URI.- Returns:
- A new Query with the $skiptoken option set in the URI generated by the returned query.
-
-