Class QueryUtils


  • public class QueryUtils
    extends Object
    Utility methods for parsing various OSLC HTTP query parameter clauses; e.g. oslc.where
    • Field Detail

      • WILDCARD_PROPERTY_LIST

        public static final Properties WILDCARD_PROPERTY_LIST
        A property list that selects all properties
    • Constructor Detail

      • QueryUtils

        public QueryUtils()
    • Method Detail

      • parsePrefixes

        public static Map<String,​String> parsePrefixes​(String prefixExpression)
                                                      throws ParseException
        Parse a oslc.prefix clause into a map between prefixes and corresponding URIs

        Note: Object.toString() of result has been overridden to return input expression.

        Parameters:
        prefixExpression - the oslc.prefix expression
        Returns:
        the prefix map
        Throws:
        ParseException
      • parseWhere

        public static WhereClause parseWhere​(String whereExpression,
                                             Map<String,​String> prefixMap)
                                      throws ParseException
        Parse a oslc.where expression
        Parameters:
        whereExpression - contents of an oslc.where HTTP query parameter
        prefixMap - map between XML namespace prefixes and associated URLs
        Returns:
        the parsed where clause
        Throws:
        ParseException
      • parseSelect

        public static SelectClause parseSelect​(String selectExpression,
                                               Map<String,​String> prefixMap)
                                        throws ParseException
        Parse a oslc.select expression
        Parameters:
        selectExpression - contents of an oslc.select HTTP query parameter
        prefixMap - map between XML namespace prefixes and associated URLs
        Returns:
        the parsed select clause
        Throws:
        ParseException
      • parseProperties

        public static PropertiesClause parseProperties​(String propertiesExpression,
                                                       Map<String,​String> prefixMap)
                                                throws ParseException
        Parse a oslc.properties expression
        Parameters:
        propertiesExpression - contents of an oslc.properties HTTP query parameter
        prefixMap - map between XML namespace prefixes and associated URLs
        Returns:
        the parsed properties clause
        Throws:
        ParseException
      • parseOrderBy

        public static OrderByClause parseOrderBy​(String orderByExpression,
                                                 Map<String,​String> prefixMap)
                                          throws ParseException
        Parse a oslc.orderBy expression
        Parameters:
        orderByExpression - contents of an oslc.orderBy HTTP query parameter
        prefixMap - map between XML namespace prefixes and associated URLs
        Returns:
        the parsed order by clause
        Throws:
        ParseException
      • invertSelectedProperties

        public static Map<String,​Object> invertSelectedProperties​(Properties properties)
        Create a map representation of the Properties returned from parsing oslc.properties or oslc.select URL query parameters suitable for generating a property result from an HTTP GET request.

        The map keys are the property names; i.e. the local name of the property concatenated to the XML namespace of the property. The values of the map are:

        • Wildcard, if all properties at this level are to be output. No recursion below this level is to be done.
        • OSLC4JConstants.OSL4J_PROPERTY_SINGLETON - if only the named property is to be output, without recursion
        • a nested property list to recurse through
        Parameters:
        properties -
        Returns:
        the property map
      • parseSearchTerms

        public static SearchTermsClause parseSearchTerms​(String searchTermsExpression)
                                                  throws ParseException
        Parse an oslc.searchTerms expression

        Note: Object.toString() of result has been overridden to return input expression.

        Parameters:
        searchTermsExpression - contents of an oslc.searchTerms HTTP query parameter
        Returns:
        the parsed search terms clause
        Throws:
        ParseException