Class QueryParameters
- java.lang.Object
-
- com.sodius.oslc.server.process.query.QueryParameters
-
public class QueryParameters extends Object
OSLC query parameters parsed from an HTTP request.- Since:
- 3.6.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueryParameters.QueryParametersBuilderA builder to parse OSLC query parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidapplySelectedProperties(HttpServletRequest request, Class<?> resourceShape)Configures the request to support selective properties, to enable clients to retrieve only selected property values.static QueryParameters.QueryParametersBuilderfrom(HttpServletRequest request, QueryParameter... scope)Creates a builder to parse OSLC query parameters, controlled by the given scope.Optional<OrderByClause>getOrderBy()Returns the order by clause parsed from theoslc.orderByparameter, or an empty optional if absent.Optional<Integer>getPageSize()Returns theoslc.pageSizeparameter, or an empty optional if absent.Map<String,String>getPrefixes()Returns the map of prefix/namespace mappings defined in theoslc.prefixparameter, or an empty map if absent.Optional<PropertiesClause>getProperties()Returns the properties clause parsed from theoslc.propertiesparameter, or an empty optional if absent.Predicate<Object>getPropertiesPredicate()Returns a predicate to test whether a given property is part of the ones set in theoslc.propertiesparameter.Optional<SearchTermsClause>getSearchTerm()Returns the search terms clause parsed from theoslc.searchTermsparameter, or an empty optional if absent.Optional<SelectClause>getSelect()Returns the select clause parsed from theoslc.selectparameter, or an empty optional if absent.Map<String,Object>getSelectInvertedProperties()Returns the selected properties, as found on theoslc.selectparameter.Predicate<Object>getSelectPredicate()Returns a predicate to test whether a given property is part of the ones set in theoslc.selectparameter.Optional<WhereClause>getWhere()Returns the where clause parsed from theoslc.whereparameter, or an empty optional if absent.booleanisPaging()Returns theoslc.pagingparameter, orfalseif absent
-
-
-
Method Detail
-
from
public static QueryParameters.QueryParametersBuilder from(HttpServletRequest request, QueryParameter... scope)
Creates a builder to parse OSLC query parameters, controlled by the given scope.The given array of parameters is to restrict which ones are parsed from the HTTP request. Any parameter not listed here is ignored, i.e. the parameter is not parsed from the HTTP request even if present. If the array is empty, all known parameters are parsed.
To use only selective properties for a GET end-point, you may prefer using
applySelectedProperties(HttpServletRequest, Class). To use only selective properties for a PUT end-point, you may prefer usingOslcProperties.of(HttpServletRequest).- Parameters:
request- the HTTP requestscope- the OSLC query parameters to parse- Returns:
- a new builder instance
- Throws:
NullPointerException- if request is null
-
applySelectedProperties
public static void applySelectedProperties(HttpServletRequest request, Class<?> resourceShape)
Configures the request to support selective properties, to enable clients to retrieve only selected property values. This method shall be called on a GET end-point before responding with a given resource.This method parses the
oslc.selectandoslc.prefixparameters and sets the"org.eclipse.lyo.oslc4j.selected.properties"attribute on the request. This makes the XML and JSON serializers to respond only with properties that match the selected ones.The prefixes used in the
oslc.selectexpression are resolved to namespaces using theoslc.prefixparameter, if any, but also with ones defined on theOslcSchemaof the given resource shape and, last, with well known OSLC prefixes (RDF, OSLC Core, etc.).- Parameters:
request- the HTTP requestresourceShape- the type of resource responded by the GET end-point, to determine the OSLC prefixes that can be used- Throws:
NullPointerException- if request or resourceShape is null
-
getPrefixes
public Map<String,String> getPrefixes()
Returns the map of prefix/namespace mappings defined in theoslc.prefixparameter, or an empty map if absent.- Returns:
- an unmodifiable map of prefix/namespace mappings
-
getWhere
public Optional<WhereClause> getWhere()
Returns the where clause parsed from theoslc.whereparameter, or an empty optional if absent.The where clause can then be processed using a
QueryWhereHandler.- Returns:
- the parsed where clause
- See Also:
QueryWhereHandler
-
getSearchTerm
public Optional<SearchTermsClause> getSearchTerm()
Returns the search terms clause parsed from theoslc.searchTermsparameter, or an empty optional if absent.- Returns:
- the parsed search terms clause
-
getOrderBy
public Optional<OrderByClause> getOrderBy()
Returns the order by clause parsed from theoslc.orderByparameter, or an empty optional if absent.- Returns:
- the parsed order by clause
-
getProperties
public Optional<PropertiesClause> getProperties()
Returns the properties clause parsed from theoslc.propertiesparameter, or an empty optional if absent.- Returns:
- the parsed properties clause
-
getPropertiesPredicate
public Predicate<Object> getPropertiesPredicate()
Returns a predicate to test whether a given property is part of the ones set in theoslc.propertiesparameter. If the parameter is absent or is a wildcard ("*"), the predicate returnstrue.The property used as predicate argument can be either:
- a
URI- the namespace and local part of a property (e.g.http://purl.org/dc/terms/title) - a
String- either a URI string (e.g.http://purl.org/dc/terms/title) or prefixed name (e.g.dcterms:title) - a
javax.xml.namespace.QName- either a namespace and local part (e.g.http://purl.org/dc/terms/title) or prefix and local part (e.g.dcterms:title)
- Returns:
- a predicate to test whether a given property is accepted
- a
-
getSelect
public Optional<SelectClause> getSelect()
Returns the select clause parsed from theoslc.selectparameter, or an empty optional if absent.- Returns:
- the parsed select clause
-
getSelectInvertedProperties
public Map<String,Object> getSelectInvertedProperties()
Returns the selected properties, as found on theoslc.selectparameter. The returned map can be set either:- as
"org.eclipse.lyo.oslc4j.selected.properties"attribute on the request (you may prefer usingapplySelectedProperties(HttpServletRequest, Class)for this) - as
propertiesargument ofResponseInfoCollectionorResponseInfoArray
- Returns:
- the selected properties found on the
oslc.selectparameter
- as
-
getSelectPredicate
public Predicate<Object> getSelectPredicate()
Returns a predicate to test whether a given property is part of the ones set in theoslc.selectparameter. If the parameter is absent or is a wildcard ("*"), the predicate returnstrue.The property used as predicate argument can be either:
- a
URI- the namespace and local part of a property (e.g.http://purl.org/dc/terms/title) - a
String- either a URI string (e.g.http://purl.org/dc/terms/title) or prefixed name (e.g.dcterms:title) - a
javax.xml.namespace.QName- either a namespace and local part (e.g.http://purl.org/dc/terms/title) or prefix and local part (e.g.dcterms:title)
- Returns:
- a predicate to test whether a given property is accepted
- a
-
isPaging
public boolean isPaging()
Returns theoslc.pagingparameter, orfalseif absent- Returns:
- the
oslc.pagingparameter
-
-