You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/02/18 09:21:31 UTC
[6/6] git commit: [OLINGO-63] Uri Parser: add percent decoding
[OLINGO-63] Uri Parser: add percent decoding
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/e8a63a58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/e8a63a58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/e8a63a58
Branch: refs/heads/master
Commit: e8a63a58e96df7bb2fd3e7017c105591cd74c4aa
Parents: 7a67ea2
Author: Sven Kobler <sv...@sap.com>
Authored: Mon Feb 17 17:23:08 2014 +0100
Committer: Sven Kobler <sv...@sap.com>
Committed: Tue Feb 18 09:19:57 2014 +0100
----------------------------------------------------------------------
.../server/api/uri/UriResourceNavigation.java | 2 +-
.../odata4/server/core/uri/antlr/UriParser.g4 | 311 +--
.../olingo/odata4/server/core/uri/Parser.java | 134 --
.../odata4/server/core/uri/UriInfoImpl.java | 288 ---
.../server/core/uri/UriParameterImpl.java | 83 -
.../server/core/uri/UriParseTreeVisitor.java | 2181 ------------------
.../server/core/uri/UriResourceActionImpl.java | 77 -
.../uri/UriResourceComplexPropertyImpl.java | 70 -
.../server/core/uri/UriResourceCountImpl.java | 35 -
.../core/uri/UriResourceEntitySetImpl.java | 67 -
.../core/uri/UriResourceFunctionImpl.java | 111 -
.../odata4/server/core/uri/UriResourceImpl.java | 39 -
.../server/core/uri/UriResourceItImpl.java | 65 -
.../core/uri/UriResourceLambdaAllImpl.java | 73 -
.../core/uri/UriResourceLambdaAnyImpl.java | 72 -
.../core/uri/UriResourceLambdaVarImpl.java | 70 -
.../uri/UriResourceNavigationPropertyImpl.java | 63 -
.../uri/UriResourcePrimitivePropertyImpl.java | 59 -
.../server/core/uri/UriResourceRefImpl.java | 36 -
.../server/core/uri/UriResourceRootImpl.java | 62 -
.../core/uri/UriResourceSingletonImpl.java | 71 -
.../uri/UriResourceStartingTypeFilterImpl.java | 68 -
.../server/core/uri/UriResourceTypedImpl.java | 60 -
.../server/core/uri/UriResourceValueImpl.java | 36 -
.../core/uri/UriResourceWithKeysImpl.java | 98 -
.../server/core/uri/apiimpl/UriInfoImpl.java | 294 +++
.../core/uri/apiimpl/UriParameterImpl.java | 83 +
.../core/uri/apiimpl/UriResourceActionImpl.java | 77 +
.../apiimpl/UriResourceComplexPropertyImpl.java | 70 +
.../core/uri/apiimpl/UriResourceCountImpl.java | 35 +
.../uri/apiimpl/UriResourceEntitySetImpl.java | 67 +
.../uri/apiimpl/UriResourceFunctionImpl.java | 111 +
.../core/uri/apiimpl/UriResourceImpl.java | 39 +
.../core/uri/apiimpl/UriResourceItImpl.java | 65 +
.../uri/apiimpl/UriResourceLambdaAllImpl.java | 73 +
.../uri/apiimpl/UriResourceLambdaAnyImpl.java | 72 +
.../uri/apiimpl/UriResourceLambdaVarImpl.java | 70 +
.../UriResourceNavigationPropertyImpl.java | 63 +
.../UriResourcePrimitivePropertyImpl.java | 59 +
.../core/uri/apiimpl/UriResourceRefImpl.java | 36 +
.../core/uri/apiimpl/UriResourceRootImpl.java | 62 +
.../uri/apiimpl/UriResourceSingletonImpl.java | 71 +
.../UriResourceStartingTypeFilterImpl.java | 68 +
.../core/uri/apiimpl/UriResourceTypedImpl.java | 60 +
.../core/uri/apiimpl/UriResourceValueImpl.java | 36 +
.../uri/apiimpl/UriResourceWithKeysImpl.java | 98 +
.../odata4/server/core/uri/parser/Parser.java | 450 ++++
.../odata4/server/core/uri/parser/RawUri.java | 46 +
.../server/core/uri/parser/UriContext.java | 79 +
.../server/core/uri/parser/UriDecoder.java | 140 ++
.../core/uri/parser/UriParseTreeVisitor.java | 2095 +++++++++++++++++
.../uri/queryoption/expression/MemberImpl.java | 9 +-
.../server/core/testutil/ExpandValidator.java | 2 +-
.../server/core/testutil/FilterValidator.java | 14 +-
.../odata4/server/core/testutil/ParserTest.java | 2 +-
.../server/core/testutil/ParserValidator.java | 12 +-
.../core/testutil/UriResourceValidator.java | 31 +-
.../server/core/testutil/UriValidator.java | 29 +-
.../odata4/server/core/uri/RawUriTest.java | 149 ++
.../odata4/server/core/uri/UriInfoImplTest.java | 6 +-
.../server/core/uri/UriParameterImplTest.java | 38 +-
.../core/uri/antlr/TestFullResourcePath.java | 49 +-
.../odata4/server/core/uri/antlr/TestLexer.java | 11 +-
.../server/core/uri/antlr/TestParser.java | 30 +-
.../core/uri/antlr/TestUriParserImpl.java | 19 +-
.../core/uri/queryoption/QueryOptionTest.java | 20 +-
.../queryoption/expression/ExpressionTest.java | 17 +-
67 files changed, 4820 insertions(+), 4268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e8a63a58/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/UriResourceNavigation.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/UriResourceNavigation.java b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/UriResourceNavigation.java
index 509e0ed..50b8485 100644
--- a/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/UriResourceNavigation.java
+++ b/odata4-lib/odata4-server-api/src/main/java/org/apache/olingo/odata4/server/api/uri/UriResourceNavigation.java
@@ -32,5 +32,5 @@ public interface UriResourceNavigation extends UriResourcePartTyped {
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e8a63a58/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4 b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4
index 82d2d60..c9c627b 100644
--- a/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4
+++ b/odata4-lib/odata4-server-core/src/main/antlr4/org/apache/olingo/odata4/server/core/uri/antlr/UriParser.g4
@@ -17,134 +17,80 @@
* under the License.
******************************************************************************/
- grammar UriParser;
-
-
-//Antlr4 (as most parsers) has a lexer for token detection and a parser which defines
-//rules based on the tokens. However its hard to define a clear lexer on the
-//ODATA URI syntax due to some reasons:
-// - the syntax is based on the URI specification and there fore contains the definition
-// of delimiters and percent encoding
-// - the syntax includes JSON
-// - the syntax includes a expression syntax which comes from ODATA itself (e.g. $filter)
-// - the syntax includes searchstring and searchword
-// - the ABNF describing syntax is not defined in a context free manner
-// so there are several kinds of "String" tokens:
-// - strings with single quotes,
-// - strings with single quotes and a special syntax within the quotes (like geometry data)
-// - strings with double quotes
-// - strings without quotes ( usually identifiers, searchstrings, searchwords, custom parameters)
-// but each with different allowed charactersets
-// Drawing a simple line between lexer and parser is not possible.
-//
-// This grammer is a compromiss we have choosen to satisfy the requirements we have
-// - the grammer is context free
-// - this makes the parser much simpler and we have a clear saparation between parsing and
-// EDM validation, but also creates a parse tree which is not semantically correct from the
-// EDM perspective ( e.g.it will not pass the EDM validation)
-// - the grammer can not be applied on a full URI string
-// - the URI should be split according the URI specification before used as input for the
-// ODATA parser
-// - while creating the grammer the antlr lexer modes where only allowed in pure lexer grammers
-// not in combined grammers, and is was not possible to include lexer grammer with a mode into
-// a combined grammar without creating JAVA errors.
-
-// see https://github.com/antlr/antlr4/issues/160 "Support importing multi-mode lexer grammars"
-
-
-//Naming convention
-// ...
-//Decoding encoding
-//- within rule "resourcePath": special chars used in EDM.Strings must still be encoded when
-// used as tokenizer input
-// e.g. .../Employees(id='Hugo%2FMueller')/EmployeeName <-- SLASH must be encoded to '%2F' in "Hugo/Mueller"
-// but it must not be encoded before the EmployeeName
+grammar UriParser;
+//------------------------------------------------------------------------------
+// This grammer refers to the "odata-abnf-construction-rules.txt" Revision 517.
+// URL: https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-construction-rules.txt?rev=517
+
+// While contructing this grammer we tried to keep it close to the ABNF. However this is not really possible
+// in order to support
+// - percent decoding
+// - operator precedence
+// - have context free grammar ( without out java snipples to add context)
+// - generate the parser in diffend target languages
+// Currently not supported
+// - $search
+// - geometry data
+// - json data in url
+//------------------------------------------------------------------------------
options {
- language = Java;
- tokenVocab=UriLexer;
+ language = Java;
+ tokenVocab = UriLexer;
}
-
//;------------------------------------------------------------------------------
//; 0. URI
//;------------------------------------------------------------------------------
-//ABNF odataUri and serviceRoot are currently not used here
-//odataUri = serviceRoot [ odataRelativeUri ]
-//
-//serviceRoot = ( "https" / "http" ) ; Note: case-insensitive
-// "://" host [ ":" port ]
-// "/" *( segment-nz "/" )
+batchEOF : BATCH EOF;
+entityEOF : vNS=namespace vODI=odataIdentifier;
-odataRelativeUriEOF : odataRelativeUri? EOF;
-
-//QM and FRAGMENT enable next lexer mode
-//TODO add the new "ENTITYCAST"
-odataRelativeUri : BATCH # altBatch
- | ENTITY QM vEO=entityOptions # altEntity
- | ENTITY SLASH vNS=namespace vODI=odataIdentifier QM vEO=entityOptionsCast # altEntityCast
- | METADATA ( QM vF=format )? ( FRAGMENT vCF=contextFragment )? # altMetadata
- | vRP=resourcePath ( QM vQO=queryOptions )? # altResourcePath
- ;
+metadataEOF : METADATA EOF;
//;------------------------------------------------------------------------------
//; 1. Resource Path
//;------------------------------------------------------------------------------
-resourcePath : vAll=ALL
- | vCJ=crossjoin
- | vlPS=pathSegments
- ;
-crossjoin : CROSSJOIN OPEN WSP? vlODI+=odataIdentifier WSP? ( COMMA WSP? vlODI+=odataIdentifier WSP?)* CLOSE;
+//resourcePathEOF : vlPS=pathSegments EOF;
+
+crossjoinEOF : CROSSJOIN OPEN WSP? vlODI+=odataIdentifier WSP? ( COMMA WSP? vlODI+=odataIdentifier WSP?)* CLOSE EOF;
+
+allEOF : ALL;
+
+pathSegmentEOF : (pathSegment | constSegment) EOF;
-pathSegments : vlPS+=pathSegment (SLASH vlPS+=pathSegment)* vCS=constSegment?;
+pathSegments : vlPS+=pathSegment (SLASH vlPS+=pathSegment)* (SLASH vCS=constSegment)?;
pathSegment : vNS=namespace? vODI=odataIdentifier vlNVO+=nameValueOptList*;
-nameValueOptList : OPEN (vVO=valueOnly | vNVL=nameValueList)? CLOSE;
-valueOnly : vV=commonExpr ;
+nameValueOptList : OPEN (vVO=commonExpr | vNVL=nameValueList)? CLOSE;
nameValueList : WSP* vlNVP+=nameValuePair WSP* ( COMMA WSP* vlNVP+=nameValuePair WSP*)* ;
nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vCOM=commonExpr /*TODO | val2=enumX*/);
-constSegment : SLASH (vV=value | vC=count | vR=ref | vAll=allExpr | vAny=anyExpr);
+constSegment : (vV=value | vC=count | vR=ref | vAll=allExpr | vAny=anyExpr);
count : COUNT;
ref : REF;
value : VALUE;
+
//;------------------------------------------------------------------------------
//; 2. Query Options
//;------------------------------------------------------------------------------
-queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;
-
-queryOption : systemQueryOption
- | AT_Q aliasAndValue
- | customQueryOption
- ;
+queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;
-entityOptions : (vlEOb+=entityOption AMP )* vlEOm=id ( AMP vlEOa+=entityOption )*;
-entityOption : format
- | customQueryOption
- ;
-
-entityOptionsCast : (vlEOb+=entityOptionCast AMP )* vlEOm=id ( AMP vlEOa+=entityOptionCast )*;
-entityOptionCast : expand
- | format
- | select
- | filter
- | customQueryOption
- ;
+queryOption : systemQueryOption
+ | AT_Q aliasAndValue;
systemQueryOption : expand
| filter
| format
- | id
| inlinecount
- | orderBy
+ | orderBy
| search
| select
| skip
@@ -152,31 +98,35 @@ systemQueryOption : expand
| top
;
-id : ID EQ REST;
skiptoken : SKIPTOKEN EQ REST;
-expand : EXPAND EQ vlEI+=expandItem ( COMMA vlEI+=expandItem )*;
+expand : EXPAND EQ expandItems;
+
+expandItemsEOF : expandItems EOF;
+expandItems : vlEI+=expandItem ( COMMA vlEI+=expandItem )*;
+
expandItem : vS=STAR ( SLASH vR=ref | OPEN LEVELS EQ ( vL=INT | vM=MAX) CLOSE )?
| vEP=expandPath vEPE=expandPathExtension?;
expandPath : vlPS+=pathSegment (SLASH vlPS+=pathSegment)*;
-//expandPath : expandPathSegment ( SLASH expandPathSegment )*;
-//expandPathSegment : vNS=namespace? vODI=odataIdentifier;
expandPathExtension : OPEN vlEO+=expandOption ( SEMI vlEO+=expandOption )* CLOSE
| SLASH vR=ref ( OPEN vlEOR+=expandRefOption ( SEMI vlEOR+=expandRefOption )* CLOSE )?
| SLASH vC=count ( OPEN vlEOC+=expandCountOption ( SEMI vlEOC+=expandCountOption )* CLOSE )?
;
+
expandCountOption : filter
| search
;
+
expandRefOption : expandCountOption
| orderBy
| skip
| top
| inlinecount
;
+
expandOption : expandRefOption
| select
| expand
@@ -186,10 +136,16 @@ levels : LEVELS EQ ( INT | MAX );
filter : FILTER EQ commonExpr;
-orderBy : ORDERBY EQ WSP* vlOI+=orderByItem ( WSP* COMMA WSP* vlOI+=orderByItem )*;
+filterExpressionEOF : commonExpr EOF;
+
+orderBy : ORDERBY EQ orderList;
+
+orderByEOF : orderList EOF;
+
+orderList : vlOI+=orderByItem ( WSP* COMMA WSP* vlOI+=orderByItem )*;
+
orderByItem : vC=commonExpr ( WSP ( vA=ASC | vD=DESC ) )?;
-//this is completly done in lexer grammer to avoid ambiguities with odataIdentifier and STRING
skip : SKIP EQ INT;
top : TOP EQ INT;
format : FORMAT EQ ( ATOM | JSON | XML | PCHARS ( SLASH PCHARS)?);
@@ -214,67 +170,43 @@ searchPhrase : SEARCHPHRASE;
searchWord : SEARCHWORD;
select : SELECT EQ vlSI+=selectItem ( COMMA vlSI+=selectItem )*;
+selectEOF : vlSI+=selectItem ( COMMA vlSI+=selectItem )*;
+
selectItem : vlSS+=selectSegment ( SLASH vlSS+=selectSegment ) *;
selectSegment : vNS=namespace? ( vODI=odataIdentifier | vS=STAR );
aliasAndValue : vODI=ODATAIDENTIFIER EQ vV=parameterValue;
-parameterValue : //TODO json not supported arrayOrObject
- commonExpr
- ;
-
-
-customQueryOption : customName ( EQ customValue)?
+parameterValue : commonExpr //TODO json not supported arrayOrObject
;
-customName : CUSTOMNAME;
-customValue : REST;
-
-
//;------------------------------------------------------------------------------
//; 3. Context URL Fragments
//;------------------------------------------------------------------------------
-//TODO add ps+=pathSegment (SLASH ps+=pathSegment)*
-contextFragment : REST;
-propertyList : OPEN propertyListItem ( COMMA propertyListItem )* CLOSE;
-propertyListItem : STAR //; all structural properties
- | propertyListProperty
- ;
-propertyListProperty : namespace? odataIdentifier ( SLASH namespace? odataIdentifier)* ( PLUS )? ( propertyList)?
- ;
-
+contextFragment : REST; // the context fragment is only required on the client side
//;------------------------------------------------------------------------------
//; 4. Expressions
//;------------------------------------------------------------------------------
-// this expression part of the grammer is not similar to the ABNF because
-// we had to introduced operator precesence witch is not reflected in the ABNF
-
-test : test_expr EOF;
-test_expr : INT
- //| test_expr /*WSP*/ ( '!' | '*' ) /*WSP*/ test_expr;
- //| test_expr WSP ( '!' | '*' ) WSP test_expr;
- | test_expr ( WSP '!' WSP | WSP '*' WSP ) test_expr;
-
-commonExpr : OPEN commonExpr CLOSE #altPharenthesis
- | vE1=commonExpr (WSP HAS WSP) vE2=commonExpr #altHas
- | methodCallExpr #altMethod
- | ( unary WSP ) commonExpr #altUnary
- | anyExpr #altAny
- | allExpr #altAll
- | memberExpr #altMember
- | vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult
- | vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd
+commonExpr : OPEN commonExpr CLOSE #altPharenthesis
+ | vE1=commonExpr (WSP HAS WSP) vE2=commonExpr #altHas
+ | methodCallExpr #altMethod
+ | ( unary WSP ) commonExpr #altUnary
+ | anyExpr #altAny
+ | allExpr #altAll
+ | memberExpr #altMember
+ | vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult
+ | vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd
| vE1=commonExpr (WSP vO=GT WSP | WSP vO=GE WSP | WSP vO=LT WSP
- | WSP vO=LE WSP ) vE2=commonExpr #altComparism
- | vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality
- | vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd
- | vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr
- | rootExpr #altRoot //; $...
- | AT odataIdentifier #altAlias // @...
- | primitiveLiteral #altLiteral // ...
+ | WSP vO=LE WSP ) vE2=commonExpr #altComparism
+ | vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality
+ | vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd
+ | vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr
+ | rootExpr #altRoot // $...
+ | AT odataIdentifier #altAlias // @...
+ | primitiveLiteral #altLiteral // ...
;
unary : (MINUS| NOT) ;
@@ -412,7 +344,6 @@ odataIdentifier : ODATAIDENTIFIER;
//;------------------------------------------------------------------------------
-/*TODO add missing values*/
primitiveLiteral : nullrule
| booleanNonCase
| DECIMAL //includes double and single literals
@@ -442,77 +373,67 @@ primitiveLiteral : nullrule
;
-nullrule : NULLVALUE;// (SQUOTE qualifiedtypename SQUOTE)?;
+nullrule : NULLVALUE;
booleanNonCase : BOOLEAN | TRUE | FALSE;
string : STRING;
enumLit : vNS=namespace vODI=odataIdentifier vValues=STRING;
-//enum : namespace odataIdentifier STRING;
-enumValues : vlODI+=odataIdentifier ( COMMA vlODI+=odataIdentifier )*;
-//singleEnumValue : odataIdentifier / INT;
-
-
-geographyCollection : GEOGRAPHY fullCollectionLiteral SQUOTE;
-fullCollectionLiteral : sridLiteral collectionLiteral;
-
-collectionLiteral : (COLLECTION ) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE;
-
-geoLiteral : collectionLiteral
- | lineStringLiteral
- | multipointLiteral
- | multilineStringLiteral
- | multipolygonLiteral
- | pointLiteral
- | polygonLiteral;
-
-geographyLineString : GEOGRAPHY fullLineStringLiteral SQUOTE;
-fullLineStringLiteral : sridLiteral lineStringLiteral;
-lineStringLiteral : LINESTRING lineStringData;
-lineStringData : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
+enumValues : vlODI+=odataIdentifier ( COMMA vlODI+=odataIdentifier )*;
-geographyMultilineString : GEOGRAPHY fullMultilineStringLiteral SQUOTE;
-fullMultilineStringLiteral : sridLiteral multilineStringLiteral;
-multilineStringLiteral : MULTILINESTRING OPEN ( lineStringData ( COMMA lineStringData )* )? CLOSE;
+geographyCollection : GEOGRAPHY fullCollectionLiteral SQUOTE;
+fullCollectionLiteral : sridLiteral collectionLiteral;
-geographyMultipoint : GEOGRAPHY fullMultipointLiteral SQUOTE;
-fullMultipointLiteral : sridLiteral multipointLiteral;
-multipointLiteral : MULTIPOINT OPEN ( pointData ( COMMA pointData )* )? CLOSE ;
+collectionLiteral : (COLLECTION ) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE;
-geographyMultipolygon : GEOGRAPHY fullmultipolygonLiteral SQUOTE;
-fullmultipolygonLiteral : sridLiteral multipolygonLiteral;
-multipolygonLiteral : MULTIPOLYGON OPEN ( polygonData ( COMMA polygonData )* )? CLOSE;
+geoLiteral : collectionLiteral
+ | lineStringLiteral
+ | multipointLiteral
+ | multilineStringLiteral
+ | multipolygonLiteral
+ | pointLiteral
+ | polygonLiteral;
-geographyPoint : GEOGRAPHY fullpointLiteral SQUOTE;
-fullpointLiteral : sridLiteral pointLiteral;
+geographyLineString : GEOGRAPHY fullLineStringLiteral SQUOTE;
+fullLineStringLiteral : sridLiteral lineStringLiteral;
+lineStringLiteral : LINESTRING lineStringData;
+lineStringData : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
-pointLiteral : GEO_POINT pointData;
-pointData : OPEN positionLiteral CLOSE;
+geographyMultilineString : GEOGRAPHY fullMultilineStringLiteral SQUOTE;
+fullMultilineStringLiteral : sridLiteral multilineStringLiteral;
+multilineStringLiteral : MULTILINESTRING OPEN ( lineStringData ( COMMA lineStringData )* )? CLOSE;
-positionLiteral : (DECIMAL | INT ) WSP (DECIMAL | INT ); //; longitude, then latitude
+geographyMultipoint : GEOGRAPHY fullMultipointLiteral SQUOTE;
+fullMultipointLiteral : sridLiteral multipointLiteral;
+multipointLiteral : MULTIPOINT OPEN ( pointData ( COMMA pointData )* )? CLOSE ;
+geographyMultipolygon : GEOGRAPHY fullmultipolygonLiteral SQUOTE;
+fullmultipolygonLiteral : sridLiteral multipolygonLiteral;
+multipolygonLiteral : MULTIPOLYGON OPEN ( polygonData ( COMMA polygonData )* )? CLOSE;
-geographyPolygon : GEOGRAPHY fullPolygonLiteral SQUOTE;
-fullPolygonLiteral : sridLiteral polygonLiteral;
-polygonLiteral : POLYGON polygonData;
-polygonData : OPEN ringLiteral ( COMMA ringLiteral )* CLOSE;
-ringLiteral : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
-
+geographyPoint : GEOGRAPHY fullpointLiteral SQUOTE;
+fullpointLiteral : sridLiteral pointLiteral;
-geometryCollection : GEOMETRY fullCollectionLiteral SQUOTE;
-geometryLineString : GEOMETRY fullLineStringLiteral SQUOTE;
-geometryMultilineString : GEOMETRY fullMultilineStringLiteral SQUOTE;
-geometryMultipoint : GEOMETRY fullMultipointLiteral SQUOTE;
-geometryMultipolygon : GEOMETRY fullmultipolygonLiteral SQUOTE;
-geometryPoint : GEOMETRY fullpointLiteral SQUOTE;
-geometryPolygon : GEOMETRY fullPolygonLiteral SQUOTE;
+pointLiteral : GEO_POINT pointData;
+pointData : OPEN positionLiteral CLOSE;
-sridLiteral : SRID EQ INT SEMI;
+positionLiteral : (DECIMAL | INT ) WSP (DECIMAL | INT ); //; longitude, then latitude
+geographyPolygon : GEOGRAPHY fullPolygonLiteral SQUOTE;
+fullPolygonLiteral : sridLiteral polygonLiteral;
+polygonLiteral : POLYGON polygonData;
+polygonData : OPEN ringLiteral ( COMMA ringLiteral )* CLOSE;
+ringLiteral : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE;
+
+geometryCollection : GEOMETRY fullCollectionLiteral SQUOTE;
+geometryLineString : GEOMETRY fullLineStringLiteral SQUOTE;
+geometryMultilineString : GEOMETRY fullMultilineStringLiteral SQUOTE;
+geometryMultipoint : GEOMETRY fullMultipointLiteral SQUOTE;
+geometryMultipolygon : GEOMETRY fullmultipolygonLiteral SQUOTE;
+geometryPoint : GEOMETRY fullpointLiteral SQUOTE;
+geometryPolygon : GEOMETRY fullPolygonLiteral SQUOTE;
+sridLiteral : SRID EQ INT SEMI;
-/*
-mode MODEd333gh;
-MO12E1 : 'ASD' -> mode(DEFAULT_MODE);*/
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e8a63a58/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/Parser.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/Parser.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/Parser.java
deleted file mode 100644
index a97c899..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/Parser.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.server.core.uri;
-
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.BailErrorStrategy;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.atn.PredictionMode;
-import org.antlr.v4.runtime.misc.ParseCancellationException;
-import org.apache.olingo.odata4.server.api.uri.UriInfo;
-import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer;
-import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser;
-import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
-
-public class Parser {
- public UriInfo parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor)
- throws UriParserException {
-
- try {
- OdataRelativeUriEOFContext parseTree = parseInput(input, true);
-
- // reset visitor
- uriParseTreeVisitor.init();
- parseTree.accept(uriParseTreeVisitor);
- UriInfoImpl uriInput = uriParseTreeVisitor.getUriInfo();
-
- return uriInput;
-
- } catch (ParseCancellationException e) {
- Throwable cause = e.getCause();
- if (cause instanceof UriParserException) {
- throw (UriParserException) cause;
- }
- }
- throw new UriParserSyntaxException("unknown syntax error");
- }
-
- private OdataRelativeUriEOFContext parseInput(final String input, boolean onResource)
- throws UriParserSyntaxException {
- UriParserParser parser = null;
- UriLexer lexer = null;
- OdataRelativeUriEOFContext ret = null;
-
- // Use 2 stage approach to improve performance
- // see https://github.com/antlr/antlr4/issues/192
-
- // stage = 1
- try {
- // create parser
- lexer = new UriLexer(new ANTLRInputStream(input));
- parser = new UriParserParser(new CommonTokenStream(lexer));
-
- // Set error strategy
- addStage1ErrorStategy(parser);
-
- // Set error collector
- addStage1ErrorListener(parser);
-
- // user the faster LL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
-
- // parse
- ret = parser.odataRelativeUriEOF();
-
- } catch (ParseCancellationException hardException) {
- // stage = 2
- try {
-
- // create parser
- lexer = new UriLexer(new ANTLRInputStream(input));
- parser = new UriParserParser(new CommonTokenStream(lexer));
-
- // Set error strategy
- addStage2ErrorStategy(parser);
-
- // Set error collector
- addStage2ErrorListener(parser);
-
- // Use the slower SLL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.LL);
-
- // parse
- ret = parser.odataRelativeUriEOF();
-
- } catch (Exception weakException) {
- throw new UriParserSyntaxException("Error in syntax", weakException);
-
- // exceptionOnStage = 2;
- }
- } catch (Exception hardException) {
- throw new UriParserSyntaxException("Error in syntax", hardException);
- }
-
- return ret;
- }
-
- protected void addStage1ErrorStategy(UriParserParser parser) {
- // Throw exception at first syntax error
- parser.setErrorHandler(new BailErrorStrategy());
-
- }
-
- protected void addStage2ErrorStategy(UriParserParser parser) {
- // Throw exception at first syntax error
- parser.setErrorHandler(new BailErrorStrategy());
- }
-
- protected void addStage1ErrorListener(UriParserParser parser) {
- // No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy)
- parser.removeErrorListeners();
- }
-
- protected void addStage2ErrorListener(UriParserParser parser) {
- // No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy)
- parser.removeErrorListeners();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e8a63a58/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java
deleted file mode 100644
index b37a8bd..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriInfoImpl.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.server.core.uri;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
-import org.apache.olingo.odata4.server.api.uri.UriInfo;
-import org.apache.olingo.odata4.server.api.uri.UriInfoAll;
-import org.apache.olingo.odata4.server.api.uri.UriInfoBatch;
-import org.apache.olingo.odata4.server.api.uri.UriInfoCrossjoin;
-import org.apache.olingo.odata4.server.api.uri.UriInfoEntityId;
-import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
-import org.apache.olingo.odata4.server.api.uri.UriInfoMetadata;
-import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
-import org.apache.olingo.odata4.server.api.uri.UriInfoService;
-import org.apache.olingo.odata4.server.api.uri.UriResource;
-import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.FormatOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.IdOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.SelectOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.SkipTokenOption;
-import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
-import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption;
-import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.SearchOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.SkipOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.SkipTokenOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.SystemQueryOptionImpl;
-import org.apache.olingo.odata4.server.core.uri.queryoption.TopOptionImpl;
-
-public class UriInfoImpl implements UriInfo {
-
- private UriInfoKind kind;
-
- private List<String> entitySetNames = new ArrayList<String>(); // for $entity
- private EdmEntityType entityTypeCast; // for $entity
-
- // Query options
- private List<CustomQueryOptionImpl> customQueryOptions = new ArrayList<CustomQueryOptionImpl>();
- private ExpandOptionImpl expandOption;
- private FilterOptionImpl filterOption;
- private FormatOptionImpl formatOption;
- private IdOption idOption;
- private InlineCountOptionImpl inlineCountOption;
- private OrderByOptionImpl orderByOption;
- private SearchOptionImpl searchOption;
- private SelectOptionImpl selectOption;
- private SkipOptionImpl skipOption;
- private SkipTokenOptionImpl skipTokenOption;
- private TopOptionImpl topOption;
-
- private String fragment;
-
- private UriResource lastResourcePart;
- private List<UriResource> pathParts = new ArrayList<UriResource>();
-
- @Override
- public UriInfoAll asUriInfoAll() {
- return this;
- }
-
- @Override
- public UriInfoBatch asUriInfoBatch() {
- return this;
- }
-
- @Override
- public UriInfoCrossjoin asUriInfoCrossjoin() {
- return this;
- }
-
- @Override
- public UriInfoEntityId asUriInfoEntityId() {
- return this;
- }
-
- @Override
- public UriInfoMetadata asUriInfoMetadata() {
- return this;
- }
-
- @Override
- public UriInfoResource asUriInfoResource() {
- return this;
- }
-
- @Override
- public List<String> getEntitySetNames() {
- return Collections.unmodifiableList(entitySetNames);
- }
-
- public void addEntitySetName(final String entitySet) {
- entitySetNames.add(entitySet);
- }
-
- @Override
- public List<UriResource> getUriResourceParts() {
- List<UriResource> returnList = new ArrayList<UriResource>();
- for (UriResource item : pathParts) {
- returnList.add(item);
- }
- return Collections.unmodifiableList(returnList);
- }
-
- public UriInfoImpl addResourcePart(final UriResourceImpl uriPathInfo) {
- pathParts.add(uriPathInfo);
- lastResourcePart = uriPathInfo;
- return this;
- }
-
- @Override
- public List<CustomQueryOption> getCustomQueryOptions() {
- List<CustomQueryOption> retList = new ArrayList<CustomQueryOption>();
- for (CustomQueryOptionImpl item : customQueryOptions) {
- retList.add(item);
- }
- return retList;
- }
-
- @Override
- public EdmEntityType getEntityTypeCast() {
- return entityTypeCast;
- }
-
- public UriInfoImpl setEntityTypeCast(final EdmEntityType type) {
- entityTypeCast = type;
- return this;
- }
-
- @Override
- public ExpandOption getExpandOption() {
- return expandOption;
- }
-
- @Override
- public FilterOption getFilterOption() {
- return filterOption;
- }
-
- @Override
- public FormatOption getFormatOption() {
- return formatOption;
- }
-
- @Override
- public IdOption getIdOption() {
- return idOption;
- }
-
- @Override
- public InlineCountOption getInlineCountOption() {
- return inlineCountOption;
- }
-
- @Override
- public UriInfoKind getKind() {
- return kind;
- }
-
- public UriInfoImpl setKind(final UriInfoKind kind) {
- this.kind = kind;
- return this;
- }
-
- public UriResource getLastResourcePart() {
- return lastResourcePart;
- }
-
- @Override
- public OrderByOption getOrderByOption() {
- return orderByOption;
- }
-
- @Override
- public SearchOption getSearchOption() {
-
- return searchOption;
- }
-
- @Override
- public SelectOption getSelectOption() {
- return selectOption;
- }
-
- @Override
- public SkipOption getSkipOption() {
- return skipOption;
- }
-
- @Override
- public SkipTokenOption getSkipTokenOption() {
- return skipTokenOption;
- }
-
- @Override
- public TopOption getTopOption() {
- return topOption;
- }
-
-
- public UriInfoImpl setQueryOptions(final List<QueryOptionImpl> list) {
-
- for (QueryOptionImpl item : list) {
- if (item instanceof SystemQueryOptionImpl) {
- setSystemQueryOption((SystemQueryOptionImpl)item);
- } else if (item instanceof CustomQueryOptionImpl) {
- customQueryOptions.add((CustomQueryOptionImpl) item);
- }
- }
- return this;
- }
-
- public UriInfoImpl setSystemQueryOption(SystemQueryOptionImpl systemOption) {
-
- if (systemOption.getKind() == SupportedQueryOptions.EXPAND) {
- expandOption = (ExpandOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.FILTER) {
- filterOption = (FilterOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.FORMAT) {
- formatOption = (FormatOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.ID) {
- idOption = (IdOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) {
- inlineCountOption = (InlineCountOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) {
- orderByOption = (OrderByOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.SEARCH) {
- searchOption = (SearchOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.SELECT) {
- selectOption = (SelectOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.SKIP) {
- skipOption = (SkipOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.SKIPTOKEN) {
- skipTokenOption = (SkipTokenOptionImpl) systemOption;
- } else if (systemOption.getKind() == SupportedQueryOptions.TOP) {
- topOption = (TopOptionImpl) systemOption;
- }
- return this;
- }
-
- @Override
- public UriInfoService asUriInfoService() {
- return this;
- }
-
-
- public String getFragment() {
- return fragment;
- }
-
- public UriInfoImpl setFragment(String fragment) {
- this.fragment = fragment;
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e8a63a58/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriParameterImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriParameterImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriParameterImpl.java
deleted file mode 100644
index e87c89d..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/UriParameterImpl.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.server.core.uri;
-
-import org.apache.olingo.odata4.server.api.uri.UriParameter;
-import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
-
-public class UriParameterImpl implements UriParameter {
- private String name;
- private String text;
- private String alias;
- private Expression expression;
- private String referencedProperty;
-
- @Override
- public String getName() {
- return name;
- }
-
- public UriParameterImpl setName(final String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public String getAlias() {
- return alias;
- }
-
- public UriParameterImpl setAlias(final String alias) {
- this.alias = alias;
- return this;
- }
-
- @Override
- public String getText() {
- return text;
- }
-
- public UriParameterImpl setText(final String text) {
- this.text = text;
- return this;
- }
-
- @Override
- public Expression getExression() {
- return expression;
- }
-
- public UriParameterImpl setExpression(final ExpressionImpl expression) {
- this.expression = expression;
- return this;
- }
-
- @Override
- public String getRefencedProperty() {
- return this.referencedProperty;
- }
-
- public UriParameterImpl setRefencedProperty(String referencedProperty) {
- this.referencedProperty = referencedProperty;
- return this;
- }
-
-}