Class CompiledBlockVisitor
java.lang.Object
com.igormaznitsa.jbbp.compiler.conversion.CompiledBlockVisitor
- Direct Known Subclasses:
JBBPToJavaConverter
Visitor implements Template pattern to visitSpecial all fields of compiled parser data block.
- Since:
- 1.3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final JBBPCompiledBlockCompiled block to be processed, must not be null.protected final intParser flags to be used for the translation. -
Constructor Summary
ConstructorsConstructorDescriptionCompiledBlockVisitor(int parserFlags, JBBPCompiledBlock notNullCompiledBlock) The Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAuxiliary function to check that parser flag to skip remaining fields without exception is set.final CompiledBlockVisitorvisit()The Main method of the class, it processes compiled block and make calls to template methods.voidvisitActionItem(int offsetInCompiledBlock, int actionType, JBBPIntegerValueEvaluator nullableArgument) Visit an action item (like skip, align or reset counter command)voidvisitBitField(int offsetInCompiledBlock, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNameFieldInfo, boolean readWholeStream, JBBPIntegerValueEvaluator notNullFieldSize, JBBPIntegerValueEvaluator nullableArraySize) Visit a custom type field.voidvisitCustomField(int offsetInCompiledBlock, JBBPFieldTypeParameterContainer notNullFieldType, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPIntegerValueEvaluator nullableArraySize, JBBPIntegerValueEvaluator extraDataValue) Visit a custom type field.voidvisitEnd()Called after visit each item.voidvisitPrimitiveField(int offsetInCompiledBlock, int primitiveType, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStreamAsArray, boolean altFieldType, JBBPIntegerValueEvaluator nullableArraySize) Visit a primitive data fieldvoidCalled before visit of each item.voidvisitStructureEnd(int offsetInCompiledBlock, JBBPNamedFieldInfo nullableNameFieldInfo) End visit of a structurevoidvisitStructureStart(int offsetInCompiledBlock, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPIntegerValueEvaluator nullableArraySize) Visit a structure field.voidvisitValField(int offsetInCompiledBlock, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nameFieldInfo, JBBPIntegerValueEvaluator expression) Visit field contains virtual field defined through VAL type.voidvisitVarField(int offsetInCompiledBlock, JBBPNamedFieldInfo nullableNameFieldInfo, JBBPByteOrder byteOrder, boolean readWholeStream, JBBPIntegerValueEvaluator nullableArraySize, JBBPIntegerValueEvaluator extraDataValue) Visit a variable field (which is defined with var data type)
-
Field Details
-
compiledBlock
Compiled block to be processed, must not be null. -
parserFlags
protected final int parserFlagsParser flags to be used for the translation.
-
-
Constructor Details
-
CompiledBlockVisitor
The Constructor.- Parameters:
parserFlags- parser flagsnotNullCompiledBlock- 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
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 blockactionType- the action typenullableArgument- 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 blockbyteOrder- byteOrdernameFieldInfo- name of the field, must not be nullexpression- 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 blockprimitiveType- the primitive typenullableNameFieldInfo- field info, null if the field is anonymous onebyteOrder- byte order for the field, must not be nullreadWholeStreamAsArray- if true then it is an array with unknown size till the stream endaltFieldType- flag shows that field type is alternative one, INT should be recognized as FLOAT and LONG as DOUBLE and BOOL as STRINGnullableArraySize- 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 blocknullableNameFieldInfo- field info, null if the field is anonymous onebyteOrder- byte order for the field, must not be nullreadWholeStream- true if whole stream should be read as array of var type, false otherwisenullableArraySize- if not null then evaluator of array size to be read from streamextraDataValue- 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 blocknotNullFieldType- field type info, must not be nullnullableNameFieldInfo- field info, null if the field is anonymous onebyteOrder- byte order for the field, must not be nullreadWholeStream- true if whole stream should be read as array of var type, false otherwisenullableArraySize- if not null then evaluator of array size to be read from streamextraDataValue- 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 blockbyteOrder- byte order for the field, must not be nullnullableNameFieldInfo- field info, null if the field is anonymous onereadWholeStream- true if whole stream should be read as array of var type, false otherwisenotNullFieldSize- evaluator to calculate size of the field, must not be nullnullableArraySize- 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 blockbyteOrder- byte order for the field, must not be nullreadWholeStream- true if whole stream should be read as array of var type, false otherwisenullableNameFieldInfo- field info, null if the field is anonymous onenullableArraySize- if not null then evaluator of array size to be read from stream
-
visitStructureEnd
End visit of a structure- Parameters:
offsetInCompiledBlock- offset in the compiled blocknullableNameFieldInfo- 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.
-