org.apache.olingo.odata2.api.uri
Class UriParser

java.lang.Object
  extended by org.apache.olingo.odata2.api.uri.UriParser

public abstract class UriParser
extends Object

Wrapper for UriParser functionality.


Constructor Summary
UriParser()
           
 
Method Summary
abstract  ExpandSelectTreeNode buildExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand)
          Creates an optimized expression tree out of $expand and $select expressions.
static ExpandSelectTreeNode createExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand)
          Creates an optimized expression tree out of $expand and $select expressions.
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.
abstract  UriInfo parse(List<PathSegment> pathSegments, Map<String,String> queryParameters)
          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 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

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 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:

If no EDM is provided the expression parser performs a lax validation:

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 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:

If no EDM is provided the expression parser performs a lax validation:

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

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-2015 The Apache Software Foundation. All Rights Reserved.