|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.asn1new.ber.tlv.Value
public class Value
This class stores the data decoded from a TLV.
Field Summary | |
---|---|
private int |
currentPos
The current position of the last byte in the data buffer |
private byte[] |
data
The data buffer. |
private static byte[] |
ENCODED_FALSE
|
private static byte[] |
ENCODED_TRUE
Pre-encoded PDUs for a TRUE and FALSE TLV |
static byte |
FALSE_VALUE
The encoded byte for a FALSE value |
private static int |
FOUR_BYTE_MAX
|
private static int |
FOUR_BYTE_MIN
|
private static int |
ONE_BYTE_MAX
Integer limits for encoding |
private static int |
ONE_BYTE_MIN
|
static long |
serialVersionUID
|
private static int |
THREE_BYTE_MAX
|
private static int |
THREE_BYTE_MIN
|
static byte |
TRUE_VALUE
The encoded byte for a TRUE value |
private static int |
TWO_BYTE_MAX
|
private static int |
TWO_BYTE_MIN
|
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(java.nio.ByteBuffer data)
Append some bytes to the data buffer. |
java.lang.Object |
clone()
Clone the Value |
static void |
encode(java.nio.ByteBuffer buffer,
boolean bool)
Encode a boolean value |
static void |
encode(java.nio.ByteBuffer buffer,
byte[] bytes)
Encode an OctetString value |
static void |
encode(java.nio.ByteBuffer buffer,
int value)
Encode an integer value |
static void |
encode(java.nio.ByteBuffer buffer,
OctetString string)
Encode an OctetString value |
static void |
encode(java.nio.ByteBuffer buffer,
OID oid)
Encode an OID value |
static void |
encode(java.nio.ByteBuffer buffer,
java.lang.String string)
Encode a String value |
static void |
encodeEnumerated(java.nio.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(java.nio.ByteBuffer data)
Set a block of bytes in the Value |
java.lang.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
private byte[] data
private int currentPos
public static final byte TRUE_VALUE
public static final byte FALSE_VALUE
private static final byte[] ENCODED_TRUE
private static final byte[] ENCODED_FALSE
private static final int ONE_BYTE_MAX
private static final int ONE_BYTE_MIN
private static final int TWO_BYTE_MAX
private static final int TWO_BYTE_MIN
private static final int THREE_BYTE_MAX
private static final int THREE_BYTE_MIN
private static final int FOUR_BYTE_MAX
private static final int FOUR_BYTE_MIN
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 java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Thrown when the cloning failedpublic byte[] getData()
public void setData(java.nio.ByteBuffer data)
data
- The data to set.public void addData(java.nio.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(java.nio.ByteBuffer buffer, java.lang.String string) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putstring
- The String to be encoded. It is supposed to be UTF-8
org.apache.asn1.codec.EncoderException
public static void encode(java.nio.ByteBuffer buffer, OctetString string) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putstring
- The OctetString to be encoded
org.apache.asn1.codec.EncoderException
public static void encode(java.nio.ByteBuffer buffer, byte[] bytes) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putbyte[]
- The bytes to be encoded
org.apache.asn1.codec.EncoderException
public static void encode(java.nio.ByteBuffer buffer, OID oid) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putstring
- The OID to be encoded
org.apache.asn1.codec.EncoderException
public static void encode(java.nio.ByteBuffer buffer, int value) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putvalue
- The integer to be encoded
org.apache.asn1.codec.EncoderException
public static void encodeEnumerated(java.nio.ByteBuffer buffer, int value) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putvalue
- The integer to be encoded
org.apache.asn1.codec.EncoderException
public static void encode(java.nio.ByteBuffer buffer, boolean bool) throws org.apache.asn1.codec.EncoderException
buffer
- The PDU in which the value will be putbool
- The boolean to be encoded
org.apache.asn1.codec.EncoderException
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |