From 2f239945846c85298ad956e98a31bf47603b3e23 Mon Sep 17 00:00:00 2001 From: 4lfant <4lfant@gmail.com> Date: Mon, 21 Oct 2019 23:55:35 +0300 Subject: [PATCH] Offline --- build.gradle | 10 +- src/com/backendless/DataStoreFactory.java | 1211 ++--- src/com/backendless/IDataStore.java | 377 +- src/com/backendless/Persistence.java | 51 +- .../persistence/DataQueryBuilder.java | 23 + .../persistence/MapDrivenDataStore.java | 118 +- .../offline/AndroidTransactionStorage.java | 73 + .../persistence/offline/CallbackManager.java | 84 + .../offline/ConnectivityManager.java | 51 + .../offline/DataRetrievalPolicy.java | 7 + .../persistence/offline/DatabaseHelper.java | 125 + .../persistence/offline/DatabaseManager.java | 21 + .../offline/LocalStorageManager.java | 250 + .../offline/LocalStoragePolicy.java | 7 + .../offline/OfflineAwareCallback.java | 11 + .../offline/PendingOperationEnum.java | 7 + .../offline/SQLiteDatabaseManager.java | 181 + .../offline/SyncCompletionCallback.java | 8 + .../persistence/offline/SyncError.java | 11 + .../persistence/offline/SyncFailure.java | 16 + .../persistence/offline/SyncManager.java | 280 ++ .../persistence/offline/SyncStatusReport.java | 11 + .../persistence/offline/SyncSuccess.java | 16 + .../persistence/offline/Transaction.java | 49 + .../offline/TransactionManager.java | 44 + .../offline/TransactionStorage.java | 12 + .../offline/TransactionStorageFactory.java | 46 + .../AndroidBackendlessQueryVisitor.java | 396 ++ .../offline/visitor/bcknd/DateUtil.java | 29 + .../offline/visitor/bcknd/UnitConvertor.java | 47 + .../offline/visitor/bcknd/Units.java | 18 + .../offline/visitor/gen/BackendlessQuery.g4 | 309 ++ .../visitor/gen/BackendlessQuery.interp | 179 + .../visitor/gen/BackendlessQuery.tokens | 89 + .../gen/BackendlessQueryBaseListener.java | 879 ++++ .../gen/BackendlessQueryBaseVisitor.java | 504 ++ .../visitor/gen/BackendlessQueryLexer.interp | 244 + .../visitor/gen/BackendlessQueryLexer.java | 322 ++ .../visitor/gen/BackendlessQueryLexer.tokens | 89 + .../visitor/gen/BackendlessQueryListener.java | 794 ++++ .../visitor/gen/BackendlessQueryParser.java | 4073 +++++++++++++++++ .../visitor/gen/BackendlessQueryVisitor.java | 475 ++ .../visitor/res/AggregateFunction.java | 16 + .../visitor/res/AggregateOperator.java | 20 + .../visitor/res/CombinedCondition.java | 18 + .../visitor/res/ComparisonCondition.java | 18 + .../offline/visitor/res/Condition.java | 4 + .../offline/visitor/res/Expression.java | 18 + .../visitor/res/ExpressionOperator.java | 20 + .../offline/visitor/res/Field.java | 22 + .../offline/visitor/res/LikeCondition.java | 19 + .../offline/visitor/res/NotCondition.java | 14 + .../offline/visitor/res/NullCondition.java | 16 + .../offline/visitor/res/Operator.java | 25 + .../offline/visitor/res/QueryPart.java | 4 + .../offline/visitor/res/SelectQuery.java | 53 + .../offline/visitor/res/SortField.java | 19 + .../offline/visitor/res/Table.java | 14 + .../offline/visitor/res/Value.java | 14 + 59 files changed, 11122 insertions(+), 739 deletions(-) create mode 100644 src/com/backendless/persistence/offline/AndroidTransactionStorage.java create mode 100644 src/com/backendless/persistence/offline/CallbackManager.java create mode 100644 src/com/backendless/persistence/offline/ConnectivityManager.java create mode 100644 src/com/backendless/persistence/offline/DataRetrievalPolicy.java create mode 100644 src/com/backendless/persistence/offline/DatabaseHelper.java create mode 100644 src/com/backendless/persistence/offline/DatabaseManager.java create mode 100644 src/com/backendless/persistence/offline/LocalStorageManager.java create mode 100644 src/com/backendless/persistence/offline/LocalStoragePolicy.java create mode 100644 src/com/backendless/persistence/offline/OfflineAwareCallback.java create mode 100644 src/com/backendless/persistence/offline/PendingOperationEnum.java create mode 100644 src/com/backendless/persistence/offline/SQLiteDatabaseManager.java create mode 100644 src/com/backendless/persistence/offline/SyncCompletionCallback.java create mode 100644 src/com/backendless/persistence/offline/SyncError.java create mode 100644 src/com/backendless/persistence/offline/SyncFailure.java create mode 100644 src/com/backendless/persistence/offline/SyncManager.java create mode 100644 src/com/backendless/persistence/offline/SyncStatusReport.java create mode 100644 src/com/backendless/persistence/offline/SyncSuccess.java create mode 100644 src/com/backendless/persistence/offline/Transaction.java create mode 100644 src/com/backendless/persistence/offline/TransactionManager.java create mode 100644 src/com/backendless/persistence/offline/TransactionStorage.java create mode 100644 src/com/backendless/persistence/offline/TransactionStorageFactory.java create mode 100644 src/com/backendless/persistence/offline/visitor/AndroidBackendlessQueryVisitor.java create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/DateUtil.java create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/UnitConvertor.java create mode 100644 src/com/backendless/persistence/offline/visitor/bcknd/Units.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.g4 create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.interp create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.tokens create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseListener.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseVisitor.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.interp create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.tokens create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryListener.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryParser.java create mode 100644 src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryVisitor.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/AggregateFunction.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/AggregateOperator.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/CombinedCondition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/ComparisonCondition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Condition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Expression.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/ExpressionOperator.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Field.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/LikeCondition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/NotCondition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/NullCondition.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Operator.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/QueryPart.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/SelectQuery.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/SortField.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Table.java create mode 100644 src/com/backendless/persistence/offline/visitor/res/Value.java diff --git a/build.gradle b/build.gradle index a856af25f..4c2c906b1 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,9 @@ uploadArchives { pom.whenConfigured { p -> p.dependencies = p.dependencies.findAll { - dep -> ( dep.artifactId != "commons" && dep.artifactId != "weborbclient" ) + dep -> ( dep.artifactId != "commons" && + dep.artifactId != "weborbclient" && + dep.artifactId != "antlr4-runtime" ) } } @@ -181,7 +183,8 @@ def libsToPackage() { def artifactsToPackage = [ ["com.backendless", "commons"], - ["weborb", "weborbclient"] + ["weborb", "weborbclient"], + ["org.antlr", "antlr4-runtime"] ] def libsToPackage = ["mediaLib.jar"] @@ -263,10 +266,13 @@ dependencies { } compileOnly( group: "weborb", name: "weborbclient", version: "5.1.0.212", changing: true) + compileOnly( group: 'org.antlr', name: 'antlr4-runtime', version: '4.7.2', changing: true) + compileOnly ('io.socket:socket.io-client:1.0.0') { // excluding org.json which is provided by Android exclude group: 'org.json', module: 'json' } + } apply plugin: 'java' diff --git a/src/com/backendless/DataStoreFactory.java b/src/com/backendless/DataStoreFactory.java index 6f5270b84..e4c8cc646 100644 --- a/src/com/backendless/DataStoreFactory.java +++ b/src/com/backendless/DataStoreFactory.java @@ -1,554 +1,659 @@ -/* - * ******************************************************************************************************************** - *

- * BACKENDLESS.COM CONFIDENTIAL - *

- * ******************************************************************************************************************** - *

- * Copyright 2(Integer)null12 BACKENDLESS.COM. All Rights Reserved. - *

- * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers, - * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its - * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret - * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden - * unless prior written permission is obtained from Backendless.com. - *

- * ******************************************************************************************************************** - */ - -package com.backendless; - -import com.backendless.async.callback.AsyncCallback; -import com.backendless.exceptions.BackendlessException; -import com.backendless.persistence.BackendlessSerializer; -import com.backendless.persistence.DataQueryBuilder; -import com.backendless.persistence.LoadRelationsQueryBuilder; -import com.backendless.rt.data.EventHandler; -import com.backendless.rt.data.EventHandlerFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -class DataStoreFactory -{ - private static final List emptyRelations = new ArrayList(); - private final static EventHandlerFactory eventHandlerFactory = new EventHandlerFactory(); - - protected static IDataStore createDataStore( final Class entityClass ) - { - - return new IDataStore() - { - private EventHandler eventHandler = eventHandlerFactory.of( entityClass ); - - @Override - public List create( List objects ) throws BackendlessException - { - return Backendless.Persistence.create( objects ); - } - - @Override - public void create( List objects, AsyncCallback> responder ) throws BackendlessException - { - Backendless.Persistence.create( objects, responder ); - } - - @Override - public E save( final E entity ) throws BackendlessException - { - return Backendless.Persistence.save( entity ); - } - - @Override - public void save( final E entity, final AsyncCallback responder ) - { - Backendless.Persistence.save( entity, responder ); - } - - @Override - public Long remove( final E entity ) throws BackendlessException - { - return Backendless.Persistence.remove( entity ); - } - - @Override - public void remove( final E entity, final AsyncCallback responder ) - { - Backendless.Persistence.remove( entity, responder ); - } - - @Override - public int remove( final String whereClause ) throws BackendlessException - { - return Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause ); - } - - @Override - public void remove( final String whereClause, AsyncCallback responder ) throws BackendlessException - { - Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause, responder ); - } - - @Override - public int update( final String whereClause, Map changes ) throws BackendlessException - { - return Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes ); - } - - @Override - public void update( final String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException - { - Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes, responder ); - } - - @Override - public E findFirst() throws BackendlessException - { - return Backendless.Persistence.first( entityClass ); - } - - @Override - public E findFirst( Integer relationsDepth ) throws BackendlessException - { - return findFirst( emptyRelations, relationsDepth ); - } - - @Override - public E findFirst( List relations ) throws BackendlessException - { - return findFirst( relations, (Integer)null ); - } - - private E findFirst( List relations, Integer relationsDepth ) throws BackendlessException - { - return Backendless.Persistence.first( entityClass, relations, relationsDepth ); - } - - @Override - public int getObjectCount() - { - return Backendless.Persistence.getObjectCount( entityClass ); - } - - @Override - public int getObjectCount( DataQueryBuilder dataQueryBuilder ) - { - return Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder ); - } - - public void findFirst( final AsyncCallback responder ) - { - Backendless.Persistence.first( entityClass, responder ); - } - - @Override - public void findFirst( Integer relationsDepth, final AsyncCallback responder ) - { - findFirst( emptyRelations, relationsDepth, responder ); - } - - @Override - public void findFirst( List relations, AsyncCallback responder ) - { - findFirst( relations, (Integer)null, responder ); - } - - private void findFirst( List relations, Integer relationsDepth, final AsyncCallback responder ) - { - Backendless.Persistence.first( entityClass, relations, relationsDepth, responder ); - } - - @Override - public E findLast() throws BackendlessException - { - return Backendless.Persistence.last( entityClass ); - } - - @Override - public E findLast( Integer relationsDepth ) throws BackendlessException - { - return findLast( emptyRelations, relationsDepth ); - } - - @Override - public E findLast( List relations ) throws BackendlessException - { - return findLast( relations, (Integer)null ); - } - - private E findLast( List relations, Integer relationsDepth ) throws BackendlessException - { - return Backendless.Persistence.last( entityClass, relations, relationsDepth ); - } - - @Override - public void findLast( final AsyncCallback responder ) - { - Backendless.Persistence.last( entityClass, responder ); - } - - @Override - public void findLast( Integer relationsDepth, final AsyncCallback responder ) - { - findLast( emptyRelations, relationsDepth, responder ); - } - - @Override - public void findLast( List relations, AsyncCallback responder ) - { - findLast( relations, (Integer)null, responder ); - } - - private void findLast( List relations, Integer relationsDepth, final AsyncCallback responder ) - { - Backendless.Persistence.last( entityClass, relations, relationsDepth, responder ); - } - - @Override - public List find() throws BackendlessException - { - return Backendless.Persistence.find( entityClass, DataQueryBuilder.create() ); - } - - @Override - public List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException - { - return Backendless.Persistence.find( entityClass, dataQueryBuilder ); - } - - @Override - public void find( AsyncCallback> responder ) - { - Backendless.Persistence.find( entityClass, DataQueryBuilder.create(), responder ); - } - - @Override - public void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder ) - { - Backendless.Persistence.find( entityClass, dataQueryBuilder, responder ); - } - - @Override - public E findById( String objectId ) throws BackendlessException - { - return findById( objectId, emptyRelations ); - } - - @Override - public E findById( String objectId, List relations ) throws BackendlessException - { - return Backendless.Persistence.findById( entityClass, objectId, relations ); - } - - @Override - public E findById( String objectId, Integer relationsDepth ) throws BackendlessException - { - return Backendless.Persistence.findById( entityClass, objectId, emptyRelations, relationsDepth ); - } - - @Override - public E findById( String objectId, List relations, Integer relationsDepth ) throws BackendlessException - { - return Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth ); - } - - @Override - public E findById( E entity ) - { - return findById( entity, emptyRelations ); - } - - @Override - public E findById( E entity, List relations ) - { - return findById( entity, relations, (Integer)null ); - } - - @Override - public E findById( E entity, Integer relationsDepth ) - { - return findById( entity, emptyRelations, relationsDepth ); - } - - @Override - public E findById( E entity, List relations, Integer relationsDepth ) - { - return Backendless.Data.findById( entity, relations, relationsDepth ); - } - - @Override - public void findById( String objectId, AsyncCallback responder ) - { - findById( objectId, emptyRelations, responder ); - } - - @Override - public void findById( String objectId, List relations, AsyncCallback responder ) - { - Backendless.Persistence.findById( entityClass, objectId, relations, responder ); - } - - @Override - public void findById( String objectId, Integer relationsDepth, AsyncCallback responder ) - { - findById( objectId, emptyRelations, relationsDepth, responder ); - } - - @Override - public void findById( String objectId, List relations, Integer relationsDepth, AsyncCallback responder ) - { - Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth, responder ); - } - - @Override - public void findById( E entity, AsyncCallback responder ) - { - findById( entity, emptyRelations, responder ); - } - - @Override - public void findById( E entity, List relations, AsyncCallback responder ) - { - findById( entity, relations, (Integer)null, responder ); - } - - @Override - public void findById( E entity, Integer relationsDepth, AsyncCallback responder ) - { - findById( entity, emptyRelations, relationsDepth, responder ); - } - - @Override - public void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder ) - { - Backendless.Data.findById( entity, relations, relationsDepth, responder ); - } - - @Override - public E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException - { - return Backendless.Persistence.findById( entityClass, id, queryBuilder ); - } - - @Override - public E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException - { - return Backendless.Persistence.findById( entity, queryBuilder ); - } - - @Override - public void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder ) - { - Backendless.Persistence.findById( entityClass, id, queryBuilder, responder ); - } - - @Override - public void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder ) - { - Backendless.Persistence.findById( entity, queryBuilder, responder ); - } - - @Override - public List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder ) - { - String typeName = BackendlessSerializer.getSimpleName( entityClass ); - return Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType() ); - } - - @Override - public void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder ) - { - String typeName = BackendlessSerializer.getSimpleName( entityClass ); - Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType(), responder ); - } - - @Override - public void getObjectCount( AsyncCallback responder ) - { - Backendless.Persistence.getObjectCount( entityClass, responder ); - } - - @Override - public void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder ) - { - Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder, responder ); - } - - @Override - public int addRelation( E parent, String relationColumnName, Collection children ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args ); - } - - @Override - public void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); - } - - @Override - public int addRelation( E parent, String relationColumnName, String whereClause ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args ); - } - - @Override - public void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); - } - - @Override - public int setRelation( E parent, String relationColumnName, Collection children ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args ); - } - - @Override - public void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args, callback ); - } - - @Override - public int setRelation( E parent, String relationColumnName, String whereClause ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args ); - } - - @Override - public void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); - } - - @Override - public int deleteRelation( E parent, String relationColumnName, Collection children ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args ); - } - - @Override - public void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - Collection childObjectIds = new ArrayList<>(); - for( R child : children ) - { - String childObjectId = Persistence.getEntityId( child ); - childObjectIds.add( childObjectId ); - } - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback ); - } - - @Override - public int deleteRelation( E parent, String relationColumnName, String whereClause ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args ); - } - - @Override - public void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) - { - String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); - - String parentObjectId = Persistence.getEntityId( parent ); - - Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; - Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback ); - } - - @Override - public EventHandler rt() - { - return eventHandler; - } - }; - } +/* + * ******************************************************************************************************************** + *

+ * BACKENDLESS.COM CONFIDENTIAL + *

+ * ******************************************************************************************************************** + *

+ * Copyright 2(Integer)null12 BACKENDLESS.COM. All Rights Reserved. + *

+ * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers, + * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its + * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret + * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden + * unless prior written permission is obtained from Backendless.com. + *

+ * ******************************************************************************************************************** + */ + +package com.backendless; + +import com.backendless.async.callback.AsyncCallback; +import com.backendless.exceptions.BackendlessException; +import com.backendless.persistence.BackendlessSerializer; +import com.backendless.persistence.DataQueryBuilder; +import com.backendless.persistence.LoadRelationsQueryBuilder; +import com.backendless.persistence.offline.LocalStorageManager; +import com.backendless.persistence.offline.OfflineAwareCallback; +import com.backendless.persistence.offline.SyncCompletionCallback; +import com.backendless.persistence.offline.SyncManager; +import com.backendless.persistence.offline.TransactionManager; +import com.backendless.rt.data.EventHandler; +import com.backendless.rt.data.EventHandlerFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import static com.backendless.persistence.BackendlessSerializer.serializeToMap; + +class DataStoreFactory +{ + private static final List emptyRelations = new ArrayList(); + private static final EventHandlerFactory eventHandlerFactory = new EventHandlerFactory(); + private static final TransactionManager transactionManager = TransactionManager.getInstance(); + private static final SyncManager syncManager = SyncManager.getInstance(); + + protected static IDataStore createDataStore( final Class entityClass ) + { + + return new IDataStore() + { + private EventHandler eventHandler = eventHandlerFactory.of( entityClass ); + private final LocalStorageManager storageManager = new LocalStorageManager( + BackendlessSerializer.getSimpleName( entityClass )); + + @Override + public List create( List objects ) throws BackendlessException + { + return Backendless.Persistence.create( objects ); + } + + @Override + public void create( List objects, AsyncCallback> responder ) throws BackendlessException + { + Backendless.Persistence.create( objects, responder ); + } + + @Override + public E save( final E entity ) throws BackendlessException + { + return Backendless.Persistence.save( entity ); + } + + @Override + public void save( final E entity, final AsyncCallback responder ) + { + Backendless.Persistence.save( entity, responder ); + } + + @Override + public Long remove( final E entity ) throws BackendlessException + { + return Backendless.Persistence.remove( entity ); + } + + @Override + public void remove( final E entity, final AsyncCallback responder ) + { + Backendless.Persistence.remove( entity, responder ); + } + + @Override + public int remove( final String whereClause ) throws BackendlessException + { + return Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause ); + } + + @Override + public void remove( final String whereClause, AsyncCallback responder ) throws BackendlessException + { + Backendless.Persistence.remove( BackendlessSerializer.getSimpleName( entityClass ), whereClause, responder ); + } + + @Override + public int update( final String whereClause, Map changes ) throws BackendlessException + { + return Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes ); + } + + @Override + public void update( final String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException + { + Backendless.Persistence.update( BackendlessSerializer.getSimpleName( entityClass ), whereClause, changes, responder ); + } + + @Override + public E findFirst() throws BackendlessException + { + return Backendless.Persistence.first( entityClass ); + } + + @Override + public E findFirst( Integer relationsDepth ) throws BackendlessException + { + return findFirst( emptyRelations, relationsDepth ); + } + + @Override + public E findFirst( List relations ) throws BackendlessException + { + return findFirst( relations, (Integer)null ); + } + + private E findFirst( List relations, Integer relationsDepth ) throws BackendlessException + { + return Backendless.Persistence.first( entityClass, relations, relationsDepth ); + } + + @Override + public int getObjectCount() + { + return Backendless.Persistence.getObjectCount( entityClass ); + } + + @Override + public int getObjectCount( DataQueryBuilder dataQueryBuilder ) + { + return Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder ); + } + + public void findFirst( final AsyncCallback responder ) + { + Backendless.Persistence.first( entityClass, responder ); + } + + @Override + public void findFirst( Integer relationsDepth, final AsyncCallback responder ) + { + findFirst( emptyRelations, relationsDepth, responder ); + } + + @Override + public void findFirst( List relations, AsyncCallback responder ) + { + findFirst( relations, (Integer)null, responder ); + } + + private void findFirst( List relations, Integer relationsDepth, final AsyncCallback responder ) + { + Backendless.Persistence.first( entityClass, relations, relationsDepth, responder ); + } + + @Override + public E findLast() throws BackendlessException + { + return Backendless.Persistence.last( entityClass ); + } + + @Override + public E findLast( Integer relationsDepth ) throws BackendlessException + { + return findLast( emptyRelations, relationsDepth ); + } + + @Override + public E findLast( List relations ) throws BackendlessException + { + return findLast( relations, (Integer)null ); + } + + private E findLast( List relations, Integer relationsDepth ) throws BackendlessException + { + return Backendless.Persistence.last( entityClass, relations, relationsDepth ); + } + + @Override + public void findLast( final AsyncCallback responder ) + { + Backendless.Persistence.last( entityClass, responder ); + } + + @Override + public void findLast( Integer relationsDepth, final AsyncCallback responder ) + { + findLast( emptyRelations, relationsDepth, responder ); + } + + @Override + public void findLast( List relations, AsyncCallback responder ) + { + findLast( relations, (Integer)null, responder ); + } + + private void findLast( List relations, Integer relationsDepth, final AsyncCallback responder ) + { + Backendless.Persistence.last( entityClass, relations, relationsDepth, responder ); + } + + @Override + public List find() throws BackendlessException + { + return find(DataQueryBuilder.create() ); + } + + @Override + public List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException + { + if (!storageManager.shouldRetrieveOnline(dataQueryBuilder)) + return storageManager.find(entityClass, dataQueryBuilder); + + List result = Backendless.Persistence.find( entityClass, dataQueryBuilder ); + storageManager.store(result, dataQueryBuilder); + return result; + } + + @Override + public void find( AsyncCallback> responder ) + { + find(DataQueryBuilder.create(), responder ); + } + + @Override + public void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder ) + { + if (!storageManager.shouldRetrieveOnline(dataQueryBuilder)) { + storageManager.find(entityClass, dataQueryBuilder, responder); + return; + } + + AsyncCallback> storeCallback = storageManager.getStoreCallback(dataQueryBuilder, responder); + + Backendless.Persistence.find( entityClass, dataQueryBuilder, storeCallback ); + } + + @Override + public E findById( String objectId ) throws BackendlessException + { + return findById( objectId, emptyRelations ); + } + + @Override + public E findById( String objectId, List relations ) throws BackendlessException + { + return Backendless.Persistence.findById( entityClass, objectId, relations ); + } + + @Override + public E findById( String objectId, Integer relationsDepth ) throws BackendlessException + { + return Backendless.Persistence.findById( entityClass, objectId, emptyRelations, relationsDepth ); + } + + @Override + public E findById( String objectId, List relations, Integer relationsDepth ) throws BackendlessException + { + return Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth ); + } + + @Override + public E findById( E entity ) + { + return findById( entity, emptyRelations ); + } + + @Override + public E findById( E entity, List relations ) + { + return findById( entity, relations, (Integer)null ); + } + + @Override + public E findById( E entity, Integer relationsDepth ) + { + return findById( entity, emptyRelations, relationsDepth ); + } + + @Override + public E findById( E entity, List relations, Integer relationsDepth ) + { + return Backendless.Data.findById( entity, relations, relationsDepth ); + } + + @Override + public void findById( String objectId, AsyncCallback responder ) + { + findById( objectId, emptyRelations, responder ); + } + + @Override + public void findById( String objectId, List relations, AsyncCallback responder ) + { + Backendless.Persistence.findById( entityClass, objectId, relations, responder ); + } + + @Override + public void findById( String objectId, Integer relationsDepth, AsyncCallback responder ) + { + findById( objectId, emptyRelations, relationsDepth, responder ); + } + + @Override + public void findById( String objectId, List relations, Integer relationsDepth, AsyncCallback responder ) + { + Backendless.Persistence.findById( entityClass, objectId, relations, relationsDepth, responder ); + } + + @Override + public void findById( E entity, AsyncCallback responder ) + { + findById( entity, emptyRelations, responder ); + } + + @Override + public void findById( E entity, List relations, AsyncCallback responder ) + { + findById( entity, relations, (Integer)null, responder ); + } + + @Override + public void findById( E entity, Integer relationsDepth, AsyncCallback responder ) + { + findById( entity, emptyRelations, relationsDepth, responder ); + } + + @Override + public void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder ) + { + Backendless.Data.findById( entity, relations, relationsDepth, responder ); + } + + @Override + public E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException + { + return Backendless.Persistence.findById( entityClass, id, queryBuilder ); + } + + @Override + public E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException + { + return Backendless.Persistence.findById( entity, queryBuilder ); + } + + @Override + public void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder ) + { + Backendless.Persistence.findById( entityClass, id, queryBuilder, responder ); + } + + @Override + public void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder ) + { + Backendless.Persistence.findById( entity, queryBuilder, responder ); + } + + @Override + public List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder ) + { + String typeName = BackendlessSerializer.getSimpleName( entityClass ); + return Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType() ); + } + + @Override + public void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder ) + { + String typeName = BackendlessSerializer.getSimpleName( entityClass ); + Backendless.Persistence.loadRelations( typeName, objectId, queryBuilder, queryBuilder.getRelationType(), responder ); + } + + @Override + public void getObjectCount( AsyncCallback responder ) + { + Backendless.Persistence.getObjectCount( entityClass, responder ); + } + + @Override + public void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder ) + { + Backendless.Persistence.getObjectCount( entityClass, dataQueryBuilder, responder ); + } + + @Override + public int addRelation( E parent, String relationColumnName, Collection children ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args ); + } + + @Override + public void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); + } + + @Override + public int addRelation( E parent, String relationColumnName, String whereClause ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args ); + } + + @Override + public void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); + } + + @Override + public int setRelation( E parent, String relationColumnName, Collection children ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args ); + } + + @Override + public void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args, callback ); + } + + @Override + public int setRelation( E parent, String relationColumnName, String whereClause ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "setRelation", args ); + } + + @Override + public void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "addRelation", args, callback ); + } + + @Override + public int deleteRelation( E parent, String relationColumnName, Collection children ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args ); + } + + @Override + public void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + Collection childObjectIds = new ArrayList<>(); + for( R child : children ) + { + String childObjectId = Persistence.getEntityId( child ); + childObjectIds.add( childObjectId ); + } + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, childObjectIds }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback ); + } + + @Override + public int deleteRelation( E parent, String relationColumnName, String whereClause ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args ); + } + + @Override + public void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ) + { + String parentTableName = BackendlessSerializer.getSimpleName( parent.getClass() ); + + String parentObjectId = Persistence.getEntityId( parent ); + + Object[] args = new Object[] { parentTableName, relationColumnName, parentObjectId, whereClause }; + Invoker.invokeAsync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "deleteRelation", args, callback ); + } + + @Override + public EventHandler rt() + { + return eventHandler; + } + + /* + TODO: OFFLINE SECTION + */ + + @Override + public void initLocalDatabase(String whereClause, AsyncCallback responder) { + storageManager.initDatabase(whereClause, responder); + } + + @Override + public void clearLocalDatabase() { + storageManager.clearLocalDatabase(); + } + + @Override + public void saveEventually(E entity) { + saveEventually(entity, null); + } + + @Override + public void saveEventually(E entity, OfflineAwareCallback responder) { + int blLocalId = storageManager.save(entity, responder); + Map serializedEntity = serializeToMap( entity ); + serializedEntity.put("blLocalId", blLocalId); + + Object[] args = new Object[] { + BackendlessSerializer.getSimpleName( entity.getClass() ), + serializedEntity}; + + transactionManager.scheduleOperation("save", args, entityClass.getName(), responder); + } + + @Override + public void removeEventually(E entity) { + removeEventually(entity, null); + } + + @Override + public void removeEventually(E entity, OfflineAwareCallback responder) { + final Map serializedEntity = serializeToMap( entity ); + + Object[] args = new Object[] { + BackendlessSerializer.getSimpleName( entity.getClass() ), + serializedEntity }; + + transactionManager.scheduleOperation("remove", args, entityClass.getName(), responder); + } + + @Override + public void onSave(AsyncCallback responder) { + transactionManager.onSave(BackendlessSerializer.getSimpleName( entityClass ), responder); + + } + + @Override + public void onRemove(AsyncCallback responder) { + transactionManager.onRemove(BackendlessSerializer.getSimpleName( entityClass ), responder); + + } + + @Override + public void enableAutoSync() { + syncManager.enableAutoSync(BackendlessSerializer.getSimpleName( entityClass )); + } + + @Override + public void disableAutoSync() { + syncManager.disableAutoSync(BackendlessSerializer.getSimpleName( entityClass )); + } + + @Override + public boolean isAutoSyncEnabled() { + return syncManager.isAutoSyncEnabled(BackendlessSerializer.getSimpleName( entityClass )); + } + + @Override + public void startOfflineSync(SyncCompletionCallback callback) { + syncManager.startSemiAutoSynchronization(BackendlessSerializer.getSimpleName( entityClass ), callback); + } + + + }; + } } \ No newline at end of file diff --git a/src/com/backendless/IDataStore.java b/src/com/backendless/IDataStore.java index 75a3be8d8..e1b2fa18f 100644 --- a/src/com/backendless/IDataStore.java +++ b/src/com/backendless/IDataStore.java @@ -1,175 +1,202 @@ -/* - * ******************************************************************************************************************** - *

- * BACKENDLESS.COM CONFIDENTIAL - *

- * ******************************************************************************************************************** - *

- * Copyright 2012 BACKENDLESS.COM. All Rights Reserved. - *

- * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers, - * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its - * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret - * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden - * unless prior written permission is obtained from Backendless.com. - *

- * ******************************************************************************************************************** - */ - -package com.backendless; - -import com.backendless.async.callback.AsyncCallback; -import com.backendless.exceptions.BackendlessException; -import com.backendless.persistence.DataQueryBuilder; -import com.backendless.persistence.LoadRelationsQueryBuilder; -import com.backendless.rt.data.EventHandler; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -public interface IDataStore -{ - List create( List objects ) throws BackendlessException; - - void create( List objects, AsyncCallback> responder ) throws BackendlessException; - - E save( E entity ) throws BackendlessException; - - void save( E entity, AsyncCallback responder ); - - Long remove( E entity ) throws BackendlessException; - - void remove( E entity, AsyncCallback responder ); - - int remove( String whereClause ) throws BackendlessException; - - void remove( String whereClause, AsyncCallback responder ) throws BackendlessException; - - int update( String whereClause, Map changes ) throws BackendlessException; - - void update( String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException; - - E findFirst() throws BackendlessException; - - E findFirst( Integer relationsDepth ) throws BackendlessException; - - E findFirst( List relations ) throws BackendlessException; - - void findFirst( AsyncCallback responder ); - - void findFirst( Integer relationsDepth, AsyncCallback responder ); - - void findFirst( List relations, AsyncCallback responder ); - - E findLast() throws BackendlessException; - - E findLast( Integer relationsDepth ) throws BackendlessException; - - E findLast( List relations ) throws BackendlessException; - - void findLast( AsyncCallback responder ); - - void findLast( Integer relationsDepth, AsyncCallback responder ); - - void findLast( List relations, AsyncCallback responder ); - - List find() throws BackendlessException; - - List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException; - - void find( AsyncCallback> responder ); - - void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder ); - - E findById( String id ) throws BackendlessException; - - E findById( String id, List relations ) throws BackendlessException; - - E findById( String id, Integer relationsDepth ) throws BackendlessException; - - E findById( String id, List relations, Integer relationsDepth ) throws BackendlessException; - - E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException; - - E findById( E entity ) throws BackendlessException; - - E findById( E entity, List relations ) throws BackendlessException; - - E findById( E entity, Integer relationsDepth ) throws BackendlessException; - - E findById( E entity, List relations, Integer relationsDepth ) throws BackendlessException; - - E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException; - - int getObjectCount(); - - int getObjectCount( DataQueryBuilder dataQueryBuilder ); - - void findById( String id, AsyncCallback responder ); - - void findById( String id, List relations, AsyncCallback responder ); - - void findById( String id, Integer relationsDepth, AsyncCallback responder ); - - void findById( String id, List relations, Integer relationsDepth, AsyncCallback responder ); - - void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder ); - - void findById( E entity, AsyncCallback responder ); - - void findById( E entity, List relations, AsyncCallback responder ); - - void findById( E entity, Integer relationsDepth, AsyncCallback responder ); - - void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder ); - - void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder ); - - /** - * @see com.backendless.persistence.LoadRelationsQueryBuilder - * - * @param objectId parentObjectId - * @param child relation type - */ - List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder ); - - /** - * @see com.backendless.persistence.LoadRelationsQueryBuilder - * - * @param objectId parentObjectId - * @param child relation type - * @param responder asynchronous callback - */ - void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder ); - - void getObjectCount( AsyncCallback responder ); - - void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder ); - - int addRelation( E parent, String relationColumnName, Collection children ); - - void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); - - int addRelation( E parent, String relationColumnName, String whereClause ); - - void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); - - int setRelation( E parent, String relationColumnName, Collection children ); - - void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); - - int setRelation( E parent, String relationColumnName, String whereClause ); - - void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); - - int deleteRelation( E parent, String relationColumnName, Collection children ); - - void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); - - int deleteRelation( E parent, String relationColumnName, String whereClause ); - - void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); - - EventHandler rt(); -} +/* + * ******************************************************************************************************************** + *

+ * BACKENDLESS.COM CONFIDENTIAL + *

+ * ******************************************************************************************************************** + *

+ * Copyright 2012 BACKENDLESS.COM. All Rights Reserved. + *

+ * NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers, + * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its + * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret + * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden + * unless prior written permission is obtained from Backendless.com. + *

+ * ******************************************************************************************************************** + */ + +package com.backendless; + +import android.support.annotation.Nullable; + +import com.backendless.async.callback.AsyncCallback; +import com.backendless.exceptions.BackendlessException; +import com.backendless.persistence.DataQueryBuilder; +import com.backendless.persistence.LoadRelationsQueryBuilder; +import com.backendless.persistence.offline.OfflineAwareCallback; +import com.backendless.persistence.offline.SyncCompletionCallback; +import com.backendless.rt.data.EventHandler; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public interface IDataStore +{ + List create( List objects ) throws BackendlessException; + + void create( List objects, AsyncCallback> responder ) throws BackendlessException; + + E save( E entity ) throws BackendlessException; + + void save( E entity, AsyncCallback responder ); + + Long remove( E entity ) throws BackendlessException; + + void remove( E entity, AsyncCallback responder ); + + int remove( String whereClause ) throws BackendlessException; + + void remove( String whereClause, AsyncCallback responder ) throws BackendlessException; + + int update( String whereClause, Map changes ) throws BackendlessException; + + void update( String whereClause, Map changes, AsyncCallback responder ) throws BackendlessException; + + E findFirst() throws BackendlessException; + + E findFirst( Integer relationsDepth ) throws BackendlessException; + + E findFirst( List relations ) throws BackendlessException; + + void findFirst( AsyncCallback responder ); + + void findFirst( Integer relationsDepth, AsyncCallback responder ); + + void findFirst( List relations, AsyncCallback responder ); + + E findLast() throws BackendlessException; + + E findLast( Integer relationsDepth ) throws BackendlessException; + + E findLast( List relations ) throws BackendlessException; + + void findLast( AsyncCallback responder ); + + void findLast( Integer relationsDepth, AsyncCallback responder ); + + void findLast( List relations, AsyncCallback responder ); + + List find() throws BackendlessException; + + List find( DataQueryBuilder dataQueryBuilder ) throws BackendlessException; + + void find( AsyncCallback> responder ); + + void find( DataQueryBuilder dataQueryBuilder, AsyncCallback> responder ); + + E findById( String id ) throws BackendlessException; + + E findById( String id, List relations ) throws BackendlessException; + + E findById( String id, Integer relationsDepth ) throws BackendlessException; + + E findById( String id, List relations, Integer relationsDepth ) throws BackendlessException; + + E findById( String id, DataQueryBuilder queryBuilder ) throws BackendlessException; + + E findById( E entity ) throws BackendlessException; + + E findById( E entity, List relations ) throws BackendlessException; + + E findById( E entity, Integer relationsDepth ) throws BackendlessException; + + E findById( E entity, List relations, Integer relationsDepth ) throws BackendlessException; + + E findById( E entity, DataQueryBuilder queryBuilder ) throws BackendlessException; + + int getObjectCount(); + + int getObjectCount( DataQueryBuilder dataQueryBuilder ); + + void findById( String id, AsyncCallback responder ); + + void findById( String id, List relations, AsyncCallback responder ); + + void findById( String id, Integer relationsDepth, AsyncCallback responder ); + + void findById( String id, List relations, Integer relationsDepth, AsyncCallback responder ); + + void findById( String id, DataQueryBuilder queryBuilder, AsyncCallback responder ); + + void findById( E entity, AsyncCallback responder ); + + void findById( E entity, List relations, AsyncCallback responder ); + + void findById( E entity, Integer relationsDepth, AsyncCallback responder ); + + void findById( E entity, List relations, Integer relationsDepth, AsyncCallback responder ); + + void findById( E entity, DataQueryBuilder queryBuilder, AsyncCallback responder ); + + /** + * @see com.backendless.persistence.LoadRelationsQueryBuilder + * + * @param objectId parentObjectId + * @param child relation type + */ + List loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder ); + + /** + * @see com.backendless.persistence.LoadRelationsQueryBuilder + * + * @param objectId parentObjectId + * @param child relation type + * @param responder asynchronous callback + */ + void loadRelations( String objectId, LoadRelationsQueryBuilder queryBuilder, AsyncCallback> responder ); + + void getObjectCount( AsyncCallback responder ); + + void getObjectCount( DataQueryBuilder dataQueryBuilder, AsyncCallback responder ); + + int addRelation( E parent, String relationColumnName, Collection children ); + + void addRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); + + int addRelation( E parent, String relationColumnName, String whereClause ); + + void addRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); + + int setRelation( E parent, String relationColumnName, Collection children ); + + void setRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); + + int setRelation( E parent, String relationColumnName, String whereClause ); + + void setRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); + + int deleteRelation( E parent, String relationColumnName, Collection children ); + + void deleteRelation( E parent, String relationColumnName, Collection children, AsyncCallback callback ); + + int deleteRelation( E parent, String relationColumnName, String whereClause ); + + void deleteRelation( E parent, String relationColumnName, String whereClause, AsyncCallback callback ); + + EventHandler rt(); + + /* + TODO: OFFLINE SECTION + */ + + void initLocalDatabase(@Nullable String whereClause, AsyncCallback responder); + + void clearLocalDatabase(); + + void saveEventually(E entity); + void saveEventually(E entity, OfflineAwareCallback responder ); + + void removeEventually(E entity); + void removeEventually(E entity, OfflineAwareCallback responder ); + + void onSave(AsyncCallback responder); + void onRemove(AsyncCallback responder); + + void enableAutoSync(); + void disableAutoSync(); + boolean isAutoSyncEnabled(); + + void startOfflineSync(SyncCompletionCallback responder); +} diff --git a/src/com/backendless/Persistence.java b/src/com/backendless/Persistence.java index 1b0ee437a..d09fb93e8 100644 --- a/src/com/backendless/Persistence.java +++ b/src/com/backendless/Persistence.java @@ -30,6 +30,12 @@ import com.backendless.persistence.LoadRelationsQueryBuilder; import com.backendless.persistence.MapDrivenDataStore; import com.backendless.persistence.QueryOptions; +import com.backendless.persistence.offline.DataRetrievalPolicy; +import com.backendless.persistence.offline.DatabaseManager; +import com.backendless.persistence.offline.LocalStoragePolicy; +import com.backendless.persistence.offline.SQLiteDatabaseManager; +import com.backendless.persistence.offline.SyncCompletionCallback; +import com.backendless.persistence.offline.SyncManager; import com.backendless.property.ObjectProperty; import com.backendless.utils.MapEntityUtil; import com.backendless.utils.ReflectionUtil; @@ -50,6 +56,9 @@ import java.util.List; import java.util.Map; +import static com.backendless.persistence.offline.DataRetrievalPolicy.*; +import static com.backendless.persistence.offline.LocalStoragePolicy.DONOTSTOREANY; + public final class Persistence { public final static String PERSISTENCE_MANAGER_SERVER_ALIAS = "com.backendless.services.persistence.PersistenceService"; @@ -67,6 +76,18 @@ public final class Persistence private static final Persistence instance = new Persistence(); + + /* + TODO: OFFLINE SECTION + */ + + private final DatabaseManager databaseManager; + private final SyncManager syncManager; + + public DataRetrievalPolicy RetrievalPolicy = ONLINEONLY; + public LocalStoragePolicy LocalStoragePolicy = DONOTSTOREANY; + + static Persistence getInstance() { return instance; @@ -77,6 +98,10 @@ private Persistence() Types.addClientClassMapping( "com.backendless.services.persistence.BackendlessDataQuery", BackendlessDataQuery.class ); Types.addClientClassMapping( "com.backendless.services.persistence.ObjectProperty", ObjectProperty.class ); Types.addClientClassMapping( "com.backendless.services.persistence.QueryOptions", QueryOptions.class ); + + databaseManager = SQLiteDatabaseManager.getInstance(); + syncManager = SyncManager.getInstance(); + syncManager.startAutoSynchronization(); } public void mapTableToClass( String tableName, Class clazz ) @@ -947,7 +972,7 @@ public void callStoredProcedure( String procedureName, Map argum Invoker.invokeAsync( PERSISTENCE_MANAGER_SERVER_ALIAS, "callStoredProcedure", args, responder, ResponderHelper.getCollectionAdaptingResponder( HashMap.class ) ); } - private Map serializeEntityBeforeCreate( final E entity ) + Map serializeEntityBeforeCreate( final E entity ) { if( entity == null ) throw new IllegalArgumentException( ExceptionMessage.NULL_ENTITY ); @@ -970,4 +995,28 @@ public Object substitute( Object o ) return serializedEntity; } + + /* + TODO: OFFLINE SECTION + */ + + public void clearLocalDatabase() { + databaseManager.resetDatabase(); + } + + public void enableAutoSync() { + syncManager.enableAutoSync(); + } + + public void disableAutoSync() { + syncManager.disableAutoSync(); + } + + public boolean isAutoSyncEnabled() { + return syncManager.isAutoSyncEnabled(); + } + + public void startOfflineSync(SyncCompletionCallback callback) { + syncManager.startSemiAutoSynchronization(callback); + } } \ No newline at end of file diff --git a/src/com/backendless/persistence/DataQueryBuilder.java b/src/com/backendless/persistence/DataQueryBuilder.java index f8c392790..a951ab297 100644 --- a/src/com/backendless/persistence/DataQueryBuilder.java +++ b/src/com/backendless/persistence/DataQueryBuilder.java @@ -1,5 +1,8 @@ package com.backendless.persistence; +import com.backendless.persistence.offline.DataRetrievalPolicy; +import com.backendless.persistence.offline.LocalStoragePolicy; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -13,6 +16,8 @@ public class DataQueryBuilder private String whereClause; private List groupBy; private String havingClause; + private DataRetrievalPolicy retrievalPolicy; + private LocalStoragePolicy storagePolicy; private DataQueryBuilder() { @@ -170,4 +175,22 @@ public DataQueryBuilder setHavingClause( String havingClause ) this.havingClause = havingClause; return this; } + + public DataQueryBuilder setRetrievalPolicy(DataRetrievalPolicy retrievalPolicy) { + this.retrievalPolicy = retrievalPolicy; + return this; + } + + public DataRetrievalPolicy getRetrievalPolicy() { + return retrievalPolicy; + } + + public LocalStoragePolicy getStoragePolicy() { + return storagePolicy; + } + + public DataQueryBuilder setStoragePolicy(LocalStoragePolicy storagePolicy) { + this.storagePolicy = storagePolicy; + return this; + } } diff --git a/src/com/backendless/persistence/MapDrivenDataStore.java b/src/com/backendless/persistence/MapDrivenDataStore.java index 731e6639b..3a70d4cd7 100644 --- a/src/com/backendless/persistence/MapDrivenDataStore.java +++ b/src/com/backendless/persistence/MapDrivenDataStore.java @@ -18,6 +18,8 @@ package com.backendless.persistence; +import android.support.annotation.Nullable; + import com.backendless.Backendless; import com.backendless.IDataStore; import com.backendless.Invoker; @@ -27,6 +29,11 @@ import com.backendless.exceptions.BackendlessException; import com.backendless.exceptions.BackendlessFault; import com.backendless.exceptions.ExceptionMessage; +import com.backendless.persistence.offline.LocalStorageManager; +import com.backendless.persistence.offline.OfflineAwareCallback; +import com.backendless.persistence.offline.SyncCompletionCallback; +import com.backendless.persistence.offline.SyncManager; +import com.backendless.persistence.offline.TransactionManager; import com.backendless.rt.data.EventHandler; import com.backendless.rt.data.EventHandlerFactory; import com.backendless.utils.ResponderHelper; @@ -45,18 +52,28 @@ import java.util.List; import java.util.Map; + public class MapDrivenDataStore implements IDataStore { private static final List emptyRelations = new ArrayList(); - private final static EventHandlerFactory eventHandlerFactory = new EventHandlerFactory(); + private static final EventHandlerFactory eventHandlerFactory = new EventHandlerFactory(); private String tableName; private final EventHandler eventHandler; + /* + TODO: OFFLINE SECTION + */ + + private static final TransactionManager transactionManager = TransactionManager.getInstance(); + private static final SyncManager syncManager = SyncManager.getInstance(); + private final LocalStorageManager storageManager; + public MapDrivenDataStore( String tableName ) { this.tableName = tableName; eventHandler = eventHandlerFactory.of( tableName ); + storageManager = new LocalStorageManager(tableName); } @Override @@ -340,10 +357,15 @@ public List find() throws BackendlessException @Override public List find( DataQueryBuilder dataQuery ) throws BackendlessException { - Object[] args = new Object[] { tableName, dataQuery.build() }; + if (!storageManager.shouldRetrieveOnline(dataQuery)) + return storageManager.find(Map.class, dataQuery); - return Invoker.invokeSync( Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "find", args, - ResponderHelper.getCollectionAdaptingResponder( HashMap.class ) ); + Object[] args = new Object[]{tableName, dataQuery.build()}; + + List result = Invoker.invokeSync(Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "find", args, + ResponderHelper.getCollectionAdaptingResponder(HashMap.class)); + storageManager.store(result, dataQuery); + return result; } @Override @@ -357,9 +379,17 @@ public void find( final DataQueryBuilder dataQuery, final AsyncCallback> storeCallback = storageManager.getStoreCallback(dataQuery, callback); + + Object[] args = new Object[]{tableName, dataQuery.build()}; + Invoker.invokeAsync(Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS, "find", args, storeCallback, + ResponderHelper.getCollectionAdaptingResponder(HashMap.class)); + } catch( Throwable e ) { @@ -771,7 +801,79 @@ public EventHandler rt() return eventHandler; } - private class MapDrivenResponder implements IRawResponder + /* + TODO: OFFLINE SECTION + */ + + @Override + public void initLocalDatabase(@Nullable String whereClause, AsyncCallback responder) { + storageManager.initDatabase(whereClause, responder); + } + + @Override + public void clearLocalDatabase() { + storageManager.clearLocalDatabase(); + } + + + @Override + public void saveEventually(Map entity) { + saveEventually(entity, null); + } + + @Override + public void saveEventually(Map entity, OfflineAwareCallback responder) { + int blLocalId = storageManager.save(entity, responder); + entity.put("blLocalId", blLocalId); + + Object[] args = new Object[] { tableName, entity }; + + transactionManager.scheduleOperation("save", args, null, responder); + } + + @Override + public void removeEventually(Map entity) { + removeEventually(entity, null); + } + + @Override + public void removeEventually(Map entity, OfflineAwareCallback responder) { + Object[] args = new Object[] { tableName, entity }; + + transactionManager.scheduleOperation("remove", args, null, responder); + } + + @Override + public void onSave(AsyncCallback responder) { + transactionManager.onSave(tableName, responder); + } + + @Override + public void onRemove(AsyncCallback responder) { + transactionManager.onRemove(tableName, responder); + } + + @Override + public void enableAutoSync() { + syncManager.enableAutoSync(tableName); + } + + @Override + public void disableAutoSync() { + syncManager.disableAutoSync(tableName); + } + + @Override + public boolean isAutoSyncEnabled() { + return syncManager.isAutoSyncEnabled(tableName); + } + + @Override + public void startOfflineSync(SyncCompletionCallback callback) { + syncManager.startSemiAutoSynchronization(tableName, callback); + } + + private class MapDrivenResponder implements IRawResponder { private IResponder nextResponder; diff --git a/src/com/backendless/persistence/offline/AndroidTransactionStorage.java b/src/com/backendless/persistence/offline/AndroidTransactionStorage.java new file mode 100644 index 000000000..1c85eeae8 --- /dev/null +++ b/src/com/backendless/persistence/offline/AndroidTransactionStorage.java @@ -0,0 +1,73 @@ +package com.backendless.persistence.offline; + +import android.content.Context; +import android.content.SharedPreferences; + +import com.backendless.util.JSONConverter; +import com.backendless.utils.JSONConverterWeborbImpl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class AndroidTransactionStorage implements TransactionStorage { + private final static String PREF_TAG = "ENDLESS_TRANSACTION"; + private final static String TRANSACTIONS_KEY = "blPendingTransactions"; + private final SharedPreferences prefs; + private final JSONConverter jsonConverter; + + public AndroidTransactionStorage(Context context) { + prefs = context.getSharedPreferences(PREF_TAG, Context.MODE_PRIVATE); + jsonConverter = new JSONConverterWeborbImpl(); + } + + @Override + public void put(Transaction transaction) { + List transactions = get(); + transactions.add(transaction); + + String json = jsonConverter.writeObject(transactions); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(TRANSACTIONS_KEY, json); + editor.apply(); + } + + @Override + public List get() { + String json = prefs.getString(TRANSACTIONS_KEY, "[]"); + + Object[] objects = jsonConverter.readObject(json, Object[].class); + List transactions = new ArrayList<>(); + for (Object object : objects) { + Map map = (Map) object; + Transaction transaction = new Transaction( + (String) map.get("methodName"), + (Object[]) map.get("args"), + (String) map.get("id"), + (String) map.get("className")); + transactions.add(transaction); + } + return transactions; + } + + @Override + public void remove(Transaction transactionToRemove) { + List transactions = get(); + int removeIndex = -1; + + for (int i = 0; i < transactions.size(); i++) { + if (transactions.get(i).getId().equals(transactionToRemove.getId())) { + removeIndex = i; + break; + } + } + if (removeIndex != -1) { + transactions.remove(removeIndex); + String json = jsonConverter.writeObject(transactions); + + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(TRANSACTIONS_KEY, json); + editor.apply(); + } + } +} diff --git a/src/com/backendless/persistence/offline/CallbackManager.java b/src/com/backendless/persistence/offline/CallbackManager.java new file mode 100644 index 000000000..56569f0af --- /dev/null +++ b/src/com/backendless/persistence/offline/CallbackManager.java @@ -0,0 +1,84 @@ +package com.backendless.persistence.offline; + +import com.backendless.async.callback.AsyncCallback; +import com.backendless.exceptions.BackendlessFault; + +import java.util.HashMap; +import java.util.Map; + +public class CallbackManager { + private final static CallbackManager instance = new CallbackManager(); + + private final Map globalSaveCallbacks = new HashMap<>(); + private final Map globalRemoveCallbacks = new HashMap<>(); + private final Map offlineAwareCallbacks = new HashMap<>(); + + private CallbackManager() + { + + } + + public static CallbackManager getInstance() { + return instance; + } + + + public void putGlobalSaveCallback(String tableName, AsyncCallback callback) { + globalSaveCallbacks.put(tableName, callback); + } + + public void putGlobalRemoveCallback(String tableName, AsyncCallback callback) { + globalRemoveCallbacks.put(tableName, callback); + } + + public void putOfflineAwareCallback(String transactionId, OfflineAwareCallback callback) { + offlineAwareCallbacks.put(transactionId, callback); + } + + public void handleRemoteResponse(Object entity, Transaction transaction) { + String transactionId = transaction.getId(); + OfflineAwareCallback offlineAwareCallback = offlineAwareCallbacks.get(transactionId); + if (offlineAwareCallback != null) { + offlineAwareCallback.handleRemoteResponse(entity); + } else { + String tableName = (String) transaction.getArgs()[0]; + + if (transaction.getMethodName().equals("save")) { + AsyncCallback callback = globalSaveCallbacks.get(tableName); + if (callback != null) + callback.handleResponse(entity); + } else if (transaction.getMethodName().equals("remove")) { + AsyncCallback callback = globalRemoveCallbacks.get(tableName); + if (callback != null) + callback.handleResponse(entity); + } + } + } + + public void handleRemoteFault(Throwable e, Transaction transaction) { + String transactionId = transaction.getId(); + BackendlessFault fault = new BackendlessFault(e); + OfflineAwareCallback offlineAwareCallback = offlineAwareCallbacks.get(transactionId); + if (offlineAwareCallback != null) { + offlineAwareCallback.handleRemoteFault(fault); + } else { + String tableName = (String) transaction.getArgs()[0]; + + if (transaction.getMethodName().equals("save")) { + AsyncCallback callback = globalSaveCallbacks.get(tableName); + if (callback != null) + callback.handleFault(fault); + } else if (transaction.getMethodName().equals("remove")) { + AsyncCallback callback = globalRemoveCallbacks.get(tableName); + if (callback != null) + callback.handleFault(fault); + } + } + } + + public OfflineAwareCallback getOfflineAwareCallback(Transaction transaction) { + String id = transaction.getId(); + return offlineAwareCallbacks.get(id); + } + +} diff --git a/src/com/backendless/persistence/offline/ConnectivityManager.java b/src/com/backendless/persistence/offline/ConnectivityManager.java new file mode 100644 index 000000000..4f74758a1 --- /dev/null +++ b/src/com/backendless/persistence/offline/ConnectivityManager.java @@ -0,0 +1,51 @@ +package com.backendless.persistence.offline; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.NetworkInfo; + +import com.backendless.ContextHandler; + +public class ConnectivityManager { + private final static ConnectivityManager instance = new ConnectivityManager(); + private final SyncManager syncManager; + private boolean isConnected; + + public static ConnectivityManager getInstance() { + return instance; + } + + private ConnectivityManager() { + syncManager = SyncManager.getInstance(); + registerReceiver(); + } + + private void registerReceiver() { + BroadcastReceiver networkStateReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + isConnected = isNetworkAvailable(context); + if (isConnected) syncManager.startAutoSynchronization(); + } + }; + IntentFilter filter = new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION); + ContextHandler.getAppContext().registerReceiver(networkStateReceiver, filter); + } + + private boolean isNetworkAvailable(Context context) { + android.net.ConnectivityManager cm = (android.net.ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + + NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); + if (activeNetwork != null) { + return activeNetwork.getState() == NetworkInfo.State.CONNECTED; + } + return false; + } + + public boolean isConnected() { + return isConnected; + } +} diff --git a/src/com/backendless/persistence/offline/DataRetrievalPolicy.java b/src/com/backendless/persistence/offline/DataRetrievalPolicy.java new file mode 100644 index 000000000..a30baf196 --- /dev/null +++ b/src/com/backendless/persistence/offline/DataRetrievalPolicy.java @@ -0,0 +1,7 @@ +package com.backendless.persistence.offline; + +public enum DataRetrievalPolicy { + OFFLINEONLY, + ONLINEONLY, + DYNAMIC, +} diff --git a/src/com/backendless/persistence/offline/DatabaseHelper.java b/src/com/backendless/persistence/offline/DatabaseHelper.java new file mode 100644 index 000000000..547be458d --- /dev/null +++ b/src/com/backendless/persistence/offline/DatabaseHelper.java @@ -0,0 +1,125 @@ +package com.backendless.persistence.offline; + +import android.content.ContentValues; +import android.database.Cursor; + +import com.backendless.exceptions.ExceptionMessage; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryLexer; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryParser; +import com.backendless.persistence.offline.visitor.AndroidBackendlessQueryVisitor; +import com.backendless.persistence.offline.visitor.res.QueryPart; + +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DatabaseHelper { + + public static ContentValues mapToContentValues(Map map) { + ContentValues contentValues = new ContentValues(); + + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + + if (value == null) + continue; + + if (value instanceof String) + contentValues.put(key, (String) value); + else if (value instanceof Byte) + contentValues.put(key, (Byte) value); + else if (value instanceof Short) + contentValues.put(key, (Short) value); + else if (value instanceof Integer) + contentValues.put(key, (Integer) value); + else if (value instanceof Long) + contentValues.put(key, (Long) value); + else if (value instanceof Float) + contentValues.put(key, (Float) value); + else if (value instanceof Double) + contentValues.put(key, (Double) value); + else if (value instanceof Boolean) + contentValues.put(key, (Boolean) value); + else if (value instanceof Date) + contentValues.put(key, ((Date) value).getTime()); + else throw new IllegalArgumentException(ExceptionMessage.ILLEGAL_ARGUMENT_EXCEPTION); + } + + return contentValues; + } + + public static List cursorToMap(Cursor cursor) { + List result = new ArrayList<>(); + + while (cursor.moveToNext()) { + Map object = new HashMap<>(); + for (String columnName : cursor.getColumnNames()) { + int columnIndex = cursor.getColumnIndex(columnName); + + int type = cursor.getType(columnIndex); + switch (type) { + case Cursor.FIELD_TYPE_STRING: + object.put(columnName, cursor.getString(columnIndex)); + break; + case Cursor.FIELD_TYPE_INTEGER: + object.put(columnName, cursor.getInt(columnIndex)); + break; + case Cursor.FIELD_TYPE_FLOAT: + object.put(columnName, cursor.getFloat(columnIndex)); + break; + } + } + result.add(object); + } + + cursor.close(); + + return result; + } + + public static String getColumnDeclaration(String columnName, Object columnValue) { + StringBuilder declaration = new StringBuilder(); + + declaration + .append(", ") + .append(columnName) + .append(' '); + + if (columnValue instanceof String) + declaration.append("TEXT"); + else if (columnValue instanceof Byte || + columnValue instanceof Short || + columnValue instanceof Integer || + columnValue instanceof Long || + columnValue instanceof Boolean) + declaration.append("INTEGER"); + else if (columnValue instanceof Float || + columnValue instanceof Double) + declaration.append("REAL"); + else if (columnValue == null) + return ""; + else throw new IllegalArgumentException(ExceptionMessage.ILLEGAL_ARGUMENT_EXCEPTION); + + + return declaration.toString(); + } + + public static String parseClause(String whereClause) { + BackendlessQueryLexer lexer = new BackendlessQueryLexer(CharStreams.fromString(whereClause)); + CommonTokenStream tokenStream = new CommonTokenStream(lexer); + BackendlessQueryParser parser = new BackendlessQueryParser(tokenStream); + + BackendlessQueryParser.ConditionContext ctx = parser.condition(); + + AndroidBackendlessQueryVisitor visitor = new AndroidBackendlessQueryVisitor(); + QueryPart visit = visitor.visit(ctx); + + return visit == null ? "" : visit.toString(); + } +} diff --git a/src/com/backendless/persistence/offline/DatabaseManager.java b/src/com/backendless/persistence/offline/DatabaseManager.java new file mode 100644 index 000000000..fa3299c0b --- /dev/null +++ b/src/com/backendless/persistence/offline/DatabaseManager.java @@ -0,0 +1,21 @@ +package com.backendless.persistence.offline; + +import java.util.List; +import java.util.Map; + +public interface DatabaseManager { + + List select(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit); + + Map insert(String table, Map values); + + Map update(String table, Map values, String whereClause, String[] whereArgs); + + Map delete(String table, String whereClause, String[] whereArgs); + + boolean isTableEmpty(String table); + + void dropTable(String tableName); + + void resetDatabase(); +} diff --git a/src/com/backendless/persistence/offline/LocalStorageManager.java b/src/com/backendless/persistence/offline/LocalStorageManager.java new file mode 100644 index 000000000..24686c89a --- /dev/null +++ b/src/com/backendless/persistence/offline/LocalStorageManager.java @@ -0,0 +1,250 @@ +package com.backendless.persistence.offline; + +import android.database.sqlite.SQLiteException; +import android.support.annotation.Nullable; +import android.text.TextUtils; + +import com.backendless.Backendless; +import com.backendless.IDataStore; +import com.backendless.ThreadPoolService; +import com.backendless.async.callback.AsyncCallback; +import com.backendless.exceptions.BackendlessException; +import com.backendless.exceptions.BackendlessFault; +import com.backendless.persistence.BackendlessDataQuery; +import com.backendless.persistence.DataQueryBuilder; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weborb.exceptions.AdaptingException; +import weborb.reader.AnonymousObject; + +import static com.backendless.persistence.BackendlessSerializer.serializeToMap; +import static com.backendless.persistence.offline.DataRetrievalPolicy.ONLINEONLY; +import static com.backendless.persistence.offline.DatabaseHelper.parseClause; +import static com.backendless.persistence.offline.LocalStoragePolicy.STOREALL; + +public class LocalStorageManager { + private final DatabaseManager databaseManager; + private String tableName; + + public LocalStorageManager(String tableName) + { + this.tableName = tableName; + databaseManager = SQLiteDatabaseManager.getInstance(); + } + + public void initDatabase(@Nullable final String whereClause, final AsyncCallback responder) { + if (!databaseManager.isTableEmpty(tableName)) { + if (responder != null) { + responder.handleFault(new BackendlessFault("The database cannot be initialized because it is not empty.")); + } + return; + } + + ThreadPoolService.getPoolExecutor().execute(new Runnable() { + @Override + public void run() { + int pageSize = 100; + int listSize; + int totalCount = 0; + final IDataStore dataStore = Backendless.Data.of(tableName); + final DataQueryBuilder queryBuilder = DataQueryBuilder + .create() + .setPageSize(pageSize) + .setOffset(0) + .setWhereClause(whereClause) + .setRetrievalPolicy(ONLINEONLY) + .setStoragePolicy(STOREALL); + + try { + do { + List result = dataStore.find(queryBuilder); + listSize = result.size(); + totalCount += listSize; + queryBuilder.prepareNextPage(); + } while (listSize == pageSize); + if (responder != null) + responder.handleResponse(totalCount); + } catch (Throwable e) { + if (responder != null) + responder.handleFault(new BackendlessFault(e)); + } + } + }); + } + + public void clearLocalDatabase() { + databaseManager.dropTable(tableName); + } + + public List find(Class clazz, DataQueryBuilder queryBuilder) { + BackendlessDataQuery dataQuery = queryBuilder.build(); + List entities = databaseManager.select( + tableName, + null, + parseClause(dataQuery.getWhereClause()), + null, + TextUtils.join(",", dataQuery.getGroupBy()), + dataQuery.getHavingClause(), + TextUtils.join(",", dataQuery.getQueryOptions().getSortBy()), + String.valueOf(dataQuery.getPageSize())); + if (clazz == Map.class) { + return (List) entities; + } else { + List serializedEntities = new ArrayList<>(); + for (Map map : entities) { + try { + serializedEntities.add((E) new AnonymousObject(new HashMap<>(map)).adapt(clazz)); + } catch (AdaptingException ignored) { } + } + return serializedEntities; + } + } + + public void find(final Class clazz, final DataQueryBuilder queryBuilder, final AsyncCallback> callback) { + ThreadPoolService.getPoolExecutor().execute( new Runnable() + { + @Override + public void run() + { + try + { + List result = find(clazz, queryBuilder); + if (callback != null) + callback.handleResponse(result); + } + catch( BackendlessException e ) + { + if (callback != null) + callback.handleFault( new BackendlessFault( e ) ); + } + } + } ); + } + + public int save(E entity, OfflineAwareCallback responder) { + Map serializedEntity; + if (entity instanceof Map) { + serializedEntity = (Map) entity; + } else { + serializedEntity = serializeToMap( entity ); + } + try { + Map result; + if (serializedEntity.containsKey("objectId") && serializedEntity.get("objectId") != null) { + result = update(serializedEntity); + } else { + result = create(serializedEntity); + } + + if (responder != null) { + if (entity instanceof Map) { + responder.handleLocalResponse((E) result); + } else { + responder.handleLocalResponse(entity); + } + } + + return (int) result.get("blLocalId"); + } catch (Throwable e) { + if (responder != null) + responder.handleLocalFault(new BackendlessFault(e)); + } + return -1; + } + + public Map create(Map entity) { + return databaseManager.insert(tableName, entity); + } + + public Map update(Map entity) { + return update(entity, "objectId = '" + entity.get("objectId") + "'"); + } + + public Map update(Map entity, String whereClause) { + return databaseManager.update(tableName, entity, whereClause, null); + } + + public void remove(Object callbackObject, String objectId, OfflineAwareCallback responder) { + try { + String whereClause = "objectId = '" + objectId + "'"; + databaseManager.delete(tableName, whereClause, null); + if (responder != null) + responder.handleLocalResponse(callbackObject); + } catch (Throwable e) { + if (responder != null) + responder.handleLocalFault(new BackendlessFault(e)); + } + } + + public void store(List entities, DataQueryBuilder queryBuilder) { + LocalStoragePolicy storagePolicy = queryBuilder.getStoragePolicy(); + if (storagePolicy == null) + storagePolicy = Backendless.Data.LocalStoragePolicy; + switch (storagePolicy) { + case STOREUPDATED: { + for (E entity : entities) { + try { + if (entity instanceof Map) + update((Map) entity); + else + update(serializeToMap(entity)); + } catch (SQLiteException ignored) {} + } + break; + } + case STOREALL: { + for (E entity : entities) { + try { + if (entity instanceof Map) + update((Map) entity); + else + update(serializeToMap(entity)); + } catch (SQLiteException e) { + if (entity instanceof Map) + create((Map) entity); + else + create(serializeToMap(entity)); + } + } + break; + } + case DONOTSTOREANY: + default: break; + + } + } + + public boolean shouldRetrieveOnline(DataQueryBuilder dataQuery) { + DataRetrievalPolicy retrievalPolicy = dataQuery.getRetrievalPolicy(); + if (retrievalPolicy == null) + retrievalPolicy = Backendless.Data.RetrievalPolicy; + switch (retrievalPolicy) { + case ONLINEONLY: return true; + case OFFLINEONLY: return false; + case DYNAMIC: return ConnectivityManager.getInstance().isConnected(); + default: return true; + } + } + + public AsyncCallback> getStoreCallback(final DataQueryBuilder dataQuery, + final AsyncCallback> callback ) { + return new AsyncCallback>() { + @Override + public void handleResponse(List response) { + store(response, dataQuery); + if (callback != null) + callback.handleResponse(response); + } + + @Override + public void handleFault(BackendlessFault fault) { + if (callback != null) + callback.handleFault(fault); + } + } ; + } +} diff --git a/src/com/backendless/persistence/offline/LocalStoragePolicy.java b/src/com/backendless/persistence/offline/LocalStoragePolicy.java new file mode 100644 index 000000000..7fd7417bc --- /dev/null +++ b/src/com/backendless/persistence/offline/LocalStoragePolicy.java @@ -0,0 +1,7 @@ +package com.backendless.persistence.offline; + +public enum LocalStoragePolicy { + STOREALL, + DONOTSTOREANY, + STOREUPDATED, +} diff --git a/src/com/backendless/persistence/offline/OfflineAwareCallback.java b/src/com/backendless/persistence/offline/OfflineAwareCallback.java new file mode 100644 index 000000000..8761bfee9 --- /dev/null +++ b/src/com/backendless/persistence/offline/OfflineAwareCallback.java @@ -0,0 +1,11 @@ +package com.backendless.persistence.offline; + +import com.backendless.exceptions.BackendlessFault; + +public interface OfflineAwareCallback +{ + void handleLocalResponse( T response ); + void handleLocalFault( BackendlessFault fault ); + void handleRemoteResponse( T response ); + void handleRemoteFault( BackendlessFault fault ); +} diff --git a/src/com/backendless/persistence/offline/PendingOperationEnum.java b/src/com/backendless/persistence/offline/PendingOperationEnum.java new file mode 100644 index 000000000..0eadbfb45 --- /dev/null +++ b/src/com/backendless/persistence/offline/PendingOperationEnum.java @@ -0,0 +1,7 @@ +package com.backendless.persistence.offline; + +public enum PendingOperationEnum { + CREATE, + UPDATE, + REMOVE +} diff --git a/src/com/backendless/persistence/offline/SQLiteDatabaseManager.java b/src/com/backendless/persistence/offline/SQLiteDatabaseManager.java new file mode 100644 index 000000000..4670c6a4a --- /dev/null +++ b/src/com/backendless/persistence/offline/SQLiteDatabaseManager.java @@ -0,0 +1,181 @@ +package com.backendless.persistence.offline; + +import android.content.ContentValues; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +import com.backendless.ContextHandler; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static com.backendless.persistence.offline.DatabaseHelper.cursorToMap; +import static com.backendless.persistence.offline.DatabaseHelper.getColumnDeclaration; +import static com.backendless.persistence.offline.DatabaseHelper.mapToContentValues; + +public class SQLiteDatabaseManager implements DatabaseManager { + private final static SQLiteDatabaseManager instance = new SQLiteDatabaseManager(); + private final String databaseName = "BackendlessLocalStorage.db"; + private final int databaseVersion = 1; + private SQLiteOpenHelper helper; + private SQLiteDatabase db; + + public static SQLiteDatabaseManager getInstance() + { + return instance; + } + + private SQLiteDatabaseManager() { + initHelper(); + } + + @Override + public List select(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) { + Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy, limit); + + return cursorToMap(cursor); + } + + @Override + public Map insert(String table, Map values) { + createTableIfNotExists(table, values); + + ContentValues contentValues = mapToContentValues(values); + contentValues.put("blLocalTimestamp", System.currentTimeMillis() / 1000); + contentValues.put("___class", table); + + long rowId = db.insert(table, null, contentValues); + if (rowId == -1) throw new SQLiteException("Could not insert the row into the table " + table); + List result = select(table, null, "rowid = " + rowId, + null, null, null, null, "1"); + if (result.size() == 0) throw new SQLiteException("Could not find the '" + table + "' entry with row id: " + rowId); + return result.get(0); + } + + @Override + public Map update(String table, Map values, String whereClause, String[] whereArgs) { + if (!tableExists(table)) throw new SQLiteException("Local table with name '" + table + "' doesn't exist"); + + ContentValues contentValues = mapToContentValues(values); + int updated = db.update(table, contentValues, whereClause, whereArgs); + if (updated == 0) throw new SQLiteException("No rows were affected by the update operation"); + + String objectId = (String) values.get("objectId"); + if (objectId != null) { + List result = select(table, null, "objectId = '" + objectId + "'", + null, null, null, null, null); + if (result.size() == 0) throw new SQLiteException("Could not find the '" + table + "' entry with objectId: " + objectId); + return result.get(0); + } else { + throw new SQLiteException("Could not find the '" + table + "' entry without objectId"); + } + } + + @Override + public Map delete(String table, String whereClause, String[] whereArgs) { + if (!tableExists(table)) throw new SQLiteException("Local table with name '" + table + "' doesn't exist"); + + List result = select(table, null, whereClause, + whereArgs, null, null, null, null); + if (result.size() == 0) throw new SQLiteException("Could not find the '" + table + "' entry where " + whereClause); + Map entry = result.get(0); + + int deleted = db.delete(table, whereClause, whereArgs); + if (deleted == 0) throw new SQLiteException("No rows were affected by the delete operation"); + return entry; + } + + @Override + public boolean isTableEmpty(String table) { + if (!tableExists(table)) return true; + String query = "SELECT count(*) FROM " + table; + Cursor cursor = db.rawQuery(query, null); + cursor.moveToFirst(); + int count = cursor.getInt(0); + return count == 0; + } + + @Override + public void dropTable(String tableName) { + String dropQuery = "DROP TABLE IF EXISTS " + tableName; + db.execSQL(dropQuery); + } + + @Override + public void resetDatabase() { + helper.close(); + db.close(); + SQLiteDatabase.deleteDatabase(new File(db.getPath())); + initHelper(); + } + + private void initHelper() { + helper = new SQLiteOpenHelper( + ContextHandler.getAppContext(), databaseName, null, databaseVersion) { + + @Override + public void onCreate(SQLiteDatabase sqLiteDatabase) { + + } + + @Override + public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { + + } + }; + + db = helper.getWritableDatabase(); + } + + private boolean tableExists(String table) { + String query = "SELECT name FROM sqlite_master WHERE type='table' AND name='" + table + "'"; + Cursor cursor = db.rawQuery(query, null); + int count = cursor.getCount(); + cursor.close(); + return count > 0; + } + + private void createTableIfNotExists(String table, Map values) { + StringBuilder sql = new StringBuilder("CREATE TABLE IF NOT EXISTS " + table + " ("); + + for (Iterator> it = sdkTypes.entrySet().iterator(); it.hasNext();) { + Map.Entry entry = it.next(); + sql.append(entry.getKey()); + sql.append(' '); + sql.append(entry.getValue()); + + if (it.hasNext()) { + sql.append(", "); + } + } + + for (Map.Entry entry : values.entrySet()) { + if (!sdkTypes.containsKey(entry.getKey())) { + sql.append(getColumnDeclaration(entry.getKey(), entry.getValue())); + } + } + sql.append(')'); + + db.execSQL(sql.toString()); + } + + private static Map sdkTypes = new HashMap() {{ + put("blLocalId", "INTEGER PRIMARY KEY AUTOINCREMENT"); + put("blPendingOperation", "INTEGER"); + put("blLocalTimestamp", "INTEGER"); + put("created", "INTEGER"); + put("updated", "INTEGER"); + put("___class", "TEXT"); + put("objectId", "TEXT"); + put("ownerId", "TEXT"); + }}; + + + +} diff --git a/src/com/backendless/persistence/offline/SyncCompletionCallback.java b/src/com/backendless/persistence/offline/SyncCompletionCallback.java new file mode 100644 index 000000000..10951a6c5 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncCompletionCallback.java @@ -0,0 +1,8 @@ +package com.backendless.persistence.offline; + +import java.util.Map; + +public interface SyncCompletionCallback +{ + void syncCompleted( Map syncStatusMap ); +} diff --git a/src/com/backendless/persistence/offline/SyncError.java b/src/com/backendless/persistence/offline/SyncError.java new file mode 100644 index 000000000..73c895632 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncError.java @@ -0,0 +1,11 @@ +package com.backendless.persistence.offline; + +public class SyncError { + public Object object; + public String error; + + public SyncError(Object object, String error) { + this.object = object; + this.error = error; + } +} diff --git a/src/com/backendless/persistence/offline/SyncFailure.java b/src/com/backendless/persistence/offline/SyncFailure.java new file mode 100644 index 000000000..8b81dd655 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncFailure.java @@ -0,0 +1,16 @@ +package com.backendless.persistence.offline; + +import java.util.ArrayList; +import java.util.List; + +public class SyncFailure { + public List createErrors; + public List updateErrors; + public List deleteErrors; + + public SyncFailure() { + this.createErrors = new ArrayList<>(); + this.updateErrors = new ArrayList<>(); + this.deleteErrors = new ArrayList<>(); + } +} diff --git a/src/com/backendless/persistence/offline/SyncManager.java b/src/com/backendless/persistence/offline/SyncManager.java new file mode 100644 index 000000000..f466e5274 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncManager.java @@ -0,0 +1,280 @@ +package com.backendless.persistence.offline; + +import android.database.sqlite.SQLiteException; + +import com.backendless.ContextHandler; +import com.backendless.Invoker; +import com.backendless.ThreadPoolService; +import com.backendless.exceptions.BackendlessException; +import com.backendless.utils.ResponderHelper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import weborb.client.IChainedResponder; +import weborb.exceptions.AdaptingException; +import weborb.reader.AnonymousObject; + +import static com.backendless.Persistence.PERSISTENCE_MANAGER_SERVER_ALIAS; +import static com.backendless.persistence.BackendlessSerializer.serializeToMap; +import static com.backendless.persistence.offline.SyncManager.SyncMode.AUTO; +import static com.backendless.persistence.offline.SyncManager.SyncMode.SEMI_AUTO; + +public class SyncManager { + private final static SyncManager instance = new SyncManager(); + private final CallbackManager callbackManager; + private final TransactionStorage transactionStorage; + private boolean isSyncing = false; + private Map tableSyncMap; + private boolean isAutoSyncEnabled = false; + + private SyncManager() { + TransactionStorageFactory.instance().init(ContextHandler.getAppContext()); + transactionStorage = TransactionStorageFactory.instance().getStorage(); + callbackManager = CallbackManager.getInstance(); + tableSyncMap = new HashMap<>(); + } + + public static SyncManager getInstance() { + return instance; + } + + + public void startAutoSynchronization() { + if (ConnectivityManager.getInstance().isConnected()) + ThreadPoolService.getPoolExecutor().execute(new SyncRunnable()); + } + + public void startSemiAutoSynchronization(SyncCompletionCallback callback) { + if (ConnectivityManager.getInstance().isConnected()) + ThreadPoolService.getPoolExecutor().execute(new SyncRunnable(callback)); + } + + public void startSemiAutoSynchronization(String tableName, SyncCompletionCallback callback) { + if (ConnectivityManager.getInstance().isConnected()) + ThreadPoolService.getPoolExecutor().execute(new SyncRunnable(tableName, callback)); + } + + public boolean isAutoSyncEnabled() { + return isAutoSyncEnabled; + } + + public boolean isAutoSyncEnabled(String tableName) { + return tableSyncMap.containsKey(tableName) && tableSyncMap.get(tableName); + } + public void enableAutoSync() { + isAutoSyncEnabled = true; + } + + public void enableAutoSync(String tableName) { + tableSyncMap.put(tableName, true); + } + + public void disableAutoSync() { + isAutoSyncEnabled = false; + } + + public void disableAutoSync(String tableName) { + tableSyncMap.put(tableName, false); + } + + + + class SyncRunnable implements Runnable { + private final SyncMode syncMode; + private String tableName; + private SyncCompletionCallback callback; + private Map syncStatusMap = new HashMap<>(); + + SyncRunnable() { + this(AUTO, null, null); + } + + SyncRunnable(SyncCompletionCallback callback) { + this(SEMI_AUTO, null, callback); + } + + SyncRunnable(String tableName, SyncCompletionCallback callback) { + this(SEMI_AUTO, tableName, callback); + } + + SyncRunnable(SyncMode syncMode, String tableName, SyncCompletionCallback callback) { + this.syncMode = syncMode; + this.tableName = tableName; + this.callback = callback; + } + + @Override + public void run() { + if (isSyncing) return; + isSyncing = true; + syncTransactions(); + isSyncing = false; + } + + void syncTransactions() { + List transactions = transactionStorage.get(); + for (Transaction transaction : transactions) { + String transactionTableName = (String) transaction.getArgs()[0]; + + if (syncMode == SEMI_AUTO && tableName != null && !transactionTableName.equals(tableName)) continue; + + if (syncMode == AUTO && !isAutoSyncEnabled && !isAutoSyncEnabled(transactionTableName)) + continue; + + try { + + if (transaction.getMethodName().equals("remove")) { + Map entity = (Map) transaction.getArgs()[1]; + Invoker.invokeSync(PERSISTENCE_MANAGER_SERVER_ALIAS, + transaction.getMethodName(), transaction.getArgs()); + + if (transaction.getClassName() != null) { + Object serializedEntity = new AnonymousObject(new HashMap<>(entity)) + .adapt(Class.forName(transaction.getClassName())); + callbackManager.handleRemoteResponse(serializedEntity, transaction); + handleSyncSuccess(transaction, serializedEntity); + } else { + callbackManager.handleRemoteResponse(entity, transaction); + handleSyncSuccess(transaction, entity); + } + + // delete local entity + processRemoveTransaction(transaction); + + // remove completed transaction from the storage + transactionStorage.remove(transaction); + } else { + // remove local fields + Integer localId = (Integer) ((Map) transaction.getArgs()[1]).remove("blLocalId"); + + IChainedResponder responder = null; + if (transaction.getClassName() != null) + responder = ResponderHelper.getPOJOAdaptingResponder( Class.forName(transaction.getClassName()) ); + + Object result = Invoker.invokeSync(PERSISTENCE_MANAGER_SERVER_ALIAS, + transaction.getMethodName(), transaction.getArgs(), responder); + + // notify the registered callback if present + callbackManager.handleRemoteResponse(result, transaction); + + handleSyncSuccess(transaction, result); + + // update local entity with server response + if (transaction.getClassName() != null) + updateLocalEntity(serializeToMap(result), transaction, localId); + else + updateLocalEntity(result, transaction, localId); + + // remove completed transaction from the storage + transactionStorage.remove(transaction); + } + } catch( Throwable e ) { + callbackManager.handleRemoteFault(e, transaction); + + handleSyncFailure(transaction, e); + + // Delete the transaction if the fault is internal + if (isInternalFault(e)) + transactionStorage.remove(transaction); + } + } + + // notify the completion callback if present + if (syncMode == SEMI_AUTO && callback != null) + callback.syncCompleted(syncStatusMap); + } + + private void updateLocalEntity(Object result, Transaction transaction, Integer localId) { + if (!(result instanceof Map)) return; + + String tableName = (String) transaction.getArgs()[0]; + LocalStorageManager storageManager = new LocalStorageManager(tableName); + if (localId != null) { + storageManager.update((Map) result, "blLocalId = " + localId); + } else { + storageManager.create((Map) result); + } + } + + private void processRemoveTransaction(Transaction transaction) { + String tableName = (String) transaction.getArgs()[0]; + Map entity = (Map) transaction.getArgs()[1]; + + Object callbackObject = null; + if (transaction.getClassName() == null) { + callbackObject = entity; + } else { + try { + callbackObject = new AnonymousObject(new HashMap<>(entity)) + .adapt(Class.forName(transaction.getClassName())); + } catch (AdaptingException | ClassNotFoundException ignored) { } + } + LocalStorageManager storageManager = new LocalStorageManager(tableName); + if (entity.containsKey("objectId")) { + storageManager.remove(callbackObject, (String) entity.get("objectId"), + callbackManager.getOfflineAwareCallback(transaction)); + } + } + + private void handleSyncSuccess(Transaction transaction, Object result) { + String tableName = (String) transaction.getArgs()[0]; + Map entity = (Map) transaction.getArgs()[1]; + + SyncStatusReport syncStatusReport = syncStatusMap.get(tableName); + if (syncStatusReport == null) + syncStatusReport = new SyncStatusReport(); + + if (transaction.getMethodName().equals("save")) { + if (entity.containsKey("objectId")) + syncStatusReport.successfulCompletion.updated.add(result); + else + syncStatusReport.successfulCompletion.created.add(result); + } else if (transaction.getMethodName().equals("remove")) { + syncStatusReport.successfulCompletion.deleted.add(result); + } + + syncStatusMap.put(tableName, syncStatusReport); + } + + private void handleSyncFailure(Transaction transaction, Throwable e) { + String tableName = (String) transaction.getArgs()[0]; + Map entity = (Map) transaction.getArgs()[1]; + + SyncError syncError = new SyncError(entity, e.getMessage()); + + SyncStatusReport syncStatusReport = syncStatusMap.get(tableName); + if (syncStatusReport == null) + syncStatusReport = new SyncStatusReport(); + + if (transaction.getMethodName().equals("save")) { + if (entity.containsKey("objectId")) + syncStatusReport.failedCompletion.updateErrors.add(syncError); + else + syncStatusReport.failedCompletion.createErrors.add(syncError); + } else if (transaction.getMethodName().equals("remove")) { + syncStatusReport.failedCompletion.deleteErrors.add(syncError); + } + + syncStatusMap.put(tableName, syncStatusReport); + } + + private boolean isInternalFault(Throwable e) { + if (e instanceof SQLiteException) return true; + + if (e instanceof BackendlessException) { + BackendlessException backendlessException = (BackendlessException) e; + return !backendlessException.getCode().equals("Internal client exception"); + } + return false; + } + } + + enum SyncMode { + AUTO, + SEMI_AUTO, + MANUAL + } +} diff --git a/src/com/backendless/persistence/offline/SyncStatusReport.java b/src/com/backendless/persistence/offline/SyncStatusReport.java new file mode 100644 index 000000000..10e75ba05 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncStatusReport.java @@ -0,0 +1,11 @@ +package com.backendless.persistence.offline; + +public class SyncStatusReport { + public SyncSuccess successfulCompletion; + public SyncFailure failedCompletion; + + public SyncStatusReport() { + successfulCompletion = new SyncSuccess(); + failedCompletion = new SyncFailure(); + } +} diff --git a/src/com/backendless/persistence/offline/SyncSuccess.java b/src/com/backendless/persistence/offline/SyncSuccess.java new file mode 100644 index 000000000..7bd6123a6 --- /dev/null +++ b/src/com/backendless/persistence/offline/SyncSuccess.java @@ -0,0 +1,16 @@ +package com.backendless.persistence.offline; + +import java.util.ArrayList; +import java.util.List; + +public class SyncSuccess { + public List created; + public List updated; + public List deleted; + + public SyncSuccess() { + this.created = new ArrayList<>(); + this.updated = new ArrayList<>(); + this.deleted = new ArrayList<>(); + } +} diff --git a/src/com/backendless/persistence/offline/Transaction.java b/src/com/backendless/persistence/offline/Transaction.java new file mode 100644 index 000000000..e9efd1959 --- /dev/null +++ b/src/com/backendless/persistence/offline/Transaction.java @@ -0,0 +1,49 @@ +package com.backendless.persistence.offline; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.UUID; + +public class Transaction implements Serializable { + private final String methodName; + private final Object[] args; + private final String id; + private final String className; + + public Transaction(String methodName, Object[] args, String className) { + this(methodName, args, UUID.randomUUID().toString(), className); + } + + public Transaction(String methodName, Object[] args, String id, String className) { + this.methodName = methodName; + this.args = args; + this.id = id; + this.className = className; + } + + public String getMethodName() { + return methodName; + } + + public Object[] getArgs() { + return args; + } + + public String getId() { + return id; + } + + public String getClassName() { + return className; + } + + @Override + public String toString() { + return "Transaction{" + + "methodName='" + methodName + '\'' + + ", args=" + Arrays.toString(args) + + ", id='" + id + '\'' + + ", className='" + className + '\'' + + '}'; + } +} diff --git a/src/com/backendless/persistence/offline/TransactionManager.java b/src/com/backendless/persistence/offline/TransactionManager.java new file mode 100644 index 000000000..49c0e83d4 --- /dev/null +++ b/src/com/backendless/persistence/offline/TransactionManager.java @@ -0,0 +1,44 @@ +package com.backendless.persistence.offline; + +import com.backendless.ContextHandler; +import com.backendless.async.callback.AsyncCallback; + +public class TransactionManager { + private final static TransactionManager instance = new TransactionManager(); + private final CallbackManager callbackManager; + private final TransactionStorage transactionStorage; + private final SyncManager syncManager; + + + private TransactionManager() { + TransactionStorageFactory.instance().init(ContextHandler.getAppContext()); + transactionStorage = TransactionStorageFactory.instance().getStorage(); + callbackManager = CallbackManager.getInstance(); + syncManager = SyncManager.getInstance(); + } + + public static TransactionManager getInstance() + { + return instance; + } + + public void onSave(String tableName, AsyncCallback callback) { + callbackManager.putGlobalSaveCallback(tableName, callback); + } + + public void onRemove(String tableName, AsyncCallback callback) { + callbackManager.putGlobalRemoveCallback(tableName, callback); + } + + public void scheduleOperation(String methodName, Object[] args, String className, + OfflineAwareCallback responder) { + Transaction transaction = new Transaction(methodName, args, className); + + callbackManager.putOfflineAwareCallback(transaction.getId(), responder); + + transactionStorage.put(transaction); + + syncManager.startAutoSynchronization(); + } + +} diff --git a/src/com/backendless/persistence/offline/TransactionStorage.java b/src/com/backendless/persistence/offline/TransactionStorage.java new file mode 100644 index 000000000..d4876e071 --- /dev/null +++ b/src/com/backendless/persistence/offline/TransactionStorage.java @@ -0,0 +1,12 @@ +package com.backendless.persistence.offline; + +import java.util.List; + +public interface TransactionStorage { + + void put(Transaction transaction); + + List get(); + + void remove(Transaction transaction); +} diff --git a/src/com/backendless/persistence/offline/TransactionStorageFactory.java b/src/com/backendless/persistence/offline/TransactionStorageFactory.java new file mode 100644 index 000000000..d82f2f3f7 --- /dev/null +++ b/src/com/backendless/persistence/offline/TransactionStorageFactory.java @@ -0,0 +1,46 @@ +package com.backendless.persistence.offline; + + +import android.content.Context; + +import com.backendless.Backendless; +import com.backendless.exceptions.ExceptionMessage; + +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +public class TransactionStorageFactory +{ + private static AndroidTransactionStorage androidTransactionStorage; + private static TransactionStorageFactory instance = new TransactionStorageFactory(); + + public static TransactionStorageFactory instance() + { + return instance; + } + + private TransactionStorageFactory() + { + } + + public void init( Context context ) + { + if (androidTransactionStorage == null) + androidTransactionStorage = new AndroidTransactionStorage( context ); + } + + public TransactionStorage getStorage() + { + if( Backendless.isAndroid() && androidTransactionStorage == null ) + throw new IllegalArgumentException( ExceptionMessage.INIT_BEFORE_USE ); + + if( Backendless.isAndroid() ) + return androidTransactionStorage; + + // CodeRunner + if( Backendless.isCodeRunner() ) + throw new NotImplementedException(); + + // Java + throw new NotImplementedException(); + } +} diff --git a/src/com/backendless/persistence/offline/visitor/AndroidBackendlessQueryVisitor.java b/src/com/backendless/persistence/offline/visitor/AndroidBackendlessQueryVisitor.java new file mode 100644 index 000000000..45e572102 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/AndroidBackendlessQueryVisitor.java @@ -0,0 +1,396 @@ +package com.backendless.persistence.offline.visitor; + +import com.backendless.persistence.offline.visitor.bcknd.DateUtil; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryBaseVisitor; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryParser; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryParser.Expression_atomContext; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryParser.Select_list_elemContext; +import com.backendless.persistence.offline.visitor.gen.BackendlessQueryParser.Sort_by_elemContext; +import com.backendless.persistence.offline.visitor.res.*; + +import java.util.*; + +import static com.backendless.persistence.offline.visitor.res.AggregateOperator.*; +import static com.backendless.persistence.offline.visitor.res.ExpressionOperator.*; +import static com.backendless.persistence.offline.visitor.res.Operator.*; +import static com.backendless.persistence.offline.visitor.res.SortField.SortOrder.*; + +public class AndroidBackendlessQueryVisitor extends BackendlessQueryBaseVisitor +{ + private Table databaseTable; + private Map joins; + private Set fields; + + private final Map aliases = new HashMap<>(); + + private boolean isInHavingClause = false; + private boolean isInWhereClause = false; + + private final DateUtil dateUtil = new DateUtil(); + + @Override + public SelectQuery visitSelect_statement(BackendlessQueryParser.Select_statementContext ctx ) + { + databaseTable = visitTable_name( ctx.table_name() ); + joins = new LinkedHashMap<>(); // order should be preserved for SQL joins + fields = new HashSet<>(); + + for (Select_list_elemContext context : ctx.select_list().select_list_elem()) { + fields.add((Field) visit( context )); + } + + final SelectQuery query = new SelectQuery(); + query.from = this.databaseTable; + + if( ctx.condition() != null ) + { + isInWhereClause = true; + query.condition = (Condition) visit( ctx.condition() ); + isInWhereClause = false; + } + + if( ctx.group_by_clause() != null ) + { + for (Expression_atomContext context : ctx.group_by_clause().expression_atom()) { + query.groupBy.add((Field) visit( context )); + } + } + + if( ctx.having_clause() != null ) + { + query.having = (Condition) visit( ctx.having_clause() ); + } + + if( ctx.sort_by_clause() != null ) + { + for (Sort_by_elemContext context : ctx.sort_by_clause().sort_by_elem()) { + query.orderBy.add(visitSort_by_elem(context)); + } + } + +// joins.forEach( ( table, condition ) -> query.addJoin( table, JoinType.LEFT_OUTER_JOIN, condition ) ); + + if( ctx.limit_clause() != null ) + { + query.limit = Integer.parseInt( ctx.limit_clause().INT( 0 ).getText() ); + if( ctx.limit_clause().OFFSET() != null ) + query.offset = Integer.parseInt( ctx.limit_clause().INT( 1 ).getText() ) ; + } + + query.selectList = ( fields ); + + return query; + } + + @Override + public Field visitSimpleSelectElem( BackendlessQueryParser.SimpleSelectElemContext ctx ) + { + return (Field) visit( ctx.expression_atom() ); + } + + @Override + public Field visitAliasedSelectElem( BackendlessQueryParser.AliasedSelectElemContext ctx ) + { + final Field field = (Field) visit( ctx.expression_atom() ); + final String alias = ctx.alias().getText(); + + field.alias = alias; + + aliases.put( alias, field ); + + return field; + } + + @Override + public SortField visitSort_by_elem( Sort_by_elemContext ctx ) + { + Field field = (Field) visit( ctx.expression_atom() ); + + if( ctx.ASC() != null ) + return new SortField(field, ASC); + else if( ctx.DESC() != null ) + return new SortField(field, DESC); + else + return new SortField(field, ASC); + } + + @Override + public Table visitTable_name( BackendlessQueryParser.Table_nameContext ctx ) + { + final String tableName = ctx.regular_id().getText(); + return new Table(tableName); + } + + @Override + public QueryPart visitHaving_clause( BackendlessQueryParser.Having_clauseContext ctx ) + { + isInHavingClause = true; + final QueryPart result = super.visitHaving_clause( ctx ); + isInHavingClause = false; + return result; + } + + // conditions + + @Override + public Condition visitNotCondition( BackendlessQueryParser.NotConditionContext ctx ) + { + final Condition condition = (Condition) visit( ctx.condition() ); + return new NotCondition( condition ); + } + + @Override + public Condition visitAndCondition( BackendlessQueryParser.AndConditionContext ctx ) + { + final Condition condition1 = (Condition) visit( ctx.condition( 0 ) ); + final Condition condition2 = (Condition) visit( ctx.condition( 1 ) ); + + return new CombinedCondition(condition1, Operator.AND, condition2); + } + + @Override + public Condition visitOrCondition( BackendlessQueryParser.OrConditionContext ctx ) + { + final Condition condition1 = (Condition) visit( ctx.condition( 0 ) ); + final Condition condition2 = (Condition) visit( ctx.condition( 1 ) ); + + return new CombinedCondition(condition1, Operator.OR, condition2); + } + + @Override + public Condition visitNestedCondition( BackendlessQueryParser.NestedConditionContext ctx ) + { + return (Condition) visit( ctx.condition() ); + } + + @Override + public Condition visitIsNullCondition( BackendlessQueryParser.IsNullConditionContext ctx ) + { + final Field field = (Field) visit( ctx.expression_atom() ); + + return new NullCondition(field, true); + } + + @Override + public Condition visitIsNotNullCondition( BackendlessQueryParser.IsNotNullConditionContext ctx ) + { + final Field field = (Field) visit( ctx.expression_atom() ); + + return new NullCondition(field, false); + } + + @Override + public Condition visitLikeCondition( BackendlessQueryParser.LikeConditionContext ctx ) + { + Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new LikeCondition(param1, ctx.NOT() == null, param2); + } + + // comparison conditions + + @Override + public Condition visitEqualCondition( BackendlessQueryParser.EqualConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, EQUAL, field2); + } + + @Override + public Condition visitNotEqualCondition( BackendlessQueryParser.NotEqualConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, NOT_EQUAL, field2); + } + + @Override + public Condition visitGreaterThanOrEqualCondition( BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, GREATER_THAN_OR_EQUAL, field2); + } + + @Override + public Condition visitGreaterThanCondition( BackendlessQueryParser.GreaterThanConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, Operator.GREATER_THAN, field2); + } + + @Override + public Condition visitLessThanOrEqualCondition( BackendlessQueryParser.LessThanOrEqualConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, LESS_THAN_OR_EQUAL, field2); + } + + @Override + public Condition visitLessThanCondition( BackendlessQueryParser.LessThanConditionContext ctx ) + { + final Field field1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field field2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new ComparisonCondition(field1, LESS_THAN, field2); + } + + // expression atoms + + @Override + public Field visitUnaryMinusExpressionAtom( BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx ) + { + final Field param = (Field) visit( ctx.expression_atom() ); + return new Expression(param, MULTIPLY, new Value<>(-1)); + } + + @Override + public Field visitMultiplicationExpressionAtom( + BackendlessQueryParser.MultiplicationExpressionAtomContext ctx ) + { + final Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new Expression(param1, MULTIPLY, param2); + } + + @Override + public Field visitDivisionExpressionAtom( BackendlessQueryParser.DivisionExpressionAtomContext ctx ) + { + final Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new Expression(param1, DIVIDE, param2); + } + + @Override + public Field visitModuloExpressionAtom( BackendlessQueryParser.ModuloExpressionAtomContext ctx ) + { + final Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new Expression(param1, MODULO, param2); + } + + @Override + public Field visitAdditionExpressionAtom( BackendlessQueryParser.AdditionExpressionAtomContext ctx ) + { + final Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new Expression(param1, ADD, param2); + } + + @Override + public Field visitSubtractionExpressionAtom( + BackendlessQueryParser.SubtractionExpressionAtomContext ctx ) + { + final Field param1 = (Field) visit( ctx.expression_atom( 0 ) ); + final Field param2 = (Field) visit( ctx.expression_atom( 1 ) ); + + return new Expression(param1, SUBTRACT, param2); + } + + // expression atom constants + + @Override + public Value visitStringConstant( BackendlessQueryParser.StringConstantContext ctx ) + { + final String text = ctx.string_literal().getText(); + final String unquotedText = text.substring( 1, text.length() - 1 ); + final String unescapedText = text.replace( "''", "'" ); + + // check whether this String is a date + try { + return new Value<>(dateUtil.getTimestampFromString(unquotedText)); + } catch (IllegalArgumentException e) { + return new Value<>(unescapedText); + } + } + + @Override + public Value visitDecimalNumericConstant( BackendlessQueryParser.DecimalNumericConstantContext ctx ) + { + final long number = Long.parseLong( ctx.getText() ); + return new Value<>( number ); + } + + @Override + public Value visitFloatNumericConstant( BackendlessQueryParser.FloatNumericConstantContext ctx ) + { + final double number = Double.parseDouble( ctx.getText() ); + return new Value<>( number ); + } + + @Override + public Value visitTrueBooleanConstant( BackendlessQueryParser.TrueBooleanConstantContext ctx ) + { + return new Value<>( Boolean.TRUE ); + } + + @Override + public Value visitFalseBooleanConstant( BackendlessQueryParser.FalseBooleanConstantContext ctx ) + { + return new Value<>( Boolean.FALSE ); + } + + // function call visit methods + @Override + public QueryPart visitUnknown_function( BackendlessQueryParser.Unknown_functionContext ctx ) + { + throw new IllegalArgumentException( "No such function " + ctx.unknown_name().regular_id().getText() ); + } + + @Override + public AggregateFunction visitAvgFunction( BackendlessQueryParser.AvgFunctionContext ctx ) + { + final Field field= (Field) visit( ctx.expression_atom() ); + return new AggregateFunction(AVG, field ); + } + + @Override + public AggregateFunction visitMaxFunction( BackendlessQueryParser.MaxFunctionContext ctx ) + { + final Field field= (Field) visit( ctx.expression_atom() ); + return new AggregateFunction(MAX, field ); + } + + @Override + public AggregateFunction visitMinFunction( BackendlessQueryParser.MinFunctionContext ctx ) + { + final Field field= (Field) visit( ctx.expression_atom() ); + return new AggregateFunction(MIN, field ); + } + + @Override + public AggregateFunction visitSumFunction( BackendlessQueryParser.SumFunctionContext ctx ) + { + final Field field= (Field) visit( ctx.expression_atom() ); + return new AggregateFunction(SUM, field ); + } + + @Override + public AggregateFunction visitCountFunction( BackendlessQueryParser.CountFunctionContext ctx ) + { + final Field field= (Field) visit( ctx.expression_atom() ); + return new AggregateFunction(COUNT, field ); + } + + @Override + public Field visitSimple_column( BackendlessQueryParser.Simple_columnContext ctx ) + { + final String columnName = ctx.regular_id().getText(); + return new Field(columnName); + } + + +} diff --git a/src/com/backendless/persistence/offline/visitor/bcknd/DateUtil.java b/src/com/backendless/persistence/offline/visitor/bcknd/DateUtil.java new file mode 100644 index 000000000..a3748b3a7 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/bcknd/DateUtil.java @@ -0,0 +1,29 @@ +package com.backendless.persistence.offline.visitor.bcknd; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +public class DateUtil { + private static final String dateFormats = "EEE MMM dd HH:mm:ss zzz yyyy;yyyy-MM-dd'T'HH:mm:ss.SSS'Z';MM/dd/yyyy HH:mm:ss 'GMT'z;MM.dd.yyyy HH:mm:ss 'GMT'z;MM-dd-yyyy HH:mm:ss 'GMT'z;MM/dd/yyyy HH:mm:ss z;MM.dd.yyyy HH:mm:ss z;MM.dd.yyyy HH:mm:ss;MM-dd-yyyy HH:mm:ss;MM/dd/yyyy HH:mm:ss;MM.dd.yyyy;MM-dd-yyyy;MM/dd/yyyy HH:mm:ss 'GMT'Z;MM/dd/yyyy HH:mm;MM/dd/yyyy;dd/MMM/yyyy;dd-MMM-yyyy;EEEEE, d MMMMM yyyy;yyyy/MM/d/HH:mm:ss;yyyy-MM-dd'T'HH:mm:ss;EEEEE, MMMMM d, yyyy;MMMMM d, yyyy;yyyy M d;yyyyMMMd;yyyy-MMM-d;yyyy-M-d, E;'Date' yyyy-MM-dd;yyyy-MM-dd'T'HH:mm:ss;yyyy-MM-dd'T'HH:mmZ;yyyy-MM-dd;yyyy-'W'w;yyyy-DDD;d MMMMM yyyy, HH'h' mm'm' ss's'"; + private final List formatters; + + public DateUtil() { + formatters = new ArrayList<>(); + for (String pattern : dateFormats.split(";")) { + formatters.add(new SimpleDateFormat(pattern)); + } + } + + public String getTimestampFromString(String value) throws IllegalArgumentException { + for (SimpleDateFormat formatter : formatters) { + try { + return String.valueOf(formatter.parse(value).getTime()); + } catch (ParseException ignored) { } + } + + throw new IllegalArgumentException("Invalid date format"); + } + +} + diff --git a/src/com/backendless/persistence/offline/visitor/bcknd/UnitConvertor.java b/src/com/backendless/persistence/offline/visitor/bcknd/UnitConvertor.java new file mode 100644 index 000000000..407dc8a4d --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/bcknd/UnitConvertor.java @@ -0,0 +1,47 @@ +package com.backendless.persistence.offline.visitor.bcknd; + +public class UnitConvertor +{ + public final static double METER_TO_KILOMETER = 1000; + public final static double METER_TO_MILES = 1609.344; + public final static double METER_TO_YARD = 0.9144; + public final static double METER_TO_FOOT = 0.3048; + + public static double convertToMeter(double value, Units unit) + { + switch( unit ) + { + case METERS: + return value; + case KILOMETERS: + return value * METER_TO_KILOMETER; + case YARDS: + return value * METER_TO_YARD; + case FEET: + return value * METER_TO_FOOT; + case MILES: + return value * METER_TO_MILES; + default: + throw new RuntimeException( "Unknown unit of measure" ); + } + } + + public static double convertFromMeter( double value, Units unit ) + { + switch( unit ) + { + case METERS: + return value; + case KILOMETERS: + return value / METER_TO_KILOMETER; + case YARDS: + return value / METER_TO_YARD; + case FEET: + return value / METER_TO_FOOT; + case MILES: + return value / METER_TO_MILES; + default: + throw new RuntimeException( "Unknown unit of measure" ); + } + } +} diff --git a/src/com/backendless/persistence/offline/visitor/bcknd/Units.java b/src/com/backendless/persistence/offline/visitor/bcknd/Units.java new file mode 100644 index 000000000..65659ada6 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/bcknd/Units.java @@ -0,0 +1,18 @@ +package com.backendless.persistence.offline.visitor.bcknd; + +public enum Units +{ + KILOMETERS(1000), MILES(1609.344), METERS(1), FEET(0.3048), YARDS(0.9144); + + private double metersInUnit; + + private Units( double metersInUnit ) + { + this.metersInUnit = metersInUnit; + } + + public double getMetersInUnit() + { + return metersInUnit; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.g4 b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.g4 new file mode 100644 index 000000000..50d111e9a --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.g4 @@ -0,0 +1,309 @@ +grammar BackendlessQuery; + +//@header{ +//package com.backendless.query.gen; +//} + +select_statement + : table_name '[' condition? ']' + '.' + select_list + group_by_clause? + having_clause? + sort_by_clause? + limit_clause? + ; + +select_list + : '{' select_list_elem (',' select_list_elem)* '}' + | select_list_elem + ; + +select_list_elem + : expression_atom #simpleSelectElem + | expression_atom AS alias #aliasedSelectElem + ; + +group_by_clause + : GROUP BY expression_atom (',' expression_atom)* + ; + +having_clause + : HAVING condition + ; + +sort_by_clause + : SORT BY sort_by_elem (',' sort_by_elem)* + ; + +sort_by_elem + : expression_atom (ASC | DESC)? + ; + +limit_clause + : LIMIT INT (OFFSET INT)? + ; + +function_call + : aggregate_windowed_function + | units_function + | spatial_convert_function + | spatial_function + | unknown_function + ; + +spatial_convert_function + : aswkb_function + | aswkt_function + | asgeojson_function + ; + +spatial_function_parameter + : simple_column + | constant + ; + +aswkb_function + : AsWKB '(' spatial_function_parameter ')' + ; + +aswkt_function + : AsWKT '(' spatial_function_parameter ')' + ; + +asgeojson_function + : AsGeoJSON '(' spatial_function_parameter ')' + ; + +spatial_function + : distance_function + | distance_on_sphere + ; + +distance_function + : DISTANCE '(' spatial_function_parameter ',' spatial_function_parameter ')' + | DISTANCE '(' expression_atom ',' expression_atom ',' expression_atom ',' expression_atom ')' + ; + +distance_on_sphere + : DISTANCE_ON_SPHERE '(' spatial_function_parameter ',' spatial_function_parameter (',' expression_atom)? ')' + ; + +units_function + : FT '(' numeric_literal ')' #ftUnitsFunction + | KM '(' numeric_literal ')' #kmUnitsFunction + | MI '(' numeric_literal ')' #miUnitsFunction + | YD '(' numeric_literal ')' #ydUnitsFunction + ; + +aggregate_windowed_function + : AVG '(' expression_atom ')' #avgFunction + | MAX '(' expression_atom ')' #maxFunction + | MIN '(' expression_atom ')' #minFunction + | SUM '(' expression_atom ')' #sumFunction + | COUNT '(' expression_atom ')' #countFunction + ; + +condition + : (NOT | '!') condition #notCondition + | condition (AND | '&&') condition #andCondition + | condition (OR | '||') condition #orCondition + | '(' condition ')' #nestedCondition + | expression_atom NOT? IN + '(' (select_statement | expression_atom) + (','(select_statement | expression_atom))* ')' #inCondition + | expression_atom IS NULL #isNullCondition + | expression_atom IS NOT NULL #isNotNullCondition + | expression_atom NOT? LIKE expression_atom #likeCondition + | expression_atom ('=' | AT) expression_atom #equalCondition + | expression_atom ('!=' | '<>') expression_atom #notEqualCondition + | expression_atom ('>=' | AT OR AFTER) expression_atom #greaterThanOrEqualCondition + | expression_atom ('>' | AFTER) expression_atom #greaterThanCondition + | expression_atom ('<=' | AT OR BEFORE) expression_atom #lessThanOrEqualCondition + | expression_atom ('<' | BEFORE) expression_atom #lessThanCondition + ; + +expression_atom + : constant #constantExpressionAtom + | full_column_name #fullColumnNameExpressionAtom + | function_call #functionCallExpressionAtom + | '-' expression_atom #unaryMinusExpressionAtom + | expression_atom '*' expression_atom #multiplicationExpressionAtom + | expression_atom '/' expression_atom #divisionExpressionAtom + | expression_atom '%' expression_atom #moduloExpressionAtom + | expression_atom '+' expression_atom #additionExpressionAtom + | expression_atom '-' expression_atom #subtractionExpressionAtom + ; + +full_column_name + : single_column_name + | relation_column + ; + +single_column_name + : simple_column + | inverse_relation_column + ; + +relation_column + : single_column_name '.' (relation_column | single_column_name) + ; + +inverse_relation_column + : table_name '[' full_column_name ']' '.' full_column_name + ; + +unknown_function + : unknown_name '(' expression_atom ')' + ; + +alias: regular_id; +table_name: regular_id; +simple_column: regular_id; +unknown_name: regular_id; + +constant + : string_literal #stringConstant + | numeric_literal #numericConstant + | boolean_literal #booleanConstant + | NULL #nullConstant + ; + +boolean_literal + : TRUE #trueBooleanConstant + | FALSE #falseBooleanConstant + ; + +numeric_literal + : INT #decimalNumericConstant + | INT? '.' INT #floatNumericConstant + ; + +string_literal + : CHAR_STRING + ; + +regular_id + : ID + // in order to make it possible to use keywords as identifiers (e.g. column or table names) + // we need to specify them here separately, otherwise antlr4 parses them as keywords resulting in invalid query + // see https://stackoverflow.com/a/41427981/1813669 + | keyword_as_id + ; + +keyword_as_id + : AFTER + | AND + | AT + | AS + | ASC + | AVG + | BEFORE + | BY + | COUNT + | DESC + | DISTANCE + | DISTANCE_ON_SPHERE + | DIV + | ESCAPE + | FALSE + | FT + | GROUP + | HAVING + | IN + | IS + | KM + | LIMIT + | LIKE + | MAX + | MI + | MIN + | MOD + | NOT + | NULL + | OFFSET + | OR + | SELECT + | SORT + | SUM + | TRUE + | YD + ; + +AFTER : A F T E R ; +AND : A N D ; +AT : A T ; +AS : A S ; +ASC : A S C ; +AVG : A V G ; +BEFORE : B E F O R E ; +BY : B Y ; +COUNT : C O U N T ; +DESC : D E S C ; +DISTANCE : D I S T A N C E ; +DISTANCE_ON_SPHERE : D I S T A N C E '_' O N '_' S P H E R E ; +DIV : D I V ; +ESCAPE : E S C A P E ; +FALSE : F A L S E ; +FT : F T ; +GROUP : G R O U P ; +HAVING : H A V I N G ; +IN : I N ; +IS : I S ; +KM : K M ; +LIMIT : L I M I T ; +LIKE : L I K E ; +MAX : M A X ; +MI : M I ; +MIN : M I N ; +MOD : M O D ; +NOT : N O T ; +NULL : N U L L ; +OFFSET : O F F S E T ; +OR : O R ; +SELECT : S E L E C T ; +SORT : S O R T ; +SUM : S U M ; +TRUE : T R U E ; +YD : Y D ; +AsWKB : A S W K B ; +AsWKT : A S W K T ; +AsGeoJSON : A S G E O J S O N ; + +ID: (LETTER | '_') (LETTER | DIGIT | '$' | '_' | '#')*; + +INT: DIGIT+; +CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; + +WS: [ \t\r\n]+ -> skip; + +fragment DIGIT : [0-9] ; +fragment LETTER : [a-zA-Z] ; +fragment NEWLINE : '\r'? '\n' ; + +fragment A: [aA]; +fragment B: [bB]; +fragment C: [cC]; +fragment D: [dD]; +fragment E: [eE]; +fragment F: [fF]; +fragment G: [gG]; +fragment H: [hH]; +fragment I: [iI]; +fragment J: [jJ]; +fragment K: [kK]; +fragment L: [lL]; +fragment M: [mM]; +fragment N: [nN]; +fragment O: [oO]; +fragment P: [pP]; +fragment Q: [qQ]; +fragment R: [rR]; +fragment S: [sS]; +fragment T: [tT]; +fragment U: [uU]; +fragment V: [vV]; +fragment W: [wW]; +fragment X: [xX]; +fragment Y: [yY]; +fragment Z: [zZ]; \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.interp b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.interp new file mode 100644 index 000000000..77f6ebeda --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.interp @@ -0,0 +1,179 @@ +token literal names: +null +'[' +']' +'.' +'{' +',' +'}' +'(' +')' +'!' +'&&' +'||' +'=' +'!=' +'<>' +'>=' +'>' +'<=' +'<' +'-' +'*' +'/' +'%' +'+' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +AFTER +AND +AT +AS +ASC +AVG +BEFORE +BY +COUNT +DESC +DISTANCE +DISTANCE_ON_SPHERE +DIV +ESCAPE +FALSE +FT +GROUP +HAVING +IN +IS +KM +LIMIT +LIKE +MAX +MI +MIN +MOD +NOT +NULL +OFFSET +OR +SELECT +SORT +SUM +TRUE +YD +AsWKB +AsWKT +AsGeoJSON +ID +INT +CHAR_STRING +WS + +rule names: +select_statement +select_list +select_list_elem +group_by_clause +having_clause +sort_by_clause +sort_by_elem +limit_clause +function_call +spatial_convert_function +spatial_function_parameter +aswkb_function +aswkt_function +asgeojson_function +spatial_function +distance_function +distance_on_sphere +units_function +aggregate_windowed_function +condition +expression_atom +full_column_name +single_column_name +relation_column +inverse_relation_column +unknown_function +alias +table_name +simple_column +unknown_name +constant +boolean_literal +numeric_literal +string_literal +regular_id +keyword_as_id + + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 68, 444, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 3, 2, 3, 2, 3, 2, 5, 2, 78, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 84, 10, 2, 3, 2, 5, 2, 87, 10, 2, 3, 2, 5, 2, 90, 10, 2, 3, 2, 5, 2, 93, 10, 2, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 99, 10, 3, 12, 3, 14, 3, 102, 11, 3, 3, 3, 3, 3, 3, 3, 5, 3, 107, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 114, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 7, 5, 121, 10, 5, 12, 5, 14, 5, 124, 11, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 7, 7, 134, 10, 7, 12, 7, 14, 7, 137, 11, 7, 3, 8, 3, 8, 5, 8, 141, 10, 8, 3, 9, 3, 9, 3, 9, 3, 9, 5, 9, 147, 10, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 154, 10, 10, 3, 11, 3, 11, 3, 11, 5, 11, 159, 10, 11, 3, 12, 3, 12, 5, 12, 163, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 5, 16, 182, 10, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 5, 17, 202, 10, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 5, 18, 211, 10, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 5, 19, 235, 10, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 5, 20, 262, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 273, 10, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 279, 10, 21, 3, 21, 3, 21, 3, 21, 5, 21, 284, 10, 21, 7, 21, 286, 10, 21, 12, 21, 14, 21, 289, 11, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 304, 10, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 322, 10, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 335, 10, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 5, 21, 343, 10, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 7, 21, 351, 10, 21, 12, 21, 14, 21, 354, 11, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 5, 22, 362, 10, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 379, 10, 22, 12, 22, 14, 22, 382, 11, 22, 3, 23, 3, 23, 5, 23, 386, 10, 23, 3, 24, 3, 24, 5, 24, 390, 10, 24, 3, 25, 3, 25, 3, 25, 3, 25, 5, 25, 396, 10, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 5, 32, 422, 10, 32, 3, 33, 3, 33, 5, 33, 426, 10, 33, 3, 34, 3, 34, 5, 34, 430, 10, 34, 3, 34, 3, 34, 5, 34, 434, 10, 34, 3, 35, 3, 35, 3, 36, 3, 36, 5, 36, 440, 10, 36, 3, 37, 3, 37, 3, 37, 2, 4, 40, 42, 38, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 2, 11, 4, 2, 30, 30, 35, 35, 4, 2, 11, 11, 53, 53, 4, 2, 14, 14, 28, 28, 3, 2, 15, 16, 4, 2, 18, 18, 26, 26, 4, 2, 20, 20, 32, 32, 4, 2, 12, 12, 27, 27, 4, 2, 13, 13, 56, 56, 3, 2, 26, 61, 2, 474, 2, 74, 3, 2, 2, 2, 4, 106, 3, 2, 2, 2, 6, 113, 3, 2, 2, 2, 8, 115, 3, 2, 2, 2, 10, 125, 3, 2, 2, 2, 12, 128, 3, 2, 2, 2, 14, 138, 3, 2, 2, 2, 16, 142, 3, 2, 2, 2, 18, 153, 3, 2, 2, 2, 20, 158, 3, 2, 2, 2, 22, 162, 3, 2, 2, 2, 24, 164, 3, 2, 2, 2, 26, 169, 3, 2, 2, 2, 28, 174, 3, 2, 2, 2, 30, 181, 3, 2, 2, 2, 32, 201, 3, 2, 2, 2, 34, 203, 3, 2, 2, 2, 36, 234, 3, 2, 2, 2, 38, 261, 3, 2, 2, 2, 40, 342, 3, 2, 2, 2, 42, 361, 3, 2, 2, 2, 44, 385, 3, 2, 2, 2, 46, 389, 3, 2, 2, 2, 48, 391, 3, 2, 2, 2, 50, 397, 3, 2, 2, 2, 52, 404, 3, 2, 2, 2, 54, 409, 3, 2, 2, 2, 56, 411, 3, 2, 2, 2, 58, 413, 3, 2, 2, 2, 60, 415, 3, 2, 2, 2, 62, 421, 3, 2, 2, 2, 64, 425, 3, 2, 2, 2, 66, 433, 3, 2, 2, 2, 68, 435, 3, 2, 2, 2, 70, 439, 3, 2, 2, 2, 72, 441, 3, 2, 2, 2, 74, 75, 5, 56, 29, 2, 75, 77, 7, 3, 2, 2, 76, 78, 5, 40, 21, 2, 77, 76, 3, 2, 2, 2, 77, 78, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 80, 7, 4, 2, 2, 80, 81, 7, 5, 2, 2, 81, 83, 5, 4, 3, 2, 82, 84, 5, 8, 5, 2, 83, 82, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 86, 3, 2, 2, 2, 85, 87, 5, 10, 6, 2, 86, 85, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 89, 3, 2, 2, 2, 88, 90, 5, 12, 7, 2, 89, 88, 3, 2, 2, 2, 89, 90, 3, 2, 2, 2, 90, 92, 3, 2, 2, 2, 91, 93, 5, 16, 9, 2, 92, 91, 3, 2, 2, 2, 92, 93, 3, 2, 2, 2, 93, 3, 3, 2, 2, 2, 94, 95, 7, 6, 2, 2, 95, 100, 5, 6, 4, 2, 96, 97, 7, 7, 2, 2, 97, 99, 5, 6, 4, 2, 98, 96, 3, 2, 2, 2, 99, 102, 3, 2, 2, 2, 100, 98, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 103, 3, 2, 2, 2, 102, 100, 3, 2, 2, 2, 103, 104, 7, 8, 2, 2, 104, 107, 3, 2, 2, 2, 105, 107, 5, 6, 4, 2, 106, 94, 3, 2, 2, 2, 106, 105, 3, 2, 2, 2, 107, 5, 3, 2, 2, 2, 108, 114, 5, 42, 22, 2, 109, 110, 5, 42, 22, 2, 110, 111, 7, 29, 2, 2, 111, 112, 5, 54, 28, 2, 112, 114, 3, 2, 2, 2, 113, 108, 3, 2, 2, 2, 113, 109, 3, 2, 2, 2, 114, 7, 3, 2, 2, 2, 115, 116, 7, 42, 2, 2, 116, 117, 7, 33, 2, 2, 117, 122, 5, 42, 22, 2, 118, 119, 7, 7, 2, 2, 119, 121, 5, 42, 22, 2, 120, 118, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 122, 123, 3, 2, 2, 2, 123, 9, 3, 2, 2, 2, 124, 122, 3, 2, 2, 2, 125, 126, 7, 43, 2, 2, 126, 127, 5, 40, 21, 2, 127, 11, 3, 2, 2, 2, 128, 129, 7, 58, 2, 2, 129, 130, 7, 33, 2, 2, 130, 135, 5, 14, 8, 2, 131, 132, 7, 7, 2, 2, 132, 134, 5, 14, 8, 2, 133, 131, 3, 2, 2, 2, 134, 137, 3, 2, 2, 2, 135, 133, 3, 2, 2, 2, 135, 136, 3, 2, 2, 2, 136, 13, 3, 2, 2, 2, 137, 135, 3, 2, 2, 2, 138, 140, 5, 42, 22, 2, 139, 141, 9, 2, 2, 2, 140, 139, 3, 2, 2, 2, 140, 141, 3, 2, 2, 2, 141, 15, 3, 2, 2, 2, 142, 143, 7, 47, 2, 2, 143, 146, 7, 66, 2, 2, 144, 145, 7, 55, 2, 2, 145, 147, 7, 66, 2, 2, 146, 144, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 17, 3, 2, 2, 2, 148, 154, 5, 38, 20, 2, 149, 154, 5, 36, 19, 2, 150, 154, 5, 20, 11, 2, 151, 154, 5, 30, 16, 2, 152, 154, 5, 52, 27, 2, 153, 148, 3, 2, 2, 2, 153, 149, 3, 2, 2, 2, 153, 150, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 153, 152, 3, 2, 2, 2, 154, 19, 3, 2, 2, 2, 155, 159, 5, 24, 13, 2, 156, 159, 5, 26, 14, 2, 157, 159, 5, 28, 15, 2, 158, 155, 3, 2, 2, 2, 158, 156, 3, 2, 2, 2, 158, 157, 3, 2, 2, 2, 159, 21, 3, 2, 2, 2, 160, 163, 5, 58, 30, 2, 161, 163, 5, 62, 32, 2, 162, 160, 3, 2, 2, 2, 162, 161, 3, 2, 2, 2, 163, 23, 3, 2, 2, 2, 164, 165, 7, 62, 2, 2, 165, 166, 7, 9, 2, 2, 166, 167, 5, 22, 12, 2, 167, 168, 7, 10, 2, 2, 168, 25, 3, 2, 2, 2, 169, 170, 7, 63, 2, 2, 170, 171, 7, 9, 2, 2, 171, 172, 5, 22, 12, 2, 172, 173, 7, 10, 2, 2, 173, 27, 3, 2, 2, 2, 174, 175, 7, 64, 2, 2, 175, 176, 7, 9, 2, 2, 176, 177, 5, 22, 12, 2, 177, 178, 7, 10, 2, 2, 178, 29, 3, 2, 2, 2, 179, 182, 5, 32, 17, 2, 180, 182, 5, 34, 18, 2, 181, 179, 3, 2, 2, 2, 181, 180, 3, 2, 2, 2, 182, 31, 3, 2, 2, 2, 183, 184, 7, 36, 2, 2, 184, 185, 7, 9, 2, 2, 185, 186, 5, 22, 12, 2, 186, 187, 7, 7, 2, 2, 187, 188, 5, 22, 12, 2, 188, 189, 7, 10, 2, 2, 189, 202, 3, 2, 2, 2, 190, 191, 7, 36, 2, 2, 191, 192, 7, 9, 2, 2, 192, 193, 5, 42, 22, 2, 193, 194, 7, 7, 2, 2, 194, 195, 5, 42, 22, 2, 195, 196, 7, 7, 2, 2, 196, 197, 5, 42, 22, 2, 197, 198, 7, 7, 2, 2, 198, 199, 5, 42, 22, 2, 199, 200, 7, 10, 2, 2, 200, 202, 3, 2, 2, 2, 201, 183, 3, 2, 2, 2, 201, 190, 3, 2, 2, 2, 202, 33, 3, 2, 2, 2, 203, 204, 7, 37, 2, 2, 204, 205, 7, 9, 2, 2, 205, 206, 5, 22, 12, 2, 206, 207, 7, 7, 2, 2, 207, 210, 5, 22, 12, 2, 208, 209, 7, 7, 2, 2, 209, 211, 5, 42, 22, 2, 210, 208, 3, 2, 2, 2, 210, 211, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 213, 7, 10, 2, 2, 213, 35, 3, 2, 2, 2, 214, 215, 7, 41, 2, 2, 215, 216, 7, 9, 2, 2, 216, 217, 5, 66, 34, 2, 217, 218, 7, 10, 2, 2, 218, 235, 3, 2, 2, 2, 219, 220, 7, 46, 2, 2, 220, 221, 7, 9, 2, 2, 221, 222, 5, 66, 34, 2, 222, 223, 7, 10, 2, 2, 223, 235, 3, 2, 2, 2, 224, 225, 7, 50, 2, 2, 225, 226, 7, 9, 2, 2, 226, 227, 5, 66, 34, 2, 227, 228, 7, 10, 2, 2, 228, 235, 3, 2, 2, 2, 229, 230, 7, 61, 2, 2, 230, 231, 7, 9, 2, 2, 231, 232, 5, 66, 34, 2, 232, 233, 7, 10, 2, 2, 233, 235, 3, 2, 2, 2, 234, 214, 3, 2, 2, 2, 234, 219, 3, 2, 2, 2, 234, 224, 3, 2, 2, 2, 234, 229, 3, 2, 2, 2, 235, 37, 3, 2, 2, 2, 236, 237, 7, 31, 2, 2, 237, 238, 7, 9, 2, 2, 238, 239, 5, 42, 22, 2, 239, 240, 7, 10, 2, 2, 240, 262, 3, 2, 2, 2, 241, 242, 7, 49, 2, 2, 242, 243, 7, 9, 2, 2, 243, 244, 5, 42, 22, 2, 244, 245, 7, 10, 2, 2, 245, 262, 3, 2, 2, 2, 246, 247, 7, 51, 2, 2, 247, 248, 7, 9, 2, 2, 248, 249, 5, 42, 22, 2, 249, 250, 7, 10, 2, 2, 250, 262, 3, 2, 2, 2, 251, 252, 7, 59, 2, 2, 252, 253, 7, 9, 2, 2, 253, 254, 5, 42, 22, 2, 254, 255, 7, 10, 2, 2, 255, 262, 3, 2, 2, 2, 256, 257, 7, 34, 2, 2, 257, 258, 7, 9, 2, 2, 258, 259, 5, 42, 22, 2, 259, 260, 7, 10, 2, 2, 260, 262, 3, 2, 2, 2, 261, 236, 3, 2, 2, 2, 261, 241, 3, 2, 2, 2, 261, 246, 3, 2, 2, 2, 261, 251, 3, 2, 2, 2, 261, 256, 3, 2, 2, 2, 262, 39, 3, 2, 2, 2, 263, 264, 8, 21, 1, 2, 264, 265, 9, 3, 2, 2, 265, 343, 5, 40, 21, 16, 266, 267, 7, 9, 2, 2, 267, 268, 5, 40, 21, 2, 268, 269, 7, 10, 2, 2, 269, 343, 3, 2, 2, 2, 270, 272, 5, 42, 22, 2, 271, 273, 7, 53, 2, 2, 272, 271, 3, 2, 2, 2, 272, 273, 3, 2, 2, 2, 273, 274, 3, 2, 2, 2, 274, 275, 7, 44, 2, 2, 275, 278, 7, 9, 2, 2, 276, 279, 5, 2, 2, 2, 277, 279, 5, 42, 22, 2, 278, 276, 3, 2, 2, 2, 278, 277, 3, 2, 2, 2, 279, 287, 3, 2, 2, 2, 280, 283, 7, 7, 2, 2, 281, 284, 5, 2, 2, 2, 282, 284, 5, 42, 22, 2, 283, 281, 3, 2, 2, 2, 283, 282, 3, 2, 2, 2, 284, 286, 3, 2, 2, 2, 285, 280, 3, 2, 2, 2, 286, 289, 3, 2, 2, 2, 287, 285, 3, 2, 2, 2, 287, 288, 3, 2, 2, 2, 288, 290, 3, 2, 2, 2, 289, 287, 3, 2, 2, 2, 290, 291, 7, 10, 2, 2, 291, 343, 3, 2, 2, 2, 292, 293, 5, 42, 22, 2, 293, 294, 7, 45, 2, 2, 294, 295, 7, 54, 2, 2, 295, 343, 3, 2, 2, 2, 296, 297, 5, 42, 22, 2, 297, 298, 7, 45, 2, 2, 298, 299, 7, 53, 2, 2, 299, 300, 7, 54, 2, 2, 300, 343, 3, 2, 2, 2, 301, 303, 5, 42, 22, 2, 302, 304, 7, 53, 2, 2, 303, 302, 3, 2, 2, 2, 303, 304, 3, 2, 2, 2, 304, 305, 3, 2, 2, 2, 305, 306, 7, 48, 2, 2, 306, 307, 5, 42, 22, 2, 307, 343, 3, 2, 2, 2, 308, 309, 5, 42, 22, 2, 309, 310, 9, 4, 2, 2, 310, 311, 5, 42, 22, 2, 311, 343, 3, 2, 2, 2, 312, 313, 5, 42, 22, 2, 313, 314, 9, 5, 2, 2, 314, 315, 5, 42, 22, 2, 315, 343, 3, 2, 2, 2, 316, 321, 5, 42, 22, 2, 317, 322, 7, 17, 2, 2, 318, 319, 7, 28, 2, 2, 319, 320, 7, 56, 2, 2, 320, 322, 7, 26, 2, 2, 321, 317, 3, 2, 2, 2, 321, 318, 3, 2, 2, 2, 322, 323, 3, 2, 2, 2, 323, 324, 5, 42, 22, 2, 324, 343, 3, 2, 2, 2, 325, 326, 5, 42, 22, 2, 326, 327, 9, 6, 2, 2, 327, 328, 5, 42, 22, 2, 328, 343, 3, 2, 2, 2, 329, 334, 5, 42, 22, 2, 330, 335, 7, 19, 2, 2, 331, 332, 7, 28, 2, 2, 332, 333, 7, 56, 2, 2, 333, 335, 7, 32, 2, 2, 334, 330, 3, 2, 2, 2, 334, 331, 3, 2, 2, 2, 335, 336, 3, 2, 2, 2, 336, 337, 5, 42, 22, 2, 337, 343, 3, 2, 2, 2, 338, 339, 5, 42, 22, 2, 339, 340, 9, 7, 2, 2, 340, 341, 5, 42, 22, 2, 341, 343, 3, 2, 2, 2, 342, 263, 3, 2, 2, 2, 342, 266, 3, 2, 2, 2, 342, 270, 3, 2, 2, 2, 342, 292, 3, 2, 2, 2, 342, 296, 3, 2, 2, 2, 342, 301, 3, 2, 2, 2, 342, 308, 3, 2, 2, 2, 342, 312, 3, 2, 2, 2, 342, 316, 3, 2, 2, 2, 342, 325, 3, 2, 2, 2, 342, 329, 3, 2, 2, 2, 342, 338, 3, 2, 2, 2, 343, 352, 3, 2, 2, 2, 344, 345, 12, 15, 2, 2, 345, 346, 9, 8, 2, 2, 346, 351, 5, 40, 21, 16, 347, 348, 12, 14, 2, 2, 348, 349, 9, 9, 2, 2, 349, 351, 5, 40, 21, 15, 350, 344, 3, 2, 2, 2, 350, 347, 3, 2, 2, 2, 351, 354, 3, 2, 2, 2, 352, 350, 3, 2, 2, 2, 352, 353, 3, 2, 2, 2, 353, 41, 3, 2, 2, 2, 354, 352, 3, 2, 2, 2, 355, 356, 8, 22, 1, 2, 356, 362, 5, 62, 32, 2, 357, 362, 5, 44, 23, 2, 358, 362, 5, 18, 10, 2, 359, 360, 7, 21, 2, 2, 360, 362, 5, 42, 22, 8, 361, 355, 3, 2, 2, 2, 361, 357, 3, 2, 2, 2, 361, 358, 3, 2, 2, 2, 361, 359, 3, 2, 2, 2, 362, 380, 3, 2, 2, 2, 363, 364, 12, 7, 2, 2, 364, 365, 7, 22, 2, 2, 365, 379, 5, 42, 22, 8, 366, 367, 12, 6, 2, 2, 367, 368, 7, 23, 2, 2, 368, 379, 5, 42, 22, 7, 369, 370, 12, 5, 2, 2, 370, 371, 7, 24, 2, 2, 371, 379, 5, 42, 22, 6, 372, 373, 12, 4, 2, 2, 373, 374, 7, 25, 2, 2, 374, 379, 5, 42, 22, 5, 375, 376, 12, 3, 2, 2, 376, 377, 7, 21, 2, 2, 377, 379, 5, 42, 22, 4, 378, 363, 3, 2, 2, 2, 378, 366, 3, 2, 2, 2, 378, 369, 3, 2, 2, 2, 378, 372, 3, 2, 2, 2, 378, 375, 3, 2, 2, 2, 379, 382, 3, 2, 2, 2, 380, 378, 3, 2, 2, 2, 380, 381, 3, 2, 2, 2, 381, 43, 3, 2, 2, 2, 382, 380, 3, 2, 2, 2, 383, 386, 5, 46, 24, 2, 384, 386, 5, 48, 25, 2, 385, 383, 3, 2, 2, 2, 385, 384, 3, 2, 2, 2, 386, 45, 3, 2, 2, 2, 387, 390, 5, 58, 30, 2, 388, 390, 5, 50, 26, 2, 389, 387, 3, 2, 2, 2, 389, 388, 3, 2, 2, 2, 390, 47, 3, 2, 2, 2, 391, 392, 5, 46, 24, 2, 392, 395, 7, 5, 2, 2, 393, 396, 5, 48, 25, 2, 394, 396, 5, 46, 24, 2, 395, 393, 3, 2, 2, 2, 395, 394, 3, 2, 2, 2, 396, 49, 3, 2, 2, 2, 397, 398, 5, 56, 29, 2, 398, 399, 7, 3, 2, 2, 399, 400, 5, 44, 23, 2, 400, 401, 7, 4, 2, 2, 401, 402, 7, 5, 2, 2, 402, 403, 5, 44, 23, 2, 403, 51, 3, 2, 2, 2, 404, 405, 5, 60, 31, 2, 405, 406, 7, 9, 2, 2, 406, 407, 5, 42, 22, 2, 407, 408, 7, 10, 2, 2, 408, 53, 3, 2, 2, 2, 409, 410, 5, 70, 36, 2, 410, 55, 3, 2, 2, 2, 411, 412, 5, 70, 36, 2, 412, 57, 3, 2, 2, 2, 413, 414, 5, 70, 36, 2, 414, 59, 3, 2, 2, 2, 415, 416, 5, 70, 36, 2, 416, 61, 3, 2, 2, 2, 417, 422, 5, 68, 35, 2, 418, 422, 5, 66, 34, 2, 419, 422, 5, 64, 33, 2, 420, 422, 7, 54, 2, 2, 421, 417, 3, 2, 2, 2, 421, 418, 3, 2, 2, 2, 421, 419, 3, 2, 2, 2, 421, 420, 3, 2, 2, 2, 422, 63, 3, 2, 2, 2, 423, 426, 7, 60, 2, 2, 424, 426, 7, 40, 2, 2, 425, 423, 3, 2, 2, 2, 425, 424, 3, 2, 2, 2, 426, 65, 3, 2, 2, 2, 427, 434, 7, 66, 2, 2, 428, 430, 7, 66, 2, 2, 429, 428, 3, 2, 2, 2, 429, 430, 3, 2, 2, 2, 430, 431, 3, 2, 2, 2, 431, 432, 7, 5, 2, 2, 432, 434, 7, 66, 2, 2, 433, 427, 3, 2, 2, 2, 433, 429, 3, 2, 2, 2, 434, 67, 3, 2, 2, 2, 435, 436, 7, 67, 2, 2, 436, 69, 3, 2, 2, 2, 437, 440, 7, 65, 2, 2, 438, 440, 5, 72, 37, 2, 439, 437, 3, 2, 2, 2, 439, 438, 3, 2, 2, 2, 440, 71, 3, 2, 2, 2, 441, 442, 9, 10, 2, 2, 442, 73, 3, 2, 2, 2, 43, 77, 83, 86, 89, 92, 100, 106, 113, 122, 135, 140, 146, 153, 158, 162, 181, 201, 210, 234, 261, 272, 278, 283, 287, 303, 321, 334, 342, 350, 352, 361, 378, 380, 385, 389, 395, 421, 425, 429, 433, 439] \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.tokens b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.tokens new file mode 100644 index 000000000..c532f5778 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQuery.tokens @@ -0,0 +1,89 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +AFTER=24 +AND=25 +AT=26 +AS=27 +ASC=28 +AVG=29 +BEFORE=30 +BY=31 +COUNT=32 +DESC=33 +DISTANCE=34 +DISTANCE_ON_SPHERE=35 +DIV=36 +ESCAPE=37 +FALSE=38 +FT=39 +GROUP=40 +HAVING=41 +IN=42 +IS=43 +KM=44 +LIMIT=45 +LIKE=46 +MAX=47 +MI=48 +MIN=49 +MOD=50 +NOT=51 +NULL=52 +OFFSET=53 +OR=54 +SELECT=55 +SORT=56 +SUM=57 +TRUE=58 +YD=59 +AsWKB=60 +AsWKT=61 +AsGeoJSON=62 +ID=63 +INT=64 +CHAR_STRING=65 +WS=66 +'['=1 +']'=2 +'.'=3 +'{'=4 +','=5 +'}'=6 +'('=7 +')'=8 +'!'=9 +'&&'=10 +'||'=11 +'='=12 +'!='=13 +'<>'=14 +'>='=15 +'>'=16 +'<='=17 +'<'=18 +'-'=19 +'*'=20 +'/'=21 +'%'=22 +'+'=23 diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseListener.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseListener.java new file mode 100644 index 000000000..cf1bde95a --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseListener.java @@ -0,0 +1,879 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link BackendlessQueryListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +public class BackendlessQueryBaseListener implements BackendlessQueryListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSelect_statement(BackendlessQueryParser.Select_statementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSelect_statement(BackendlessQueryParser.Select_statementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSelect_list(BackendlessQueryParser.Select_listContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSelect_list(BackendlessQueryParser.Select_listContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterHaving_clause(BackendlessQueryParser.Having_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitHaving_clause(BackendlessQueryParser.Having_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunction_call(BackendlessQueryParser.Function_callContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunction_call(BackendlessQueryParser.Function_callContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDistance_function(BackendlessQueryParser.Distance_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDistance_function(BackendlessQueryParser.Distance_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMinFunction(BackendlessQueryParser.MinFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMinFunction(BackendlessQueryParser.MinFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSumFunction(BackendlessQueryParser.SumFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSumFunction(BackendlessQueryParser.SumFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCountFunction(BackendlessQueryParser.CountFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCountFunction(BackendlessQueryParser.CountFunctionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInCondition(BackendlessQueryParser.InConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInCondition(BackendlessQueryParser.InConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEqualCondition(BackendlessQueryParser.EqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEqualCondition(BackendlessQueryParser.EqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOrCondition(BackendlessQueryParser.OrConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOrCondition(BackendlessQueryParser.OrConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAndCondition(BackendlessQueryParser.AndConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAndCondition(BackendlessQueryParser.AndConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotCondition(BackendlessQueryParser.NotConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotCondition(BackendlessQueryParser.NotConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLikeCondition(BackendlessQueryParser.LikeConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLikeCondition(BackendlessQueryParser.LikeConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNestedCondition(BackendlessQueryParser.NestedConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNestedCondition(BackendlessQueryParser.NestedConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRelation_column(BackendlessQueryParser.Relation_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRelation_column(BackendlessQueryParser.Relation_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAlias(BackendlessQueryParser.AliasContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAlias(BackendlessQueryParser.AliasContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTable_name(BackendlessQueryParser.Table_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTable_name(BackendlessQueryParser.Table_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSimple_column(BackendlessQueryParser.Simple_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSimple_column(BackendlessQueryParser.Simple_columnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStringConstant(BackendlessQueryParser.StringConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStringConstant(BackendlessQueryParser.StringConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNumericConstant(BackendlessQueryParser.NumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNumericConstant(BackendlessQueryParser.NumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNullConstant(BackendlessQueryParser.NullConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNullConstant(BackendlessQueryParser.NullConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterString_literal(BackendlessQueryParser.String_literalContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitString_literal(BackendlessQueryParser.String_literalContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRegular_id(BackendlessQueryParser.Regular_idContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRegular_id(BackendlessQueryParser.Regular_idContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseVisitor.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseVisitor.java new file mode 100644 index 000000000..fb3df9b38 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryBaseVisitor.java @@ -0,0 +1,504 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link BackendlessQueryVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public class BackendlessQueryBaseVisitor extends AbstractParseTreeVisitor implements BackendlessQueryVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSelect_statement(BackendlessQueryParser.Select_statementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSelect_list(BackendlessQueryParser.Select_listContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitHaving_clause(BackendlessQueryParser.Having_clauseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunction_call(BackendlessQueryParser.Function_callContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDistance_function(BackendlessQueryParser.Distance_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMinFunction(BackendlessQueryParser.MinFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSumFunction(BackendlessQueryParser.SumFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCountFunction(BackendlessQueryParser.CountFunctionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitInCondition(BackendlessQueryParser.InConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEqualCondition(BackendlessQueryParser.EqualConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOrCondition(BackendlessQueryParser.OrConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAndCondition(BackendlessQueryParser.AndConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNotCondition(BackendlessQueryParser.NotConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLikeCondition(BackendlessQueryParser.LikeConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNestedCondition(BackendlessQueryParser.NestedConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitRelation_column(BackendlessQueryParser.Relation_columnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAlias(BackendlessQueryParser.AliasContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTable_name(BackendlessQueryParser.Table_nameContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSimple_column(BackendlessQueryParser.Simple_columnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStringConstant(BackendlessQueryParser.StringConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNumericConstant(BackendlessQueryParser.NumericConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNullConstant(BackendlessQueryParser.NullConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitString_literal(BackendlessQueryParser.String_literalContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitRegular_id(BackendlessQueryParser.Regular_idContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.interp b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.interp new file mode 100644 index 000000000..33d360234 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.interp @@ -0,0 +1,244 @@ +token literal names: +null +'[' +']' +'.' +'{' +',' +'}' +'(' +')' +'!' +'&&' +'||' +'=' +'!=' +'<>' +'>=' +'>' +'<=' +'<' +'-' +'*' +'/' +'%' +'+' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +AFTER +AND +AT +AS +ASC +AVG +BEFORE +BY +COUNT +DESC +DISTANCE +DISTANCE_ON_SPHERE +DIV +ESCAPE +FALSE +FT +GROUP +HAVING +IN +IS +KM +LIMIT +LIKE +MAX +MI +MIN +MOD +NOT +NULL +OFFSET +OR +SELECT +SORT +SUM +TRUE +YD +AsWKB +AsWKT +AsGeoJSON +ID +INT +CHAR_STRING +WS + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +T__13 +T__14 +T__15 +T__16 +T__17 +T__18 +T__19 +T__20 +T__21 +T__22 +AFTER +AND +AT +AS +ASC +AVG +BEFORE +BY +COUNT +DESC +DISTANCE +DISTANCE_ON_SPHERE +DIV +ESCAPE +FALSE +FT +GROUP +HAVING +IN +IS +KM +LIMIT +LIKE +MAX +MI +MIN +MOD +NOT +NULL +OFFSET +OR +SELECT +SORT +SUM +TRUE +YD +AsWKB +AsWKT +AsGeoJSON +ID +INT +CHAR_STRING +WS +DIGIT +LETTER +NEWLINE +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 68, 548, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 4, 81, 9, 81, 4, 82, 9, 82, 4, 83, 9, 83, 4, 84, 9, 84, 4, 85, 9, 85, 4, 86, 9, 86, 4, 87, 9, 87, 4, 88, 9, 88, 4, 89, 9, 89, 4, 90, 9, 90, 4, 91, 9, 91, 4, 92, 9, 92, 4, 93, 9, 93, 4, 94, 9, 94, 4, 95, 9, 95, 4, 96, 9, 96, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 5, 64, 454, 10, 64, 3, 64, 3, 64, 3, 64, 7, 64, 459, 10, 64, 12, 64, 14, 64, 462, 11, 64, 3, 65, 6, 65, 465, 10, 65, 13, 65, 14, 65, 466, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 7, 66, 474, 10, 66, 12, 66, 14, 66, 477, 11, 66, 3, 66, 3, 66, 3, 67, 6, 67, 482, 10, 67, 13, 67, 14, 67, 483, 3, 67, 3, 67, 3, 68, 3, 68, 3, 69, 3, 69, 3, 70, 5, 70, 493, 10, 70, 3, 70, 3, 70, 3, 71, 3, 71, 3, 72, 3, 72, 3, 73, 3, 73, 3, 74, 3, 74, 3, 75, 3, 75, 3, 76, 3, 76, 3, 77, 3, 77, 3, 78, 3, 78, 3, 79, 3, 79, 3, 80, 3, 80, 3, 81, 3, 81, 3, 82, 3, 82, 3, 83, 3, 83, 3, 84, 3, 84, 3, 85, 3, 85, 3, 86, 3, 86, 3, 87, 3, 87, 3, 88, 3, 88, 3, 89, 3, 89, 3, 90, 3, 90, 3, 91, 3, 91, 3, 92, 3, 92, 3, 93, 3, 93, 3, 94, 3, 94, 3, 95, 3, 95, 3, 96, 3, 96, 2, 2, 97, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 55, 109, 56, 111, 57, 113, 58, 115, 59, 117, 60, 119, 61, 121, 62, 123, 63, 125, 64, 127, 65, 129, 66, 131, 67, 133, 68, 135, 2, 137, 2, 139, 2, 141, 2, 143, 2, 145, 2, 147, 2, 149, 2, 151, 2, 153, 2, 155, 2, 157, 2, 159, 2, 161, 2, 163, 2, 165, 2, 167, 2, 169, 2, 171, 2, 173, 2, 175, 2, 177, 2, 179, 2, 181, 2, 183, 2, 185, 2, 187, 2, 189, 2, 191, 2, 3, 2, 33, 4, 2, 37, 38, 97, 97, 5, 2, 12, 12, 15, 15, 41, 41, 5, 2, 11, 12, 15, 15, 34, 34, 3, 2, 50, 59, 4, 2, 67, 92, 99, 124, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 69, 69, 101, 101, 4, 2, 70, 70, 102, 102, 4, 2, 71, 71, 103, 103, 4, 2, 72, 72, 104, 104, 4, 2, 73, 73, 105, 105, 4, 2, 74, 74, 106, 106, 4, 2, 75, 75, 107, 107, 4, 2, 76, 76, 108, 108, 4, 2, 77, 77, 109, 109, 4, 2, 78, 78, 110, 110, 4, 2, 79, 79, 111, 111, 4, 2, 80, 80, 112, 112, 4, 2, 81, 81, 113, 113, 4, 2, 82, 82, 114, 114, 4, 2, 83, 83, 115, 115, 4, 2, 84, 84, 116, 116, 4, 2, 85, 85, 117, 117, 4, 2, 86, 86, 118, 118, 4, 2, 87, 87, 119, 119, 4, 2, 88, 88, 120, 120, 4, 2, 89, 89, 121, 121, 4, 2, 90, 90, 122, 122, 4, 2, 91, 91, 123, 123, 4, 2, 92, 92, 124, 124, 2, 528, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 2, 133, 3, 2, 2, 2, 3, 193, 3, 2, 2, 2, 5, 195, 3, 2, 2, 2, 7, 197, 3, 2, 2, 2, 9, 199, 3, 2, 2, 2, 11, 201, 3, 2, 2, 2, 13, 203, 3, 2, 2, 2, 15, 205, 3, 2, 2, 2, 17, 207, 3, 2, 2, 2, 19, 209, 3, 2, 2, 2, 21, 211, 3, 2, 2, 2, 23, 214, 3, 2, 2, 2, 25, 217, 3, 2, 2, 2, 27, 219, 3, 2, 2, 2, 29, 222, 3, 2, 2, 2, 31, 225, 3, 2, 2, 2, 33, 228, 3, 2, 2, 2, 35, 230, 3, 2, 2, 2, 37, 233, 3, 2, 2, 2, 39, 235, 3, 2, 2, 2, 41, 237, 3, 2, 2, 2, 43, 239, 3, 2, 2, 2, 45, 241, 3, 2, 2, 2, 47, 243, 3, 2, 2, 2, 49, 245, 3, 2, 2, 2, 51, 251, 3, 2, 2, 2, 53, 255, 3, 2, 2, 2, 55, 258, 3, 2, 2, 2, 57, 261, 3, 2, 2, 2, 59, 265, 3, 2, 2, 2, 61, 269, 3, 2, 2, 2, 63, 276, 3, 2, 2, 2, 65, 279, 3, 2, 2, 2, 67, 285, 3, 2, 2, 2, 69, 290, 3, 2, 2, 2, 71, 299, 3, 2, 2, 2, 73, 318, 3, 2, 2, 2, 75, 322, 3, 2, 2, 2, 77, 329, 3, 2, 2, 2, 79, 335, 3, 2, 2, 2, 81, 338, 3, 2, 2, 2, 83, 344, 3, 2, 2, 2, 85, 351, 3, 2, 2, 2, 87, 354, 3, 2, 2, 2, 89, 357, 3, 2, 2, 2, 91, 360, 3, 2, 2, 2, 93, 366, 3, 2, 2, 2, 95, 371, 3, 2, 2, 2, 97, 375, 3, 2, 2, 2, 99, 378, 3, 2, 2, 2, 101, 382, 3, 2, 2, 2, 103, 386, 3, 2, 2, 2, 105, 390, 3, 2, 2, 2, 107, 395, 3, 2, 2, 2, 109, 402, 3, 2, 2, 2, 111, 405, 3, 2, 2, 2, 113, 412, 3, 2, 2, 2, 115, 417, 3, 2, 2, 2, 117, 421, 3, 2, 2, 2, 119, 426, 3, 2, 2, 2, 121, 429, 3, 2, 2, 2, 123, 435, 3, 2, 2, 2, 125, 441, 3, 2, 2, 2, 127, 453, 3, 2, 2, 2, 129, 464, 3, 2, 2, 2, 131, 468, 3, 2, 2, 2, 133, 481, 3, 2, 2, 2, 135, 487, 3, 2, 2, 2, 137, 489, 3, 2, 2, 2, 139, 492, 3, 2, 2, 2, 141, 496, 3, 2, 2, 2, 143, 498, 3, 2, 2, 2, 145, 500, 3, 2, 2, 2, 147, 502, 3, 2, 2, 2, 149, 504, 3, 2, 2, 2, 151, 506, 3, 2, 2, 2, 153, 508, 3, 2, 2, 2, 155, 510, 3, 2, 2, 2, 157, 512, 3, 2, 2, 2, 159, 514, 3, 2, 2, 2, 161, 516, 3, 2, 2, 2, 163, 518, 3, 2, 2, 2, 165, 520, 3, 2, 2, 2, 167, 522, 3, 2, 2, 2, 169, 524, 3, 2, 2, 2, 171, 526, 3, 2, 2, 2, 173, 528, 3, 2, 2, 2, 175, 530, 3, 2, 2, 2, 177, 532, 3, 2, 2, 2, 179, 534, 3, 2, 2, 2, 181, 536, 3, 2, 2, 2, 183, 538, 3, 2, 2, 2, 185, 540, 3, 2, 2, 2, 187, 542, 3, 2, 2, 2, 189, 544, 3, 2, 2, 2, 191, 546, 3, 2, 2, 2, 193, 194, 7, 93, 2, 2, 194, 4, 3, 2, 2, 2, 195, 196, 7, 95, 2, 2, 196, 6, 3, 2, 2, 2, 197, 198, 7, 48, 2, 2, 198, 8, 3, 2, 2, 2, 199, 200, 7, 125, 2, 2, 200, 10, 3, 2, 2, 2, 201, 202, 7, 46, 2, 2, 202, 12, 3, 2, 2, 2, 203, 204, 7, 127, 2, 2, 204, 14, 3, 2, 2, 2, 205, 206, 7, 42, 2, 2, 206, 16, 3, 2, 2, 2, 207, 208, 7, 43, 2, 2, 208, 18, 3, 2, 2, 2, 209, 210, 7, 35, 2, 2, 210, 20, 3, 2, 2, 2, 211, 212, 7, 40, 2, 2, 212, 213, 7, 40, 2, 2, 213, 22, 3, 2, 2, 2, 214, 215, 7, 126, 2, 2, 215, 216, 7, 126, 2, 2, 216, 24, 3, 2, 2, 2, 217, 218, 7, 63, 2, 2, 218, 26, 3, 2, 2, 2, 219, 220, 7, 35, 2, 2, 220, 221, 7, 63, 2, 2, 221, 28, 3, 2, 2, 2, 222, 223, 7, 62, 2, 2, 223, 224, 7, 64, 2, 2, 224, 30, 3, 2, 2, 2, 225, 226, 7, 64, 2, 2, 226, 227, 7, 63, 2, 2, 227, 32, 3, 2, 2, 2, 228, 229, 7, 64, 2, 2, 229, 34, 3, 2, 2, 2, 230, 231, 7, 62, 2, 2, 231, 232, 7, 63, 2, 2, 232, 36, 3, 2, 2, 2, 233, 234, 7, 62, 2, 2, 234, 38, 3, 2, 2, 2, 235, 236, 7, 47, 2, 2, 236, 40, 3, 2, 2, 2, 237, 238, 7, 44, 2, 2, 238, 42, 3, 2, 2, 2, 239, 240, 7, 49, 2, 2, 240, 44, 3, 2, 2, 2, 241, 242, 7, 39, 2, 2, 242, 46, 3, 2, 2, 2, 243, 244, 7, 45, 2, 2, 244, 48, 3, 2, 2, 2, 245, 246, 5, 141, 71, 2, 246, 247, 5, 151, 76, 2, 247, 248, 5, 179, 90, 2, 248, 249, 5, 149, 75, 2, 249, 250, 5, 175, 88, 2, 250, 50, 3, 2, 2, 2, 251, 252, 5, 141, 71, 2, 252, 253, 5, 167, 84, 2, 253, 254, 5, 147, 74, 2, 254, 52, 3, 2, 2, 2, 255, 256, 5, 141, 71, 2, 256, 257, 5, 179, 90, 2, 257, 54, 3, 2, 2, 2, 258, 259, 5, 141, 71, 2, 259, 260, 5, 177, 89, 2, 260, 56, 3, 2, 2, 2, 261, 262, 5, 141, 71, 2, 262, 263, 5, 177, 89, 2, 263, 264, 5, 145, 73, 2, 264, 58, 3, 2, 2, 2, 265, 266, 5, 141, 71, 2, 266, 267, 5, 183, 92, 2, 267, 268, 5, 153, 77, 2, 268, 60, 3, 2, 2, 2, 269, 270, 5, 143, 72, 2, 270, 271, 5, 149, 75, 2, 271, 272, 5, 151, 76, 2, 272, 273, 5, 169, 85, 2, 273, 274, 5, 175, 88, 2, 274, 275, 5, 149, 75, 2, 275, 62, 3, 2, 2, 2, 276, 277, 5, 143, 72, 2, 277, 278, 5, 189, 95, 2, 278, 64, 3, 2, 2, 2, 279, 280, 5, 145, 73, 2, 280, 281, 5, 169, 85, 2, 281, 282, 5, 181, 91, 2, 282, 283, 5, 167, 84, 2, 283, 284, 5, 179, 90, 2, 284, 66, 3, 2, 2, 2, 285, 286, 5, 147, 74, 2, 286, 287, 5, 149, 75, 2, 287, 288, 5, 177, 89, 2, 288, 289, 5, 145, 73, 2, 289, 68, 3, 2, 2, 2, 290, 291, 5, 147, 74, 2, 291, 292, 5, 157, 79, 2, 292, 293, 5, 177, 89, 2, 293, 294, 5, 179, 90, 2, 294, 295, 5, 141, 71, 2, 295, 296, 5, 167, 84, 2, 296, 297, 5, 145, 73, 2, 297, 298, 5, 149, 75, 2, 298, 70, 3, 2, 2, 2, 299, 300, 5, 147, 74, 2, 300, 301, 5, 157, 79, 2, 301, 302, 5, 177, 89, 2, 302, 303, 5, 179, 90, 2, 303, 304, 5, 141, 71, 2, 304, 305, 5, 167, 84, 2, 305, 306, 5, 145, 73, 2, 306, 307, 5, 149, 75, 2, 307, 308, 7, 97, 2, 2, 308, 309, 5, 169, 85, 2, 309, 310, 5, 167, 84, 2, 310, 311, 7, 97, 2, 2, 311, 312, 5, 177, 89, 2, 312, 313, 5, 171, 86, 2, 313, 314, 5, 155, 78, 2, 314, 315, 5, 149, 75, 2, 315, 316, 5, 175, 88, 2, 316, 317, 5, 149, 75, 2, 317, 72, 3, 2, 2, 2, 318, 319, 5, 147, 74, 2, 319, 320, 5, 157, 79, 2, 320, 321, 5, 183, 92, 2, 321, 74, 3, 2, 2, 2, 322, 323, 5, 149, 75, 2, 323, 324, 5, 177, 89, 2, 324, 325, 5, 145, 73, 2, 325, 326, 5, 141, 71, 2, 326, 327, 5, 171, 86, 2, 327, 328, 5, 149, 75, 2, 328, 76, 3, 2, 2, 2, 329, 330, 5, 151, 76, 2, 330, 331, 5, 141, 71, 2, 331, 332, 5, 163, 82, 2, 332, 333, 5, 177, 89, 2, 333, 334, 5, 149, 75, 2, 334, 78, 3, 2, 2, 2, 335, 336, 5, 151, 76, 2, 336, 337, 5, 179, 90, 2, 337, 80, 3, 2, 2, 2, 338, 339, 5, 153, 77, 2, 339, 340, 5, 175, 88, 2, 340, 341, 5, 169, 85, 2, 341, 342, 5, 181, 91, 2, 342, 343, 5, 171, 86, 2, 343, 82, 3, 2, 2, 2, 344, 345, 5, 155, 78, 2, 345, 346, 5, 141, 71, 2, 346, 347, 5, 183, 92, 2, 347, 348, 5, 157, 79, 2, 348, 349, 5, 167, 84, 2, 349, 350, 5, 153, 77, 2, 350, 84, 3, 2, 2, 2, 351, 352, 5, 157, 79, 2, 352, 353, 5, 167, 84, 2, 353, 86, 3, 2, 2, 2, 354, 355, 5, 157, 79, 2, 355, 356, 5, 177, 89, 2, 356, 88, 3, 2, 2, 2, 357, 358, 5, 161, 81, 2, 358, 359, 5, 165, 83, 2, 359, 90, 3, 2, 2, 2, 360, 361, 5, 163, 82, 2, 361, 362, 5, 157, 79, 2, 362, 363, 5, 165, 83, 2, 363, 364, 5, 157, 79, 2, 364, 365, 5, 179, 90, 2, 365, 92, 3, 2, 2, 2, 366, 367, 5, 163, 82, 2, 367, 368, 5, 157, 79, 2, 368, 369, 5, 161, 81, 2, 369, 370, 5, 149, 75, 2, 370, 94, 3, 2, 2, 2, 371, 372, 5, 165, 83, 2, 372, 373, 5, 141, 71, 2, 373, 374, 5, 187, 94, 2, 374, 96, 3, 2, 2, 2, 375, 376, 5, 165, 83, 2, 376, 377, 5, 157, 79, 2, 377, 98, 3, 2, 2, 2, 378, 379, 5, 165, 83, 2, 379, 380, 5, 157, 79, 2, 380, 381, 5, 167, 84, 2, 381, 100, 3, 2, 2, 2, 382, 383, 5, 165, 83, 2, 383, 384, 5, 169, 85, 2, 384, 385, 5, 147, 74, 2, 385, 102, 3, 2, 2, 2, 386, 387, 5, 167, 84, 2, 387, 388, 5, 169, 85, 2, 388, 389, 5, 179, 90, 2, 389, 104, 3, 2, 2, 2, 390, 391, 5, 167, 84, 2, 391, 392, 5, 181, 91, 2, 392, 393, 5, 163, 82, 2, 393, 394, 5, 163, 82, 2, 394, 106, 3, 2, 2, 2, 395, 396, 5, 169, 85, 2, 396, 397, 5, 151, 76, 2, 397, 398, 5, 151, 76, 2, 398, 399, 5, 177, 89, 2, 399, 400, 5, 149, 75, 2, 400, 401, 5, 179, 90, 2, 401, 108, 3, 2, 2, 2, 402, 403, 5, 169, 85, 2, 403, 404, 5, 175, 88, 2, 404, 110, 3, 2, 2, 2, 405, 406, 5, 177, 89, 2, 406, 407, 5, 149, 75, 2, 407, 408, 5, 163, 82, 2, 408, 409, 5, 149, 75, 2, 409, 410, 5, 145, 73, 2, 410, 411, 5, 179, 90, 2, 411, 112, 3, 2, 2, 2, 412, 413, 5, 177, 89, 2, 413, 414, 5, 169, 85, 2, 414, 415, 5, 175, 88, 2, 415, 416, 5, 179, 90, 2, 416, 114, 3, 2, 2, 2, 417, 418, 5, 177, 89, 2, 418, 419, 5, 181, 91, 2, 419, 420, 5, 165, 83, 2, 420, 116, 3, 2, 2, 2, 421, 422, 5, 179, 90, 2, 422, 423, 5, 175, 88, 2, 423, 424, 5, 181, 91, 2, 424, 425, 5, 149, 75, 2, 425, 118, 3, 2, 2, 2, 426, 427, 5, 189, 95, 2, 427, 428, 5, 147, 74, 2, 428, 120, 3, 2, 2, 2, 429, 430, 5, 141, 71, 2, 430, 431, 5, 177, 89, 2, 431, 432, 5, 185, 93, 2, 432, 433, 5, 161, 81, 2, 433, 434, 5, 143, 72, 2, 434, 122, 3, 2, 2, 2, 435, 436, 5, 141, 71, 2, 436, 437, 5, 177, 89, 2, 437, 438, 5, 185, 93, 2, 438, 439, 5, 161, 81, 2, 439, 440, 5, 179, 90, 2, 440, 124, 3, 2, 2, 2, 441, 442, 5, 141, 71, 2, 442, 443, 5, 177, 89, 2, 443, 444, 5, 153, 77, 2, 444, 445, 5, 149, 75, 2, 445, 446, 5, 169, 85, 2, 446, 447, 5, 159, 80, 2, 447, 448, 5, 177, 89, 2, 448, 449, 5, 169, 85, 2, 449, 450, 5, 167, 84, 2, 450, 126, 3, 2, 2, 2, 451, 454, 5, 137, 69, 2, 452, 454, 7, 97, 2, 2, 453, 451, 3, 2, 2, 2, 453, 452, 3, 2, 2, 2, 454, 460, 3, 2, 2, 2, 455, 459, 5, 137, 69, 2, 456, 459, 5, 135, 68, 2, 457, 459, 9, 2, 2, 2, 458, 455, 3, 2, 2, 2, 458, 456, 3, 2, 2, 2, 458, 457, 3, 2, 2, 2, 459, 462, 3, 2, 2, 2, 460, 458, 3, 2, 2, 2, 460, 461, 3, 2, 2, 2, 461, 128, 3, 2, 2, 2, 462, 460, 3, 2, 2, 2, 463, 465, 5, 135, 68, 2, 464, 463, 3, 2, 2, 2, 465, 466, 3, 2, 2, 2, 466, 464, 3, 2, 2, 2, 466, 467, 3, 2, 2, 2, 467, 130, 3, 2, 2, 2, 468, 475, 7, 41, 2, 2, 469, 474, 10, 3, 2, 2, 470, 471, 7, 41, 2, 2, 471, 474, 7, 41, 2, 2, 472, 474, 5, 139, 70, 2, 473, 469, 3, 2, 2, 2, 473, 470, 3, 2, 2, 2, 473, 472, 3, 2, 2, 2, 474, 477, 3, 2, 2, 2, 475, 473, 3, 2, 2, 2, 475, 476, 3, 2, 2, 2, 476, 478, 3, 2, 2, 2, 477, 475, 3, 2, 2, 2, 478, 479, 7, 41, 2, 2, 479, 132, 3, 2, 2, 2, 480, 482, 9, 4, 2, 2, 481, 480, 3, 2, 2, 2, 482, 483, 3, 2, 2, 2, 483, 481, 3, 2, 2, 2, 483, 484, 3, 2, 2, 2, 484, 485, 3, 2, 2, 2, 485, 486, 8, 67, 2, 2, 486, 134, 3, 2, 2, 2, 487, 488, 9, 5, 2, 2, 488, 136, 3, 2, 2, 2, 489, 490, 9, 6, 2, 2, 490, 138, 3, 2, 2, 2, 491, 493, 7, 15, 2, 2, 492, 491, 3, 2, 2, 2, 492, 493, 3, 2, 2, 2, 493, 494, 3, 2, 2, 2, 494, 495, 7, 12, 2, 2, 495, 140, 3, 2, 2, 2, 496, 497, 9, 7, 2, 2, 497, 142, 3, 2, 2, 2, 498, 499, 9, 8, 2, 2, 499, 144, 3, 2, 2, 2, 500, 501, 9, 9, 2, 2, 501, 146, 3, 2, 2, 2, 502, 503, 9, 10, 2, 2, 503, 148, 3, 2, 2, 2, 504, 505, 9, 11, 2, 2, 505, 150, 3, 2, 2, 2, 506, 507, 9, 12, 2, 2, 507, 152, 3, 2, 2, 2, 508, 509, 9, 13, 2, 2, 509, 154, 3, 2, 2, 2, 510, 511, 9, 14, 2, 2, 511, 156, 3, 2, 2, 2, 512, 513, 9, 15, 2, 2, 513, 158, 3, 2, 2, 2, 514, 515, 9, 16, 2, 2, 515, 160, 3, 2, 2, 2, 516, 517, 9, 17, 2, 2, 517, 162, 3, 2, 2, 2, 518, 519, 9, 18, 2, 2, 519, 164, 3, 2, 2, 2, 520, 521, 9, 19, 2, 2, 521, 166, 3, 2, 2, 2, 522, 523, 9, 20, 2, 2, 523, 168, 3, 2, 2, 2, 524, 525, 9, 21, 2, 2, 525, 170, 3, 2, 2, 2, 526, 527, 9, 22, 2, 2, 527, 172, 3, 2, 2, 2, 528, 529, 9, 23, 2, 2, 529, 174, 3, 2, 2, 2, 530, 531, 9, 24, 2, 2, 531, 176, 3, 2, 2, 2, 532, 533, 9, 25, 2, 2, 533, 178, 3, 2, 2, 2, 534, 535, 9, 26, 2, 2, 535, 180, 3, 2, 2, 2, 536, 537, 9, 27, 2, 2, 537, 182, 3, 2, 2, 2, 538, 539, 9, 28, 2, 2, 539, 184, 3, 2, 2, 2, 540, 541, 9, 29, 2, 2, 541, 186, 3, 2, 2, 2, 542, 543, 9, 30, 2, 2, 543, 188, 3, 2, 2, 2, 544, 545, 9, 31, 2, 2, 545, 190, 3, 2, 2, 2, 546, 547, 9, 32, 2, 2, 547, 192, 3, 2, 2, 2, 11, 2, 453, 458, 460, 466, 473, 475, 483, 492, 3, 8, 2, 2] \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.java new file mode 100644 index 000000000..29e81b9a8 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.java @@ -0,0 +1,322 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class BackendlessQueryLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, AFTER=24, + AND=25, AT=26, AS=27, ASC=28, AVG=29, BEFORE=30, BY=31, COUNT=32, DESC=33, + DISTANCE=34, DISTANCE_ON_SPHERE=35, DIV=36, ESCAPE=37, FALSE=38, FT=39, + GROUP=40, HAVING=41, IN=42, IS=43, KM=44, LIMIT=45, LIKE=46, MAX=47, MI=48, + MIN=49, MOD=50, NOT=51, NULL=52, OFFSET=53, OR=54, SELECT=55, SORT=56, + SUM=57, TRUE=58, YD=59, AsWKB=60, AsWKT=61, AsGeoJSON=62, ID=63, INT=64, + CHAR_STRING=65, WS=66; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "AFTER", "AND", + "AT", "AS", "ASC", "AVG", "BEFORE", "BY", "COUNT", "DESC", "DISTANCE", + "DISTANCE_ON_SPHERE", "DIV", "ESCAPE", "FALSE", "FT", "GROUP", "HAVING", + "IN", "IS", "KM", "LIMIT", "LIKE", "MAX", "MI", "MIN", "MOD", "NOT", + "NULL", "OFFSET", "OR", "SELECT", "SORT", "SUM", "TRUE", "YD", "AsWKB", + "AsWKT", "AsGeoJSON", "ID", "INT", "CHAR_STRING", "WS", "DIGIT", "LETTER", + "NEWLINE", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", + "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'['", "']'", "'.'", "'{'", "','", "'}'", "'('", "')'", "'!'", + "'&&'", "'||'", "'='", "'!='", "'<>'", "'>='", "'>'", "'<='", "'<'", + "'-'", "'*'", "'/'", "'%'", "'+'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + "AFTER", "AND", "AT", "AS", "ASC", "AVG", "BEFORE", "BY", "COUNT", "DESC", + "DISTANCE", "DISTANCE_ON_SPHERE", "DIV", "ESCAPE", "FALSE", "FT", "GROUP", + "HAVING", "IN", "IS", "KM", "LIMIT", "LIKE", "MAX", "MI", "MIN", "MOD", + "NOT", "NULL", "OFFSET", "OR", "SELECT", "SORT", "SUM", "TRUE", "YD", + "AsWKB", "AsWKT", "AsGeoJSON", "ID", "INT", "CHAR_STRING", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public BackendlessQueryLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "BackendlessQuery.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2D\u0224\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ + "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ + "\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+ + "`\t`\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3"+ + "\n\3\n\3\13\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3\17"+ + "\3\20\3\20\3\20\3\21\3\21\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25"+ + "\3\26\3\26\3\27\3\27\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31\3\32\3\32"+ + "\3\32\3\32\3\33\3\33\3\33\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36"+ + "\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3!\3!\3!\3!\3!"+ + "\3!\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3"+ + "$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3"+ + "&\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\3"+ + "*\3*\3+\3+\3+\3,\3,\3,\3-\3-\3-\3.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3/\3\60"+ + "\3\60\3\60\3\60\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63"+ + "\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\66"+ + "\3\66\3\66\3\67\3\67\3\67\38\38\38\38\38\38\38\39\39\39\39\39\3:\3:\3"+ + ":\3:\3;\3;\3;\3;\3;\3<\3<\3<\3=\3=\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3?\3"+ + "?\3?\3?\3?\3?\3?\3?\3?\3?\3@\3@\5@\u01c6\n@\3@\3@\3@\7@\u01cb\n@\f@\16"+ + "@\u01ce\13@\3A\6A\u01d1\nA\rA\16A\u01d2\3B\3B\3B\3B\3B\7B\u01da\nB\fB"+ + "\16B\u01dd\13B\3B\3B\3C\6C\u01e2\nC\rC\16C\u01e3\3C\3C\3D\3D\3E\3E\3F"+ + "\5F\u01ed\nF\3F\3F\3G\3G\3H\3H\3I\3I\3J\3J\3K\3K\3L\3L\3M\3M\3N\3N\3O"+ + "\3O\3P\3P\3Q\3Q\3R\3R\3S\3S\3T\3T\3U\3U\3V\3V\3W\3W\3X\3X\3Y\3Y\3Z\3Z"+ + "\3[\3[\3\\\3\\\3]\3]\3^\3^\3_\3_\3`\3`\2\2a\3\3\5\4\7\5\t\6\13\7\r\b\17"+ + "\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+"+ + "\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+"+ + "U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q:s;u{?}@\177A\u0081"+ + "B\u0083C\u0085D\u0087\2\u0089\2\u008b\2\u008d\2\u008f\2\u0091\2\u0093"+ + "\2\u0095\2\u0097\2\u0099\2\u009b\2\u009d\2\u009f\2\u00a1\2\u00a3\2\u00a5"+ + "\2\u00a7\2\u00a9\2\u00ab\2\u00ad\2\u00af\2\u00b1\2\u00b3\2\u00b5\2\u00b7"+ + "\2\u00b9\2\u00bb\2\u00bd\2\u00bf\2\3\2!\4\2%&aa\5\2\f\f\17\17))\5\2\13"+ + "\f\17\17\"\"\3\2\62;\4\2C\\c|\4\2CCcc\4\2DDdd\4\2EEee\4\2FFff\4\2GGgg"+ + "\4\2HHhh\4\2IIii\4\2JJjj\4\2KKkk\4\2LLll\4\2MMmm\4\2NNnn\4\2OOoo\4\2P"+ + "Ppp\4\2QQqq\4\2RRrr\4\2SSss\4\2TTtt\4\2UUuu\4\2VVvv\4\2WWww\4\2XXxx\4"+ + "\2YYyy\4\2ZZzz\4\2[[{{\4\2\\\\||\2\u0210\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3"+ + "\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2"+ + "\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35"+ + "\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)"+ + "\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2"+ + "\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2"+ + "A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3"+ + "\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2"+ + "\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2"+ + "g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3"+ + "\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3"+ + "\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\3\u00c1\3\2\2\2"+ + "\5\u00c3\3\2\2\2\7\u00c5\3\2\2\2\t\u00c7\3\2\2\2\13\u00c9\3\2\2\2\r\u00cb"+ + "\3\2\2\2\17\u00cd\3\2\2\2\21\u00cf\3\2\2\2\23\u00d1\3\2\2\2\25\u00d3\3"+ + "\2\2\2\27\u00d6\3\2\2\2\31\u00d9\3\2\2\2\33\u00db\3\2\2\2\35\u00de\3\2"+ + "\2\2\37\u00e1\3\2\2\2!\u00e4\3\2\2\2#\u00e6\3\2\2\2%\u00e9\3\2\2\2\'\u00eb"+ + "\3\2\2\2)\u00ed\3\2\2\2+\u00ef\3\2\2\2-\u00f1\3\2\2\2/\u00f3\3\2\2\2\61"+ + "\u00f5\3\2\2\2\63\u00fb\3\2\2\2\65\u00ff\3\2\2\2\67\u0102\3\2\2\29\u0105"+ + "\3\2\2\2;\u0109\3\2\2\2=\u010d\3\2\2\2?\u0114\3\2\2\2A\u0117\3\2\2\2C"+ + "\u011d\3\2\2\2E\u0122\3\2\2\2G\u012b\3\2\2\2I\u013e\3\2\2\2K\u0142\3\2"+ + "\2\2M\u0149\3\2\2\2O\u014f\3\2\2\2Q\u0152\3\2\2\2S\u0158\3\2\2\2U\u015f"+ + "\3\2\2\2W\u0162\3\2\2\2Y\u0165\3\2\2\2[\u0168\3\2\2\2]\u016e\3\2\2\2_"+ + "\u0173\3\2\2\2a\u0177\3\2\2\2c\u017a\3\2\2\2e\u017e\3\2\2\2g\u0182\3\2"+ + "\2\2i\u0186\3\2\2\2k\u018b\3\2\2\2m\u0192\3\2\2\2o\u0195\3\2\2\2q\u019c"+ + "\3\2\2\2s\u01a1\3\2\2\2u\u01a5\3\2\2\2w\u01aa\3\2\2\2y\u01ad\3\2\2\2{"+ + "\u01b3\3\2\2\2}\u01b9\3\2\2\2\177\u01c5\3\2\2\2\u0081\u01d0\3\2\2\2\u0083"+ + "\u01d4\3\2\2\2\u0085\u01e1\3\2\2\2\u0087\u01e7\3\2\2\2\u0089\u01e9\3\2"+ + "\2\2\u008b\u01ec\3\2\2\2\u008d\u01f0\3\2\2\2\u008f\u01f2\3\2\2\2\u0091"+ + "\u01f4\3\2\2\2\u0093\u01f6\3\2\2\2\u0095\u01f8\3\2\2\2\u0097\u01fa\3\2"+ + "\2\2\u0099\u01fc\3\2\2\2\u009b\u01fe\3\2\2\2\u009d\u0200\3\2\2\2\u009f"+ + "\u0202\3\2\2\2\u00a1\u0204\3\2\2\2\u00a3\u0206\3\2\2\2\u00a5\u0208\3\2"+ + "\2\2\u00a7\u020a\3\2\2\2\u00a9\u020c\3\2\2\2\u00ab\u020e\3\2\2\2\u00ad"+ + "\u0210\3\2\2\2\u00af\u0212\3\2\2\2\u00b1\u0214\3\2\2\2\u00b3\u0216\3\2"+ + "\2\2\u00b5\u0218\3\2\2\2\u00b7\u021a\3\2\2\2\u00b9\u021c\3\2\2\2\u00bb"+ + "\u021e\3\2\2\2\u00bd\u0220\3\2\2\2\u00bf\u0222\3\2\2\2\u00c1\u00c2\7]"+ + "\2\2\u00c2\4\3\2\2\2\u00c3\u00c4\7_\2\2\u00c4\6\3\2\2\2\u00c5\u00c6\7"+ + "\60\2\2\u00c6\b\3\2\2\2\u00c7\u00c8\7}\2\2\u00c8\n\3\2\2\2\u00c9\u00ca"+ + "\7.\2\2\u00ca\f\3\2\2\2\u00cb\u00cc\7\177\2\2\u00cc\16\3\2\2\2\u00cd\u00ce"+ + "\7*\2\2\u00ce\20\3\2\2\2\u00cf\u00d0\7+\2\2\u00d0\22\3\2\2\2\u00d1\u00d2"+ + "\7#\2\2\u00d2\24\3\2\2\2\u00d3\u00d4\7(\2\2\u00d4\u00d5\7(\2\2\u00d5\26"+ + "\3\2\2\2\u00d6\u00d7\7~\2\2\u00d7\u00d8\7~\2\2\u00d8\30\3\2\2\2\u00d9"+ + "\u00da\7?\2\2\u00da\32\3\2\2\2\u00db\u00dc\7#\2\2\u00dc\u00dd\7?\2\2\u00dd"+ + "\34\3\2\2\2\u00de\u00df\7>\2\2\u00df\u00e0\7@\2\2\u00e0\36\3\2\2\2\u00e1"+ + "\u00e2\7@\2\2\u00e2\u00e3\7?\2\2\u00e3 \3\2\2\2\u00e4\u00e5\7@\2\2\u00e5"+ + "\"\3\2\2\2\u00e6\u00e7\7>\2\2\u00e7\u00e8\7?\2\2\u00e8$\3\2\2\2\u00e9"+ + "\u00ea\7>\2\2\u00ea&\3\2\2\2\u00eb\u00ec\7/\2\2\u00ec(\3\2\2\2\u00ed\u00ee"+ + "\7,\2\2\u00ee*\3\2\2\2\u00ef\u00f0\7\61\2\2\u00f0,\3\2\2\2\u00f1\u00f2"+ + "\7\'\2\2\u00f2.\3\2\2\2\u00f3\u00f4\7-\2\2\u00f4\60\3\2\2\2\u00f5\u00f6"+ + "\5\u008dG\2\u00f6\u00f7\5\u0097L\2\u00f7\u00f8\5\u00b3Z\2\u00f8\u00f9"+ + "\5\u0095K\2\u00f9\u00fa\5\u00afX\2\u00fa\62\3\2\2\2\u00fb\u00fc\5\u008d"+ + "G\2\u00fc\u00fd\5\u00a7T\2\u00fd\u00fe\5\u0093J\2\u00fe\64\3\2\2\2\u00ff"+ + "\u0100\5\u008dG\2\u0100\u0101\5\u00b3Z\2\u0101\66\3\2\2\2\u0102\u0103"+ + "\5\u008dG\2\u0103\u0104\5\u00b1Y\2\u01048\3\2\2\2\u0105\u0106\5\u008d"+ + "G\2\u0106\u0107\5\u00b1Y\2\u0107\u0108\5\u0091I\2\u0108:\3\2\2\2\u0109"+ + "\u010a\5\u008dG\2\u010a\u010b\5\u00b7\\\2\u010b\u010c\5\u0099M\2\u010c"+ + "<\3\2\2\2\u010d\u010e\5\u008fH\2\u010e\u010f\5\u0095K\2\u010f\u0110\5"+ + "\u0097L\2\u0110\u0111\5\u00a9U\2\u0111\u0112\5\u00afX\2\u0112\u0113\5"+ + "\u0095K\2\u0113>\3\2\2\2\u0114\u0115\5\u008fH\2\u0115\u0116\5\u00bd_\2"+ + "\u0116@\3\2\2\2\u0117\u0118\5\u0091I\2\u0118\u0119\5\u00a9U\2\u0119\u011a"+ + "\5\u00b5[\2\u011a\u011b\5\u00a7T\2\u011b\u011c\5\u00b3Z\2\u011cB\3\2\2"+ + "\2\u011d\u011e\5\u0093J\2\u011e\u011f\5\u0095K\2\u011f\u0120\5\u00b1Y"+ + "\2\u0120\u0121\5\u0091I\2\u0121D\3\2\2\2\u0122\u0123\5\u0093J\2\u0123"+ + "\u0124\5\u009dO\2\u0124\u0125\5\u00b1Y\2\u0125\u0126\5\u00b3Z\2\u0126"+ + "\u0127\5\u008dG\2\u0127\u0128\5\u00a7T\2\u0128\u0129\5\u0091I\2\u0129"+ + "\u012a\5\u0095K\2\u012aF\3\2\2\2\u012b\u012c\5\u0093J\2\u012c\u012d\5"+ + "\u009dO\2\u012d\u012e\5\u00b1Y\2\u012e\u012f\5\u00b3Z\2\u012f\u0130\5"+ + "\u008dG\2\u0130\u0131\5\u00a7T\2\u0131\u0132\5\u0091I\2\u0132\u0133\5"+ + "\u0095K\2\u0133\u0134\7a\2\2\u0134\u0135\5\u00a9U\2\u0135\u0136\5\u00a7"+ + "T\2\u0136\u0137\7a\2\2\u0137\u0138\5\u00b1Y\2\u0138\u0139\5\u00abV\2\u0139"+ + "\u013a\5\u009bN\2\u013a\u013b\5\u0095K\2\u013b\u013c\5\u00afX\2\u013c"+ + "\u013d\5\u0095K\2\u013dH\3\2\2\2\u013e\u013f\5\u0093J\2\u013f\u0140\5"+ + "\u009dO\2\u0140\u0141\5\u00b7\\\2\u0141J\3\2\2\2\u0142\u0143\5\u0095K"+ + "\2\u0143\u0144\5\u00b1Y\2\u0144\u0145\5\u0091I\2\u0145\u0146\5\u008dG"+ + "\2\u0146\u0147\5\u00abV\2\u0147\u0148\5\u0095K\2\u0148L\3\2\2\2\u0149"+ + "\u014a\5\u0097L\2\u014a\u014b\5\u008dG\2\u014b\u014c\5\u00a3R\2\u014c"+ + "\u014d\5\u00b1Y\2\u014d\u014e\5\u0095K\2\u014eN\3\2\2\2\u014f\u0150\5"+ + "\u0097L\2\u0150\u0151\5\u00b3Z\2\u0151P\3\2\2\2\u0152\u0153\5\u0099M\2"+ + "\u0153\u0154\5\u00afX\2\u0154\u0155\5\u00a9U\2\u0155\u0156\5\u00b5[\2"+ + "\u0156\u0157\5\u00abV\2\u0157R\3\2\2\2\u0158\u0159\5\u009bN\2\u0159\u015a"+ + "\5\u008dG\2\u015a\u015b\5\u00b7\\\2\u015b\u015c\5\u009dO\2\u015c\u015d"+ + "\5\u00a7T\2\u015d\u015e\5\u0099M\2\u015eT\3\2\2\2\u015f\u0160\5\u009d"+ + "O\2\u0160\u0161\5\u00a7T\2\u0161V\3\2\2\2\u0162\u0163\5\u009dO\2\u0163"+ + "\u0164\5\u00b1Y\2\u0164X\3\2\2\2\u0165\u0166\5\u00a1Q\2\u0166\u0167\5"+ + "\u00a5S\2\u0167Z\3\2\2\2\u0168\u0169\5\u00a3R\2\u0169\u016a\5\u009dO\2"+ + "\u016a\u016b\5\u00a5S\2\u016b\u016c\5\u009dO\2\u016c\u016d\5\u00b3Z\2"+ + "\u016d\\\3\2\2\2\u016e\u016f\5\u00a3R\2\u016f\u0170\5\u009dO\2\u0170\u0171"+ + "\5\u00a1Q\2\u0171\u0172\5\u0095K\2\u0172^\3\2\2\2\u0173\u0174\5\u00a5"+ + "S\2\u0174\u0175\5\u008dG\2\u0175\u0176\5\u00bb^\2\u0176`\3\2\2\2\u0177"+ + "\u0178\5\u00a5S\2\u0178\u0179\5\u009dO\2\u0179b\3\2\2\2\u017a\u017b\5"+ + "\u00a5S\2\u017b\u017c\5\u009dO\2\u017c\u017d\5\u00a7T\2\u017dd\3\2\2\2"+ + "\u017e\u017f\5\u00a5S\2\u017f\u0180\5\u00a9U\2\u0180\u0181\5\u0093J\2"+ + "\u0181f\3\2\2\2\u0182\u0183\5\u00a7T\2\u0183\u0184\5\u00a9U\2\u0184\u0185"+ + "\5\u00b3Z\2\u0185h\3\2\2\2\u0186\u0187\5\u00a7T\2\u0187\u0188\5\u00b5"+ + "[\2\u0188\u0189\5\u00a3R\2\u0189\u018a\5\u00a3R\2\u018aj\3\2\2\2\u018b"+ + "\u018c\5\u00a9U\2\u018c\u018d\5\u0097L\2\u018d\u018e\5\u0097L\2\u018e"+ + "\u018f\5\u00b1Y\2\u018f\u0190\5\u0095K\2\u0190\u0191\5\u00b3Z\2\u0191"+ + "l\3\2\2\2\u0192\u0193\5\u00a9U\2\u0193\u0194\5\u00afX\2\u0194n\3\2\2\2"+ + "\u0195\u0196\5\u00b1Y\2\u0196\u0197\5\u0095K\2\u0197\u0198\5\u00a3R\2"+ + "\u0198\u0199\5\u0095K\2\u0199\u019a\5\u0091I\2\u019a\u019b\5\u00b3Z\2"+ + "\u019bp\3\2\2\2\u019c\u019d\5\u00b1Y\2\u019d\u019e\5\u00a9U\2\u019e\u019f"+ + "\5\u00afX\2\u019f\u01a0\5\u00b3Z\2\u01a0r\3\2\2\2\u01a1\u01a2\5\u00b1"+ + "Y\2\u01a2\u01a3\5\u00b5[\2\u01a3\u01a4\5\u00a5S\2\u01a4t\3\2\2\2\u01a5"+ + "\u01a6\5\u00b3Z\2\u01a6\u01a7\5\u00afX\2\u01a7\u01a8\5\u00b5[\2\u01a8"+ + "\u01a9\5\u0095K\2\u01a9v\3\2\2\2\u01aa\u01ab\5\u00bd_\2\u01ab\u01ac\5"+ + "\u0093J\2\u01acx\3\2\2\2\u01ad\u01ae\5\u008dG\2\u01ae\u01af\5\u00b1Y\2"+ + "\u01af\u01b0\5\u00b9]\2\u01b0\u01b1\5\u00a1Q\2\u01b1\u01b2\5\u008fH\2"+ + "\u01b2z\3\2\2\2\u01b3\u01b4\5\u008dG\2\u01b4\u01b5\5\u00b1Y\2\u01b5\u01b6"+ + "\5\u00b9]\2\u01b6\u01b7\5\u00a1Q\2\u01b7\u01b8\5\u00b3Z\2\u01b8|\3\2\2"+ + "\2\u01b9\u01ba\5\u008dG\2\u01ba\u01bb\5\u00b1Y\2\u01bb\u01bc\5\u0099M"+ + "\2\u01bc\u01bd\5\u0095K\2\u01bd\u01be\5\u00a9U\2\u01be\u01bf\5\u009fP"+ + "\2\u01bf\u01c0\5\u00b1Y\2\u01c0\u01c1\5\u00a9U\2\u01c1\u01c2\5\u00a7T"+ + "\2\u01c2~\3\2\2\2\u01c3\u01c6\5\u0089E\2\u01c4\u01c6\7a\2\2\u01c5\u01c3"+ + "\3\2\2\2\u01c5\u01c4\3\2\2\2\u01c6\u01cc\3\2\2\2\u01c7\u01cb\5\u0089E"+ + "\2\u01c8\u01cb\5\u0087D\2\u01c9\u01cb\t\2\2\2\u01ca\u01c7\3\2\2\2\u01ca"+ + "\u01c8\3\2\2\2\u01ca\u01c9\3\2\2\2\u01cb\u01ce\3\2\2\2\u01cc\u01ca\3\2"+ + "\2\2\u01cc\u01cd\3\2\2\2\u01cd\u0080\3\2\2\2\u01ce\u01cc\3\2\2\2\u01cf"+ + "\u01d1\5\u0087D\2\u01d0\u01cf\3\2\2\2\u01d1\u01d2\3\2\2\2\u01d2\u01d0"+ + "\3\2\2\2\u01d2\u01d3\3\2\2\2\u01d3\u0082\3\2\2\2\u01d4\u01db\7)\2\2\u01d5"+ + "\u01da\n\3\2\2\u01d6\u01d7\7)\2\2\u01d7\u01da\7)\2\2\u01d8\u01da\5\u008b"+ + "F\2\u01d9\u01d5\3\2\2\2\u01d9\u01d6\3\2\2\2\u01d9\u01d8\3\2\2\2\u01da"+ + "\u01dd\3\2\2\2\u01db\u01d9\3\2\2\2\u01db\u01dc\3\2\2\2\u01dc\u01de\3\2"+ + "\2\2\u01dd\u01db\3\2\2\2\u01de\u01df\7)\2\2\u01df\u0084\3\2\2\2\u01e0"+ + "\u01e2\t\4\2\2\u01e1\u01e0\3\2\2\2\u01e2\u01e3\3\2\2\2\u01e3\u01e1\3\2"+ + "\2\2\u01e3\u01e4\3\2\2\2\u01e4\u01e5\3\2\2\2\u01e5\u01e6\bC\2\2\u01e6"+ + "\u0086\3\2\2\2\u01e7\u01e8\t\5\2\2\u01e8\u0088\3\2\2\2\u01e9\u01ea\t\6"+ + "\2\2\u01ea\u008a\3\2\2\2\u01eb\u01ed\7\17\2\2\u01ec\u01eb\3\2\2\2\u01ec"+ + "\u01ed\3\2\2\2\u01ed\u01ee\3\2\2\2\u01ee\u01ef\7\f\2\2\u01ef\u008c\3\2"+ + "\2\2\u01f0\u01f1\t\7\2\2\u01f1\u008e\3\2\2\2\u01f2\u01f3\t\b\2\2\u01f3"+ + "\u0090\3\2\2\2\u01f4\u01f5\t\t\2\2\u01f5\u0092\3\2\2\2\u01f6\u01f7\t\n"+ + "\2\2\u01f7\u0094\3\2\2\2\u01f8\u01f9\t\13\2\2\u01f9\u0096\3\2\2\2\u01fa"+ + "\u01fb\t\f\2\2\u01fb\u0098\3\2\2\2\u01fc\u01fd\t\r\2\2\u01fd\u009a\3\2"+ + "\2\2\u01fe\u01ff\t\16\2\2\u01ff\u009c\3\2\2\2\u0200\u0201\t\17\2\2\u0201"+ + "\u009e\3\2\2\2\u0202\u0203\t\20\2\2\u0203\u00a0\3\2\2\2\u0204\u0205\t"+ + "\21\2\2\u0205\u00a2\3\2\2\2\u0206\u0207\t\22\2\2\u0207\u00a4\3\2\2\2\u0208"+ + "\u0209\t\23\2\2\u0209\u00a6\3\2\2\2\u020a\u020b\t\24\2\2\u020b\u00a8\3"+ + "\2\2\2\u020c\u020d\t\25\2\2\u020d\u00aa\3\2\2\2\u020e\u020f\t\26\2\2\u020f"+ + "\u00ac\3\2\2\2\u0210\u0211\t\27\2\2\u0211\u00ae\3\2\2\2\u0212\u0213\t"+ + "\30\2\2\u0213\u00b0\3\2\2\2\u0214\u0215\t\31\2\2\u0215\u00b2\3\2\2\2\u0216"+ + "\u0217\t\32\2\2\u0217\u00b4\3\2\2\2\u0218\u0219\t\33\2\2\u0219\u00b6\3"+ + "\2\2\2\u021a\u021b\t\34\2\2\u021b\u00b8\3\2\2\2\u021c\u021d\t\35\2\2\u021d"+ + "\u00ba\3\2\2\2\u021e\u021f\t\36\2\2\u021f\u00bc\3\2\2\2\u0220\u0221\t"+ + "\37\2\2\u0221\u00be\3\2\2\2\u0222\u0223\t \2\2\u0223\u00c0\3\2\2\2\13"+ + "\2\u01c5\u01ca\u01cc\u01d2\u01d9\u01db\u01e3\u01ec\3\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.tokens b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.tokens new file mode 100644 index 000000000..c532f5778 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryLexer.tokens @@ -0,0 +1,89 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +AFTER=24 +AND=25 +AT=26 +AS=27 +ASC=28 +AVG=29 +BEFORE=30 +BY=31 +COUNT=32 +DESC=33 +DISTANCE=34 +DISTANCE_ON_SPHERE=35 +DIV=36 +ESCAPE=37 +FALSE=38 +FT=39 +GROUP=40 +HAVING=41 +IN=42 +IS=43 +KM=44 +LIMIT=45 +LIKE=46 +MAX=47 +MI=48 +MIN=49 +MOD=50 +NOT=51 +NULL=52 +OFFSET=53 +OR=54 +SELECT=55 +SORT=56 +SUM=57 +TRUE=58 +YD=59 +AsWKB=60 +AsWKT=61 +AsGeoJSON=62 +ID=63 +INT=64 +CHAR_STRING=65 +WS=66 +'['=1 +']'=2 +'.'=3 +'{'=4 +','=5 +'}'=6 +'('=7 +')'=8 +'!'=9 +'&&'=10 +'||'=11 +'='=12 +'!='=13 +'<>'=14 +'>='=15 +'>'=16 +'<='=17 +'<'=18 +'-'=19 +'*'=20 +'/'=21 +'%'=22 +'+'=23 diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryListener.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryListener.java new file mode 100644 index 000000000..08e92bda3 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryListener.java @@ -0,0 +1,794 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link BackendlessQueryParser}. + */ +public interface BackendlessQueryListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#select_statement}. + * @param ctx the parse tree + */ + void enterSelect_statement(BackendlessQueryParser.Select_statementContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#select_statement}. + * @param ctx the parse tree + */ + void exitSelect_statement(BackendlessQueryParser.Select_statementContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#select_list}. + * @param ctx the parse tree + */ + void enterSelect_list(BackendlessQueryParser.Select_listContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#select_list}. + * @param ctx the parse tree + */ + void exitSelect_list(BackendlessQueryParser.Select_listContext ctx); + /** + * Enter a parse tree produced by the {@code simpleSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + */ + void enterSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx); + /** + * Exit a parse tree produced by the {@code simpleSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + */ + void exitSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx); + /** + * Enter a parse tree produced by the {@code aliasedSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + */ + void enterAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx); + /** + * Exit a parse tree produced by the {@code aliasedSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + */ + void exitAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#group_by_clause}. + * @param ctx the parse tree + */ + void enterGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#group_by_clause}. + * @param ctx the parse tree + */ + void exitGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#having_clause}. + * @param ctx the parse tree + */ + void enterHaving_clause(BackendlessQueryParser.Having_clauseContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#having_clause}. + * @param ctx the parse tree + */ + void exitHaving_clause(BackendlessQueryParser.Having_clauseContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#sort_by_clause}. + * @param ctx the parse tree + */ + void enterSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#sort_by_clause}. + * @param ctx the parse tree + */ + void exitSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#sort_by_elem}. + * @param ctx the parse tree + */ + void enterSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#sort_by_elem}. + * @param ctx the parse tree + */ + void exitSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#limit_clause}. + * @param ctx the parse tree + */ + void enterLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#limit_clause}. + * @param ctx the parse tree + */ + void exitLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#function_call}. + * @param ctx the parse tree + */ + void enterFunction_call(BackendlessQueryParser.Function_callContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#function_call}. + * @param ctx the parse tree + */ + void exitFunction_call(BackendlessQueryParser.Function_callContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#spatial_convert_function}. + * @param ctx the parse tree + */ + void enterSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#spatial_convert_function}. + * @param ctx the parse tree + */ + void exitSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#spatial_function_parameter}. + * @param ctx the parse tree + */ + void enterSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#spatial_function_parameter}. + * @param ctx the parse tree + */ + void exitSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#aswkb_function}. + * @param ctx the parse tree + */ + void enterAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#aswkb_function}. + * @param ctx the parse tree + */ + void exitAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#aswkt_function}. + * @param ctx the parse tree + */ + void enterAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#aswkt_function}. + * @param ctx the parse tree + */ + void exitAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#asgeojson_function}. + * @param ctx the parse tree + */ + void enterAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#asgeojson_function}. + * @param ctx the parse tree + */ + void exitAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#spatial_function}. + * @param ctx the parse tree + */ + void enterSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#spatial_function}. + * @param ctx the parse tree + */ + void exitSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#distance_function}. + * @param ctx the parse tree + */ + void enterDistance_function(BackendlessQueryParser.Distance_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#distance_function}. + * @param ctx the parse tree + */ + void exitDistance_function(BackendlessQueryParser.Distance_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#distance_on_sphere}. + * @param ctx the parse tree + */ + void enterDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#distance_on_sphere}. + * @param ctx the parse tree + */ + void exitDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx); + /** + * Enter a parse tree produced by the {@code ftUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void enterFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code ftUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void exitFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code kmUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void enterKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code kmUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void exitKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code miUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void enterMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code miUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void exitMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code ydUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void enterYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code ydUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + */ + void exitYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code avgFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void enterAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code avgFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void exitAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code maxFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void enterMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code maxFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void exitMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code minFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void enterMinFunction(BackendlessQueryParser.MinFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code minFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void exitMinFunction(BackendlessQueryParser.MinFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code sumFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void enterSumFunction(BackendlessQueryParser.SumFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code sumFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void exitSumFunction(BackendlessQueryParser.SumFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code countFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void enterCountFunction(BackendlessQueryParser.CountFunctionContext ctx); + /** + * Exit a parse tree produced by the {@code countFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + */ + void exitCountFunction(BackendlessQueryParser.CountFunctionContext ctx); + /** + * Enter a parse tree produced by the {@code inCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterInCondition(BackendlessQueryParser.InConditionContext ctx); + /** + * Exit a parse tree produced by the {@code inCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitInCondition(BackendlessQueryParser.InConditionContext ctx); + /** + * Enter a parse tree produced by the {@code equalCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterEqualCondition(BackendlessQueryParser.EqualConditionContext ctx); + /** + * Exit a parse tree produced by the {@code equalCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitEqualCondition(BackendlessQueryParser.EqualConditionContext ctx); + /** + * Enter a parse tree produced by the {@code orCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterOrCondition(BackendlessQueryParser.OrConditionContext ctx); + /** + * Exit a parse tree produced by the {@code orCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitOrCondition(BackendlessQueryParser.OrConditionContext ctx); + /** + * Enter a parse tree produced by the {@code lessThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx); + /** + * Exit a parse tree produced by the {@code lessThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx); + /** + * Enter a parse tree produced by the {@code andCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterAndCondition(BackendlessQueryParser.AndConditionContext ctx); + /** + * Exit a parse tree produced by the {@code andCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitAndCondition(BackendlessQueryParser.AndConditionContext ctx); + /** + * Enter a parse tree produced by the {@code isNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx); + /** + * Exit a parse tree produced by the {@code isNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx); + /** + * Enter a parse tree produced by the {@code notCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterNotCondition(BackendlessQueryParser.NotConditionContext ctx); + /** + * Exit a parse tree produced by the {@code notCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitNotCondition(BackendlessQueryParser.NotConditionContext ctx); + /** + * Enter a parse tree produced by the {@code likeCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterLikeCondition(BackendlessQueryParser.LikeConditionContext ctx); + /** + * Exit a parse tree produced by the {@code likeCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitLikeCondition(BackendlessQueryParser.LikeConditionContext ctx); + /** + * Enter a parse tree produced by the {@code isNotNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx); + /** + * Exit a parse tree produced by the {@code isNotNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx); + /** + * Enter a parse tree produced by the {@code nestedCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterNestedCondition(BackendlessQueryParser.NestedConditionContext ctx); + /** + * Exit a parse tree produced by the {@code nestedCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitNestedCondition(BackendlessQueryParser.NestedConditionContext ctx); + /** + * Enter a parse tree produced by the {@code notEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx); + /** + * Exit a parse tree produced by the {@code notEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx); + /** + * Enter a parse tree produced by the {@code greaterThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx); + /** + * Exit a parse tree produced by the {@code greaterThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx); + /** + * Enter a parse tree produced by the {@code greaterThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx); + /** + * Exit a parse tree produced by the {@code greaterThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx); + /** + * Enter a parse tree produced by the {@code lessThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void enterLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx); + /** + * Exit a parse tree produced by the {@code lessThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + */ + void exitLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx); + /** + * Enter a parse tree produced by the {@code divisionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code divisionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code moduloExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code moduloExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code constantExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code constantExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code functionCallExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code functionCallExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code subtractionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code subtractionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code fullColumnNameExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code fullColumnNameExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code multiplicationExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code multiplicationExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code unaryMinusExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code unaryMinusExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx); + /** + * Enter a parse tree produced by the {@code additionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void enterAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx); + /** + * Exit a parse tree produced by the {@code additionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + */ + void exitAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#full_column_name}. + * @param ctx the parse tree + */ + void enterFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#full_column_name}. + * @param ctx the parse tree + */ + void exitFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#single_column_name}. + * @param ctx the parse tree + */ + void enterSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#single_column_name}. + * @param ctx the parse tree + */ + void exitSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#relation_column}. + * @param ctx the parse tree + */ + void enterRelation_column(BackendlessQueryParser.Relation_columnContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#relation_column}. + * @param ctx the parse tree + */ + void exitRelation_column(BackendlessQueryParser.Relation_columnContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#inverse_relation_column}. + * @param ctx the parse tree + */ + void enterInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#inverse_relation_column}. + * @param ctx the parse tree + */ + void exitInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#unknown_function}. + * @param ctx the parse tree + */ + void enterUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#unknown_function}. + * @param ctx the parse tree + */ + void exitUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#alias}. + * @param ctx the parse tree + */ + void enterAlias(BackendlessQueryParser.AliasContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#alias}. + * @param ctx the parse tree + */ + void exitAlias(BackendlessQueryParser.AliasContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#table_name}. + * @param ctx the parse tree + */ + void enterTable_name(BackendlessQueryParser.Table_nameContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#table_name}. + * @param ctx the parse tree + */ + void exitTable_name(BackendlessQueryParser.Table_nameContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#simple_column}. + * @param ctx the parse tree + */ + void enterSimple_column(BackendlessQueryParser.Simple_columnContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#simple_column}. + * @param ctx the parse tree + */ + void exitSimple_column(BackendlessQueryParser.Simple_columnContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#unknown_name}. + * @param ctx the parse tree + */ + void enterUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#unknown_name}. + * @param ctx the parse tree + */ + void exitUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx); + /** + * Enter a parse tree produced by the {@code stringConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void enterStringConstant(BackendlessQueryParser.StringConstantContext ctx); + /** + * Exit a parse tree produced by the {@code stringConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void exitStringConstant(BackendlessQueryParser.StringConstantContext ctx); + /** + * Enter a parse tree produced by the {@code numericConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void enterNumericConstant(BackendlessQueryParser.NumericConstantContext ctx); + /** + * Exit a parse tree produced by the {@code numericConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void exitNumericConstant(BackendlessQueryParser.NumericConstantContext ctx); + /** + * Enter a parse tree produced by the {@code booleanConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void enterBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx); + /** + * Exit a parse tree produced by the {@code booleanConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void exitBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx); + /** + * Enter a parse tree produced by the {@code nullConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void enterNullConstant(BackendlessQueryParser.NullConstantContext ctx); + /** + * Exit a parse tree produced by the {@code nullConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + */ + void exitNullConstant(BackendlessQueryParser.NullConstantContext ctx); + /** + * Enter a parse tree produced by the {@code trueBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + */ + void enterTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx); + /** + * Exit a parse tree produced by the {@code trueBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + */ + void exitTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx); + /** + * Enter a parse tree produced by the {@code falseBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + */ + void enterFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx); + /** + * Exit a parse tree produced by the {@code falseBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + */ + void exitFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx); + /** + * Enter a parse tree produced by the {@code decimalNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + */ + void enterDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx); + /** + * Exit a parse tree produced by the {@code decimalNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + */ + void exitDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx); + /** + * Enter a parse tree produced by the {@code floatNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + */ + void enterFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx); + /** + * Exit a parse tree produced by the {@code floatNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + */ + void exitFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#string_literal}. + * @param ctx the parse tree + */ + void enterString_literal(BackendlessQueryParser.String_literalContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#string_literal}. + * @param ctx the parse tree + */ + void exitString_literal(BackendlessQueryParser.String_literalContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#regular_id}. + * @param ctx the parse tree + */ + void enterRegular_id(BackendlessQueryParser.Regular_idContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#regular_id}. + * @param ctx the parse tree + */ + void exitRegular_id(BackendlessQueryParser.Regular_idContext ctx); + /** + * Enter a parse tree produced by {@link BackendlessQueryParser#keyword_as_id}. + * @param ctx the parse tree + */ + void enterKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx); + /** + * Exit a parse tree produced by {@link BackendlessQueryParser#keyword_as_id}. + * @param ctx the parse tree + */ + void exitKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx); +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryParser.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryParser.java new file mode 100644 index 000000000..70b2791a5 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryParser.java @@ -0,0 +1,4073 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; + +import java.util.List; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class BackendlessQueryParser extends Parser { + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, AFTER=24, + AND=25, AT=26, AS=27, ASC=28, AVG=29, BEFORE=30, BY=31, COUNT=32, DESC=33, + DISTANCE=34, DISTANCE_ON_SPHERE=35, DIV=36, ESCAPE=37, FALSE=38, FT=39, + GROUP=40, HAVING=41, IN=42, IS=43, KM=44, LIMIT=45, LIKE=46, MAX=47, MI=48, + MIN=49, MOD=50, NOT=51, NULL=52, OFFSET=53, OR=54, SELECT=55, SORT=56, + SUM=57, TRUE=58, YD=59, AsWKB=60, AsWKT=61, AsGeoJSON=62, ID=63, INT=64, + CHAR_STRING=65, WS=66; + public static final int + RULE_select_statement = 0, RULE_select_list = 1, RULE_select_list_elem = 2, + RULE_group_by_clause = 3, RULE_having_clause = 4, RULE_sort_by_clause = 5, + RULE_sort_by_elem = 6, RULE_limit_clause = 7, RULE_function_call = 8, + RULE_spatial_convert_function = 9, RULE_spatial_function_parameter = 10, + RULE_aswkb_function = 11, RULE_aswkt_function = 12, RULE_asgeojson_function = 13, + RULE_spatial_function = 14, RULE_distance_function = 15, RULE_distance_on_sphere = 16, + RULE_units_function = 17, RULE_aggregate_windowed_function = 18, RULE_condition = 19, + RULE_expression_atom = 20, RULE_full_column_name = 21, RULE_single_column_name = 22, + RULE_relation_column = 23, RULE_inverse_relation_column = 24, RULE_unknown_function = 25, + RULE_alias = 26, RULE_table_name = 27, RULE_simple_column = 28, RULE_unknown_name = 29, + RULE_constant = 30, RULE_boolean_literal = 31, RULE_numeric_literal = 32, + RULE_string_literal = 33, RULE_regular_id = 34, RULE_keyword_as_id = 35; + private static String[] makeRuleNames() { + return new String[] { + "select_statement", "select_list", "select_list_elem", "group_by_clause", + "having_clause", "sort_by_clause", "sort_by_elem", "limit_clause", "function_call", + "spatial_convert_function", "spatial_function_parameter", "aswkb_function", + "aswkt_function", "asgeojson_function", "spatial_function", "distance_function", + "distance_on_sphere", "units_function", "aggregate_windowed_function", + "condition", "expression_atom", "full_column_name", "single_column_name", + "relation_column", "inverse_relation_column", "unknown_function", "alias", + "table_name", "simple_column", "unknown_name", "constant", "boolean_literal", + "numeric_literal", "string_literal", "regular_id", "keyword_as_id" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'['", "']'", "'.'", "'{'", "','", "'}'", "'('", "')'", "'!'", + "'&&'", "'||'", "'='", "'!='", "'<>'", "'>='", "'>'", "'<='", "'<'", + "'-'", "'*'", "'/'", "'%'", "'+'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + "AFTER", "AND", "AT", "AS", "ASC", "AVG", "BEFORE", "BY", "COUNT", "DESC", + "DISTANCE", "DISTANCE_ON_SPHERE", "DIV", "ESCAPE", "FALSE", "FT", "GROUP", + "HAVING", "IN", "IS", "KM", "LIMIT", "LIKE", "MAX", "MI", "MIN", "MOD", + "NOT", "NULL", "OFFSET", "OR", "SELECT", "SORT", "SUM", "TRUE", "YD", + "AsWKB", "AsWKT", "AsGeoJSON", "ID", "INT", "CHAR_STRING", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "BackendlessQuery.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public BackendlessQueryParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + public static class Select_statementContext extends ParserRuleContext { + public Table_nameContext table_name() { + return getRuleContext(Table_nameContext.class,0); + } + public Select_listContext select_list() { + return getRuleContext(Select_listContext.class,0); + } + public ConditionContext condition() { + return getRuleContext(ConditionContext.class,0); + } + public Group_by_clauseContext group_by_clause() { + return getRuleContext(Group_by_clauseContext.class,0); + } + public Having_clauseContext having_clause() { + return getRuleContext(Having_clauseContext.class,0); + } + public Sort_by_clauseContext sort_by_clause() { + return getRuleContext(Sort_by_clauseContext.class,0); + } + public Limit_clauseContext limit_clause() { + return getRuleContext(Limit_clauseContext.class,0); + } + public Select_statementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_select_statement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSelect_statement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSelect_statement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSelect_statement(this); + else return visitor.visitChildren(this); + } + } + + public final Select_statementContext select_statement() throws RecognitionException { + Select_statementContext _localctx = new Select_statementContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_select_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(72); + table_name(); + setState(73); + match(T__0); + setState(75); + _errHandler.sync(this); + _la = _input.LA(1); + if (((((_la - 3)) & ~0x3f) == 0 && ((1L << (_la - 3)) & ((1L << (T__2 - 3)) | (1L << (T__6 - 3)) | (1L << (T__8 - 3)) | (1L << (T__18 - 3)) | (1L << (AFTER - 3)) | (1L << (AND - 3)) | (1L << (AT - 3)) | (1L << (AS - 3)) | (1L << (ASC - 3)) | (1L << (AVG - 3)) | (1L << (BEFORE - 3)) | (1L << (BY - 3)) | (1L << (COUNT - 3)) | (1L << (DESC - 3)) | (1L << (DISTANCE - 3)) | (1L << (DISTANCE_ON_SPHERE - 3)) | (1L << (DIV - 3)) | (1L << (ESCAPE - 3)) | (1L << (FALSE - 3)) | (1L << (FT - 3)) | (1L << (GROUP - 3)) | (1L << (HAVING - 3)) | (1L << (IN - 3)) | (1L << (IS - 3)) | (1L << (KM - 3)) | (1L << (LIMIT - 3)) | (1L << (LIKE - 3)) | (1L << (MAX - 3)) | (1L << (MI - 3)) | (1L << (MIN - 3)) | (1L << (MOD - 3)) | (1L << (NOT - 3)) | (1L << (NULL - 3)) | (1L << (OFFSET - 3)) | (1L << (OR - 3)) | (1L << (SELECT - 3)) | (1L << (SORT - 3)) | (1L << (SUM - 3)) | (1L << (TRUE - 3)) | (1L << (YD - 3)) | (1L << (AsWKB - 3)) | (1L << (AsWKT - 3)) | (1L << (AsGeoJSON - 3)) | (1L << (ID - 3)) | (1L << (INT - 3)) | (1L << (CHAR_STRING - 3)))) != 0)) { + { + setState(74); + condition(0); + } + } + + setState(77); + match(T__1); + setState(78); + match(T__2); + setState(79); + select_list(); + setState(81); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==GROUP) { + { + setState(80); + group_by_clause(); + } + } + + setState(84); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==HAVING) { + { + setState(83); + having_clause(); + } + } + + setState(87); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==SORT) { + { + setState(86); + sort_by_clause(); + } + } + + setState(90); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==LIMIT) { + { + setState(89); + limit_clause(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Select_listContext extends ParserRuleContext { + public List select_list_elem() { + return getRuleContexts(Select_list_elemContext.class); + } + public Select_list_elemContext select_list_elem(int i) { + return getRuleContext(Select_list_elemContext.class,i); + } + public Select_listContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_select_list; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSelect_list(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSelect_list(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSelect_list(this); + else return visitor.visitChildren(this); + } + } + + public final Select_listContext select_list() throws RecognitionException { + Select_listContext _localctx = new Select_listContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_select_list); + int _la; + try { + setState(104); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__3: + enterOuterAlt(_localctx, 1); + { + setState(92); + match(T__3); + setState(93); + select_list_elem(); + setState(98); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(94); + match(T__4); + setState(95); + select_list_elem(); + } + } + setState(100); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(101); + match(T__5); + } + break; + case T__2: + case T__18: + case AFTER: + case AND: + case AT: + case AS: + case ASC: + case AVG: + case BEFORE: + case BY: + case COUNT: + case DESC: + case DISTANCE: + case DISTANCE_ON_SPHERE: + case DIV: + case ESCAPE: + case FALSE: + case FT: + case GROUP: + case HAVING: + case IN: + case IS: + case KM: + case LIMIT: + case LIKE: + case MAX: + case MI: + case MIN: + case MOD: + case NOT: + case NULL: + case OFFSET: + case OR: + case SELECT: + case SORT: + case SUM: + case TRUE: + case YD: + case AsWKB: + case AsWKT: + case AsGeoJSON: + case ID: + case INT: + case CHAR_STRING: + enterOuterAlt(_localctx, 2); + { + setState(103); + select_list_elem(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Select_list_elemContext extends ParserRuleContext { + public Select_list_elemContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_select_list_elem; } + + public Select_list_elemContext() { } + public void copyFrom(Select_list_elemContext ctx) { + super.copyFrom(ctx); + } + } + public static class SimpleSelectElemContext extends Select_list_elemContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public SimpleSelectElemContext(Select_list_elemContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSimpleSelectElem(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSimpleSelectElem(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSimpleSelectElem(this); + else return visitor.visitChildren(this); + } + } + public static class AliasedSelectElemContext extends Select_list_elemContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public TerminalNode AS() { return getToken(BackendlessQueryParser.AS, 0); } + public AliasContext alias() { + return getRuleContext(AliasContext.class,0); + } + public AliasedSelectElemContext(Select_list_elemContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAliasedSelectElem(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAliasedSelectElem(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAliasedSelectElem(this); + else return visitor.visitChildren(this); + } + } + + public final Select_list_elemContext select_list_elem() throws RecognitionException { + Select_list_elemContext _localctx = new Select_list_elemContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_select_list_elem); + try { + setState(111); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) { + case 1: + _localctx = new SimpleSelectElemContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(106); + expression_atom(0); + } + break; + case 2: + _localctx = new AliasedSelectElemContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(107); + expression_atom(0); + setState(108); + match(AS); + setState(109); + alias(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Group_by_clauseContext extends ParserRuleContext { + public TerminalNode GROUP() { return getToken(BackendlessQueryParser.GROUP, 0); } + public TerminalNode BY() { return getToken(BackendlessQueryParser.BY, 0); } + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public Group_by_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_group_by_clause; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterGroup_by_clause(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitGroup_by_clause(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitGroup_by_clause(this); + else return visitor.visitChildren(this); + } + } + + public final Group_by_clauseContext group_by_clause() throws RecognitionException { + Group_by_clauseContext _localctx = new Group_by_clauseContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_group_by_clause); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(113); + match(GROUP); + setState(114); + match(BY); + setState(115); + expression_atom(0); + setState(120); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,8,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(116); + match(T__4); + setState(117); + expression_atom(0); + } + } + } + setState(122); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,8,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Having_clauseContext extends ParserRuleContext { + public TerminalNode HAVING() { return getToken(BackendlessQueryParser.HAVING, 0); } + public ConditionContext condition() { + return getRuleContext(ConditionContext.class,0); + } + public Having_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_having_clause; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterHaving_clause(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitHaving_clause(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitHaving_clause(this); + else return visitor.visitChildren(this); + } + } + + public final Having_clauseContext having_clause() throws RecognitionException { + Having_clauseContext _localctx = new Having_clauseContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_having_clause); + try { + enterOuterAlt(_localctx, 1); + { + setState(123); + match(HAVING); + setState(124); + condition(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Sort_by_clauseContext extends ParserRuleContext { + public TerminalNode SORT() { return getToken(BackendlessQueryParser.SORT, 0); } + public TerminalNode BY() { return getToken(BackendlessQueryParser.BY, 0); } + public List sort_by_elem() { + return getRuleContexts(Sort_by_elemContext.class); + } + public Sort_by_elemContext sort_by_elem(int i) { + return getRuleContext(Sort_by_elemContext.class,i); + } + public Sort_by_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_sort_by_clause; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSort_by_clause(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSort_by_clause(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSort_by_clause(this); + else return visitor.visitChildren(this); + } + } + + public final Sort_by_clauseContext sort_by_clause() throws RecognitionException { + Sort_by_clauseContext _localctx = new Sort_by_clauseContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_sort_by_clause); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(126); + match(SORT); + setState(127); + match(BY); + setState(128); + sort_by_elem(); + setState(133); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,9,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(129); + match(T__4); + setState(130); + sort_by_elem(); + } + } + } + setState(135); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,9,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Sort_by_elemContext extends ParserRuleContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public TerminalNode ASC() { return getToken(BackendlessQueryParser.ASC, 0); } + public TerminalNode DESC() { return getToken(BackendlessQueryParser.DESC, 0); } + public Sort_by_elemContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_sort_by_elem; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSort_by_elem(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSort_by_elem(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSort_by_elem(this); + else return visitor.visitChildren(this); + } + } + + public final Sort_by_elemContext sort_by_elem() throws RecognitionException { + Sort_by_elemContext _localctx = new Sort_by_elemContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_sort_by_elem); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(136); + expression_atom(0); + setState(138); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==ASC || _la==DESC) { + { + setState(137); + _la = _input.LA(1); + if ( !(_la==ASC || _la==DESC) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Limit_clauseContext extends ParserRuleContext { + public TerminalNode LIMIT() { return getToken(BackendlessQueryParser.LIMIT, 0); } + public List INT() { return getTokens(BackendlessQueryParser.INT); } + public TerminalNode INT(int i) { + return getToken(BackendlessQueryParser.INT, i); + } + public TerminalNode OFFSET() { return getToken(BackendlessQueryParser.OFFSET, 0); } + public Limit_clauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_limit_clause; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterLimit_clause(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitLimit_clause(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitLimit_clause(this); + else return visitor.visitChildren(this); + } + } + + public final Limit_clauseContext limit_clause() throws RecognitionException { + Limit_clauseContext _localctx = new Limit_clauseContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_limit_clause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(140); + match(LIMIT); + setState(141); + match(INT); + setState(144); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==OFFSET) { + { + setState(142); + match(OFFSET); + setState(143); + match(INT); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Function_callContext extends ParserRuleContext { + public Aggregate_windowed_functionContext aggregate_windowed_function() { + return getRuleContext(Aggregate_windowed_functionContext.class,0); + } + public Units_functionContext units_function() { + return getRuleContext(Units_functionContext.class,0); + } + public Spatial_convert_functionContext spatial_convert_function() { + return getRuleContext(Spatial_convert_functionContext.class,0); + } + public Spatial_functionContext spatial_function() { + return getRuleContext(Spatial_functionContext.class,0); + } + public Unknown_functionContext unknown_function() { + return getRuleContext(Unknown_functionContext.class,0); + } + public Function_callContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_function_call; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFunction_call(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFunction_call(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFunction_call(this); + else return visitor.visitChildren(this); + } + } + + public final Function_callContext function_call() throws RecognitionException { + Function_callContext _localctx = new Function_callContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_function_call); + try { + setState(151); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,12,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(146); + aggregate_windowed_function(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(147); + units_function(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(148); + spatial_convert_function(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(149); + spatial_function(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(150); + unknown_function(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Spatial_convert_functionContext extends ParserRuleContext { + public Aswkb_functionContext aswkb_function() { + return getRuleContext(Aswkb_functionContext.class,0); + } + public Aswkt_functionContext aswkt_function() { + return getRuleContext(Aswkt_functionContext.class,0); + } + public Asgeojson_functionContext asgeojson_function() { + return getRuleContext(Asgeojson_functionContext.class,0); + } + public Spatial_convert_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_spatial_convert_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSpatial_convert_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSpatial_convert_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSpatial_convert_function(this); + else return visitor.visitChildren(this); + } + } + + public final Spatial_convert_functionContext spatial_convert_function() throws RecognitionException { + Spatial_convert_functionContext _localctx = new Spatial_convert_functionContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_spatial_convert_function); + try { + setState(156); + _errHandler.sync(this); + switch (_input.LA(1)) { + case AsWKB: + enterOuterAlt(_localctx, 1); + { + setState(153); + aswkb_function(); + } + break; + case AsWKT: + enterOuterAlt(_localctx, 2); + { + setState(154); + aswkt_function(); + } + break; + case AsGeoJSON: + enterOuterAlt(_localctx, 3); + { + setState(155); + asgeojson_function(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Spatial_function_parameterContext extends ParserRuleContext { + public Simple_columnContext simple_column() { + return getRuleContext(Simple_columnContext.class,0); + } + public ConstantContext constant() { + return getRuleContext(ConstantContext.class,0); + } + public Spatial_function_parameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_spatial_function_parameter; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSpatial_function_parameter(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSpatial_function_parameter(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSpatial_function_parameter(this); + else return visitor.visitChildren(this); + } + } + + public final Spatial_function_parameterContext spatial_function_parameter() throws RecognitionException { + Spatial_function_parameterContext _localctx = new Spatial_function_parameterContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_spatial_function_parameter); + try { + setState(160); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,14,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(158); + simple_column(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(159); + constant(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Aswkb_functionContext extends ParserRuleContext { + public TerminalNode AsWKB() { return getToken(BackendlessQueryParser.AsWKB, 0); } + public Spatial_function_parameterContext spatial_function_parameter() { + return getRuleContext(Spatial_function_parameterContext.class,0); + } + public Aswkb_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_aswkb_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAswkb_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAswkb_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAswkb_function(this); + else return visitor.visitChildren(this); + } + } + + public final Aswkb_functionContext aswkb_function() throws RecognitionException { + Aswkb_functionContext _localctx = new Aswkb_functionContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_aswkb_function); + try { + enterOuterAlt(_localctx, 1); + { + setState(162); + match(AsWKB); + setState(163); + match(T__6); + setState(164); + spatial_function_parameter(); + setState(165); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Aswkt_functionContext extends ParserRuleContext { + public TerminalNode AsWKT() { return getToken(BackendlessQueryParser.AsWKT, 0); } + public Spatial_function_parameterContext spatial_function_parameter() { + return getRuleContext(Spatial_function_parameterContext.class,0); + } + public Aswkt_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_aswkt_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAswkt_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAswkt_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAswkt_function(this); + else return visitor.visitChildren(this); + } + } + + public final Aswkt_functionContext aswkt_function() throws RecognitionException { + Aswkt_functionContext _localctx = new Aswkt_functionContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_aswkt_function); + try { + enterOuterAlt(_localctx, 1); + { + setState(167); + match(AsWKT); + setState(168); + match(T__6); + setState(169); + spatial_function_parameter(); + setState(170); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Asgeojson_functionContext extends ParserRuleContext { + public TerminalNode AsGeoJSON() { return getToken(BackendlessQueryParser.AsGeoJSON, 0); } + public Spatial_function_parameterContext spatial_function_parameter() { + return getRuleContext(Spatial_function_parameterContext.class,0); + } + public Asgeojson_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_asgeojson_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAsgeojson_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAsgeojson_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAsgeojson_function(this); + else return visitor.visitChildren(this); + } + } + + public final Asgeojson_functionContext asgeojson_function() throws RecognitionException { + Asgeojson_functionContext _localctx = new Asgeojson_functionContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_asgeojson_function); + try { + enterOuterAlt(_localctx, 1); + { + setState(172); + match(AsGeoJSON); + setState(173); + match(T__6); + setState(174); + spatial_function_parameter(); + setState(175); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Spatial_functionContext extends ParserRuleContext { + public Distance_functionContext distance_function() { + return getRuleContext(Distance_functionContext.class,0); + } + public Distance_on_sphereContext distance_on_sphere() { + return getRuleContext(Distance_on_sphereContext.class,0); + } + public Spatial_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_spatial_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSpatial_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSpatial_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSpatial_function(this); + else return visitor.visitChildren(this); + } + } + + public final Spatial_functionContext spatial_function() throws RecognitionException { + Spatial_functionContext _localctx = new Spatial_functionContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_spatial_function); + try { + setState(179); + _errHandler.sync(this); + switch (_input.LA(1)) { + case DISTANCE: + enterOuterAlt(_localctx, 1); + { + setState(177); + distance_function(); + } + break; + case DISTANCE_ON_SPHERE: + enterOuterAlt(_localctx, 2); + { + setState(178); + distance_on_sphere(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Distance_functionContext extends ParserRuleContext { + public TerminalNode DISTANCE() { return getToken(BackendlessQueryParser.DISTANCE, 0); } + public List spatial_function_parameter() { + return getRuleContexts(Spatial_function_parameterContext.class); + } + public Spatial_function_parameterContext spatial_function_parameter(int i) { + return getRuleContext(Spatial_function_parameterContext.class,i); + } + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public Distance_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_distance_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterDistance_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitDistance_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitDistance_function(this); + else return visitor.visitChildren(this); + } + } + + public final Distance_functionContext distance_function() throws RecognitionException { + Distance_functionContext _localctx = new Distance_functionContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_distance_function); + try { + setState(199); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,16,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(181); + match(DISTANCE); + setState(182); + match(T__6); + setState(183); + spatial_function_parameter(); + setState(184); + match(T__4); + setState(185); + spatial_function_parameter(); + setState(186); + match(T__7); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(188); + match(DISTANCE); + setState(189); + match(T__6); + setState(190); + expression_atom(0); + setState(191); + match(T__4); + setState(192); + expression_atom(0); + setState(193); + match(T__4); + setState(194); + expression_atom(0); + setState(195); + match(T__4); + setState(196); + expression_atom(0); + setState(197); + match(T__7); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Distance_on_sphereContext extends ParserRuleContext { + public TerminalNode DISTANCE_ON_SPHERE() { return getToken(BackendlessQueryParser.DISTANCE_ON_SPHERE, 0); } + public List spatial_function_parameter() { + return getRuleContexts(Spatial_function_parameterContext.class); + } + public Spatial_function_parameterContext spatial_function_parameter(int i) { + return getRuleContext(Spatial_function_parameterContext.class,i); + } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public Distance_on_sphereContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_distance_on_sphere; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterDistance_on_sphere(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitDistance_on_sphere(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitDistance_on_sphere(this); + else return visitor.visitChildren(this); + } + } + + public final Distance_on_sphereContext distance_on_sphere() throws RecognitionException { + Distance_on_sphereContext _localctx = new Distance_on_sphereContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_distance_on_sphere); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(201); + match(DISTANCE_ON_SPHERE); + setState(202); + match(T__6); + setState(203); + spatial_function_parameter(); + setState(204); + match(T__4); + setState(205); + spatial_function_parameter(); + setState(208); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__4) { + { + setState(206); + match(T__4); + setState(207); + expression_atom(0); + } + } + + setState(210); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Units_functionContext extends ParserRuleContext { + public Units_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_units_function; } + + public Units_functionContext() { } + public void copyFrom(Units_functionContext ctx) { + super.copyFrom(ctx); + } + } + public static class KmUnitsFunctionContext extends Units_functionContext { + public TerminalNode KM() { return getToken(BackendlessQueryParser.KM, 0); } + public Numeric_literalContext numeric_literal() { + return getRuleContext(Numeric_literalContext.class,0); + } + public KmUnitsFunctionContext(Units_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterKmUnitsFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitKmUnitsFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitKmUnitsFunction(this); + else return visitor.visitChildren(this); + } + } + public static class YdUnitsFunctionContext extends Units_functionContext { + public TerminalNode YD() { return getToken(BackendlessQueryParser.YD, 0); } + public Numeric_literalContext numeric_literal() { + return getRuleContext(Numeric_literalContext.class,0); + } + public YdUnitsFunctionContext(Units_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterYdUnitsFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitYdUnitsFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitYdUnitsFunction(this); + else return visitor.visitChildren(this); + } + } + public static class FtUnitsFunctionContext extends Units_functionContext { + public TerminalNode FT() { return getToken(BackendlessQueryParser.FT, 0); } + public Numeric_literalContext numeric_literal() { + return getRuleContext(Numeric_literalContext.class,0); + } + public FtUnitsFunctionContext(Units_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFtUnitsFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFtUnitsFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFtUnitsFunction(this); + else return visitor.visitChildren(this); + } + } + public static class MiUnitsFunctionContext extends Units_functionContext { + public TerminalNode MI() { return getToken(BackendlessQueryParser.MI, 0); } + public Numeric_literalContext numeric_literal() { + return getRuleContext(Numeric_literalContext.class,0); + } + public MiUnitsFunctionContext(Units_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterMiUnitsFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitMiUnitsFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitMiUnitsFunction(this); + else return visitor.visitChildren(this); + } + } + + public final Units_functionContext units_function() throws RecognitionException { + Units_functionContext _localctx = new Units_functionContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_units_function); + try { + setState(232); + _errHandler.sync(this); + switch (_input.LA(1)) { + case FT: + _localctx = new FtUnitsFunctionContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(212); + match(FT); + setState(213); + match(T__6); + setState(214); + numeric_literal(); + setState(215); + match(T__7); + } + break; + case KM: + _localctx = new KmUnitsFunctionContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(217); + match(KM); + setState(218); + match(T__6); + setState(219); + numeric_literal(); + setState(220); + match(T__7); + } + break; + case MI: + _localctx = new MiUnitsFunctionContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(222); + match(MI); + setState(223); + match(T__6); + setState(224); + numeric_literal(); + setState(225); + match(T__7); + } + break; + case YD: + _localctx = new YdUnitsFunctionContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(227); + match(YD); + setState(228); + match(T__6); + setState(229); + numeric_literal(); + setState(230); + match(T__7); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Aggregate_windowed_functionContext extends ParserRuleContext { + public Aggregate_windowed_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_aggregate_windowed_function; } + + public Aggregate_windowed_functionContext() { } + public void copyFrom(Aggregate_windowed_functionContext ctx) { + super.copyFrom(ctx); + } + } + public static class CountFunctionContext extends Aggregate_windowed_functionContext { + public TerminalNode COUNT() { return getToken(BackendlessQueryParser.COUNT, 0); } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public CountFunctionContext(Aggregate_windowed_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterCountFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitCountFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitCountFunction(this); + else return visitor.visitChildren(this); + } + } + public static class SumFunctionContext extends Aggregate_windowed_functionContext { + public TerminalNode SUM() { return getToken(BackendlessQueryParser.SUM, 0); } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public SumFunctionContext(Aggregate_windowed_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSumFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSumFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSumFunction(this); + else return visitor.visitChildren(this); + } + } + public static class MinFunctionContext extends Aggregate_windowed_functionContext { + public TerminalNode MIN() { return getToken(BackendlessQueryParser.MIN, 0); } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public MinFunctionContext(Aggregate_windowed_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterMinFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitMinFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitMinFunction(this); + else return visitor.visitChildren(this); + } + } + public static class MaxFunctionContext extends Aggregate_windowed_functionContext { + public TerminalNode MAX() { return getToken(BackendlessQueryParser.MAX, 0); } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public MaxFunctionContext(Aggregate_windowed_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterMaxFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitMaxFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitMaxFunction(this); + else return visitor.visitChildren(this); + } + } + public static class AvgFunctionContext extends Aggregate_windowed_functionContext { + public TerminalNode AVG() { return getToken(BackendlessQueryParser.AVG, 0); } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public AvgFunctionContext(Aggregate_windowed_functionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAvgFunction(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAvgFunction(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAvgFunction(this); + else return visitor.visitChildren(this); + } + } + + public final Aggregate_windowed_functionContext aggregate_windowed_function() throws RecognitionException { + Aggregate_windowed_functionContext _localctx = new Aggregate_windowed_functionContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_aggregate_windowed_function); + try { + setState(259); + _errHandler.sync(this); + switch (_input.LA(1)) { + case AVG: + _localctx = new AvgFunctionContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(234); + match(AVG); + setState(235); + match(T__6); + setState(236); + expression_atom(0); + setState(237); + match(T__7); + } + break; + case MAX: + _localctx = new MaxFunctionContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(239); + match(MAX); + setState(240); + match(T__6); + setState(241); + expression_atom(0); + setState(242); + match(T__7); + } + break; + case MIN: + _localctx = new MinFunctionContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(244); + match(MIN); + setState(245); + match(T__6); + setState(246); + expression_atom(0); + setState(247); + match(T__7); + } + break; + case SUM: + _localctx = new SumFunctionContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(249); + match(SUM); + setState(250); + match(T__6); + setState(251); + expression_atom(0); + setState(252); + match(T__7); + } + break; + case COUNT: + _localctx = new CountFunctionContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(254); + match(COUNT); + setState(255); + match(T__6); + setState(256); + expression_atom(0); + setState(257); + match(T__7); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ConditionContext extends ParserRuleContext { + public ConditionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_condition; } + + public ConditionContext() { } + public void copyFrom(ConditionContext ctx) { + super.copyFrom(ctx); + } + } + public static class InConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode IN() { return getToken(BackendlessQueryParser.IN, 0); } + public List select_statement() { + return getRuleContexts(Select_statementContext.class); + } + public Select_statementContext select_statement(int i) { + return getRuleContext(Select_statementContext.class,i); + } + public TerminalNode NOT() { return getToken(BackendlessQueryParser.NOT, 0); } + public InConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterInCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitInCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitInCondition(this); + else return visitor.visitChildren(this); + } + } + public static class EqualConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode AT() { return getToken(BackendlessQueryParser.AT, 0); } + public EqualConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterEqualCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitEqualCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitEqualCondition(this); + else return visitor.visitChildren(this); + } + } + public static class OrConditionContext extends ConditionContext { + public List condition() { + return getRuleContexts(ConditionContext.class); + } + public ConditionContext condition(int i) { + return getRuleContext(ConditionContext.class,i); + } + public TerminalNode OR() { return getToken(BackendlessQueryParser.OR, 0); } + public OrConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterOrCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitOrCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitOrCondition(this); + else return visitor.visitChildren(this); + } + } + public static class LessThanConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode BEFORE() { return getToken(BackendlessQueryParser.BEFORE, 0); } + public LessThanConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterLessThanCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitLessThanCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitLessThanCondition(this); + else return visitor.visitChildren(this); + } + } + public static class AndConditionContext extends ConditionContext { + public List condition() { + return getRuleContexts(ConditionContext.class); + } + public ConditionContext condition(int i) { + return getRuleContext(ConditionContext.class,i); + } + public TerminalNode AND() { return getToken(BackendlessQueryParser.AND, 0); } + public AndConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAndCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAndCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAndCondition(this); + else return visitor.visitChildren(this); + } + } + public static class IsNullConditionContext extends ConditionContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public TerminalNode IS() { return getToken(BackendlessQueryParser.IS, 0); } + public TerminalNode NULL() { return getToken(BackendlessQueryParser.NULL, 0); } + public IsNullConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterIsNullCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitIsNullCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitIsNullCondition(this); + else return visitor.visitChildren(this); + } + } + public static class NotConditionContext extends ConditionContext { + public ConditionContext condition() { + return getRuleContext(ConditionContext.class,0); + } + public TerminalNode NOT() { return getToken(BackendlessQueryParser.NOT, 0); } + public NotConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterNotCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitNotCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitNotCondition(this); + else return visitor.visitChildren(this); + } + } + public static class LikeConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode LIKE() { return getToken(BackendlessQueryParser.LIKE, 0); } + public TerminalNode NOT() { return getToken(BackendlessQueryParser.NOT, 0); } + public LikeConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterLikeCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitLikeCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitLikeCondition(this); + else return visitor.visitChildren(this); + } + } + public static class IsNotNullConditionContext extends ConditionContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public TerminalNode IS() { return getToken(BackendlessQueryParser.IS, 0); } + public TerminalNode NOT() { return getToken(BackendlessQueryParser.NOT, 0); } + public TerminalNode NULL() { return getToken(BackendlessQueryParser.NULL, 0); } + public IsNotNullConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterIsNotNullCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitIsNotNullCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitIsNotNullCondition(this); + else return visitor.visitChildren(this); + } + } + public static class NestedConditionContext extends ConditionContext { + public ConditionContext condition() { + return getRuleContext(ConditionContext.class,0); + } + public NestedConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterNestedCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitNestedCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitNestedCondition(this); + else return visitor.visitChildren(this); + } + } + public static class NotEqualConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public NotEqualConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterNotEqualCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitNotEqualCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitNotEqualCondition(this); + else return visitor.visitChildren(this); + } + } + public static class GreaterThanConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode AFTER() { return getToken(BackendlessQueryParser.AFTER, 0); } + public GreaterThanConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterGreaterThanCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitGreaterThanCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitGreaterThanCondition(this); + else return visitor.visitChildren(this); + } + } + public static class GreaterThanOrEqualConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode AT() { return getToken(BackendlessQueryParser.AT, 0); } + public TerminalNode OR() { return getToken(BackendlessQueryParser.OR, 0); } + public TerminalNode AFTER() { return getToken(BackendlessQueryParser.AFTER, 0); } + public GreaterThanOrEqualConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterGreaterThanOrEqualCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitGreaterThanOrEqualCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitGreaterThanOrEqualCondition(this); + else return visitor.visitChildren(this); + } + } + public static class LessThanOrEqualConditionContext extends ConditionContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public TerminalNode AT() { return getToken(BackendlessQueryParser.AT, 0); } + public TerminalNode OR() { return getToken(BackendlessQueryParser.OR, 0); } + public TerminalNode BEFORE() { return getToken(BackendlessQueryParser.BEFORE, 0); } + public LessThanOrEqualConditionContext(ConditionContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterLessThanOrEqualCondition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitLessThanOrEqualCondition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitLessThanOrEqualCondition(this); + else return visitor.visitChildren(this); + } + } + + public final ConditionContext condition() throws RecognitionException { + return condition(0); + } + + private ConditionContext condition(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ConditionContext _localctx = new ConditionContext(_ctx, _parentState); + ConditionContext _prevctx = _localctx; + int _startState = 38; + enterRecursionRule(_localctx, 38, RULE_condition, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(340); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,27,_ctx) ) { + case 1: + { + _localctx = new NotConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(262); + _la = _input.LA(1); + if ( !(_la==T__8 || _la==NOT) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(263); + condition(14); + } + break; + case 2: + { + _localctx = new NestedConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(264); + match(T__6); + setState(265); + condition(0); + setState(266); + match(T__7); + } + break; + case 3: + { + _localctx = new InConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(268); + expression_atom(0); + setState(270); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==NOT) { + { + setState(269); + match(NOT); + } + } + + setState(272); + match(IN); + setState(273); + match(T__6); + setState(276); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,21,_ctx) ) { + case 1: + { + setState(274); + select_statement(); + } + break; + case 2: + { + setState(275); + expression_atom(0); + } + break; + } + setState(285); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(278); + match(T__4); + setState(281); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,22,_ctx) ) { + case 1: + { + setState(279); + select_statement(); + } + break; + case 2: + { + setState(280); + expression_atom(0); + } + break; + } + } + } + setState(287); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(288); + match(T__7); + } + break; + case 4: + { + _localctx = new IsNullConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(290); + expression_atom(0); + setState(291); + match(IS); + setState(292); + match(NULL); + } + break; + case 5: + { + _localctx = new IsNotNullConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(294); + expression_atom(0); + setState(295); + match(IS); + setState(296); + match(NOT); + setState(297); + match(NULL); + } + break; + case 6: + { + _localctx = new LikeConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(299); + expression_atom(0); + setState(301); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==NOT) { + { + setState(300); + match(NOT); + } + } + + setState(303); + match(LIKE); + setState(304); + expression_atom(0); + } + break; + case 7: + { + _localctx = new EqualConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(306); + expression_atom(0); + setState(307); + _la = _input.LA(1); + if ( !(_la==T__11 || _la==AT) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(308); + expression_atom(0); + } + break; + case 8: + { + _localctx = new NotEqualConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(310); + expression_atom(0); + setState(311); + _la = _input.LA(1); + if ( !(_la==T__12 || _la==T__13) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(312); + expression_atom(0); + } + break; + case 9: + { + _localctx = new GreaterThanOrEqualConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(314); + expression_atom(0); + setState(319); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__14: + { + setState(315); + match(T__14); + } + break; + case AT: + { + setState(316); + match(AT); + setState(317); + match(OR); + setState(318); + match(AFTER); + } + break; + default: + throw new NoViableAltException(this); + } + setState(321); + expression_atom(0); + } + break; + case 10: + { + _localctx = new GreaterThanConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(323); + expression_atom(0); + setState(324); + _la = _input.LA(1); + if ( !(_la==T__15 || _la==AFTER) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(325); + expression_atom(0); + } + break; + case 11: + { + _localctx = new LessThanOrEqualConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(327); + expression_atom(0); + setState(332); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__16: + { + setState(328); + match(T__16); + } + break; + case AT: + { + setState(329); + match(AT); + setState(330); + match(OR); + setState(331); + match(BEFORE); + } + break; + default: + throw new NoViableAltException(this); + } + setState(334); + expression_atom(0); + } + break; + case 12: + { + _localctx = new LessThanConditionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(336); + expression_atom(0); + setState(337); + _la = _input.LA(1); + if ( !(_la==T__17 || _la==BEFORE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(338); + expression_atom(0); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(350); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,29,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(348); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) { + case 1: + { + _localctx = new AndConditionContext(new ConditionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_condition); + setState(342); + if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); + setState(343); + _la = _input.LA(1); + if ( !(_la==T__9 || _la==AND) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(344); + condition(14); + } + break; + case 2: + { + _localctx = new OrConditionContext(new ConditionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_condition); + setState(345); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(346); + _la = _input.LA(1); + if ( !(_la==T__10 || _la==OR) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(347); + condition(13); + } + break; + } + } + } + setState(352); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,29,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class Expression_atomContext extends ParserRuleContext { + public Expression_atomContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression_atom; } + + public Expression_atomContext() { } + public void copyFrom(Expression_atomContext ctx) { + super.copyFrom(ctx); + } + } + public static class DivisionExpressionAtomContext extends Expression_atomContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public DivisionExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterDivisionExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitDivisionExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitDivisionExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class ModuloExpressionAtomContext extends Expression_atomContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public ModuloExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterModuloExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitModuloExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitModuloExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class ConstantExpressionAtomContext extends Expression_atomContext { + public ConstantContext constant() { + return getRuleContext(ConstantContext.class,0); + } + public ConstantExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterConstantExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitConstantExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitConstantExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class FunctionCallExpressionAtomContext extends Expression_atomContext { + public Function_callContext function_call() { + return getRuleContext(Function_callContext.class,0); + } + public FunctionCallExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFunctionCallExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFunctionCallExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFunctionCallExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class SubtractionExpressionAtomContext extends Expression_atomContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public SubtractionExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSubtractionExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSubtractionExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSubtractionExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class FullColumnNameExpressionAtomContext extends Expression_atomContext { + public Full_column_nameContext full_column_name() { + return getRuleContext(Full_column_nameContext.class,0); + } + public FullColumnNameExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFullColumnNameExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFullColumnNameExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFullColumnNameExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class MultiplicationExpressionAtomContext extends Expression_atomContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public MultiplicationExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterMultiplicationExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitMultiplicationExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitMultiplicationExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class UnaryMinusExpressionAtomContext extends Expression_atomContext { + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public UnaryMinusExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterUnaryMinusExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitUnaryMinusExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitUnaryMinusExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + public static class AdditionExpressionAtomContext extends Expression_atomContext { + public List expression_atom() { + return getRuleContexts(Expression_atomContext.class); + } + public Expression_atomContext expression_atom(int i) { + return getRuleContext(Expression_atomContext.class,i); + } + public AdditionExpressionAtomContext(Expression_atomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAdditionExpressionAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAdditionExpressionAtom(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAdditionExpressionAtom(this); + else return visitor.visitChildren(this); + } + } + + public final Expression_atomContext expression_atom() throws RecognitionException { + return expression_atom(0); + } + + private Expression_atomContext expression_atom(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + Expression_atomContext _localctx = new Expression_atomContext(_ctx, _parentState); + Expression_atomContext _prevctx = _localctx; + int _startState = 40; + enterRecursionRule(_localctx, 40, RULE_expression_atom, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(359); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,30,_ctx) ) { + case 1: + { + _localctx = new ConstantExpressionAtomContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(354); + constant(); + } + break; + case 2: + { + _localctx = new FullColumnNameExpressionAtomContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(355); + full_column_name(); + } + break; + case 3: + { + _localctx = new FunctionCallExpressionAtomContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(356); + function_call(); + } + break; + case 4: + { + _localctx = new UnaryMinusExpressionAtomContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(357); + match(T__18); + setState(358); + expression_atom(6); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(378); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,32,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(376); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,31,_ctx) ) { + case 1: + { + _localctx = new MultiplicationExpressionAtomContext(new Expression_atomContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression_atom); + setState(361); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(362); + match(T__19); + setState(363); + expression_atom(6); + } + break; + case 2: + { + _localctx = new DivisionExpressionAtomContext(new Expression_atomContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression_atom); + setState(364); + if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); + setState(365); + match(T__20); + setState(366); + expression_atom(5); + } + break; + case 3: + { + _localctx = new ModuloExpressionAtomContext(new Expression_atomContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression_atom); + setState(367); + if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)"); + setState(368); + match(T__21); + setState(369); + expression_atom(4); + } + break; + case 4: + { + _localctx = new AdditionExpressionAtomContext(new Expression_atomContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression_atom); + setState(370); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(371); + match(T__22); + setState(372); + expression_atom(3); + } + break; + case 5: + { + _localctx = new SubtractionExpressionAtomContext(new Expression_atomContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression_atom); + setState(373); + if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); + setState(374); + match(T__18); + setState(375); + expression_atom(2); + } + break; + } + } + } + setState(380); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,32,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class Full_column_nameContext extends ParserRuleContext { + public Single_column_nameContext single_column_name() { + return getRuleContext(Single_column_nameContext.class,0); + } + public Relation_columnContext relation_column() { + return getRuleContext(Relation_columnContext.class,0); + } + public Full_column_nameContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_full_column_name; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFull_column_name(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFull_column_name(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFull_column_name(this); + else return visitor.visitChildren(this); + } + } + + public final Full_column_nameContext full_column_name() throws RecognitionException { + Full_column_nameContext _localctx = new Full_column_nameContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_full_column_name); + try { + setState(383); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,33,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(381); + single_column_name(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(382); + relation_column(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Single_column_nameContext extends ParserRuleContext { + public Simple_columnContext simple_column() { + return getRuleContext(Simple_columnContext.class,0); + } + public Inverse_relation_columnContext inverse_relation_column() { + return getRuleContext(Inverse_relation_columnContext.class,0); + } + public Single_column_nameContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_single_column_name; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSingle_column_name(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSingle_column_name(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSingle_column_name(this); + else return visitor.visitChildren(this); + } + } + + public final Single_column_nameContext single_column_name() throws RecognitionException { + Single_column_nameContext _localctx = new Single_column_nameContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_single_column_name); + try { + setState(387); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,34,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(385); + simple_column(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(386); + inverse_relation_column(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Relation_columnContext extends ParserRuleContext { + public List single_column_name() { + return getRuleContexts(Single_column_nameContext.class); + } + public Single_column_nameContext single_column_name(int i) { + return getRuleContext(Single_column_nameContext.class,i); + } + public Relation_columnContext relation_column() { + return getRuleContext(Relation_columnContext.class,0); + } + public Relation_columnContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_relation_column; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterRelation_column(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitRelation_column(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitRelation_column(this); + else return visitor.visitChildren(this); + } + } + + public final Relation_columnContext relation_column() throws RecognitionException { + Relation_columnContext _localctx = new Relation_columnContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_relation_column); + try { + enterOuterAlt(_localctx, 1); + { + setState(389); + single_column_name(); + setState(390); + match(T__2); + setState(393); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,35,_ctx) ) { + case 1: + { + setState(391); + relation_column(); + } + break; + case 2: + { + setState(392); + single_column_name(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Inverse_relation_columnContext extends ParserRuleContext { + public Table_nameContext table_name() { + return getRuleContext(Table_nameContext.class,0); + } + public List full_column_name() { + return getRuleContexts(Full_column_nameContext.class); + } + public Full_column_nameContext full_column_name(int i) { + return getRuleContext(Full_column_nameContext.class,i); + } + public Inverse_relation_columnContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_inverse_relation_column; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterInverse_relation_column(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitInverse_relation_column(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitInverse_relation_column(this); + else return visitor.visitChildren(this); + } + } + + public final Inverse_relation_columnContext inverse_relation_column() throws RecognitionException { + Inverse_relation_columnContext _localctx = new Inverse_relation_columnContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_inverse_relation_column); + try { + enterOuterAlt(_localctx, 1); + { + setState(395); + table_name(); + setState(396); + match(T__0); + setState(397); + full_column_name(); + setState(398); + match(T__1); + setState(399); + match(T__2); + setState(400); + full_column_name(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Unknown_functionContext extends ParserRuleContext { + public Unknown_nameContext unknown_name() { + return getRuleContext(Unknown_nameContext.class,0); + } + public Expression_atomContext expression_atom() { + return getRuleContext(Expression_atomContext.class,0); + } + public Unknown_functionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_unknown_function; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterUnknown_function(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitUnknown_function(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitUnknown_function(this); + else return visitor.visitChildren(this); + } + } + + public final Unknown_functionContext unknown_function() throws RecognitionException { + Unknown_functionContext _localctx = new Unknown_functionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_unknown_function); + try { + enterOuterAlt(_localctx, 1); + { + setState(402); + unknown_name(); + setState(403); + match(T__6); + setState(404); + expression_atom(0); + setState(405); + match(T__7); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class AliasContext extends ParserRuleContext { + public Regular_idContext regular_id() { + return getRuleContext(Regular_idContext.class,0); + } + public AliasContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_alias; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterAlias(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitAlias(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitAlias(this); + else return visitor.visitChildren(this); + } + } + + public final AliasContext alias() throws RecognitionException { + AliasContext _localctx = new AliasContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_alias); + try { + enterOuterAlt(_localctx, 1); + { + setState(407); + regular_id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Table_nameContext extends ParserRuleContext { + public Regular_idContext regular_id() { + return getRuleContext(Regular_idContext.class,0); + } + public Table_nameContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_table_name; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterTable_name(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitTable_name(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitTable_name(this); + else return visitor.visitChildren(this); + } + } + + public final Table_nameContext table_name() throws RecognitionException { + Table_nameContext _localctx = new Table_nameContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_table_name); + try { + enterOuterAlt(_localctx, 1); + { + setState(409); + regular_id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Simple_columnContext extends ParserRuleContext { + public Regular_idContext regular_id() { + return getRuleContext(Regular_idContext.class,0); + } + public Simple_columnContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_simple_column; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterSimple_column(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitSimple_column(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitSimple_column(this); + else return visitor.visitChildren(this); + } + } + + public final Simple_columnContext simple_column() throws RecognitionException { + Simple_columnContext _localctx = new Simple_columnContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_simple_column); + try { + enterOuterAlt(_localctx, 1); + { + setState(411); + regular_id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Unknown_nameContext extends ParserRuleContext { + public Regular_idContext regular_id() { + return getRuleContext(Regular_idContext.class,0); + } + public Unknown_nameContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_unknown_name; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterUnknown_name(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitUnknown_name(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitUnknown_name(this); + else return visitor.visitChildren(this); + } + } + + public final Unknown_nameContext unknown_name() throws RecognitionException { + Unknown_nameContext _localctx = new Unknown_nameContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_unknown_name); + try { + enterOuterAlt(_localctx, 1); + { + setState(413); + regular_id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ConstantContext extends ParserRuleContext { + public ConstantContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_constant; } + + public ConstantContext() { } + public void copyFrom(ConstantContext ctx) { + super.copyFrom(ctx); + } + } + public static class NumericConstantContext extends ConstantContext { + public Numeric_literalContext numeric_literal() { + return getRuleContext(Numeric_literalContext.class,0); + } + public NumericConstantContext(ConstantContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterNumericConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitNumericConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitNumericConstant(this); + else return visitor.visitChildren(this); + } + } + public static class StringConstantContext extends ConstantContext { + public String_literalContext string_literal() { + return getRuleContext(String_literalContext.class,0); + } + public StringConstantContext(ConstantContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterStringConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitStringConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitStringConstant(this); + else return visitor.visitChildren(this); + } + } + public static class NullConstantContext extends ConstantContext { + public TerminalNode NULL() { return getToken(BackendlessQueryParser.NULL, 0); } + public NullConstantContext(ConstantContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterNullConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitNullConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitNullConstant(this); + else return visitor.visitChildren(this); + } + } + public static class BooleanConstantContext extends ConstantContext { + public Boolean_literalContext boolean_literal() { + return getRuleContext(Boolean_literalContext.class,0); + } + public BooleanConstantContext(ConstantContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterBooleanConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitBooleanConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitBooleanConstant(this); + else return visitor.visitChildren(this); + } + } + + public final ConstantContext constant() throws RecognitionException { + ConstantContext _localctx = new ConstantContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_constant); + try { + setState(419); + _errHandler.sync(this); + switch (_input.LA(1)) { + case CHAR_STRING: + _localctx = new StringConstantContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(415); + string_literal(); + } + break; + case T__2: + case INT: + _localctx = new NumericConstantContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(416); + numeric_literal(); + } + break; + case FALSE: + case TRUE: + _localctx = new BooleanConstantContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(417); + boolean_literal(); + } + break; + case NULL: + _localctx = new NullConstantContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(418); + match(NULL); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Boolean_literalContext extends ParserRuleContext { + public Boolean_literalContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_boolean_literal; } + + public Boolean_literalContext() { } + public void copyFrom(Boolean_literalContext ctx) { + super.copyFrom(ctx); + } + } + public static class TrueBooleanConstantContext extends Boolean_literalContext { + public TerminalNode TRUE() { return getToken(BackendlessQueryParser.TRUE, 0); } + public TrueBooleanConstantContext(Boolean_literalContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterTrueBooleanConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitTrueBooleanConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitTrueBooleanConstant(this); + else return visitor.visitChildren(this); + } + } + public static class FalseBooleanConstantContext extends Boolean_literalContext { + public TerminalNode FALSE() { return getToken(BackendlessQueryParser.FALSE, 0); } + public FalseBooleanConstantContext(Boolean_literalContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFalseBooleanConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFalseBooleanConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFalseBooleanConstant(this); + else return visitor.visitChildren(this); + } + } + + public final Boolean_literalContext boolean_literal() throws RecognitionException { + Boolean_literalContext _localctx = new Boolean_literalContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_boolean_literal); + try { + setState(423); + _errHandler.sync(this); + switch (_input.LA(1)) { + case TRUE: + _localctx = new TrueBooleanConstantContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(421); + match(TRUE); + } + break; + case FALSE: + _localctx = new FalseBooleanConstantContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(422); + match(FALSE); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Numeric_literalContext extends ParserRuleContext { + public Numeric_literalContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_numeric_literal; } + + public Numeric_literalContext() { } + public void copyFrom(Numeric_literalContext ctx) { + super.copyFrom(ctx); + } + } + public static class DecimalNumericConstantContext extends Numeric_literalContext { + public TerminalNode INT() { return getToken(BackendlessQueryParser.INT, 0); } + public DecimalNumericConstantContext(Numeric_literalContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterDecimalNumericConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitDecimalNumericConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitDecimalNumericConstant(this); + else return visitor.visitChildren(this); + } + } + public static class FloatNumericConstantContext extends Numeric_literalContext { + public List INT() { return getTokens(BackendlessQueryParser.INT); } + public TerminalNode INT(int i) { + return getToken(BackendlessQueryParser.INT, i); + } + public FloatNumericConstantContext(Numeric_literalContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterFloatNumericConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitFloatNumericConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitFloatNumericConstant(this); + else return visitor.visitChildren(this); + } + } + + public final Numeric_literalContext numeric_literal() throws RecognitionException { + Numeric_literalContext _localctx = new Numeric_literalContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_numeric_literal); + int _la; + try { + setState(431); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,39,_ctx) ) { + case 1: + _localctx = new DecimalNumericConstantContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(425); + match(INT); + } + break; + case 2: + _localctx = new FloatNumericConstantContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(427); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==INT) { + { + setState(426); + match(INT); + } + } + + setState(429); + match(T__2); + setState(430); + match(INT); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class String_literalContext extends ParserRuleContext { + public TerminalNode CHAR_STRING() { return getToken(BackendlessQueryParser.CHAR_STRING, 0); } + public String_literalContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_string_literal; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterString_literal(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitString_literal(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitString_literal(this); + else return visitor.visitChildren(this); + } + } + + public final String_literalContext string_literal() throws RecognitionException { + String_literalContext _localctx = new String_literalContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_string_literal); + try { + enterOuterAlt(_localctx, 1); + { + setState(433); + match(CHAR_STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Regular_idContext extends ParserRuleContext { + public TerminalNode ID() { return getToken(BackendlessQueryParser.ID, 0); } + public Keyword_as_idContext keyword_as_id() { + return getRuleContext(Keyword_as_idContext.class,0); + } + public Regular_idContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_regular_id; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterRegular_id(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitRegular_id(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitRegular_id(this); + else return visitor.visitChildren(this); + } + } + + public final Regular_idContext regular_id() throws RecognitionException { + Regular_idContext _localctx = new Regular_idContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_regular_id); + try { + setState(437); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ID: + enterOuterAlt(_localctx, 1); + { + setState(435); + match(ID); + } + break; + case AFTER: + case AND: + case AT: + case AS: + case ASC: + case AVG: + case BEFORE: + case BY: + case COUNT: + case DESC: + case DISTANCE: + case DISTANCE_ON_SPHERE: + case DIV: + case ESCAPE: + case FALSE: + case FT: + case GROUP: + case HAVING: + case IN: + case IS: + case KM: + case LIMIT: + case LIKE: + case MAX: + case MI: + case MIN: + case MOD: + case NOT: + case NULL: + case OFFSET: + case OR: + case SELECT: + case SORT: + case SUM: + case TRUE: + case YD: + enterOuterAlt(_localctx, 2); + { + setState(436); + keyword_as_id(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Keyword_as_idContext extends ParserRuleContext { + public TerminalNode AFTER() { return getToken(BackendlessQueryParser.AFTER, 0); } + public TerminalNode AND() { return getToken(BackendlessQueryParser.AND, 0); } + public TerminalNode AT() { return getToken(BackendlessQueryParser.AT, 0); } + public TerminalNode AS() { return getToken(BackendlessQueryParser.AS, 0); } + public TerminalNode ASC() { return getToken(BackendlessQueryParser.ASC, 0); } + public TerminalNode AVG() { return getToken(BackendlessQueryParser.AVG, 0); } + public TerminalNode BEFORE() { return getToken(BackendlessQueryParser.BEFORE, 0); } + public TerminalNode BY() { return getToken(BackendlessQueryParser.BY, 0); } + public TerminalNode COUNT() { return getToken(BackendlessQueryParser.COUNT, 0); } + public TerminalNode DESC() { return getToken(BackendlessQueryParser.DESC, 0); } + public TerminalNode DISTANCE() { return getToken(BackendlessQueryParser.DISTANCE, 0); } + public TerminalNode DISTANCE_ON_SPHERE() { return getToken(BackendlessQueryParser.DISTANCE_ON_SPHERE, 0); } + public TerminalNode DIV() { return getToken(BackendlessQueryParser.DIV, 0); } + public TerminalNode ESCAPE() { return getToken(BackendlessQueryParser.ESCAPE, 0); } + public TerminalNode FALSE() { return getToken(BackendlessQueryParser.FALSE, 0); } + public TerminalNode FT() { return getToken(BackendlessQueryParser.FT, 0); } + public TerminalNode GROUP() { return getToken(BackendlessQueryParser.GROUP, 0); } + public TerminalNode HAVING() { return getToken(BackendlessQueryParser.HAVING, 0); } + public TerminalNode IN() { return getToken(BackendlessQueryParser.IN, 0); } + public TerminalNode IS() { return getToken(BackendlessQueryParser.IS, 0); } + public TerminalNode KM() { return getToken(BackendlessQueryParser.KM, 0); } + public TerminalNode LIMIT() { return getToken(BackendlessQueryParser.LIMIT, 0); } + public TerminalNode LIKE() { return getToken(BackendlessQueryParser.LIKE, 0); } + public TerminalNode MAX() { return getToken(BackendlessQueryParser.MAX, 0); } + public TerminalNode MI() { return getToken(BackendlessQueryParser.MI, 0); } + public TerminalNode MIN() { return getToken(BackendlessQueryParser.MIN, 0); } + public TerminalNode MOD() { return getToken(BackendlessQueryParser.MOD, 0); } + public TerminalNode NOT() { return getToken(BackendlessQueryParser.NOT, 0); } + public TerminalNode NULL() { return getToken(BackendlessQueryParser.NULL, 0); } + public TerminalNode OFFSET() { return getToken(BackendlessQueryParser.OFFSET, 0); } + public TerminalNode OR() { return getToken(BackendlessQueryParser.OR, 0); } + public TerminalNode SELECT() { return getToken(BackendlessQueryParser.SELECT, 0); } + public TerminalNode SORT() { return getToken(BackendlessQueryParser.SORT, 0); } + public TerminalNode SUM() { return getToken(BackendlessQueryParser.SUM, 0); } + public TerminalNode TRUE() { return getToken(BackendlessQueryParser.TRUE, 0); } + public TerminalNode YD() { return getToken(BackendlessQueryParser.YD, 0); } + public Keyword_as_idContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_keyword_as_id; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).enterKeyword_as_id(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof BackendlessQueryListener ) ((BackendlessQueryListener)listener).exitKeyword_as_id(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof BackendlessQueryVisitor ) return ((BackendlessQueryVisitor)visitor).visitKeyword_as_id(this); + else return visitor.visitChildren(this); + } + } + + public final Keyword_as_idContext keyword_as_id() throws RecognitionException { + Keyword_as_idContext _localctx = new Keyword_as_idContext(_ctx, getState()); + enterRule(_localctx, 70, RULE_keyword_as_id); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(439); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AFTER) | (1L << AND) | (1L << AT) | (1L << AS) | (1L << ASC) | (1L << AVG) | (1L << BEFORE) | (1L << BY) | (1L << COUNT) | (1L << DESC) | (1L << DISTANCE) | (1L << DISTANCE_ON_SPHERE) | (1L << DIV) | (1L << ESCAPE) | (1L << FALSE) | (1L << FT) | (1L << GROUP) | (1L << HAVING) | (1L << IN) | (1L << IS) | (1L << KM) | (1L << LIMIT) | (1L << LIKE) | (1L << MAX) | (1L << MI) | (1L << MIN) | (1L << MOD) | (1L << NOT) | (1L << NULL) | (1L << OFFSET) | (1L << OR) | (1L << SELECT) | (1L << SORT) | (1L << SUM) | (1L << TRUE) | (1L << YD))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 19: + return condition_sempred((ConditionContext)_localctx, predIndex); + case 20: + return expression_atom_sempred((Expression_atomContext)_localctx, predIndex); + } + return true; + } + private boolean condition_sempred(ConditionContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 13); + case 1: + return precpred(_ctx, 12); + } + return true; + } + private boolean expression_atom_sempred(Expression_atomContext _localctx, int predIndex) { + switch (predIndex) { + case 2: + return precpred(_ctx, 5); + case 3: + return precpred(_ctx, 4); + case 4: + return precpred(_ctx, 3); + case 5: + return precpred(_ctx, 2); + case 6: + return precpred(_ctx, 1); + } + return true; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3D\u01bc\4\2\t\2\4"+ + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\3\2\3\2\3\2\5\2N\n\2\3\2\3\2\3\2\3\2\5\2"+ + "T\n\2\3\2\5\2W\n\2\3\2\5\2Z\n\2\3\2\5\2]\n\2\3\3\3\3\3\3\3\3\7\3c\n\3"+ + "\f\3\16\3f\13\3\3\3\3\3\3\3\5\3k\n\3\3\4\3\4\3\4\3\4\3\4\5\4r\n\4\3\5"+ + "\3\5\3\5\3\5\3\5\7\5y\n\5\f\5\16\5|\13\5\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3"+ + "\7\7\7\u0086\n\7\f\7\16\7\u0089\13\7\3\b\3\b\5\b\u008d\n\b\3\t\3\t\3\t"+ + "\3\t\5\t\u0093\n\t\3\n\3\n\3\n\3\n\3\n\5\n\u009a\n\n\3\13\3\13\3\13\5"+ + "\13\u009f\n\13\3\f\3\f\5\f\u00a3\n\f\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16"+ + "\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\20\3\20\5\20\u00b6\n\20\3\21\3\21"+ + "\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\21"+ + "\3\21\3\21\5\21\u00ca\n\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\5\22\u00d3"+ + "\n\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+ + "\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\5\23\u00eb\n\23\3\24\3\24"+ + "\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24"+ + "\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\3\24\5\24\u0106\n\24\3\25\3\25"+ + "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\5\25\u0111\n\25\3\25\3\25\3\25\3\25"+ + "\5\25\u0117\n\25\3\25\3\25\3\25\5\25\u011c\n\25\7\25\u011e\n\25\f\25\16"+ + "\25\u0121\13\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25"+ + "\3\25\3\25\5\25\u0130\n\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25"+ + "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\5\25\u0142\n\25\3\25\3\25\3\25\3\25"+ + "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\5\25\u014f\n\25\3\25\3\25\3\25\3\25"+ + "\3\25\3\25\5\25\u0157\n\25\3\25\3\25\3\25\3\25\3\25\3\25\7\25\u015f\n"+ + "\25\f\25\16\25\u0162\13\25\3\26\3\26\3\26\3\26\3\26\3\26\5\26\u016a\n"+ + "\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3"+ + "\26\3\26\7\26\u017b\n\26\f\26\16\26\u017e\13\26\3\27\3\27\5\27\u0182\n"+ + "\27\3\30\3\30\5\30\u0186\n\30\3\31\3\31\3\31\3\31\5\31\u018c\n\31\3\32"+ + "\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\35"+ + "\3\35\3\36\3\36\3\37\3\37\3 \3 \3 \3 \5 \u01a6\n \3!\3!\5!\u01aa\n!\3"+ + "\"\3\"\5\"\u01ae\n\"\3\"\3\"\5\"\u01b2\n\"\3#\3#\3$\3$\5$\u01b8\n$\3%"+ + "\3%\3%\2\4(*&\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64"+ + "\668:<>@BDFH\2\13\4\2\36\36##\4\2\13\13\65\65\4\2\16\16\34\34\3\2\17\20"+ + "\4\2\22\22\32\32\4\2\24\24 \4\2\f\f\33\33\4\2\r\r88\3\2\32=\2\u01da\2"+ + "J\3\2\2\2\4j\3\2\2\2\6q\3\2\2\2\bs\3\2\2\2\n}\3\2\2\2\f\u0080\3\2\2\2"+ + "\16\u008a\3\2\2\2\20\u008e\3\2\2\2\22\u0099\3\2\2\2\24\u009e\3\2\2\2\26"+ + "\u00a2\3\2\2\2\30\u00a4\3\2\2\2\32\u00a9\3\2\2\2\34\u00ae\3\2\2\2\36\u00b5"+ + "\3\2\2\2 \u00c9\3\2\2\2\"\u00cb\3\2\2\2$\u00ea\3\2\2\2&\u0105\3\2\2\2"+ + "(\u0156\3\2\2\2*\u0169\3\2\2\2,\u0181\3\2\2\2.\u0185\3\2\2\2\60\u0187"+ + "\3\2\2\2\62\u018d\3\2\2\2\64\u0194\3\2\2\2\66\u0199\3\2\2\28\u019b\3\2"+ + "\2\2:\u019d\3\2\2\2<\u019f\3\2\2\2>\u01a5\3\2\2\2@\u01a9\3\2\2\2B\u01b1"+ + "\3\2\2\2D\u01b3\3\2\2\2F\u01b7\3\2\2\2H\u01b9\3\2\2\2JK\58\35\2KM\7\3"+ + "\2\2LN\5(\25\2ML\3\2\2\2MN\3\2\2\2NO\3\2\2\2OP\7\4\2\2PQ\7\5\2\2QS\5\4"+ + "\3\2RT\5\b\5\2SR\3\2\2\2ST\3\2\2\2TV\3\2\2\2UW\5\n\6\2VU\3\2\2\2VW\3\2"+ + "\2\2WY\3\2\2\2XZ\5\f\7\2YX\3\2\2\2YZ\3\2\2\2Z\\\3\2\2\2[]\5\20\t\2\\["+ + "\3\2\2\2\\]\3\2\2\2]\3\3\2\2\2^_\7\6\2\2_d\5\6\4\2`a\7\7\2\2ac\5\6\4\2"+ + "b`\3\2\2\2cf\3\2\2\2db\3\2\2\2de\3\2\2\2eg\3\2\2\2fd\3\2\2\2gh\7\b\2\2"+ + "hk\3\2\2\2ik\5\6\4\2j^\3\2\2\2ji\3\2\2\2k\5\3\2\2\2lr\5*\26\2mn\5*\26"+ + "\2no\7\35\2\2op\5\66\34\2pr\3\2\2\2ql\3\2\2\2qm\3\2\2\2r\7\3\2\2\2st\7"+ + "*\2\2tu\7!\2\2uz\5*\26\2vw\7\7\2\2wy\5*\26\2xv\3\2\2\2y|\3\2\2\2zx\3\2"+ + "\2\2z{\3\2\2\2{\t\3\2\2\2|z\3\2\2\2}~\7+\2\2~\177\5(\25\2\177\13\3\2\2"+ + "\2\u0080\u0081\7:\2\2\u0081\u0082\7!\2\2\u0082\u0087\5\16\b\2\u0083\u0084"+ + "\7\7\2\2\u0084\u0086\5\16\b\2\u0085\u0083\3\2\2\2\u0086\u0089\3\2\2\2"+ + "\u0087\u0085\3\2\2\2\u0087\u0088\3\2\2\2\u0088\r\3\2\2\2\u0089\u0087\3"+ + "\2\2\2\u008a\u008c\5*\26\2\u008b\u008d\t\2\2\2\u008c\u008b\3\2\2\2\u008c"+ + "\u008d\3\2\2\2\u008d\17\3\2\2\2\u008e\u008f\7/\2\2\u008f\u0092\7B\2\2"+ + "\u0090\u0091\7\67\2\2\u0091\u0093\7B\2\2\u0092\u0090\3\2\2\2\u0092\u0093"+ + "\3\2\2\2\u0093\21\3\2\2\2\u0094\u009a\5&\24\2\u0095\u009a\5$\23\2\u0096"+ + "\u009a\5\24\13\2\u0097\u009a\5\36\20\2\u0098\u009a\5\64\33\2\u0099\u0094"+ + "\3\2\2\2\u0099\u0095\3\2\2\2\u0099\u0096\3\2\2\2\u0099\u0097\3\2\2\2\u0099"+ + "\u0098\3\2\2\2\u009a\23\3\2\2\2\u009b\u009f\5\30\r\2\u009c\u009f\5\32"+ + "\16\2\u009d\u009f\5\34\17\2\u009e\u009b\3\2\2\2\u009e\u009c\3\2\2\2\u009e"+ + "\u009d\3\2\2\2\u009f\25\3\2\2\2\u00a0\u00a3\5:\36\2\u00a1\u00a3\5> \2"+ + "\u00a2\u00a0\3\2\2\2\u00a2\u00a1\3\2\2\2\u00a3\27\3\2\2\2\u00a4\u00a5"+ + "\7>\2\2\u00a5\u00a6\7\t\2\2\u00a6\u00a7\5\26\f\2\u00a7\u00a8\7\n\2\2\u00a8"+ + "\31\3\2\2\2\u00a9\u00aa\7?\2\2\u00aa\u00ab\7\t\2\2\u00ab\u00ac\5\26\f"+ + "\2\u00ac\u00ad\7\n\2\2\u00ad\33\3\2\2\2\u00ae\u00af\7@\2\2\u00af\u00b0"+ + "\7\t\2\2\u00b0\u00b1\5\26\f\2\u00b1\u00b2\7\n\2\2\u00b2\35\3\2\2\2\u00b3"+ + "\u00b6\5 \21\2\u00b4\u00b6\5\"\22\2\u00b5\u00b3\3\2\2\2\u00b5\u00b4\3"+ + "\2\2\2\u00b6\37\3\2\2\2\u00b7\u00b8\7$\2\2\u00b8\u00b9\7\t\2\2\u00b9\u00ba"+ + "\5\26\f\2\u00ba\u00bb\7\7\2\2\u00bb\u00bc\5\26\f\2\u00bc\u00bd\7\n\2\2"+ + "\u00bd\u00ca\3\2\2\2\u00be\u00bf\7$\2\2\u00bf\u00c0\7\t\2\2\u00c0\u00c1"+ + "\5*\26\2\u00c1\u00c2\7\7\2\2\u00c2\u00c3\5*\26\2\u00c3\u00c4\7\7\2\2\u00c4"+ + "\u00c5\5*\26\2\u00c5\u00c6\7\7\2\2\u00c6\u00c7\5*\26\2\u00c7\u00c8\7\n"+ + "\2\2\u00c8\u00ca\3\2\2\2\u00c9\u00b7\3\2\2\2\u00c9\u00be\3\2\2\2\u00ca"+ + "!\3\2\2\2\u00cb\u00cc\7%\2\2\u00cc\u00cd\7\t\2\2\u00cd\u00ce\5\26\f\2"+ + "\u00ce\u00cf\7\7\2\2\u00cf\u00d2\5\26\f\2\u00d0\u00d1\7\7\2\2\u00d1\u00d3"+ + "\5*\26\2\u00d2\u00d0\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4"+ + "\u00d5\7\n\2\2\u00d5#\3\2\2\2\u00d6\u00d7\7)\2\2\u00d7\u00d8\7\t\2\2\u00d8"+ + "\u00d9\5B\"\2\u00d9\u00da\7\n\2\2\u00da\u00eb\3\2\2\2\u00db\u00dc\7.\2"+ + "\2\u00dc\u00dd\7\t\2\2\u00dd\u00de\5B\"\2\u00de\u00df\7\n\2\2\u00df\u00eb"+ + "\3\2\2\2\u00e0\u00e1\7\62\2\2\u00e1\u00e2\7\t\2\2\u00e2\u00e3\5B\"\2\u00e3"+ + "\u00e4\7\n\2\2\u00e4\u00eb\3\2\2\2\u00e5\u00e6\7=\2\2\u00e6\u00e7\7\t"+ + "\2\2\u00e7\u00e8\5B\"\2\u00e8\u00e9\7\n\2\2\u00e9\u00eb\3\2\2\2\u00ea"+ + "\u00d6\3\2\2\2\u00ea\u00db\3\2\2\2\u00ea\u00e0\3\2\2\2\u00ea\u00e5\3\2"+ + "\2\2\u00eb%\3\2\2\2\u00ec\u00ed\7\37\2\2\u00ed\u00ee\7\t\2\2\u00ee\u00ef"+ + "\5*\26\2\u00ef\u00f0\7\n\2\2\u00f0\u0106\3\2\2\2\u00f1\u00f2\7\61\2\2"+ + "\u00f2\u00f3\7\t\2\2\u00f3\u00f4\5*\26\2\u00f4\u00f5\7\n\2\2\u00f5\u0106"+ + "\3\2\2\2\u00f6\u00f7\7\63\2\2\u00f7\u00f8\7\t\2\2\u00f8\u00f9\5*\26\2"+ + "\u00f9\u00fa\7\n\2\2\u00fa\u0106\3\2\2\2\u00fb\u00fc\7;\2\2\u00fc\u00fd"+ + "\7\t\2\2\u00fd\u00fe\5*\26\2\u00fe\u00ff\7\n\2\2\u00ff\u0106\3\2\2\2\u0100"+ + "\u0101\7\"\2\2\u0101\u0102\7\t\2\2\u0102\u0103\5*\26\2\u0103\u0104\7\n"+ + "\2\2\u0104\u0106\3\2\2\2\u0105\u00ec\3\2\2\2\u0105\u00f1\3\2\2\2\u0105"+ + "\u00f6\3\2\2\2\u0105\u00fb\3\2\2\2\u0105\u0100\3\2\2\2\u0106\'\3\2\2\2"+ + "\u0107\u0108\b\25\1\2\u0108\u0109\t\3\2\2\u0109\u0157\5(\25\20\u010a\u010b"+ + "\7\t\2\2\u010b\u010c\5(\25\2\u010c\u010d\7\n\2\2\u010d\u0157\3\2\2\2\u010e"+ + "\u0110\5*\26\2\u010f\u0111\7\65\2\2\u0110\u010f\3\2\2\2\u0110\u0111\3"+ + "\2\2\2\u0111\u0112\3\2\2\2\u0112\u0113\7,\2\2\u0113\u0116\7\t\2\2\u0114"+ + "\u0117\5\2\2\2\u0115\u0117\5*\26\2\u0116\u0114\3\2\2\2\u0116\u0115\3\2"+ + "\2\2\u0117\u011f\3\2\2\2\u0118\u011b\7\7\2\2\u0119\u011c\5\2\2\2\u011a"+ + "\u011c\5*\26\2\u011b\u0119\3\2\2\2\u011b\u011a\3\2\2\2\u011c\u011e\3\2"+ + "\2\2\u011d\u0118\3\2\2\2\u011e\u0121\3\2\2\2\u011f\u011d\3\2\2\2\u011f"+ + "\u0120\3\2\2\2\u0120\u0122\3\2\2\2\u0121\u011f\3\2\2\2\u0122\u0123\7\n"+ + "\2\2\u0123\u0157\3\2\2\2\u0124\u0125\5*\26\2\u0125\u0126\7-\2\2\u0126"+ + "\u0127\7\66\2\2\u0127\u0157\3\2\2\2\u0128\u0129\5*\26\2\u0129\u012a\7"+ + "-\2\2\u012a\u012b\7\65\2\2\u012b\u012c\7\66\2\2\u012c\u0157\3\2\2\2\u012d"+ + "\u012f\5*\26\2\u012e\u0130\7\65\2\2\u012f\u012e\3\2\2\2\u012f\u0130\3"+ + "\2\2\2\u0130\u0131\3\2\2\2\u0131\u0132\7\60\2\2\u0132\u0133\5*\26\2\u0133"+ + "\u0157\3\2\2\2\u0134\u0135\5*\26\2\u0135\u0136\t\4\2\2\u0136\u0137\5*"+ + "\26\2\u0137\u0157\3\2\2\2\u0138\u0139\5*\26\2\u0139\u013a\t\5\2\2\u013a"+ + "\u013b\5*\26\2\u013b\u0157\3\2\2\2\u013c\u0141\5*\26\2\u013d\u0142\7\21"+ + "\2\2\u013e\u013f\7\34\2\2\u013f\u0140\78\2\2\u0140\u0142\7\32\2\2\u0141"+ + "\u013d\3\2\2\2\u0141\u013e\3\2\2\2\u0142\u0143\3\2\2\2\u0143\u0144\5*"+ + "\26\2\u0144\u0157\3\2\2\2\u0145\u0146\5*\26\2\u0146\u0147\t\6\2\2\u0147"+ + "\u0148\5*\26\2\u0148\u0157\3\2\2\2\u0149\u014e\5*\26\2\u014a\u014f\7\23"+ + "\2\2\u014b\u014c\7\34\2\2\u014c\u014d\78\2\2\u014d\u014f\7 \2\2\u014e"+ + "\u014a\3\2\2\2\u014e\u014b\3\2\2\2\u014f\u0150\3\2\2\2\u0150\u0151\5*"+ + "\26\2\u0151\u0157\3\2\2\2\u0152\u0153\5*\26\2\u0153\u0154\t\7\2\2\u0154"+ + "\u0155\5*\26\2\u0155\u0157\3\2\2\2\u0156\u0107\3\2\2\2\u0156\u010a\3\2"+ + "\2\2\u0156\u010e\3\2\2\2\u0156\u0124\3\2\2\2\u0156\u0128\3\2\2\2\u0156"+ + "\u012d\3\2\2\2\u0156\u0134\3\2\2\2\u0156\u0138\3\2\2\2\u0156\u013c\3\2"+ + "\2\2\u0156\u0145\3\2\2\2\u0156\u0149\3\2\2\2\u0156\u0152\3\2\2\2\u0157"+ + "\u0160\3\2\2\2\u0158\u0159\f\17\2\2\u0159\u015a\t\b\2\2\u015a\u015f\5"+ + "(\25\20\u015b\u015c\f\16\2\2\u015c\u015d\t\t\2\2\u015d\u015f\5(\25\17"+ + "\u015e\u0158\3\2\2\2\u015e\u015b\3\2\2\2\u015f\u0162\3\2\2\2\u0160\u015e"+ + "\3\2\2\2\u0160\u0161\3\2\2\2\u0161)\3\2\2\2\u0162\u0160\3\2\2\2\u0163"+ + "\u0164\b\26\1\2\u0164\u016a\5> \2\u0165\u016a\5,\27\2\u0166\u016a\5\22"+ + "\n\2\u0167\u0168\7\25\2\2\u0168\u016a\5*\26\b\u0169\u0163\3\2\2\2\u0169"+ + "\u0165\3\2\2\2\u0169\u0166\3\2\2\2\u0169\u0167\3\2\2\2\u016a\u017c\3\2"+ + "\2\2\u016b\u016c\f\7\2\2\u016c\u016d\7\26\2\2\u016d\u017b\5*\26\b\u016e"+ + "\u016f\f\6\2\2\u016f\u0170\7\27\2\2\u0170\u017b\5*\26\7\u0171\u0172\f"+ + "\5\2\2\u0172\u0173\7\30\2\2\u0173\u017b\5*\26\6\u0174\u0175\f\4\2\2\u0175"+ + "\u0176\7\31\2\2\u0176\u017b\5*\26\5\u0177\u0178\f\3\2\2\u0178\u0179\7"+ + "\25\2\2\u0179\u017b\5*\26\4\u017a\u016b\3\2\2\2\u017a\u016e\3\2\2\2\u017a"+ + "\u0171\3\2\2\2\u017a\u0174\3\2\2\2\u017a\u0177\3\2\2\2\u017b\u017e\3\2"+ + "\2\2\u017c\u017a\3\2\2\2\u017c\u017d\3\2\2\2\u017d+\3\2\2\2\u017e\u017c"+ + "\3\2\2\2\u017f\u0182\5.\30\2\u0180\u0182\5\60\31\2\u0181\u017f\3\2\2\2"+ + "\u0181\u0180\3\2\2\2\u0182-\3\2\2\2\u0183\u0186\5:\36\2\u0184\u0186\5"+ + "\62\32\2\u0185\u0183\3\2\2\2\u0185\u0184\3\2\2\2\u0186/\3\2\2\2\u0187"+ + "\u0188\5.\30\2\u0188\u018b\7\5\2\2\u0189\u018c\5\60\31\2\u018a\u018c\5"+ + ".\30\2\u018b\u0189\3\2\2\2\u018b\u018a\3\2\2\2\u018c\61\3\2\2\2\u018d"+ + "\u018e\58\35\2\u018e\u018f\7\3\2\2\u018f\u0190\5,\27\2\u0190\u0191\7\4"+ + "\2\2\u0191\u0192\7\5\2\2\u0192\u0193\5,\27\2\u0193\63\3\2\2\2\u0194\u0195"+ + "\5<\37\2\u0195\u0196\7\t\2\2\u0196\u0197\5*\26\2\u0197\u0198\7\n\2\2\u0198"+ + "\65\3\2\2\2\u0199\u019a\5F$\2\u019a\67\3\2\2\2\u019b\u019c\5F$\2\u019c"+ + "9\3\2\2\2\u019d\u019e\5F$\2\u019e;\3\2\2\2\u019f\u01a0\5F$\2\u01a0=\3"+ + "\2\2\2\u01a1\u01a6\5D#\2\u01a2\u01a6\5B\"\2\u01a3\u01a6\5@!\2\u01a4\u01a6"+ + "\7\66\2\2\u01a5\u01a1\3\2\2\2\u01a5\u01a2\3\2\2\2\u01a5\u01a3\3\2\2\2"+ + "\u01a5\u01a4\3\2\2\2\u01a6?\3\2\2\2\u01a7\u01aa\7<\2\2\u01a8\u01aa\7("+ + "\2\2\u01a9\u01a7\3\2\2\2\u01a9\u01a8\3\2\2\2\u01aaA\3\2\2\2\u01ab\u01b2"+ + "\7B\2\2\u01ac\u01ae\7B\2\2\u01ad\u01ac\3\2\2\2\u01ad\u01ae\3\2\2\2\u01ae"+ + "\u01af\3\2\2\2\u01af\u01b0\7\5\2\2\u01b0\u01b2\7B\2\2\u01b1\u01ab\3\2"+ + "\2\2\u01b1\u01ad\3\2\2\2\u01b2C\3\2\2\2\u01b3\u01b4\7C\2\2\u01b4E\3\2"+ + "\2\2\u01b5\u01b8\7A\2\2\u01b6\u01b8\5H%\2\u01b7\u01b5\3\2\2\2\u01b7\u01b6"+ + "\3\2\2\2\u01b8G\3\2\2\2\u01b9\u01ba\t\n\2\2\u01baI\3\2\2\2+MSVY\\djqz"+ + "\u0087\u008c\u0092\u0099\u009e\u00a2\u00b5\u00c9\u00d2\u00ea\u0105\u0110"+ + "\u0116\u011b\u011f\u012f\u0141\u014e\u0156\u015e\u0160\u0169\u017a\u017c"+ + "\u0181\u0185\u018b\u01a5\u01a9\u01ad\u01b1\u01b7"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryVisitor.java b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryVisitor.java new file mode 100644 index 000000000..b4e0f4b14 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/gen/BackendlessQueryVisitor.java @@ -0,0 +1,475 @@ +// Generated from /home/max/Dev/Projects/IntellijProjects/TestVisitor/visitor/resources/BackendlessQuery.g4 by ANTLR 4.7.2 +package com.backendless.persistence.offline.visitor.gen; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link BackendlessQueryParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface BackendlessQueryVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#select_statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSelect_statement(BackendlessQueryParser.Select_statementContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#select_list}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSelect_list(BackendlessQueryParser.Select_listContext ctx); + /** + * Visit a parse tree produced by the {@code simpleSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimpleSelectElem(BackendlessQueryParser.SimpleSelectElemContext ctx); + /** + * Visit a parse tree produced by the {@code aliasedSelectElem} + * labeled alternative in {@link BackendlessQueryParser#select_list_elem}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAliasedSelectElem(BackendlessQueryParser.AliasedSelectElemContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#group_by_clause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGroup_by_clause(BackendlessQueryParser.Group_by_clauseContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#having_clause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitHaving_clause(BackendlessQueryParser.Having_clauseContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#sort_by_clause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSort_by_clause(BackendlessQueryParser.Sort_by_clauseContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#sort_by_elem}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSort_by_elem(BackendlessQueryParser.Sort_by_elemContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#limit_clause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLimit_clause(BackendlessQueryParser.Limit_clauseContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#function_call}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction_call(BackendlessQueryParser.Function_callContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#spatial_convert_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSpatial_convert_function(BackendlessQueryParser.Spatial_convert_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#spatial_function_parameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSpatial_function_parameter(BackendlessQueryParser.Spatial_function_parameterContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#aswkb_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAswkb_function(BackendlessQueryParser.Aswkb_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#aswkt_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAswkt_function(BackendlessQueryParser.Aswkt_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#asgeojson_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAsgeojson_function(BackendlessQueryParser.Asgeojson_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#spatial_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSpatial_function(BackendlessQueryParser.Spatial_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#distance_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDistance_function(BackendlessQueryParser.Distance_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#distance_on_sphere}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDistance_on_sphere(BackendlessQueryParser.Distance_on_sphereContext ctx); + /** + * Visit a parse tree produced by the {@code ftUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFtUnitsFunction(BackendlessQueryParser.FtUnitsFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code kmUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitKmUnitsFunction(BackendlessQueryParser.KmUnitsFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code miUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMiUnitsFunction(BackendlessQueryParser.MiUnitsFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code ydUnitsFunction} + * labeled alternative in {@link BackendlessQueryParser#units_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitYdUnitsFunction(BackendlessQueryParser.YdUnitsFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code avgFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAvgFunction(BackendlessQueryParser.AvgFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code maxFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMaxFunction(BackendlessQueryParser.MaxFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code minFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMinFunction(BackendlessQueryParser.MinFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code sumFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSumFunction(BackendlessQueryParser.SumFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code countFunction} + * labeled alternative in {@link BackendlessQueryParser#aggregate_windowed_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCountFunction(BackendlessQueryParser.CountFunctionContext ctx); + /** + * Visit a parse tree produced by the {@code inCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInCondition(BackendlessQueryParser.InConditionContext ctx); + /** + * Visit a parse tree produced by the {@code equalCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEqualCondition(BackendlessQueryParser.EqualConditionContext ctx); + /** + * Visit a parse tree produced by the {@code orCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOrCondition(BackendlessQueryParser.OrConditionContext ctx); + /** + * Visit a parse tree produced by the {@code lessThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLessThanCondition(BackendlessQueryParser.LessThanConditionContext ctx); + /** + * Visit a parse tree produced by the {@code andCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAndCondition(BackendlessQueryParser.AndConditionContext ctx); + /** + * Visit a parse tree produced by the {@code isNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIsNullCondition(BackendlessQueryParser.IsNullConditionContext ctx); + /** + * Visit a parse tree produced by the {@code notCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNotCondition(BackendlessQueryParser.NotConditionContext ctx); + /** + * Visit a parse tree produced by the {@code likeCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLikeCondition(BackendlessQueryParser.LikeConditionContext ctx); + /** + * Visit a parse tree produced by the {@code isNotNullCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIsNotNullCondition(BackendlessQueryParser.IsNotNullConditionContext ctx); + /** + * Visit a parse tree produced by the {@code nestedCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNestedCondition(BackendlessQueryParser.NestedConditionContext ctx); + /** + * Visit a parse tree produced by the {@code notEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNotEqualCondition(BackendlessQueryParser.NotEqualConditionContext ctx); + /** + * Visit a parse tree produced by the {@code greaterThanCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGreaterThanCondition(BackendlessQueryParser.GreaterThanConditionContext ctx); + /** + * Visit a parse tree produced by the {@code greaterThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGreaterThanOrEqualCondition(BackendlessQueryParser.GreaterThanOrEqualConditionContext ctx); + /** + * Visit a parse tree produced by the {@code lessThanOrEqualCondition} + * labeled alternative in {@link BackendlessQueryParser#condition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLessThanOrEqualCondition(BackendlessQueryParser.LessThanOrEqualConditionContext ctx); + /** + * Visit a parse tree produced by the {@code divisionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDivisionExpressionAtom(BackendlessQueryParser.DivisionExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code moduloExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitModuloExpressionAtom(BackendlessQueryParser.ModuloExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code constantExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitConstantExpressionAtom(BackendlessQueryParser.ConstantExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code functionCallExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionCallExpressionAtom(BackendlessQueryParser.FunctionCallExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code subtractionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSubtractionExpressionAtom(BackendlessQueryParser.SubtractionExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code fullColumnNameExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFullColumnNameExpressionAtom(BackendlessQueryParser.FullColumnNameExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code multiplicationExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMultiplicationExpressionAtom(BackendlessQueryParser.MultiplicationExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code unaryMinusExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnaryMinusExpressionAtom(BackendlessQueryParser.UnaryMinusExpressionAtomContext ctx); + /** + * Visit a parse tree produced by the {@code additionExpressionAtom} + * labeled alternative in {@link BackendlessQueryParser#expression_atom}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAdditionExpressionAtom(BackendlessQueryParser.AdditionExpressionAtomContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#full_column_name}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFull_column_name(BackendlessQueryParser.Full_column_nameContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#single_column_name}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSingle_column_name(BackendlessQueryParser.Single_column_nameContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#relation_column}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRelation_column(BackendlessQueryParser.Relation_columnContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#inverse_relation_column}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInverse_relation_column(BackendlessQueryParser.Inverse_relation_columnContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#unknown_function}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnknown_function(BackendlessQueryParser.Unknown_functionContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#alias}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAlias(BackendlessQueryParser.AliasContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#table_name}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTable_name(BackendlessQueryParser.Table_nameContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#simple_column}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimple_column(BackendlessQueryParser.Simple_columnContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#unknown_name}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnknown_name(BackendlessQueryParser.Unknown_nameContext ctx); + /** + * Visit a parse tree produced by the {@code stringConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStringConstant(BackendlessQueryParser.StringConstantContext ctx); + /** + * Visit a parse tree produced by the {@code numericConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNumericConstant(BackendlessQueryParser.NumericConstantContext ctx); + /** + * Visit a parse tree produced by the {@code booleanConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBooleanConstant(BackendlessQueryParser.BooleanConstantContext ctx); + /** + * Visit a parse tree produced by the {@code nullConstant} + * labeled alternative in {@link BackendlessQueryParser#constant}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNullConstant(BackendlessQueryParser.NullConstantContext ctx); + /** + * Visit a parse tree produced by the {@code trueBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTrueBooleanConstant(BackendlessQueryParser.TrueBooleanConstantContext ctx); + /** + * Visit a parse tree produced by the {@code falseBooleanConstant} + * labeled alternative in {@link BackendlessQueryParser#boolean_literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFalseBooleanConstant(BackendlessQueryParser.FalseBooleanConstantContext ctx); + /** + * Visit a parse tree produced by the {@code decimalNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDecimalNumericConstant(BackendlessQueryParser.DecimalNumericConstantContext ctx); + /** + * Visit a parse tree produced by the {@code floatNumericConstant} + * labeled alternative in {@link BackendlessQueryParser#numeric_literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFloatNumericConstant(BackendlessQueryParser.FloatNumericConstantContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#string_literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitString_literal(BackendlessQueryParser.String_literalContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#regular_id}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRegular_id(BackendlessQueryParser.Regular_idContext ctx); + /** + * Visit a parse tree produced by {@link BackendlessQueryParser#keyword_as_id}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitKeyword_as_id(BackendlessQueryParser.Keyword_as_idContext ctx); +} \ No newline at end of file diff --git a/src/com/backendless/persistence/offline/visitor/res/AggregateFunction.java b/src/com/backendless/persistence/offline/visitor/res/AggregateFunction.java new file mode 100644 index 000000000..991024830 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/AggregateFunction.java @@ -0,0 +1,16 @@ +package com.backendless.persistence.offline.visitor.res; + +public class AggregateFunction extends Field { + private final AggregateOperator operator; + private final Field field; + + public AggregateFunction(AggregateOperator operator, Field field) { + this.operator = operator; + this.field = field; + } + + @Override + public String toString() { + return operator + "(" + field + ")"; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/AggregateOperator.java b/src/com/backendless/persistence/offline/visitor/res/AggregateOperator.java new file mode 100644 index 000000000..72cbbb42b --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/AggregateOperator.java @@ -0,0 +1,20 @@ +package com.backendless.persistence.offline.visitor.res; + +public enum AggregateOperator { + AVG("AVG"), + MAX("MAX"), + MIN("MIN"), + SUM("SUM"), + COUNT("COUNT"); + + private final String sql; + + private AggregateOperator(String sql) { + this.sql = sql; + } + + @Override + public String toString() { + return sql; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/CombinedCondition.java b/src/com/backendless/persistence/offline/visitor/res/CombinedCondition.java new file mode 100644 index 000000000..67ea0de5e --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/CombinedCondition.java @@ -0,0 +1,18 @@ +package com.backendless.persistence.offline.visitor.res; + +public class CombinedCondition implements Condition { + private final Condition leftCondition; + private final Operator operator; + private final Condition rightCondition; + + public CombinedCondition(Condition leftCondition, Operator operator, Condition rightCondition) { + this.leftCondition = leftCondition; + this.operator = operator; + this.rightCondition = rightCondition; + } + + @Override + public String toString() { + return "(" + leftCondition + ") " + operator + " (" + rightCondition + ")"; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/ComparisonCondition.java b/src/com/backendless/persistence/offline/visitor/res/ComparisonCondition.java new file mode 100644 index 000000000..7d2234f79 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/ComparisonCondition.java @@ -0,0 +1,18 @@ +package com.backendless.persistence.offline.visitor.res; + +public class ComparisonCondition implements Condition { + private Field left; + private Operator operator; + private Field right; + + public ComparisonCondition(Field left, Operator operator, Field right) { + this.left = left; + this.operator = operator; + this.right = right; + } + + @Override + public String toString() { + return left + " " + operator + " " + right; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Condition.java b/src/com/backendless/persistence/offline/visitor/res/Condition.java new file mode 100644 index 000000000..0b2ad5280 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Condition.java @@ -0,0 +1,4 @@ +package com.backendless.persistence.offline.visitor.res; + +public interface Condition extends QueryPart { +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Expression.java b/src/com/backendless/persistence/offline/visitor/res/Expression.java new file mode 100644 index 000000000..0c3ecd669 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Expression.java @@ -0,0 +1,18 @@ +package com.backendless.persistence.offline.visitor.res; + +public class Expression extends Field { + private final Field lhs; + private final ExpressionOperator operator; + private final Field rhs; + + public Expression(Field lhs, ExpressionOperator operator, Field rhs) { + this.lhs = lhs; + this.operator = operator; + this.rhs = rhs; + } + + @Override + public String toString() { + return lhs + " " + operator + " " + rhs; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/ExpressionOperator.java b/src/com/backendless/persistence/offline/visitor/res/ExpressionOperator.java new file mode 100644 index 000000000..1def6305e --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/ExpressionOperator.java @@ -0,0 +1,20 @@ +package com.backendless.persistence.offline.visitor.res; + +public enum ExpressionOperator { + ADD("+"), + SUBTRACT("-"), + MULTIPLY("*"), + DIVIDE("/"), + MODULO("%"); + + private final String sql; + + private ExpressionOperator(String sql) { + this.sql = sql; + } + + @Override + public String toString() { + return sql; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Field.java b/src/com/backendless/persistence/offline/visitor/res/Field.java new file mode 100644 index 000000000..340ba8369 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Field.java @@ -0,0 +1,22 @@ +package com.backendless.persistence.offline.visitor.res; + +public class Field implements QueryPart { + public String alias; + private String name; + + public Field() { + } + + public Field(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/LikeCondition.java b/src/com/backendless/persistence/offline/visitor/res/LikeCondition.java new file mode 100644 index 000000000..bae06e7ce --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/LikeCondition.java @@ -0,0 +1,19 @@ +package com.backendless.persistence.offline.visitor.res; + +public class LikeCondition implements Condition { + private Field left; + private boolean isLike; + private Field right; + + public LikeCondition(Field left, boolean isLike, Field right) { + this.left = left; + this.isLike = isLike; + this.right = right; + } + + @Override + public String toString() { + return left + (isLike ? " LIKE " : " NOT LIKE ") + right; + + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/NotCondition.java b/src/com/backendless/persistence/offline/visitor/res/NotCondition.java new file mode 100644 index 000000000..49b1488cf --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/NotCondition.java @@ -0,0 +1,14 @@ +package com.backendless.persistence.offline.visitor.res; + +public class NotCondition implements Condition { + private Condition condition; + + public NotCondition(Condition condition) { + this.condition = condition; + } + + @Override + public String toString() { + return "NOT " + condition; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/NullCondition.java b/src/com/backendless/persistence/offline/visitor/res/NullCondition.java new file mode 100644 index 000000000..9f065af90 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/NullCondition.java @@ -0,0 +1,16 @@ +package com.backendless.persistence.offline.visitor.res; + +public class NullCondition implements Condition { + private Field field; + private boolean isNull; + + public NullCondition(Field field, boolean isNull) { + this.field = field; + this.isNull = isNull; + } + + @Override + public String toString() { + return field + (isNull ? " IS NULL " : " IS NOT NULL "); + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Operator.java b/src/com/backendless/persistence/offline/visitor/res/Operator.java new file mode 100644 index 000000000..3b9441260 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Operator.java @@ -0,0 +1,25 @@ +package com.backendless.persistence.offline.visitor.res; + +public enum Operator { + + AND("and"), + OR("or"), + EQUAL("="), + NOT_EQUAL("!="), + GREATER_THAN_OR_EQUAL(">="), + GREATER_THAN(">"), + LESS_THAN_OR_EQUAL("<="), + LESS_THAN("<"); + + private final String sql; + + private Operator(String sql) { + this.sql = sql; + } + + @Override + public String toString() { + return sql; + } +} + diff --git a/src/com/backendless/persistence/offline/visitor/res/QueryPart.java b/src/com/backendless/persistence/offline/visitor/res/QueryPart.java new file mode 100644 index 000000000..4fb7465be --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/QueryPart.java @@ -0,0 +1,4 @@ +package com.backendless.persistence.offline.visitor.res; + +public interface QueryPart { +} diff --git a/src/com/backendless/persistence/offline/visitor/res/SelectQuery.java b/src/com/backendless/persistence/offline/visitor/res/SelectQuery.java new file mode 100644 index 000000000..91ecbafaa --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/SelectQuery.java @@ -0,0 +1,53 @@ +package com.backendless.persistence.offline.visitor.res; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class SelectQuery implements QueryPart { + public Set selectList; + public Table from; + public Condition condition; + public List groupBy; + public Condition having; + public List orderBy; + public Integer limit; + public Integer offset; + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("SELECT distinct ") + .append(listToString(selectList)) + .append("\nFROM ") + .append(from); + + if (condition != null) + builder.append("\nWHERE ").append(condition); + if (groupBy != null) + builder.append("\nGROUP BY ").append(listToString(groupBy)); + + if (having != null) + builder.append("\nHAVING ").append(having); +// if (orderBy != null) +// +// if (limit != null) + + + return builder.toString(); + } + + private String listToString(Collection list) { + return list + .stream() + .map(new Function() { + @Override + public String apply(Field field) { + return field.getName(); + } + }) + .collect(Collectors.joining(", ")); + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/SortField.java b/src/com/backendless/persistence/offline/visitor/res/SortField.java new file mode 100644 index 000000000..19342ed12 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/SortField.java @@ -0,0 +1,19 @@ +package com.backendless.persistence.offline.visitor.res; + +public class SortField extends Field { + private SortOrder order; + private Field field; + + public SortField(Field field, SortOrder order) { + this.field = field; + this.order = order; + } + + public void setOrder(SortOrder order) { + this.order = order; + } + + public enum SortOrder { + ASC, DESC + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Table.java b/src/com/backendless/persistence/offline/visitor/res/Table.java new file mode 100644 index 000000000..d3211362a --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Table.java @@ -0,0 +1,14 @@ +package com.backendless.persistence.offline.visitor.res; + +public class Table implements QueryPart { + private String tableName; + + public Table(String tableName) { + this.tableName = tableName; + } + + @Override + public String toString() { + return tableName; + } +} diff --git a/src/com/backendless/persistence/offline/visitor/res/Value.java b/src/com/backendless/persistence/offline/visitor/res/Value.java new file mode 100644 index 000000000..9d2329c70 --- /dev/null +++ b/src/com/backendless/persistence/offline/visitor/res/Value.java @@ -0,0 +1,14 @@ +package com.backendless.persistence.offline.visitor.res; + +public class Value extends Field { + T value; + + public Value(T value) { + this.value = value; + } + + @Override + public String toString() { + return value.toString(); + } +}