Class GremlinAntlrToJava

  • All Implemented Interfaces:
    org.antlr.v4.runtime.tree.ParseTreeVisitor<Object>, org.apache.tinkerpop.gremlin.language.grammar.GremlinVisitor<Object>
    Direct Known Subclasses:
    NoOpTerminalVisitor

    public class GremlinAntlrToJava
    extends DefaultGremlinBaseVisitor<Object>
    This is the entry point for converting the Gremlin Antlr grammar into Java. It is bound to a Graph instance as that instance may spawn specific Traversal or TraversalSource types. A new instance should be created for each parse execution.
    • Constructor Detail

      • GremlinAntlrToJava

        public GremlinAntlrToJava()
        Constructs a new instance and is bound to an EmptyGraph. This form of construction is helpful for generating Bytecode or for various forms of testing. Traversal instances constructed from this form will not be capable of iterating. Assumes that "g" is the name of the GraphTraversalSource.
      • GremlinAntlrToJava

        public GremlinAntlrToJava​(Graph graph)
        Constructs a new instance that is bound to the specified Graph instance. Assumes that "g" is the name of the GraphTraversalSource.
      • GremlinAntlrToJava

        protected GremlinAntlrToJava​(Graph graph,
                                     Supplier<GraphTraversal<?,​?>> createAnonymous)
        Constructs a new instance that is bound to the specified Graph instance with an override to using __ for constructing anonymous Traversal instances. Assumes that "g" is the name of the GraphTraversalSource.
      • GremlinAntlrToJava

        protected GremlinAntlrToJava​(String traversalSourceName,
                                     Graph graph,
                                     Supplier<GraphTraversal<?,​?>> createAnonymous)
        Constructs a new instance that is bound to the specified Graph instance with an override to using __ for constructing anonymous Traversal instances.
        Parameters:
        traversalSourceName - The name of the traversal source which will be "g" if not specified.
      • GremlinAntlrToJava

        protected GremlinAntlrToJava​(String traversalSourceName,
                                     Graph graph,
                                     Supplier<GraphTraversal<?,​?>> createAnonymous,
                                     GraphTraversalSource g,
                                     VariableResolver variableResolver)
        Constructs a new instance that is bound to the specified Graph instance with an override to using __ for constructing anonymous Traversal instances. If the GraphTraversalSource is provided then the Traversal will spawn from it as opposed to a fresh one from the Graph instance. When a VariableResolver is supplied it will attempt to resolve parameters in the Gremlin to objects.
        Parameters:
        traversalSourceName - The name of the traversal source which will be "g" if not specified.
    • Method Detail

      • visitQuery

        public Object visitQuery​(org.apache.tinkerpop.gremlin.language.grammar.GremlinParser.QueryContext ctx)
        Specified by:
        visitQuery in interface org.apache.tinkerpop.gremlin.language.grammar.GremlinVisitor<Object>
        Overrides:
        visitQuery in class DefaultGremlinBaseVisitor<Object>
      • visitQueryList

        public Object visitQueryList​(org.apache.tinkerpop.gremlin.language.grammar.GremlinParser.QueryListContext ctx)
        Specified by:
        visitQueryList in interface org.apache.tinkerpop.gremlin.language.grammar.GremlinVisitor<Object>
        Overrides:
        visitQueryList in class DefaultGremlinBaseVisitor<Object>
      • aggregateResult

        protected Object aggregateResult​(Object result,
                                         Object nextResult)
        Override the aggregate result behavior. If the next result is null, return the current result. This is used to handle child EOF, which is the last child of the QueryList context. If the next Result is not null, return the next result. This is used to handle multiple queries, and return only the last query result logic.
        Overrides:
        aggregateResult in class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<Object>