public abstract class BERTLV extends Object
BERTLV class encapsulates a BER TLV structure.
The rules on the allowed encoding of the Tag, length and value fields are
based on the ASN.1 BER encoding rules ISO/IEC 8825-1:2002.
The BERTLV class and the subclasses -
ConstructedBERTLV and PrimitiveBERTLV only
support encoding of the length(L) octets in definite form. These classes do
not provide support for the encoding rules of the contents octets of the
value(V) field as described in ISO/IEC 8825-1:2002.
The BERTLV class and the subclasses -
ConstructedBERTLV and PrimitiveBERTLV also
provide static methods to parse/edit a TLV structure representation in a byte
array.
| Modifier | Constructor and Description |
|---|---|
protected |
BERTLV()
Constructor creates an empty
BERTLV object capable of
encapsulating a BER TLV structure. |
| Modifier and Type | Method and Description |
|---|---|
static BERTLV |
getInstance(byte[] bArray,
short bOff,
short bLen)
Creates the
BERTLV using the input binary data. |
short |
getLength()
Returns the value of
this TLV object's Length component |
static short |
getLength(byte[] berTLVArray,
short bOff)
Returns the value of the TLV Structure's Length component in the
specified input byte array
|
BERTag |
getTag()
Returns
this value of the TLV object's Tag component |
static short |
getTag(byte[] berTLVArray,
short bTLVOff,
byte[] berTagArray,
short bTagOff)
Copies the tag component in the TLV representation in the specified input
byte array to the specified output byte array
|
abstract short |
init(byte[] bArray,
short bOff,
short bLen)
Abstract init method.
|
short |
size()
Returns the number of bytes required to represent
this TLV
structure |
short |
toBytes(byte[] outBuf,
short bOff)
Writes
this TLV structure to the specified byte array. |
static boolean |
verifyFormat(byte[] berTlvArray,
short bOff,
short bLen)
Checks if the input data is a well-formed BER TLV representation.
|
protected BERTLV()
BERTLV object capable of
encapsulating a BER TLV structure.public abstract short init(byte[] bArray,
short bOff,
short bLen)
throws TLVException
this BERTLV using the input byte data.
The capacity of this BERTLV is increased,
if required and supported, based on the size of the
input TLV data structure.
Note:
bOff+bLen is greater than bArray.length, the length
of the bArray array, an ArrayIndexOutOfBoundsException exception is thrown.
bArray - input byte arraybOff - offset within byte array containing the TLV databLen - byte length of input datathis TLV if represented in
bytesArrayIndexOutOfBoundsException - if accessing the input array would cause access of data
outside array bounds, or if the array offset or array
length parameter is negativeNullPointerException - if bArray is nullTLVException - with the following reason codes:
TLVException.INSUFFICIENT_STORAGE if
the required capacity is not available and the
implementation does not support automatic expansion.
TLVException.MALFORMED_TLV if the
input data is not a well-formed BER TLV or the input data
represents a primitive BER TLV structure and
this is a ConstructedBERTLV
object or the input data represents a constructed BER TLV
structure and this is a
PrimiitveBERTLV object.
public static BERTLV getInstance(byte[] bArray, short bOff, short bLen) throws TLVException
BERTLV using the input binary data. The
resulting BER TLV object may be a primitive or a constructed TLV object.
The object must be cast to the correct sub-class:
ConstructedBERTLV or PrimitiveBERTLV to
access the specialized API. The
init( byte[] bArray, short bOff, short bLen ) methods of
the appropriate BERTLV classes will be used to initialize
the created TLV object.
Note:
bOff+bLen is greater than bArray.length, the length
of the bArray array, an ArrayIndexOutOfBoundsException exception is thrown.
bArray - input byte arraybOff - offset within byte array containing the tlv databLen - byte length of input dataArrayIndexOutOfBoundsException - if accessing the input array would cause access of data
outside array bounds, or if the array offset or array
length parameter is negativeNullPointerException - if bArray is nullTLVException - with the following reason codes:
TLVException.ILLEGAL_SIZE if the TLV
structure requested is larger than the supported maximum
size
TLVException.MALFORMED_TLV if the
input data is not a well-formed BER TLV.
public short toBytes(byte[] outBuf,
short bOff)
this TLV structure to the specified byte array.outBuf - output byte arraybOff - offset within byte array output data beginsArrayIndexOutOfBoundsException - if accessing the output array would cause access of data
outside array bounds, or if the array offset parameter is
negativeNullPointerException - if outBuf is nullTLVException - with the following reason codes:
TLVException.TLV_SIZE_GREATER_THAN_32767
if the size of the BER TLV is > 32767.
TLVException.EMPTY_TLV if the
BERTLV object is empty.
public BERTag getTag() throws TLVException
this value of the TLV object's Tag componentthis BERTLV objectTLVException - with the following reason codes:
TLVException.EMPTY_TLV if the
BERTLV object is empty.
public short getLength()
throws TLVException
this TLV object's Length componentTLVException - with the following reason codes:
TLVException.TLV_LENGTH_GREATER_THAN_32767
if the value of the Length component is > 32767.
TLVException.EMPTY_TLV if the
BERTLV object is empty.
public short size()
this TLV
structureTLVException - with the following reason codes:
TLVException.TLV_SIZE_GREATER_THAN_32767
if the size of TLV structure is > 32767.
TLVException.EMPTY_TLV if the
BERTLV object is empty.
public static boolean verifyFormat(byte[] berTlvArray,
short bOff,
short bLen)
Note:
bOff+bLen is greater than berTlvArray.length, the length
of the berTlvArray array, an ArrayIndexOutOfBoundsException exception is thrown.
berTlvArray - input byte arraybOff - offset within byte array containing first bytebLen - byte length of input BER TLV datatrue if input data is a well formed BER TLV
structure, false otherwiseArrayIndexOutOfBoundsException - if accessing the input array would cause access of data
outside array bounds, or if the array offset or array
length parameter is negativeNullPointerException - if berTlvArray is nullpublic static short getTag(byte[] berTLVArray,
short bTLVOff,
byte[] berTagArray,
short bTagOff)
throws TLVException
berTLVArray - input byte arraybTLVOff - offset within byte array containing the tlv databerTagArray - output Tag byte arraybTagOff - offset within byte array where output beginsArrayIndexOutOfBoundsException - if accessing the input or output array would cause access
of data outside array bounds, or if either array offset
parameter is negativeNullPointerException - if either berTLVArray or
berTagArray is nullTLVException - with the following reason codes:
TLVException.ILLEGAL_SIZE if the size
of the Tag component is > 32767.
TLVException.MALFORMED_TLV if the
input data is not a well-formed BER TLV.
public static short getLength(byte[] berTLVArray,
short bOff)
throws TLVException
berTLVArray - input byte arraybOff - offset within byte array containing the tlv dataArrayIndexOutOfBoundsException - if accessing the input array would cause access of data
outside array bounds, or if the array offset parameter is
negativeNullPointerException - if berTLVArrayTLVException - with the following reason codes:
TLVException.TLV_LENGTH_GREATER_THAN_32767
if the length element(L) > 32767.
TLVException.MALFORMED_TLV if the
input data is not a well-formed BER TLV.
Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved.