Class QueryParameters
- Since:
- 3.6.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder to parse OSLC query parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplySelectedProperties(HttpServletRequest request, Class<?> resourceShape) Configures the request to support selective properties, to enable clients to retrieve only selected property values.from(HttpServletRequest request, QueryParameter... scope) Creates a builder to parse OSLC query parameters, controlled by the given scope.Returns the order by clause parsed from theoslc.orderByparameter, or an empty optional if absent.Returns theoslc.pageSizeparameter, or an empty optional if absent.Returns the map of prefix/namespace mappings defined in theoslc.prefixparameter, or an empty map if absent.Returns the properties clause parsed from theoslc.propertiesparameter, or an empty optional if absent.Returns a predicate to test whether a given property is part of the ones set in theoslc.propertiesparameter.Returns the search terms clause parsed from theoslc.searchTermsparameter, or an empty optional if absent.Returns the select clause parsed from theoslc.selectparameter, or an empty optional if absent.Returns the selected properties, as found on theoslc.selectparameter.Returns a predicate to test whether a given property is part of the ones set in theoslc.selectparameter.getWhere()Returns the where clause parsed from theoslc.whereparameter, or an empty optional if absent.booleanisPaging()Returns theoslc.pagingparameter, orfalseif absent
-
Method Details
-
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
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
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
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:
-
getSearchTerm
Returns the search terms clause parsed from theoslc.searchTermsparameter, or an empty optional if absent.- Returns:
- the parsed search terms clause
-
getOrderBy
Returns the order by clause parsed from theoslc.orderByparameter, or an empty optional if absent.- Returns:
- the parsed order by clause
-
getProperties
Returns the properties clause parsed from theoslc.propertiesparameter, or an empty optional if absent.- Returns:
- the parsed properties clause
-
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
Returns the select clause parsed from theoslc.selectparameter, or an empty optional if absent.- Returns:
- the parsed select clause
-
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
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
-
getPageSize
Returns theoslc.pageSizeparameter, or an empty optional if absent.- Returns:
- the
oslc.pageSizeparameter
-