|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.shared.asn1.ber.tlv.Value
public class Value
This class stores the data decoded from a TLV.
Field Summary | |
---|---|
static byte |
FALSE_VALUE
The encoded byte for a FALSE value |
static long |
serialVersionUID
|
static byte |
TRUE_VALUE
The encoded byte for a TRUE value |
Constructor Summary | |
---|---|
Value()
The constructor. |
|
Value(byte[] value)
The constructor. |
Method Summary | |
---|---|
void |
addData(byte[] data)
Append some bytes to the data buffer. |
void |
addData(ByteBuffer data)
Append some bytes to the data buffer. |
Object |
clone()
Clone the 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,
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 - [0x80000000 - 0xFFFFFFFF] : 0x00 0xVV 0xVV 0xVV 0xVV 2) Negative number - (~value) + 1 |
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. |
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 |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
public static final byte TRUE_VALUE
public static final byte FALSE_VALUE
Constructor Detail |
---|
public Value(byte[] value)
public Value()
Method Detail |
---|
public void init(int size)
size
- The data size to allocate.public void reset()
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
- Thrown when the cloning failedpublic byte[] getData()
public void setData(ByteBuffer data)
data
- The data to set.public void addData(ByteBuffer data)
data
- The data to append.public void setData(byte[] data)
data
- The data to set.public void addData(byte[] data)
data
- The data to append.public int getCurrentLength()
public static int getNbBytes(int value)
value
- The value to store in a byte arraysign
- The integer value sign
public static byte[] getBytes(int value)
value
- The value to store in a byte arraysign
- The value sign : positive or negative
public 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-8
EncoderException
public static void encode(ByteBuffer buffer, byte[] bytes) throws EncoderException
buffer
- The PDU in which the value will be putbyte[]
- The bytes to be encoded
EncoderException
public static void encode(ByteBuffer buffer, OID oid) throws EncoderException
buffer
- The PDU in which the value will be putstring
- The OID to be encoded
EncoderException
public static void encode(ByteBuffer buffer, int value) throws EncoderException
buffer
- The PDU in which the value will be putvalue
- The integer to be encoded
EncoderException
public 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 encoded
EncoderException
public static void encodeEnumerated(ByteBuffer buffer, int value) throws EncoderException
buffer
- The PDU in which the value will be putvalue
- The integer to be encoded
EncoderException
public static void encode(ByteBuffer buffer, boolean bool) throws EncoderException
buffer
- The PDU in which the value will be putbool
- The boolean to be encoded
EncoderException
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |