Class UriParser


  • public abstract class UriParser
    extends Object
    Wrapper for UriParser functionality.
    • 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 - Caso ocorra exceção OData
      • 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
      • 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