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 Description UriParser()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ExpandSelectTreeNodebuildExpandSelectTree(List<SelectItem> select, List<ArrayList<NavigationPropertySegment>> expand)Creates an optimized expression tree out of $expand and $select expressions.protected abstract PathSegmentbuildPathSegment(String path, Map<String,List<String>> matrixParameters)Creates 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 PathSegmentcreatePathSegment(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.abstract UriInfoparse(List<PathSegment> pathSegments, Map<String,String> queryParameters)Parses path segments and query parameters.static UriInfoparse(Edm edm, List<PathSegment> pathSegments, Map<String,String> queryParameters)Parses path segments and query parameters for the given EDM.abstract UriInfoparseAll(List<PathSegment> pathSegments, Map<String,List<String>> allQueryParameters)Parses 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.
-
-
-
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 ModelpathSegments- list of path segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
ODataException- Caso ocorra exceção OData
-
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 segmentsqueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
UriSyntaxException- Caso ocorra uma exceçãoUriNotMatchingException- Caso ocorra uma exceçãoEdmException- Caso ocorra uma exceção EDM
-
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 segmentsallQueryParameters- query parameters- Returns:
UriInfoinformation about the parsed URI- Throws:
UriSyntaxException- Caso ocorra uma exceçãoUriNotMatchingException- Caso ocorra uma exceçãoEdmException- Caso ocorra uma exceção EDM
-
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- Caso ocorra uma exceção EDM
-
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- Caso ocorra uma exceção EDM
-
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
public static PathSegment createPathSegment(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
-
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:
getKeyPredicatesFromEntityLink(org.apache.olingo.odata2.api.edm.EdmEntitySet, java.lang.String, java.net.URI)
-
-