public class BitFieldAdapter extends Object implements FieldAdapter
Constructor and Description |
---|
BitFieldAdapter(boolean isSigned)
Creates a new bit field adapter with given signed-ness.
|
Modifier and Type | Method and Description |
---|---|
BigInteger |
getBigInteger(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java BigInteger.
|
byte |
getByte(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java byte.
|
double |
getDouble(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java double.
|
float |
getFloat(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java float.
|
int |
getInt(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java int.
|
long |
getLong(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java long.
|
short |
getShort(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java short.
|
String |
getString(byte[] buf,
int offset,
int length,
int startBit,
int stopBit)
Gets the field value as a Java string, using the US-ASCII
character set to convert from bytes to characters.
|
String |
getString(byte[] buf,
int offset,
int length,
int startBit,
int stopBit,
Charset charset)
Gets the field value as a Java string, using a specified
character set to convert from bytes to characters.
|
void |
setBigInteger(BigInteger value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustified)
Sets the field value as a Java BigInteger.
|
void |
setByte(byte value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java byte.
|
void |
setDouble(double value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java double.
|
void |
setFloat(float value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java float.
|
void |
setInt(int value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java int.
|
void |
setLong(long value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java long.
|
void |
setShort(short value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed)
Sets the field value as a Java short.
|
void |
setString(String value,
int offset,
int length,
ByteBuffer buf,
boolean isRightJustifed)
Sets the field value as a Java string.
|
void |
setString(String value,
int offset,
int length,
ByteBuffer buffer,
boolean isRightJustifed,
Charset charset)
Sets the field value as a Java string, using a specified
character set to convert from characters to bytes.
|
public BitFieldAdapter(boolean isSigned)
isSigned
- true, if the bit field is signedpublic String getString(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getString
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic String getString(byte[] buf, int offset, int length, int startBit, int stopBit, Charset charset)
FieldAdapter
getString
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldscharset
- the character set to use when converting bytes to characterspublic byte getByte(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getByte
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic short getShort(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getShort
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic int getInt(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getInt
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic long getLong(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getLong
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic float getFloat(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getFloat
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic double getDouble(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getDouble
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldspublic void setString(String value, int offset, int length, ByteBuffer buf, boolean isRightJustifed)
FieldAdapter
setString
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuf
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setString(String value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed, Charset charset)
FieldAdapter
setString
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedcharset
- the character set to use when converting the string to bytespublic void setInt(int value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setInt
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setDouble(double value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setDouble
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setFloat(float value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setFloat
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setShort(short value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setShort
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setByte(byte value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setByte
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic void setLong(long value, int offset, int length, ByteBuffer buffer, boolean isRightJustifed)
FieldAdapter
setLong
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustifed
- true, if the string value should be right-justifiedpublic BigInteger getBigInteger(byte[] buf, int offset, int length, int startBit, int stopBit)
FieldAdapter
getBigInteger
in interface FieldAdapter
buf
- the byte array containing the fieldoffset
- the field offsetlength
- the length of the field datastartBit
- the start bit, for bit fieldsstopBit
- the stop bit, for bit fieldsBigInteger
public void setBigInteger(BigInteger value, int offset, int length, ByteBuffer buffer, boolean isRightJustified)
FieldAdapter
setBigInteger
in interface FieldAdapter
value
- the field valueoffset
- the field offsetlength
- the length of the valuebuffer
- the byte buffer into which to set the valueisRightJustified
- true, if the string value should be right-justifiedCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.