Class UriParser
- Direct Known Subclasses:
UriParserImpl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ExpandSelectTreeNodebuildExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand) Creates an optimized expression tree out of $expand and $select expressions.protected abstract PathSegmentCreates an path segment object.static ExpandSelectTreeNodecreateExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand) Creates an optimized expression tree out of $expand and $select expressions.static PathSegmentCreates 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.abstract UriInfoParses path segments and query parameters.abstract UriInfoDeprecated.static UriInfoParses path segments and query parameters for the given EDM.static UriInfoparse(Edm edm, List<PathSegment> pathSegments, Map<String, String> queryParameters, boolean strictFilter) Deprecated.abstract UriInfoParses path segments and query parameters.static FilterExpressionparseFilter(Edm edm, EdmEntityType edmType, String expression) Parses a $filter expression string and create an expression tree.abstract FilterExpressionparseFilterString(EdmEntityType edmType, String expression) Parses a $filter expression string and create an expression tree.static OrderByExpressionparseOrderBy(Edm edm, EdmEntityType edmType, String expression) Parses a $orderby expression string and creates an expression tree.abstract OrderByExpressionparseOrderByString(EdmEntityType edmType, String expression) Parses a $orderby expression string and creates an expression tree.
-
Constructor Details
-
UriParser
public UriParser()
-
-
Method Details
-
parse
public static UriInfo parse(Edm edm, List<PathSegment> pathSegments, Map<String, String> queryParameters) throws ODataExceptionParses path segments and query parameters for the given EDM.- Parameters:
edm- Entity Data ModelpathSegments- list of path segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
ODataException
-
parse
@Deprecated public static UriInfo parse(Edm edm, List<PathSegment> pathSegments, Map<String, String> queryParameters, boolean strictFilter) throws ODataExceptionDeprecated.Parses path segments and query parameters for the given EDM. Will not be available in higher versions- Parameters:
edm- Entity Data ModelpathSegments- list of path segmentsqueryParameters- query parametersstrictFilter- for URI Parsing of filter parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
ODataException
-
parse
@Deprecated public abstract UriInfo parse(List<PathSegment> pathSegments, Map<String, String> queryParameters, boolean strictFilter) throws UriSyntaxException, UriNotMatchingException, EdmExceptionDeprecated.Parses path segments and query parameters. This method ignores redundant system query parameters.- Parameters:
pathSegments- list of path segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
UriSyntaxExceptionUriNotMatchingExceptionEdmException
-
parse
public abstract UriInfo parse(List<PathSegment> pathSegments, Map<String, String> queryParameters) throws UriSyntaxException, UriNotMatchingException, EdmExceptionParses path segments and query parameters. This method ignores redundant system query parameters.- Parameters:
pathSegments- list of path segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
UriSyntaxExceptionUriNotMatchingExceptionEdmException
-
parseAll
public abstract UriInfo parseAll(List<PathSegment> pathSegments, Map<String, List<String>> allQueryParameters) throws UriSyntaxException, UriNotMatchingException, EdmExceptionParses path segments and query parameters. Throws an exception if there are redundant system query parameters.- Parameters:
pathSegments- list of path segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
UriSyntaxExceptionUriNotMatchingExceptionEdmException
-
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
- 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 serviceedmType- EDM type of the OData entity/complex type/... addressed by the URLexpression- $filter expression string to be parsed- Returns:
- expression tree which can be traversed with help of the interfaces
ExpressionVisitorandVisitable - Throws:
ExpressionParserException- thrown due to errors while parsing the $filter expression stringODataMessageException- 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
- 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 URLexpression- $filter expression string to be parsed- Returns:
- expression tree which can be traversed with help of the interfaces
ExpressionVisitorandVisitable - Throws:
ExpressionParserException- thrown due to errors while parsing the $filter expression stringODataMessageException- 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 serviceedmType- EDM type of the OData entity/complex type/... addressed by the URLexpression- $orderby expression string to be parsed- Returns:
- expression tree which can be traversed with help of the interfaces
ExpressionVisitorandVisitable - Throws:
ExpressionParserException- thrown due to errors while parsing the $orderby expression stringODataMessageException- 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 URLexpression- $orderby expression string to be parsed- Returns:
- expression tree which can be traversed with help of the interfaces
ExpressionVisitorandVisitable - Throws:
ExpressionParserException- thrown due to errors while parsing the $orderby expression stringODataMessageException- 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 ofselect itemsexpand- List of Lists ofnavigation 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 ofselect itemsexpand- List of Lists ofnavigation 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 segmentmatrixParameters- 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
Creates an path segment object.- Parameters:
path- path of created path segmentmatrixParameters- 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 toentityLink- the link as StringserviceRoot- the root URI of the service, may benullfor 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 toentityLink- the link as StringserviceRoot- the root URI of the service, may benullfor a relative link URI- Returns:
- a list of key predicates
- Throws:
ODataException- in case the link is malformed- See Also:
-