Package com.igormaznitsa.jbbp.utils
Class JBBPDslBuilder
java.lang.Object
com.igormaznitsa.jbbp.utils.JBBPDslBuilder
Auxiliary builder to build string JBBP script through sequent method call.
NB! The Builder generates JBBP string script which can be compiled by parser!
- Since:
- 1.4.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classInternal auxiliary class to keep found annotated fields.protected static classprotected static classprotected static classprotected static classprotected static classprotected static classprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JBBPByteOrderThe Variable contains current byte order for all next fields.protected final List<JBBPDslBuilder.Item> The List contains items added into builder.protected intValue contains number of currently opened structures. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor is private one because can't be called directly. -
Method Summary
Modifier and TypeMethodDescriptionprotected JBBPDslBuilderaddAnnotatedClass(Class<?> annotatedClass, boolean onlyFields) protected voidaddItem(JBBPDslBuilder.Item item) Align()Add 'align' directive with default value (1 byte).Align(int alignBytes) Add 'align' directive.Add 'align' directive with size calculated by expression.AnnotatedClass(Class<?> annotatedClass) Convert an annotated class into its JBBP DSL representation.AnnotatedClassFields(Class<?> annotatedClass) Add just fields of annotated class, outbound class will not be added as structure.protected StringarraySizeToString(int size) Auxiliary method to convert numeric value into array size expression.protected static StringassertExpressionChars(String expression) protected static StringassertNameIfNotNull(String name) protected static intassertNotNegativeAndZero(int value) protected static Stringstatic JBBPDslBuilderBegin()Create new builder.Bit()Add anonymous single bit field.Add named single bit field.BitArray(JBBPBitNumber bits, int size) Add anonymous fixed length bit array.BitArray(JBBPBitNumber bits, String sizeExpression) Add anonymous bit array with size calculated through expression.BitArray(String name, JBBPBitNumber bits, int size) Add named fixed length bit array.BitArray(String name, JBBPBitNumber bits, String sizeExpression) Add named bit array with size calculated through expression.Add anonymous bit array with size calculated through expression.Add named fixed length bit array, size of one bit field is calculated by expression.Add named bit array where each bit length is calculated through expression.Bits(int bits) Add anonymous fixed size bit field.Bits(JBBPBitNumber bits) Add anonymous fixed size bit field.Bits(String name, JBBPBitNumber bits) Add named fixed length bit field.Add named bit field which length calculated by expression.Bool()Add an anonymous boolean field.Add named boolean field.BoolArray(int size) Add anonymous fixed size boolean array.Add anonymous boolean array with size calculated through expression.Add named fixed size boolean array.Add named boolean array which length calculated through expression.Byte()Add anonymous signed byte field.Add named signed byte field.ByteArray(int size) Add anonymous fixed size byte array.Add anonymous byte array which size calculated through expression.Add named fixed size byte array.Add named byte array which size calculated through expression.ByteOrder(JBBPByteOrder order) Set byte order for next fieldsAdd directive to close currently opened structure or a structure array.CloseStruct(boolean closeAllOpened) Add directive to close currently opened structure or all opened structures.protected JBBPDslBuilder.BinFieldContainercollectAnnotatedFields(Class<?> annotatedClass) Allows to collect all fields which can be used for scripting.Add comment, in case that a field followed by the comment, the comment will be placed on the same line as field definition.Add anonymous custom variable.Add named custom variable.Add named parametric custom variable.CustomArray(String type, int size) Create anonymous custom type array with fixed size.CustomArray(String type, String size) Create anonymous custom type array with fixed size.CustomArray(String type, String name, int size) Create named custom type array with fixed size.CustomArray(String type, String name, int size, String param) Create named custom type array which size calculated by expression.CustomArray(String type, String name, String size) Create named custom type array with fixed size.CustomArray(String type, String name, String sizeExpression, String param) Create named custom type array which size calculated by expression.protected static StringBuilderdoTabs(boolean enable, StringBuilder buffer, int tabs) Double()Add anonymous double field.Add named double field.DoubleArray(int size) Add anonymous fixed size double array field.DoubleArray(String sizeExpression) Add anonymous double array field which size calculated trough expression.DoubleArray(String name, int size) Add named fixed size double array field.DoubleArray(String name, String sizeExpression) Add named double array field which size calculated trough expression.End()Build non-formatted script.End(boolean format) Build a formatted script.Float()Add anonymous float field.Add named float fieldFloatArray(int size) Add anonymous fixed size float array.FloatArray(String sizeExpression) Add anonymous float array which size calculated through expression.FloatArray(String name, int size) Add named fixed size float array.FloatArray(String name, String sizeExpression) Add named float array which size calculated through expression.booleanAllows to check that there is an opened structure.Int()Add anonymous integer field.Add named integer field.IntArray(int size) Add anonymous fixed size integer array.Add anonymous integer array with size calculated through expression.Add named fixed size integer array.Add named integer array with size calculated through expression.Long()Add anonymous long field.Add named long field.LongArray(int size) Add anonymous fixed size long array.Add anonymous long array which size calculated through expression.Add named fixed size long array field.Add named long array which size calculated through expression.NewLineComment(String text) Add comment which will be placed on new line.Add command to reset counter of the current read stream.Short()Added anonymous signed short field.Add named signed short field.ShortArray(int size) Add anonymous fixed size signed short array.ShortArray(String sizeExpression) Add anonymous signed short array which size calculated through expression.ShortArray(String name, int size) Add named fixed size signed short array.ShortArray(String name, String sizeExpression) Add named fixed signed short array which size calculated through expression.intsize()Get number of items added into internal item list.Skip()Add 'skip' directive with default value as one byte.Skip(int bytesToSkip) Add 'skip' directive with number of bytes to be skipped.Add 'skip' directive with number of bytes to be skipped, their number calculated through expression.String()Add anonymous string field.Add named string field.StringArray(int size) Add anonymous fixed size string array.StringArray(String sizeExpression) Add anonymous string array which size calculated through expression.StringArray(String name, int size) Add named fixed size string array.StringArray(String name, String sizeExpression) Add named string array which size calculated through expression.Struct()Create new anonymous struct.Create new named struct.StructArray(int size) Create anonymous fixed size structure array.StructArray(String sizeExpression) Create anonymous structure array which size calculated by expression.StructArray(String name, int size) Create named fixed length structure array.StructArray(String name, String sizeExpression) Create named structure array which size calculated by expression.UByte()Add anonymous unsigned byte field.Add named unsigned byte field.UByteArray(int size) Add anonymous fixed size unsigned byte array.UByteArray(String sizeExpression) Added anonymous unsigned byte array which size calculated through expression.UByteArray(String name, int size) Add named fixed size unsigned byte array.UByteArray(String name, String sizeExpression) Add named unsigned byte array which size calculated through expression.UInt()Add anonymous unsigned int field.Add named unsigned int field.UIntArray(int size) Add anonymous fixed size unsigned int array field.Add named fixed size unsigned int array field.Add named unsigned integer array field which size calculated trough expression.UShort()Add anonymous unsigned short field.Add named unsigned short field.UShortArray(int size) Add anonymous fixed size unsigned short array.UShortArray(String sizeExpression) Add anonymous unsigned short array which size calculated through expression.UShortArray(String name, int size) Add named fixed size unsigned short array.UShortArray(String name, String sizeExpression) Add named fixed unsigned short array which size calculated through expression.Add virtual field which not be read but its value will be calculated by expressionVar()Add var anonymous field.Add named var field.Add named var field.VarArray(int size) Create anonymous var array with fixed size.Create anonymous var array with size calculated through expression.Create named var array with fixed size.Create named var array with fixed size.Create named var array with fixed size.Create named var array with fixed size.
-
Field Details
-
items
The List contains items added into builder. -
byteOrder
The Variable contains current byte order for all next fields. -
openedStructCounter
protected int openedStructCounterValue contains number of currently opened structures.
-
-
Constructor Details
-
JBBPDslBuilder
protected JBBPDslBuilder()Constructor is private one because can't be called directly.
-
-
Method Details
-
Begin
Create new builder.- Returns:
- the new instance of builder, must not be null
-
assertTextNotNullAndTrimmedNotEmpty
-
assertNameIfNotNull
-
assertExpressionChars
-
assertNotNegativeAndZero
protected static int assertNotNegativeAndZero(int value) -
doTabs
-
addItem
-
size
public int size()Get number of items added into internal item list.- Returns:
- number of added items
-
arraySizeToString
Auxiliary method to convert numeric value into array size expression.- Parameters:
size- size to be converted- Returns:
- string contains expression which can be used as array size. must not be null
-
Align
Add 'align' directive with default value (1 byte).- Returns:
- the builder instance, must not be null
-
Align
Add 'align' directive.- Parameters:
alignBytes- number of bytes to be aligned, must not be zero or negative one- Returns:
- the builder instance, must not be null
- Throws:
IllegalArgumentException- if value is not acceptable
-
Align
Add 'align' directive with size calculated by expression.- Parameters:
sizeExpression- expression to be calculated to get align size, must not be null- Returns:
- the builder instance, must not be null
-
Skip
Add 'skip' directive with default value as one byte.- Returns:
- the builder instance, must not be null
-
Skip
Add 'skip' directive with number of bytes to be skipped.- Parameters:
bytesToSkip- number of bytes to be skipped, must not be zero or negative one- Returns:
- the builder instance, must not be null
- Throws:
IllegalArgumentException- if value is not acceptable
-
Skip
Add 'skip' directive with number of bytes to be skipped, their number calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate number of bytes, must not be null- Returns:
- the builder instance, must not be null
-
Custom
Add anonymous custom variable.- Parameters:
type- custom type, must not be null- Returns:
- the builder instance, must not be null
-
Var
Add var anonymous field.- Returns:
- the builder instance, must not be null
-
Var
Add named var field.- Parameters:
name- name of the field, can be null- Returns:
- the builder instance, must not be null
-
Var
Add named var field.- Parameters:
name- name of the field, can be nullparam- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
Custom
Add named custom variable.- Parameters:
type- custom type, must not be nullname- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
Custom
Add named parametric custom variable.- Parameters:
type- custom type, must not be nullname- name of the field, can be null for anonymousparam- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
Struct
Create new anonymous struct.- Returns:
- the builder instance, must not be null
-
Struct
Create new named struct.- Parameters:
name- name of structure, it can be null for anonymous one- Returns:
- the builder instance, must not be null
-
StructArray
Create anonymous structure array which size calculated by expression.- Parameters:
sizeExpression- expression to calculate array length, must not be null.- Returns:
- the builder instance, must not be null
-
StructArray
Create anonymous fixed size structure array.- Parameters:
size- fixed size of the array, if negative one then read all steam until the end- Returns:
- the builder instance, must not be null
-
StructArray
Create named fixed length structure array.- Parameters:
name- name of the structure array, can be null for anonymous onesize- fixed size of the array, if negative one then read all steam until the end- Returns:
- the builder instance, must not be null
-
StructArray
Create named structure array which size calculated by expression.- Parameters:
name- name of the structure array, can be null for anonymous onesizeExpression- expression to calculate array length, must not be null.- Returns:
- the builder instance, must not be null
-
Val
Add virtual field which not be read but its value will be calculated by expression- Parameters:
name- name of the value, it must not be null or emptyexpression- expression to calculate value, it must not be null or empty- Returns:
- the builder instance, must not be null
-
ResetCounter
Add command to reset counter of the current read stream.- Returns:
- the builder instance, must not be null
- See Also:
-
VarArray
Create anonymous var array with fixed size.- Parameters:
size- size of the array, if negative then read till end of stream.- Returns:
- the builder instance, must not be null
-
VarArray
Create anonymous var array with size calculated through expression.- Parameters:
sizeExpression- expression to calculate size.- Returns:
- the builder instance, must not be null
-
VarArray
Create named var array with fixed size.- Parameters:
name- name of the array, can be null for anonymous onesize- size of the array, if negative then read till end of stream.- Returns:
- the builder instance, must not be null
-
VarArray
Create named var array with fixed size.- Parameters:
name- name of the array, can be null for anonymous onesizeExpression- expression to calculate size of the array, must not be null.- Returns:
- the builder instance, must not be null
-
VarArray
Create named var array with fixed size.- Parameters:
name- name of the array, can be null for anonymous onesize- size of array, it can be negative if to read stream till end.param- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
VarArray
Create named var array with fixed size.- Parameters:
name- name of the array, can be null for anonymous onesizeExpression- expression to calculate size of the array, must not be null.param- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
CustomArray
Create anonymous custom type array with fixed size.- Parameters:
type- custom type, must not be nullsize- size of the array, if less than zero then read till end of stream.- Returns:
- the builder instance, must not be null
-
CustomArray
Create anonymous custom type array with fixed size.- Parameters:
type- custom type, must not be nullsize- expression to calculate size of the array, must not be null.- Returns:
- the builder instance, must not be null
-
CustomArray
Create named custom type array with fixed size.- Parameters:
type- custom type, must not be nullname- name of the array, can be null for anonymous onesize- expression to calculate size of the array, must not be null.- Returns:
- the builder instance, must not be null
-
CustomArray
Create named custom type array with fixed size.- Parameters:
type- custom type, must not be nullname- name of the array, can be null for anonymous onesize- size of the array, if less than zero then read till end of stream.- Returns:
- the builder instance, must not be null
-
CustomArray
Create named custom type array which size calculated by expression.- Parameters:
type- custom type, must not be nullname- name of the array, can be null for anonymous onesize- size of the array, if negative then read till the end of stream.param- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
CustomArray
Create named custom type array which size calculated by expression.- Parameters:
type- custom type, must not be nullname- name of the array, can be null for anonymous onesizeExpression- expression to calculate array length, must not be null.param- optional parameter for the field, can be null- Returns:
- the builder instance, must not be null
-
CloseStruct
Add directive to close currently opened structure or a structure array.- Returns:
- the builder instance, must not be null
- Throws:
IllegalStateException- if there is not any opened struct
-
CloseStruct
Add directive to close currently opened structure or all opened structures.- Parameters:
closeAllOpened- flag to close all opened structures if true, false if close only last opened structure- Returns:
- the builder instance, must not be null
- Throws:
IllegalStateException- if there is not any opened struct
-
hasOpenedStructs
public boolean hasOpenedStructs()Allows to check that there is an opened structure.- Returns:
- true if there is any opened structure, false otherwise.
-
Bit
Add anonymous single bit field.- Returns:
- the builder instance, must not be null
-
Bit
Add named single bit field.- Parameters:
name- name of the field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
Bits
Add anonymous fixed size bit field.- Parameters:
bits- , number of bits 1..7- Returns:
- the builder instance, must not be null
-
Bits
Add anonymous fixed size bit field.- Parameters:
bits- , number of bits- Returns:
- the builder instance, must not be null
-
Bits
Add named fixed length bit field.- Parameters:
name- name of the field, if null then anonymous onebits- number of bits as length of the field, must not be null- Returns:
- the builder instance, must not be null
-
Bits
Add named bit field which length calculated by expression.- Parameters:
name- name of the field, if null then anonymous onebitLenExpression- expression to calculate number of bits, must not be null- Returns:
- the builder instance, must not be null
-
BitArray
Add anonymous fixed length bit array.- Parameters:
bits- length of the field, must not be nullsize- number of elements in array, if negative then till the end of stream- Returns:
- the builder instance, must not be null
-
BitArray
Add named fixed length bit array.- Parameters:
name- name of the array, if null then anonymous onebits- length of the field, must not be nullsize- number of elements in array, if negative then till the end of stream- Returns:
- the builder instance, must not be null
-
BitArray
Add named fixed length bit array, size of one bit field is calculated by expression.- Parameters:
name- name of the array, if null then anonymous onebitLenExpression- expression to calculate length of the bit field, must not be nullsize- number of elements in array, if negative then till the end of stream- Returns:
- the builder instance, must not be null
-
BitArray
Add anonymous bit array with size calculated through expression.- Parameters:
bits- length of the field, must not be nullsizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
BitArray
Add anonymous bit array with size calculated through expression.- Parameters:
bitLenExpression- expression to calculate length of the bit field, must not be nullsizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
BitArray
Add named bit array with size calculated through expression.- Parameters:
name- name of the array, if null then anonymous onebits- length of the field, must not be nullsizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
BitArray
Add named bit array where each bit length is calculated through expression.- Parameters:
name- name of the array, if null then anonymous onebitLenExpression- expression to calculate length of the bit field, must not be nullsizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
BoolArray
Add anonymous boolean array with size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
BoolArray
Add named fixed size boolean array.- Parameters:
name- name of the array, it can be null for anonymous onesize- number of elements in array, if negative then till the end of stream- Returns:
- the builder instance, must not be null
-
BoolArray
Add anonymous fixed size boolean array.- Parameters:
size- number of elements in array, if negative then till the end of stream- Returns:
- the builder instance, must not be null
-
BoolArray
Add named boolean array which length calculated through expression.- Parameters:
name- name of the array, it can be null for anonymous onesizeExpression- expression to calculate number of elements, must not be null- Returns:
- the builder instance, must not be null
-
Bool
Add an anonymous boolean field.- Returns:
- the builder instance, must not be null
-
Bool
Add named boolean field.- Parameters:
name- name of the field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
Byte
Add anonymous signed byte field.- Returns:
- the builder instance, must not be null
-
Byte
Add named signed byte field.- Parameters:
name- name of the field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
ByteArray
Add anonymous byte array which size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate array length, must not be null or empty.- Returns:
- the builder instance, must not be null
-
ByteArray
Add anonymous fixed size byte array.- Parameters:
size- size of the array, if negative then read stream till the end.- Returns:
- the builder instance, must not be null
-
ByteArray
Add named fixed size byte array.- Parameters:
name- name of the array, it can be null fo anonymous fieldssize- size of the array, if negative then read stream till the end.- Returns:
- the builder instance, must not be null
-
ByteArray
Add named byte array which size calculated through expression.- Parameters:
name- name of the array, it can be null for anonymous fieldssizeExpression- expression to be used to calculate array length, must not be null or empty.- Returns:
- the builder instance, must not be null
-
UByte
Add anonymous unsigned byte field.- Returns:
- the builder instance, must not be null
-
UByte
Add named unsigned byte field.- Parameters:
name- name of the field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
UByteArray
Added anonymous unsigned byte array which size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate size, must not be null or empty- Returns:
- the builder instance, must not be null
-
UByteArray
Add anonymous fixed size unsigned byte array.- Parameters:
size- size of the array, if negative then read stream till the end.- Returns:
- the builder instance, must not be null
-
UByteArray
Add named fixed size unsigned byte array.- Parameters:
name- name of the field, it can be null for anonymous onesize- size of the array, if negative then read stream till the end.- Returns:
- the builder instance, must not be null
-
UByteArray
Add named unsigned byte array which size calculated through expression.- Parameters:
name- name of the field, it can be null for anonymous onesizeExpression- expression to calculate array size, must ot be null or empty.- Returns:
- the builder instance, must not be null
-
Short
Added anonymous signed short field.- Returns:
- the builder instance, must not be null
-
Short
Add named signed short field.- Parameters:
name- name of the field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
ShortArray
Add anonymous signed short array which size calculated through expression.- Parameters:
sizeExpression- expression to be used for calculation, must not be null- Returns:
- the builder instance, must not be null
-
ShortArray
Add anonymous fixed size signed short array.- Parameters:
size- size of the array, if negative then stream will be read till end- Returns:
- the builder instance, must not be null
-
ShortArray
Add named fixed size signed short array.- Parameters:
name- name of the field, if null then anonymoussize- size of the array, if negative then stream will be read till end- Returns:
- the builder instance, must not be null
-
ShortArray
Add named fixed signed short array which size calculated through expression.- Parameters:
name- name of the field, if null then anonymoussizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
UShort
Add anonymous unsigned short field.- Returns:
- the builder instance, must not be null
-
UShort
Add named unsigned short field.- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
UShortArray
Add anonymous unsigned short array which size calculated through expression.- Parameters:
sizeExpression- expression to be used for calculation, must not be null- Returns:
- the builder instance, must not be null
-
UShortArray
Add anonymous fixed size unsigned short array.- Parameters:
size- sizeof the array, if negative then read till the end of stream- Returns:
- the builder instance, must not be null
-
UShortArray
Add named fixed unsigned short array which size calculated through expression.- Parameters:
name- name of the field, if null then anonymoussizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
UShortArray
Add named fixed size unsigned short array.- Parameters:
name- name of the field, if null then anonymoussize- size of the array, if negative then stream will be read till end- Returns:
- the builder instance, must not be null
-
Int
Add anonymous integer field.- Returns:
- the builder instance, must not be null
-
Int
Add named integer field.- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
IntArray
Add anonymous integer array with size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
IntArray
Add anonymous fixed size integer array.- Parameters:
size- size of the array, if negative then read stream till the end- Returns:
- the builder instance, must not be null
-
IntArray
Add named fixed size integer array.- Parameters:
name- name of field, it can be null for anonymoussize- size of the array, if negative then read stream till the end- Returns:
- the builder instance, must not be null
-
IntArray
Add named integer array with size calculated through expression.- Parameters:
name- name of field, can be nul for anonymoussizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
Long
Add anonymous long field.- Returns:
- the builder instance, must not be null
-
Long
Add named long field.- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
LongArray
Add anonymous long array which size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
LongArray
Add anonymous fixed size long array.- Parameters:
size- size of array, if negative then read till stream end- Returns:
- the builder instance, must not be null
-
LongArray
Add named fixed size long array field.- Parameters:
name- name of field, can be null for anonymoussize- size of array, if negative then read till stream end- Returns:
- the builder instance, must not be null
-
LongArray
Add named long array which size calculated through expression.- Parameters:
name- name of the field, can be null for anonymoussizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
Float
Add anonymous float field.- Returns:
- the builder instance, must not be null
-
Float
Add named float field- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
FloatArray
Add anonymous float array which size calculated through expression.- Parameters:
sizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
FloatArray
Add anonymous fixed size float array.- Parameters:
size- size of array, if negative then read till stream end- Returns:
- the builder instance, must not be null
-
FloatArray
Add named fixed size float array.- Parameters:
name- name of field, null for anonymoussize- size of array, read till stream end if negative- Returns:
- the builder instance, must not be null
-
FloatArray
Add named float array which size calculated through expression.- Parameters:
name- name of the field, can be null for anonymoussizeExpression- expression to be used to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
Double
Add anonymous double field.- Returns:
- the builder instance, must not be null
-
UInt
Add anonymous unsigned int field.- Returns:
- the builder instance, must not be null
- Since:
- 2.0.4
-
Double
Add named double field.- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
-
UInt
Add named unsigned int field.- Parameters:
name- name of the field, can be null for anonymous- Returns:
- the builder instance, must not be null
- Since:
- 2.0.4
-
Comment
Add comment, in case that a field followed by the comment, the comment will be placed on the same line as field definition.- Parameters:
text- text of comment, can be null- Returns:
- the builder instance, must not be null
-
NewLineComment
Add comment which will be placed on new line.- Parameters:
text- text of comment, can be null- Returns:
- the builder instance, must not be null
- Since:
- 1.4.1
-
DoubleArray
Add anonymous double array field which size calculated trough expression.- Parameters:
sizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
DoubleArray
Add anonymous fixed size double array field.- Parameters:
size- size of the array, if negative then read till end of stream- Returns:
- the builder instance, must not be null
-
UIntArray
Add anonymous fixed size unsigned int array field.- Parameters:
size- size of the array, if negative then read till end of stream- Returns:
- the builder instance, must not be null
- Since:
- 2.0.4
-
DoubleArray
Add named fixed size double array field.- Parameters:
name- ame of the field, can be null for anonymoussize- size of the array, if negative then read till end of stream- Returns:
- the builder instance, must not be null
-
UIntArray
Add named unsigned integer array field which size calculated trough expression.- Parameters:
name- name of the field, can be null for anonymoussizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
- Since:
- 2.0.4
-
DoubleArray
Add named double array field which size calculated trough expression.- Parameters:
name- name of the field, can be null for anonymoussizeExpression- expression to be used to calculate array size, must not be null- Returns:
- the builder instance, must not be null
-
UIntArray
Add named fixed size unsigned int array field.- Parameters:
name- ame of the field, can be null for anonymoussize- size of the array, if negative then read till end of stream- Returns:
- the builder instance, must not be null
- Since:
- 2.0.4
-
String
Add anonymous string field.- Returns:
- the builder instance, must not be null
-
String
Add named string field.- Parameters:
name- name of field, can be null for anonymous one- Returns:
- the builder instance, must not be null
-
StringArray
Add anonymous string array which size calculated through expression.- Parameters:
sizeExpression- expression to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
StringArray
Add anonymous fixed size string array.- Parameters:
size- size of array, if negative then read till stream end- Returns:
- the builder instance, must not be null
-
StringArray
Add named fixed size string array.- Parameters:
name- name of field, can be null for anonymoussize- size of array, if negative then read till stream end- Returns:
- the builder instance, must not be null
-
StringArray
Add named string array which size calculated through expression.- Parameters:
name- name of field, can be null for anonymoussizeExpression- expression to calculate size, must not be null- Returns:
- the builder instance, must not be null
-
ByteOrder
Set byte order for next fields- Parameters:
order- order, if null then BIG_ENDIAN- Returns:
- the builder instance, must not be null
-
End
Build non-formatted script.- Returns:
- script in non-formatted form, must not be null
- Throws:
IllegalStateException- if there is an unclosed struct
-
End
Build a formatted script.- Parameters:
format- if true then make some formatting of result, false if non-formatted version allowed- Returns:
- script in formatted form, must not be null
- Throws:
IllegalStateException- if there is an unclosed struct
-
collectAnnotatedFields
Allows to collect all fields which can be used for scripting.- Parameters:
annotatedClass- class to be processed, must not be null- Returns:
- container which contains all found items
-
AnnotatedClass
Convert an annotated class into its JBBP DSL representation. NB! the method creates structure bases on class name, so that it can't be used for auto-mapping if you want use auto-mapping, useAnnotatedClassFields(Class)- Parameters:
annotatedClass- class to be converted into JBBP script, must not be null- Returns:
- the builder instance, must not be null
- See Also:
-
AnnotatedClassFields
Add just fields of annotated class, outbound class will not be added as structure. The Method allows to prepare script which will be able make mapping of field values- Parameters:
annotatedClass- class to be converted into JBBP script, must not be null- Returns:
- the builder instance, must not be null
- See Also:
-
addAnnotatedClass
-