org.apache.olingo.odata2.api.uri

## Class UriParser

- java.lang.Object
- - org.apache.olingo.odata2.api.uri.UriParser

-     public abstract class UriParser
      extends Object

  Wrapper for UriParser functionality.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UriParser()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract ExpandSelectTreeNode` | `buildExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand)` Creates an optimized expression tree out of $expand and $select expressions.
    `protected abstract PathSegment` | `buildPathSegment(String path, Map<String,List<String>> matrixParameters)` Creates an path segment object.
    `static ExpandSelectTreeNode` | `createExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand)` Creates an optimized expression tree out of $expand and $select expressions.
    `static PathSegment` | `createPathSegment(String path, Map<String,List<String>> matrixParameters)` Creates an path segment object.
    `abstract List<KeyPredicate>` | `getKeyFromEntityLink(EdmEntitySet entitySet, String entityLink, URI serviceRoot)` Retrieves the key predicates from a canonical link to an entity.
    `static List<KeyPredicate>` | `getKeyPredicatesFromEntityLink(EdmEntitySet entitySet, String entityLink, URI serviceRoot)` Retrieves the key predicates from a canonical link to an entity.
    `static UriInfo` | `parse(Edm edm, List<PathSegment> pathSegments, Map<String,String> queryParameters)` Parses path segments and query parameters for the given EDM.
    `static UriInfo` | `parse(Edm edm, List<PathSegment> pathSegments, Map<String,String> queryParameters, boolean strictFilter)` Parses path segments and query parameters for the given EDM.
    `abstract UriInfo` | `parse(List<PathSegment> pathSegments, Map<String,String> queryParameters)` Parses path segments and query parameters.
    `abstract UriInfo` | `parse(List<PathSegment> pathSegments, Map<String,String> queryParameters, boolean strictFilter)` Parses path segments and query parameters.
    `abstract UriInfo` | `parseAll(List<PathSegment> pathSegments, Map<String,List<String>> allQueryParameters)` Parses path segments and query parameters.
    `static FilterExpression` | `parseFilter(Edm edm, EdmEntityType edmType, String expression)` Parses a $filter expression string and create an expression tree.
    `abstract FilterExpression` | `parseFilterString(EdmEntityType edmType, String expression)` Parses a $filter expression string and create an expression tree.
    `static OrderByExpression` | `parseOrderBy(Edm edm, EdmEntityType edmType, String expression)` Parses a $orderby expression string and creates an expression tree.
    `abstract OrderByExpression` | `parseOrderByString(EdmEntityType edmType, String expression)` Parses a $orderby expression string and creates an expression tree.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UriParser

          public UriParser()

  - ### Method Detail

    - #### parse

          public static UriInfo parse(Edm edm,
                                      List<PathSegment> pathSegments,
                                      Map<String,String> queryParameters)
                               throws ODataException

      Parses path segments and query parameters for the given EDM.
      Parameters:
        `edm` - Entity Data Model
        `pathSegments` - list of path segments
        `queryParameters` - query parameters
      Returns:
        `UriInfo` information about the parsed URI
      Throws:
        `ODataException`

    - #### parse

          public static UriInfo parse(Edm edm,
                                      List<PathSegment> pathSegments,
                                      Map<String,String> queryParameters,
                                      boolean strictFilter)
                               throws ODataException

      Parses path segments and query parameters for the given EDM. Will not be available in higher versions
      Parameters:
        `edm` - Entity Data Model
        `pathSegments` - list of path segments
        `queryParameters` - query parameters
        `strictFilter` - for URI Parsing of filter parameters
      Returns:
        `UriInfo` information about the parsed URI
      Throws:
        `ODataException`

    - #### parse

          public abstract UriInfo parse(List<PathSegment> pathSegments,
                                        Map<String,String> queryParameters)
                                 throws UriSyntaxException,
                                        UriNotMatchingException,
                                        EdmException

      Parses path segments and query parameters. This method ignores redundant system query parameters.
      Parameters:
        `pathSegments` - list of path segments
        `queryParameters` - query parameters
      Returns:
        `UriInfo` information about the parsed URI
      Throws:
        `UriSyntaxException`
        `UriNotMatchingException`
        `EdmException`

    - #### parse

          public abstract UriInfo parse(List<PathSegment> pathSegments,
                                        Map<String,String> queryParameters,
                                        boolean strictFilter)
                                 throws UriSyntaxException,
                                        UriNotMatchingException,
                                        EdmException

      Parses path segments and query parameters. This method ignores redundant system query parameters.
      Parameters:
        `pathSegments` - list of path segments
        `queryParameters` - query parameters
        `strictFilter` - for URI Parsing of filter parameters
      Returns:
        `UriInfo` information about the parsed URI
      Throws:
        `UriSyntaxException`
        `UriNotMatchingException`
        `EdmException`

    - #### parseAll

          public abstract UriInfo parseAll(List<PathSegment> pathSegments,
                                           Map<String,List<String>> allQueryParameters)
                                    throws UriSyntaxException,
                                           UriNotMatchingException,
                                           EdmException

      Parses path segments and query parameters. Throws an exception if there are redundant system query parameters.
      Parameters:
        `pathSegments` - list of path segments
        `queryParameters` - query parameters
      Returns:
        `UriInfo` information about the parsed URI
      Throws:
        `UriSyntaxException`
        `UriNotMatchingException`
        `EdmException`

    - #### parseFilter

          public static FilterExpression parseFilter(Edm edm,
                                                     EdmEntityType edmType,
                                                     String expression)
                                              throws ExpressionParserException,
                                                     ODataMessageException

      Parses a $filter expression string and create an expression tree.

      The current expression parser supports expressions as defined in the OData specification 2.0 with the following restrictions:

      - the methods "cast", "isof" and "replace" are not supported

      The expression parser can be used with providing an Entity Data Model (EDM) and without providing it. When an EDM is provided the expression parser will be as strict as possible. That means:

      - All properties used in the expression must be defined inside the EDM,
      - the types of EDM properties will be checked against the lists of allowed types per method and per binary or unary operator, respectively
      If no EDM is provided the expression parser performs a lax validation:
      - The properties used in the expression are not looked up inside the EDM and the type of the expression node representing the property will be "null",
      - expression nodes with EDM type "null" are not considered during the parameter type validation, so the return type of the parent expression node will also become "null".
      Parameters:
        `edm` - entity data model of the accessed OData service
        `edmType` - EDM type of the OData entity/complex type/... addressed by the URL
        `expression` - $filter expression string to be parsed
      Returns:
        expression tree which can be traversed with help of the interfaces `ExpressionVisitor` and `Visitable`
      Throws:
        `ExpressionParserException` - thrown due to errors while parsing the $filter expression string
        `ODataMessageException` - for extensibility

    - #### parseFilterString

          public abstract FilterExpression parseFilterString(EdmEntityType edmType,
                                                             String expression)
                                                      throws ExpressionParserException,
                                                             ODataMessageException

      Parses a $filter expression string and create an expression tree.

      The current expression parser supports expressions as defined in the OData specification 2.0 with the following restrictions:

      - the methods "cast", "isof" and "replace" are not supported

      The expression parser can be used with providing an Entity Data Model (EDM) and without providing it. When an EDM is provided the expression parser will be as strict as possible. That means:

      - All properties used in the expression must be defined inside the EDM,
      - the types of EDM properties will be checked against the lists of allowed types per method and per binary or unary operator, respectively
      If no EDM is provided the expression parser performs a lax validation:
      - The properties used in the expression are not looked up inside the EDM and the type of the expression node representing the property will be "null",
      - expression nodes with EDM type "null" are not considered during the parameter type validation, so the return type of the parent expression node will also become "null".
      Parameters:
        `edmType` - EDM type of the OData entity/complex type/... addressed by the URL
        `expression` - $filter expression string to be parsed
      Returns:
        expression tree which can be traversed with help of the interfaces `ExpressionVisitor` and `Visitable`
      Throws:
        `ExpressionParserException` - thrown due to errors while parsing the $filter expression string
        `ODataMessageException` - for extensibility

    - #### parseOrderBy

          public static OrderByExpression parseOrderBy(Edm edm,
                                                       EdmEntityType edmType,
                                                       String expression)
                                                throws ExpressionParserException,
                                                       ODataMessageException

      Parses a $orderby expression string and creates an expression tree.
      Parameters:
        `edm` - EDM model of the accessed OData service
        `edmType` - EDM type of the OData entity/complex type/... addressed by the URL
        `expression` - $orderby expression string to be parsed
      Returns:
        expression tree which can be traversed with help of the interfaces `ExpressionVisitor` and `Visitable`
      Throws:
        `ExpressionParserException` - thrown due to errors while parsing the $orderby expression string
        `ODataMessageException` - used for extensibility

    - #### parseOrderByString

          public abstract OrderByExpression parseOrderByString(EdmEntityType edmType,
                                                               String expression)
                                                        throws ExpressionParserException,
                                                               ODataMessageException

      Parses a $orderby expression string and creates an expression tree.
      Parameters:
        `edmType` - EDM type of the OData entity/complex type/... addressed by the URL
        `expression` - $orderby expression string to be parsed
      Returns:
        expression tree which can be traversed with help of the interfaces `ExpressionVisitor` and `Visitable`
      Throws:
        `ExpressionParserException` - thrown due to errors while parsing the $orderby expression string
        `ODataMessageException` - used for extensibility

    - #### createExpandSelectTree

          public static ExpandSelectTreeNode createExpandSelectTree(List<SelectItem> select,
                                                                    List<ArrayList<NavigationPropertySegment>> expand)
                                                             throws EdmException

      Creates an optimized expression tree out of $expand and $select expressions.
      Parameters:
        `select` - List of `select items`
        `expand` - List of Lists of `navigation property segments`
      Returns:
        expression tree of type `ExpandSelectTreeNode`
      Throws:
        `EdmException`

    - #### buildExpandSelectTree

          public abstract ExpandSelectTreeNode buildExpandSelectTree(List<SelectItem> select,
                                                                     List<ArrayList<NavigationPropertySegment>> expand)
                                                              throws EdmException

      Creates an optimized expression tree out of $expand and $select expressions.
      Parameters:
        `select` - List of `select items`
        `expand` - List of Lists of `navigation property segments`
      Returns:
        expression tree of type `ExpandSelectTreeNode`
      Throws:
        `EdmException`

    - #### buildPathSegment

          protected abstract PathSegment buildPathSegment(String path,
                                                          Map<String,List<String>> matrixParameters)

      Creates an path segment object.
      Parameters:
        `path` - path of created path segment
        `matrixParameters` - Map of Lists of matrix parameters for this path segment (can be null if no matrix parameters should be set for this path segment)
      Returns:
        created path segment

    - #### createPathSegment

          public static PathSegment createPathSegment(String path,
                                                      Map<String,List<String>> matrixParameters)

      Creates an path segment object.
      Parameters:
        `path` - path of created path segment
        `matrixParameters` - Map of Lists of matrix parameters for this path segment (can be null if no matrix parameters should be set for this path segment)
      Returns:
        created path segment

    - #### getKeyPredicatesFromEntityLink

          public static List<KeyPredicate> getKeyPredicatesFromEntityLink(EdmEntitySet entitySet,
                                                                          String entityLink,
                                                                          URI serviceRoot)
                                                                   throws ODataException

      Retrieves the key predicates from a canonical link to an entity.

      A canonical link to an entity must follow the pattern `[<service root>][<entityContainer>.]<entitySet>(<key>)`, i.e., it must be a relative or absolute URI consisting of an entity set (qualified with an entity-container name if not in the default entity container) and a syntactically valid key that identifies a single entity; example: `http://example.server.com/service.svc/Employees('42')`.

      Parameters:
        `entitySet` - the entity set the entity belongs to
        `entityLink` - the link as String
        `serviceRoot` - the root URI of the service, may be `null` for a relative link URI
      Returns:
        a list of key predicates
      Throws:
        `ODataException` - in case the link is malformed

    - #### getKeyFromEntityLink

          public abstract List<KeyPredicate> getKeyFromEntityLink(EdmEntitySet entitySet,
                                                                  String entityLink,
                                                                  URI serviceRoot)
                                                           throws ODataException

      Retrieves the key predicates from a canonical link to an entity.
      Parameters:
        `entitySet` - the entity set the entity belongs to
        `entityLink` - the link as String
        `serviceRoot` - the root URI of the service, may be `null` for a relative link URI
      Returns:
        a list of key predicates
      Throws:
        `ODataException` - in case the link is malformed
      See Also:
        `getKeyPredicatesFromEntityLink(org.apache.olingo.odata2.api.edm.EdmEntitySet, java.lang.String, java.net.URI)`

Copyright © 2013-2023 The Apache Software Foundation. All Rights Reserved.