Package com.igormaznitsa.jbbp.model
Class JBBPFieldBit
java.lang.Object
com.igormaznitsa.jbbp.model.JBBPAbstractField
com.igormaznitsa.jbbp.model.JBBPFieldBit
- All Implemented Interfaces:
BitEntity,JBBPInvertableBitOrder,JBBPNamedField,JBBPNumericField,Serializable
Describes a bit field.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields inherited from class com.igormaznitsa.jbbp.model.JBBPAbstractField
fieldNameInfo, payload -
Constructor Summary
ConstructorsConstructorDescriptionJBBPFieldBit(JBBPNamedFieldInfo name, int value, JBBPBitNumber bitNumber) The Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the field value as boolean, usually if the value is 0 then false, true otherwise.doubleGet the field value as double.floatGet the field value as float.intgetAsInt()Get the field value as integer.longGet the value in inverted bit order.longGet the field value as longGet number of valuable bits in the value.Get the field type in string representation.static longreverseBits(byte value, JBBPBitNumber bits) Get the reversed bit representation of the value.Methods inherited from class com.igormaznitsa.jbbp.model.JBBPAbstractField
getFieldName, getFieldPath, getNameInfo, getPayload, setPayloadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.igormaznitsa.jbbp.model.JBBPNamedField
getNameInfo
-
Constructor Details
-
JBBPFieldBit
The Constructor.- Parameters:
name- a field name info, it can be null.value- the field valuebitNumber- number of valuable bits in the value, must not be null
-
-
Method Details
-
reverseBits
Get the reversed bit representation of the value.- Parameters:
value- the value to be reversedbits- number of bits to be reversed, must not be null- Returns:
- the reversed value
-
getBitWidth
Get number of valuable bits in the value. It plays informative role and doesn't play role during numeric value getting.- Specified by:
getBitWidthin interfaceBitEntity- Returns:
- the number of valuable bits in the value.
-
getAsDouble
public double getAsDouble()Description copied from interface:JBBPNumericFieldGet the field value as double.- Specified by:
getAsDoublein interfaceJBBPNumericField- Returns:
- the field value as double
-
getAsFloat
public float getAsFloat()Description copied from interface:JBBPNumericFieldGet the field value as float.- Specified by:
getAsFloatin interfaceJBBPNumericField- Returns:
- the field value as float
-
getAsInt
public int getAsInt()Description copied from interface:JBBPNumericFieldGet the field value as integer.- Specified by:
getAsIntin interfaceJBBPNumericField- Returns:
- the field value as integer
-
getAsLong
public long getAsLong()Description copied from interface:JBBPNumericFieldGet the field value as long- Specified by:
getAsLongin interfaceJBBPNumericField- Returns:
- the field value as long
-
getAsBool
public boolean getAsBool()Description copied from interface:JBBPNumericFieldGet the field value as boolean, usually if the value is 0 then false, true otherwise.- Specified by:
getAsBoolin interfaceJBBPNumericField- Returns:
- the field value as boolean
-
getAsInvertedBitOrder
public long getAsInvertedBitOrder()Description copied from interface:JBBPInvertableBitOrderGet the value in inverted bit order.- Specified by:
getAsInvertedBitOrderin interfaceJBBPInvertableBitOrder- Returns:
- the value in inverted bit order
-
getTypeAsString
Description copied from class:JBBPAbstractFieldGet the field type in string representation.- Specified by:
getTypeAsStringin classJBBPAbstractField- Returns:
- the string representation of field type, like 'int', 'long', 'bool [123]'
-