Class QueryUriBuilder

java.lang.Object
com.sodius.oslc.core.process.query.QueryUriBuilder

public class QueryUriBuilder extends Object
A builder that adds OSLC query parameters to URIs.
Since:
3.6.0
  • Field Details

    • WILDCARD

      public static final QName WILDCARD
      The wildcard property ("*") that may be used in oslc.select, oslc.properties and oslc.where parameters.
  • Method Details

    • create

      public static QueryUriBuilder create()
      Creates a new builder instance. The builder will use well-known namespaces for the oslc.prefix parameter if namespace bindings are not added.
      Returns:
      a URI builder
      See Also:
    • create

      public static QueryUriBuilder create(OslcNamespaces namespaces)
      Creates a new builder instance based on the given namespaces. The namespaces are used for the oslc.prefix parameter if namespace bindings are not added.
      Parameters:
      namespaces - namespaces to used for the oslc.prefix parameter
      Returns:
      a URI builder
      Throws:
      NullPointerException - if namespaces is null
    • prefix

      public QueryUriBuilder prefix(String prefix, String namespace)
      Registers a prefix to associate to a namespace, to inject in the oslc.prefix parameter.
      Parameters:
      prefix - the prefix to associate to a namespace
      namespace - a namespace
      Returns:
      this builder instance
      Throws:
      NullPointerException - if prefix or namespace is null
    • prefix

      public QueryUriBuilder prefix(Namespace... namespaces)
      Registers prefixes to associate to namespaces, to inject in the oslc.prefix parameter.
      Parameters:
      namespaces - prefix/namespace bindings
      Returns:
      this builder instance
    • where

      public QueryWhereBuilder where(QName property)
      Creates an oslc.where builder with the given property.

      The property must contain a namespace and a local part. It may also contain a prefix which, if present, is automatically registered in the oslc.prefix parameter. The property may also be WILDCARD to match all properties.

      Calling this method is for initializing the oslc.where parameter. Use and(QName) for adding another where term in the expression.

      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
    • where

      public QueryWhereBuilder where(URI property)
      Creates an oslc.where builder with the given property.

      Calling this method is for initializing the oslc.where parameter. Use and(QName) for adding another where term in the expression.

      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
      IllegalArgumentException - if the URI is not absolute
    • where

      public QueryWhereBuilder where(String property)
      Creates an oslc.where builder with the given property, represented as String URI. The property may also be a wildcard ("*")

      Calling this method is for initializing the oslc.where parameter. Use and(String) for adding another where term in the expression.

      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
      IllegalArgumentException - if the URI is not absolute
    • and

      public QueryWhereBuilder and(QName property)
      Creates a builder to append the given property with a and operator in the current oslc.where expression.

      The property must contain a namespace and a local part. It may also contain a prefix which, if present, is automatically registered in the oslc.prefix parameter.

      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
      IllegalArgumentException - if where(QName) was not called first to record a term
    • and

      public QueryWhereBuilder and(URI property)
      Creates a builder to append the given property with a and operator in the current oslc.where expression.
      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
      IllegalArgumentException - if the URI is not absolute or where(URI) was not called first to record a term
    • and

      public QueryWhereBuilder and(String property)
      Creates a builder to append the given property, represented as String URI, with a and operator in the current oslc.where expression. The property may also be a wildcard ("*")
      Parameters:
      property - the property to use in in oslc.where parameter
      Returns:
      a new term builder instance
      Throws:
      NullPointerException - if property is null
      IllegalArgumentException - if the URI is not absolute or where(String) was not called first to record a term
    • searchTerms

      public QueryUriBuilder searchTerms(String... terms)
      Adds search terms in the oslc.searchTerms parameter.
      Parameters:
      terms - search terms
      Returns:
      this builder instance
    • orderBy

      public QueryUriBuilder orderBy(QName property, OrderByType type)
      Adds a property in the oslc.orderBy parameter.

      The property must contain a namespace and a local part. It may also contain a prefix which, if present, is automatically registered in the oslc.prefix parameter.

      Parameters:
      property - the property to use in oslc.orderBy
      type - the type of ordering
      Returns:
      this builder instance
      Throws:
      NullPointerException - if property or type is null
    • orderBy

      public QueryUriBuilder orderBy(URI property, OrderByType type)
      Adds a property, represented as a URI, in the oslc.orderBy parameter.
      Parameters:
      property - the property to add in oslc.orderBy
      type - the type of ordering
      Returns:
      this builder instance
      Throws:
      NullPointerException - if property or type is null
      IllegalArgumentException - if the URI is not absolute
    • orderBy

      public QueryUriBuilder orderBy(String property, OrderByType type)
      Adds a property, represented as a String URI, in the oslc.orderBy parameter.
      Parameters:
      property - the property to add in oslc.orderBy
      type - the type of ordering
      Returns:
      this builder instance
      Throws:
      NullPointerException - if property or type is null
      IllegalArgumentException - if the URI is not absolute
    • properties

      public QueryUriBuilder properties(QName... properties)
      Adds properties in the oslc.properties parameter.

      The property must contain a namespace and a local part. It may also contain a prefix which, if present, is automatically registered in the oslc.prefix parameter. The property may also be WILDCARD to select all properties.

      Parameters:
      properties - properties to add in oslc.properties
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the QNames do not have a namespace and local part
    • properties

      public QueryUriBuilder properties(URI... properties)
      Adds properties, represented as URIs, in the oslc.properties parameter.
      Parameters:
      properties - properties to add in oslc.properties
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the URIs are not absolute
    • properties

      public QueryUriBuilder properties(String... properties)
      Adds properties, represented as String URIs, in the oslc.properties parameter. The property may also be a wildcard ("*")
      Parameters:
      properties - properties to add in oslc.properties
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the URIs are not absolute
    • select

      public QueryUriBuilder select(QName... properties)
      Adds properties in the oslc.select parameter.

      The property must contain a namespace and a local part. It may also contain a prefix which, if present, is automatically registered in the oslc.prefix parameter. The property may also be WILDCARD to select all properties.

      Parameters:
      properties - properties to add in oslc.select
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the QNames do not have a namespace and local part
    • select

      public QueryUriBuilder select(URI... properties)
      Adds properties, represented as URIs, in the oslc.select parameter.
      Parameters:
      properties - properties to add in oslc.select
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the URIs are not absolute
    • select

      public QueryUriBuilder select(String... properties)
      Adds properties, represented as String URIs, in the oslc.select parameter. The property may also be a wildcard ("*")
      Parameters:
      properties - properties to add in oslc.select
      Returns:
      this builder instance
      Throws:
      IllegalArgumentException - if the URIs are not absolute
    • paging

      public QueryUriBuilder paging(boolean paging)
      Indicates whether paging is to use as oslc.paging parameter. Setting false removes the current page size, if any.
      Parameters:
      paging - true to use paging, false otherwise
      Returns:
      this builder instance
    • pageSize

      public QueryUriBuilder pageSize(int pageSize)
      Defines the desired page size as oslc.pageSize parameter. Setting a page size also sets oslc.paging to true.
      Parameters:
      pageSize - the desired page size.
      Returns:
      this builder instance
    • build

      public URI build(URI baseUri)
      Builds a URI, by completing the given base URI with OSLC query parameters registered on this builder instance.
      Parameters:
      baseUri - the URI on which to append query parameters
      Returns:
      the URI including OSLC query parameters.
      Throws:
      NullPointerException - if baseUri is null
      See Also:
    • build

      public URI build(UriBuilder builder)
      Builds a URI, by completing the given URI builder with OSLC query parameters registered on this builder instance.
      Parameters:
      builder - the builder on which to append query parameters
      Returns:
      the URI including OSLC query parameters.
      Throws:
      NullPointerException - if builder is null
      See Also:
    • buildPostEntity

      public String buildPostEntity()
      Builds a application/x-www-form-urlencoded body that contains the OSLC query parameters registered on this builder instance. This body is to be used as a POST request entity on a query capability, when parameters are too long for a GET request.
      Returns:
      a application/x-www-form-urlencoded body including OSLC query parameters.
      See Also: