Class CompiledBlockVisitor

java.lang.Object
com.igormaznitsa.jbbp.compiler.conversion.CompiledBlockVisitor
Direct Known Subclasses:
JBBPToJavaConverter

public class CompiledBlockVisitor extends Object
Visitor implements Template pattern to visitSpecial all fields of compiled parser data block.
Since:
1.3.0
  • Field Details

    • compiledBlock

      protected final JBBPCompiledBlock compiledBlock
      Compiled block to be processed, must not be null.
    • parserFlags

      protected final int parserFlags
      Parser flags to be used for the translation.
  • Constructor Details

    • CompiledBlockVisitor

      public CompiledBlockVisitor(int parserFlags, JBBPCompiledBlock notNullCompiledBlock)
      The Constructor.
      Parameters:
      parserFlags - parser flags
      notNullCompiledBlock - compiled parser data block, must not be null
  • Method Details

    • isFlagSkipRemainingFieldsIfEOF

      protected boolean isFlagSkipRemainingFieldsIfEOF()
      Auxiliary function to check that parser flag to skip remaining fields without exception is set.
      Returns:
      true if FLAG_SKIP_REMAINING_FIELDS_IF_EOF flag is set, false otherwise
    • visit

      public final CompiledBlockVisitor visit()
      The Main method of the class, it processes compiled block and make calls to template methods.
      Returns:
      the instance of the visitor, must not be null
    • visitActionItem

      public void visitActionItem(int offsetInCompiledBlock, int actionType, JBBPIntegerValueEvaluator nullableArgument)
      Visit an action item (like skip, align or reset counter command)
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      actionType - the action type
      nullableArgument - argument for action, it can be null
      See Also:
    • visitValField

      public void visitValField(int offsetInCompiledBlock, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nameFieldInfo, JBBPIntegerValueEvaluator expression)
      Visit field contains virtual field defined through VAL type.
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      byteOrder - byteOrder
      nameFieldInfo - name of the field, must not be null
      expression - expression to calculate value
      Since:
      1.4.0
    • visitPrimitiveField

      public void visitPrimitiveField(int offsetInCompiledBlock, int primitiveType, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStreamAsArray, boolean altFieldType, JBBPIntegerValueEvaluator nullableArraySize)
      Visit a primitive data field
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      primitiveType - the primitive type
      nullableNameFieldInfo - field info, null if the field is anonymous one
      byteOrder - byte order for the field, must not be null
      readWholeStreamAsArray - if true then it is an array with unknown size till the stream end
      altFieldType - flag shows that field type is alternative one, INT should be recognized as FLOAT and LONG as DOUBLE and BOOL as STRING
      nullableArraySize - array size if the field is array, null if the field is not array or variable length array
      See Also:
    • visitVarField

      public void visitVarField(int offsetInCompiledBlock, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPIntegerValueEvaluator nullableArraySize, JBBPIntegerValueEvaluator extraDataValue)
      Visit a variable field (which is defined with var data type)
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      nullableNameFieldInfo - field info, null if the field is anonymous one
      byteOrder - byte order for the field, must not be null
      readWholeStream - true if whole stream should be read as array of var type, false otherwise
      nullableArraySize - if not null then evaluator of array size to be read from stream
      extraDataValue - if not null then extra data evaluator for the var field
    • visitCustomField

      public void visitCustomField(int offsetInCompiledBlock, JBBPFieldTypeParameterContainer notNullFieldType, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPIntegerValueEvaluator nullableArraySize, JBBPIntegerValueEvaluator extraDataValue)
      Visit a custom type field.
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      notNullFieldType - field type info, must not be null
      nullableNameFieldInfo - field info, null if the field is anonymous one
      byteOrder - byte order for the field, must not be null
      readWholeStream - true if whole stream should be read as array of var type, false otherwise
      nullableArraySize - if not null then evaluator of array size to be read from stream
      extraDataValue - if not null then extra data evaluator for the var field
    • visitBitField

      public void visitBitField(int offsetInCompiledBlock, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNameFieldInfo, boolean readWholeStream, JBBPIntegerValueEvaluator notNullFieldSize, JBBPIntegerValueEvaluator nullableArraySize)
      Visit a custom type field.
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      byteOrder - byte order for the field, must not be null
      nullableNameFieldInfo - field info, null if the field is anonymous one
      readWholeStream - true if whole stream should be read as array of var type, false otherwise
      notNullFieldSize - evaluator to calculate size of the field, must not be null
      nullableArraySize - if not null then evaluator of array size to be read from stream
    • visitStructureStart

      public void visitStructureStart(int offsetInCompiledBlock, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPIntegerValueEvaluator nullableArraySize)
      Visit a structure field.
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      byteOrder - byte order for the field, must not be null
      readWholeStream - true if whole stream should be read as array of var type, false otherwise
      nullableNameFieldInfo - field info, null if the field is anonymous one
      nullableArraySize - if not null then evaluator of array size to be read from stream
    • visitStructureEnd

      public void visitStructureEnd(int offsetInCompiledBlock, JBBPNamedFieldInfo nullableNameFieldInfo)
      End visit of a structure
      Parameters:
      offsetInCompiledBlock - offset in the compiled block
      nullableNameFieldInfo - field info, null if the field is anonymous one
    • visitStart

      public void visitStart()
      Called before visit of each item.
    • visitEnd

      public void visitEnd()
      Called after visit each item.