org.apache.tinkerpop.gremlin.process.traversal

## Class Bytecode

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.traversal.Bytecode

- All Implemented Interfaces:
    Serializable, Cloneable

      public final class Bytecode
      extends Object
      implements Cloneable, Serializable

  When a `TraversalSource` is manipulated and then a `Traversal` is spawned and mutated, a language agnostic representation of those mutations is recorded in a bytecode instance. Bytecode is simply a list of ordered instructions where an instruction is a string operator and a (flattened) array of arguments. Bytecode is used by `Translator` instances which are able to translate a traversal in one language to another by analyzing the bytecode as opposed to the Java traversal object representation on heap.

  Bytecode can be serialized between environments and machines by way of a GraphSON representation. Thus, Gremlin-Python can create bytecode in Python and ship it to Gremlin-Java for evaluation in Java.

  Author:
    Marko A. Rodriguez (http://markorodriguez.com)
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Bytecode.Binding<V>`
    `static class` | `Bytecode.Instruction`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Bytecode()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSource(String sourceName, Object... arguments)` Add a `TraversalSource` instruction to the bytecode.
    `void` | `addStep(String stepName, Object... arguments)` Add a `Traversal` instruction to the bytecode.
    `Bytecode` | `clone()`
    `boolean` | `equals(Object object)`
    `Map<String,Object>` | `getBindings()` Get all the bindings (in a nested, recursive manner) from all the arguments of all the instructions of this bytecode.
    `Iterable<Bytecode.Instruction>` | `getInstructions()` Get both the `TraversalSource` and `Traversal` instructions of this bytecode.
    `List<Bytecode.Instruction>` | `getSourceInstructions()` Get the `TraversalSource` instructions associated with this bytecode.
    `List<Bytecode.Instruction>` | `getStepInstructions()` Get the `Traversal` instructions associated with this bytecode.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Bytecode

          public Bytecode()

  - ### Method Detail

    - #### addSource

          public void addSource(String sourceName,
                                Object... arguments)

      Add a `TraversalSource` instruction to the bytecode.
      Parameters:
        `sourceName` - the traversal source method name (e.g. withSack())
        `arguments` - the traversal source method arguments

    - #### addStep

          public void addStep(String stepName,
                              Object... arguments)

      Add a `Traversal` instruction to the bytecode.
      Parameters:
        `stepName` - the traversal method name (e.g. out())
        `arguments` - the traversal method arguments

    - #### getSourceInstructions

          public List<Bytecode.Instruction> getSourceInstructions()

      Get the `TraversalSource` instructions associated with this bytecode.
      Returns:
        an iterable of instructions

    - #### getStepInstructions

          public List<Bytecode.Instruction> getStepInstructions()

      Get the `Traversal` instructions associated with this bytecode.
      Returns:
        an iterable of instructions

    - #### getInstructions

          public Iterable<Bytecode.Instruction> getInstructions()

      Get both the `TraversalSource` and `Traversal` instructions of this bytecode. The traversal source instructions are provided prior to the traversal instructions.
      Returns:
        an interable of all the instructions in this bytecode

    - #### getBindings

          public Map<String,Object> getBindings()

      Get all the bindings (in a nested, recursive manner) from all the arguments of all the instructions of this bytecode.
      Returns:
        a map of string variable and object value bindings

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object object)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### clone

          public Bytecode clone()

      Overrides:
        `clone` in class `Object`

Copyright © 2013–2018 Apache Software Foundation. All rights reserved.