public class Value extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static byte |
FALSE_VALUE
The encoded byte for a FALSE value
|
static byte |
TRUE_VALUE
The encoded byte for a TRUE value
|
| Constructor and Description |
|---|
Value()
The constructor.
|
Value(byte[] value)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addData(byte[] array)
Append some bytes to the data buffer.
|
void |
addData(ByteBuffer buffer)
Append some bytes to the data buffer.
|
static void |
encode(ByteBuffer buffer,
BitString bitString)
Encode a BIT STRING value
|
static void |
encode(ByteBuffer buffer,
boolean bool)
Encode a boolean value
|
static void |
encode(ByteBuffer buffer,
byte[] bytes)
Encode an OctetString value
|
static void |
encode(ByteBuffer buffer,
byte tag,
int value)
Encode an integer value
|
static void |
encode(ByteBuffer buffer,
int value)
Encode an integer value
|
static void |
encode(ByteBuffer buffer,
long value)
Encode a long value
|
static void |
encode(ByteBuffer buffer,
OID oid)
Encode an OID value
|
static void |
encode(ByteBuffer buffer,
String string)
Encode a String value
|
static void |
encodeEnumerated(ByteBuffer buffer,
int value)
Encode an enumerated value
|
static byte[] |
getBytes(int value)
Utility function that return a byte array representing the Value We must
respect the ASN.1 BER encoding scheme :
1) positive integer
- [0 - 0x7F] : 0xVV
- [0x80 - 0xFF] : 0x00 0xVV
- [0x0100 - 0x7FFF] : 0xVV 0xVV
- [0x8000 - 0xFFFF] : 0x00 0xVV 0xVV
- [0x010000 - 0x7FFFFF] : 0xVV 0xVV 0xVV
- [0x800000 - 0xFFFFFF] : 0x00 0xVV 0xVV 0xVV
- [0x01000000 - 0x7FFFFFFF] : 0xVV 0xVV 0xVV 0xVV
2) Negative number - (~value) + 1
|
static byte[] |
getBytes(long value)
Utility function that return a byte array representing the Value.
|
int |
getCurrentLength() |
byte[] |
getData()
Get the Values'data
|
static int |
getNbBytes(int value)
Utility function that return the number of bytes necessary to store an
integer value.
|
static int |
getNbBytes(long value)
Utility function that return the number of bytes necessary to store a
long value.
|
void |
init(int size)
Initialize the Value
|
void |
reset()
Reset the Value so that it can be reused
|
void |
setData(byte[] data)
Set a block of bytes in the Value
|
void |
setData(ByteBuffer data)
Set a block of bytes in the Value
|
String |
toString()
Return a string representing the Value
|
public static final byte TRUE_VALUE
public static final byte FALSE_VALUE
public Value(byte[] value)
value - the associated valuepublic Value()
public void init(int size)
size - The data size to allocate.public void reset()
public byte[] getData()
public void setData(ByteBuffer data)
data - The data to set.public void addData(ByteBuffer buffer)
buffer - The data to append.public void setData(byte[] data)
data - The data to set.public void addData(byte[] array)
array - The data to append.public int getCurrentLength()
public static int getNbBytes(int value)
value - The value to store in a byte arraypublic static int getNbBytes(long value)
value - The value to store in a byte arraypublic static byte[] getBytes(int value)
value - The value to store in a byte arraypublic static byte[] getBytes(long value)
value - The value to store in a byte arraypublic static void encode(ByteBuffer buffer, String string) throws EncoderException
buffer - The PDU in which the value will be putstring - The String to be encoded. It is supposed to be UTF-8EncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, BitString bitString) throws EncoderException
buffer - The PDU in which the value will be putbitString - The BitString to be encoded.EncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, byte[] bytes) throws EncoderException
buffer - The PDU in which the value will be putbytes - The bytes to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, OID oid) throws EncoderException
buffer - The PDU in which the value will be putoid - The OID to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, int value) throws EncoderException
buffer - The PDU in which the value will be putvalue - The integer to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, long value) throws EncoderException
buffer - The PDU in which the value will be putvalue - The long to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, byte tag, int value) throws EncoderException
buffer - The PDU in which the value will be puttag - The tag if it's not an UNIVERSAL onevalue - The integer to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encodeEnumerated(ByteBuffer buffer, int value) throws EncoderException
buffer - The PDU in which the value will be putvalue - The integer to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallpublic static void encode(ByteBuffer buffer, boolean bool) throws EncoderException
buffer - The PDU in which the value will be putbool - The boolean to be encodedEncoderException - if the PDU in which the value should be encoded is
two smallCopyright © 2003–2016 The Apache Software Foundation. All rights reserved.