|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectes.uc3m.it.xbe32.tlv.TLV
This class models the Type-Length-Value (TLV) structures employed by the XBE32 encoding.
From the XBE32 specification ( draft-uruena-xbe32-02.txt ):
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : : Values : : : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : | [ Padding ] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Type (16 bits): This field describes the TLV processing rules, structure and which kind of data is carried inside the Values field. The Type field has the following internal structure: 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|E| Meta | Subtype | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ C and E bits (1 bit each): These two bits specify the actions that must be taken if the processing entity does not recognize this Type value: C - Continue Processing: 0 - Discard this mandatory TLV and stop processing TLVs left. 1 - Skip this optional TLV and continue processing remaining TLVs. E - Notify Error: 0 - Do not report to the sender that this Type is unknown. 1 - Report to the sender that this Type is unknown. Meta (6 bits): This field describes the internal structure of the TLV's Values field, as well as the type of the data it contains. Subtype (8 bits): This field identifies the meaning of this TLV and/or the data carried inside the Values field. Therefore its values should be defined by the upper application/protocol that is employing the XBE32 encoding. Subtype values 0x00 and 0xFF are reserved for XBE32 use and MUST NOT be employed for other purposes. Length (16 bits): This field MUST be encoded as an unsigned binary number in network byte order (a.k.a. Big Endian, i.e, the most significant byte first). It contains the length of the whole TLV structure measured in octets, excluding padding. Length SHOULD be always equal or greater than 4 octets, that is, the length of the Type and Length values. Values and Padding (variable length): The Values field contains the actual XBE32-encoded data as described by the Type and Length fields.The Values field may be empty, that is, have zero length. In that case the Length field MUST be set to 4. If the Values field contains primitive data values, but it cannot be aligned to 4-octet words, padding space MUST be added (up to 3 padding octets) and filled with zeros (0x00) in transmission, and MUST be ignored in reception.
Complex TLVs are TLVs containing other TLVs themselves, whereas Simple TLVs contain zero or more primitive type values. Both, Complex and Simple TLVs can be created with this class.
The Values field of a XBE32 TLV could contain any of these primitive types, according to its Type.Meta part:
Type.Meta | Type.Meta value | Value type |
---|---|---|
META_COMPLEX_TLV |
0x0000-0x1F00 |
null |
META_OPAQUE_VALUE |
0x2000 |
byte[] |
META_STRING_VALUE |
0x2100 |
|
META_OPAQUE1_VALUES |
0x2400 |
byte[] |
META_INT8_VALUES |
0x2500 |
byte[] |
META_BOOLEAN_VALUES |
0x2600 |
boolean[] |
META_OPAQUE2_VALUES |
0x2800 |
byte[2][] |
META_INT16_VALUES |
0x2900 |
short[] |
META_OPAQUE4_VALUES |
0x2C00 |
byte[4][] |
META_INT32_VALUES |
0x2D00 |
int[] |
META_FLOAT32_VALUES |
0x2E00 |
float[] |
META_OPAQUE8_VALUES |
0x3000 |
byte[8][] |
META_INT64_VALUES |
0x3100 |
long[] |
META_FLOAT64_VALUES |
0x3200 |
double[] |
META_OPAQUE12_VALUES |
0x3400 |
byte[12][] |
META_OPAQUE16_VALUES |
0x3800 |
byte[16][] |
The Length field is set by the TLVWriter
class, to ensure that the
generated XBE32-encoded stream has a valid structure.
Field Summary | |
static int |
END_OF_TLV_TYPE
Type of End-of-Data TLV, which marks the end of a Complex TLV with an "unspecified" length. |
static int |
EXTENSIBLE_ATTRIBUTE_ELEMENT_TLV_TYPE
Type of TLVs containing an Extensible XBE32 Attribute Element (without flags) |
static int |
EXTENSIBLE_BOOLEAN_VALUES_TLV_TYPE
Type of TLVs containing the Boolean Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_COMPLEX_ELEMENT_TLV_TYPE
Type of TLVs containing an Extensible XBE32 Complex Element (without flags) |
static int |
EXTENSIBLE_FLOAT32_VALUES_TLV_TYPE
Type of TLVs containing the Float32 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_FLOAT64_VALUES_TLV_TYPE
Type of TLVs containing the Float64 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_ID_TLV_TYPE
Type of TLVs containing the identifier of an Extensible XBE32 Element |
static int |
EXTENSIBLE_INT16_VALUES_TLV_TYPE
Type of TLVs containing the Int16 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_INT32_VALUES_TLV_TYPE
Type of TLVs containing the Int32 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_INT64_VALUES_TLV_TYPE
Type of TLVs containing the Opaque Value of an Extensible Attribute Element |
static int |
EXTENSIBLE_INT8_VALUES_TLV_TYPE
Type of TLVs containing the Int8 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_NAME_TLV_TYPE
Type of TLVs containing the name of an Extensible XBE32 Element |
static int |
EXTENSIBLE_OPAQUE_VALUE_TLV_TYPE
Type of TLVs containing the Opaque Value of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE1_VALUES_TLV_TYPE
Type of TLVs containing the Opaque1 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE12_VALUES_TLV_TYPE
Type of TLVs containing the Opaque12 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE16_VALUES_TLV_TYPE
Type of TLVs containing the Opaque16 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE2_VALUES_TLV_TYPE
Type of TLVs containing the Opaque2 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE4_VALUES_TLV_TYPE
Type of TLVs containing the Opaque4 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_OPAQUE8_VALUES_TLV_TYPE
Type of TLVs containing the Opaque8 Values of an Extensible Attribute Element |
static int |
EXTENSIBLE_STRING_VALUE_TLV_TYPE
Type of TLVs containing the String Value of an Extensible Attribute Element |
static int |
META_BOOLEAN_VALUES
Meta value of Simple TLVs with multiple Boolean ( boolean[] )
values |
static int |
META_COMPLEX_TLV_MAX
Maximum Meta value of Complex TLVs |
static int |
META_COMPLEX_TLV_MIN
Minimum Meta value of Complex TLVs |
static int |
META_FLOAT32_VALUES
Meta value of Simple TLVs with multiple Float32 ( float[] )
values |
static int |
META_FLOAT64_VALUES
Meta value of Simple TLVs with multiple Float64 ( double[] )
values |
static int |
META_INT16_VALUES
Meta value of Simple TLVs with multiple Int16 ( short[] )
values |
static int |
META_INT32_VALUES
Meta value of Simple TLVs with multiple Int32 ( int[] )
values |
static int |
META_INT64_VALUES
Meta value of Simple TLVs with multiple Int64 ( long[] )
values |
static int |
META_INT8_VALUES
Meta value of Simple TLVs with multiple Int8 ( byte[] )
values |
static int |
META_OPAQUE_VALUE
Meta value of Simple TLVs with a single variable-length Opaque ( byte[] ) value |
static int |
META_OPAQUE1_VALUES
Meta value of Simple TLVs with multiple Opaque1 ( byte[] )
values |
static int |
META_OPAQUE12_VALUES
Meta value of Simple TLVs with multiple Opaque12 ( byte[12][] ) values |
static int |
META_OPAQUE16_VALUES
Meta value of Simple TLVs with multiple Opaque16 ( byte[16][] ) values |
static int |
META_OPAQUE2_VALUES
Meta value of Simple TLVs with multiple Opaque2 ( byte[2][] )
values |
static int |
META_OPAQUE4_VALUES
Meta value of Simple TLVs with multiple Opaque4 ( byte[4][] )
values |
static int |
META_OPAQUE8_VALUES
Meta value of Simple TLVs with multiple Opaque8 ( byte[8][] )
values |
static int |
META_STRING_VALUE
Meta value of Simple TLVs with a single variable-length String value |
Constructor Summary | |
TLV(int type)
Creates a Complex TLV with the specified Type field. |
|
TLV(int type,
Object values)
Creates a Simple TLV with the specified Type and Values fields. |
Method Summary | |
boolean |
getContinueFlag()
Returns the Continue flag of this TLV. |
static boolean |
getContinueFlag(int type)
Returns whether the Continue flag of the specified TLV Type is set or not. |
boolean |
getErrorFlag()
Returns the Error flag of this TLV. |
static boolean |
getErrorFlag(int type)
Returns whether the Error flag of the specified TLV Type is set or not. |
int |
getLength()
Returns the Length field of this TLV (without padding). |
int |
getMeta()
Returns the Meta part of this TLV. |
static int |
getMeta(int type)
Returns the Meta part of the specified TLV Type. |
int |
getPaddedLength()
Returns the total length of this TLV (with padding). |
int |
getPadding()
Returns the number of padding zeros required to align this TLV to 4-octets words. |
static int |
getPadding(int length)
Returns the number of padding zeros required to align the TLV to 4-octets words. |
int |
getSubtype()
Returns the Subtype part of this TLV. |
static int |
getSubtype(int type)
Returns the Subtype part of the specified TLV Type. |
int |
getType()
Returns the Type field of this TLV. |
Object |
getValues()
Returns the Values field of this TLV. |
boolean |
isComplex()
Returns whether this TLV is a Complex or a Simple one. |
static boolean |
isComplex(int type)
Returns whether the specified Type belongs to a Complex TLV. |
static String |
toHex(byte b)
Returns a String with the hexadecimal value of the byte parameter. |
static String |
toHex(byte[] a)
Returns a String with the hexadecimal value of the byte array parameter. |
static String |
toHex(int i)
Returns a String with the hexadecimal value of the integer parameter. |
static String |
toHex(long l)
Returns a String with the hexadecimal value of the long parameter. |
static String |
toHex(short s)
Returns a String with the hexadecimal value of the short parameter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int META_COMPLEX_TLV_MIN
public static final int META_COMPLEX_TLV_MAX
public static final int META_OPAQUE_VALUE
byte[]
) value
public static final int META_STRING_VALUE
String
value
public static final int META_OPAQUE1_VALUES
byte[]
)
values
public static final int META_INT8_VALUES
byte[]
)
values
public static final int META_BOOLEAN_VALUES
boolean[]
)
values
public static final int META_OPAQUE2_VALUES
byte[2][]
)
values
public static final int META_INT16_VALUES
short[]
)
values
public static final int META_OPAQUE4_VALUES
byte[4][]
)
values
public static final int META_INT32_VALUES
int[]
)
values
public static final int META_FLOAT32_VALUES
float[]
)
values
public static final int META_OPAQUE8_VALUES
byte[8][]
)
values
public static final int META_INT64_VALUES
long[]
)
values
public static final int META_FLOAT64_VALUES
double[]
)
values
public static final int META_OPAQUE12_VALUES
byte[12][]
) values
public static final int META_OPAQUE16_VALUES
byte[16][]
) values
public static final int END_OF_TLV_TYPE
public static final int EXTENSIBLE_COMPLEX_ELEMENT_TLV_TYPE
public static final int EXTENSIBLE_ATTRIBUTE_ELEMENT_TLV_TYPE
public static final int EXTENSIBLE_NAME_TLV_TYPE
public static final int EXTENSIBLE_ID_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE_VALUE_TLV_TYPE
public static final int EXTENSIBLE_STRING_VALUE_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE1_VALUES_TLV_TYPE
public static final int EXTENSIBLE_INT8_VALUES_TLV_TYPE
public static final int EXTENSIBLE_BOOLEAN_VALUES_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE2_VALUES_TLV_TYPE
public static final int EXTENSIBLE_INT16_VALUES_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE4_VALUES_TLV_TYPE
public static final int EXTENSIBLE_INT32_VALUES_TLV_TYPE
public static final int EXTENSIBLE_FLOAT32_VALUES_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE8_VALUES_TLV_TYPE
public static final int EXTENSIBLE_INT64_VALUES_TLV_TYPE
public static final int EXTENSIBLE_FLOAT64_VALUES_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE12_VALUES_TLV_TYPE
public static final int EXTENSIBLE_OPAQUE16_VALUES_TLV_TYPE
Constructor Detail |
public TLV(int type) throws IllegalArgumentException
type
- the Complex TLV Type field
IllegalArgumentException
- if the speficied Type value is not a
Complex onepublic TLV(int type, Object values) throws IllegalArgumentException
type
- the Simple TLV Type fieldvalues
- the Simple TLV Values field
IllegalArgumentException
- If the specified Type value is not a
Simple one, it does not match with the specified Values, or the
Values have incorrect lengthsMethod Detail |
public int getType()
public static boolean getContinueFlag(int type)
type
- the TLV Type to be queried
true
if the Continue flag is set or
false
when it is notpublic boolean getContinueFlag()
true
if the Continue flag of this TLV is set or
false
when it is notpublic static boolean getErrorFlag(int type)
type
- the TLV Type to be queried
true
if the Error flag is set or false
when it is notpublic boolean getErrorFlag()
true
if the Error flag of this TLV is set or
false
when it is notpublic static int getMeta(int type)
type
- the TLV Type to be queried
META_COMPLEX_TLV_MIN
,
META_COMPLEX_TLV_MAX
,
META_OPAQUE_VALUE
,
META_STRING_VALUE
,
META_OPAQUE1_VALUES
,
META_INT8_VALUES
,
META_BOOLEAN_VALUES
,
META_OPAQUE2_VALUES
,
META_INT16_VALUES
,
META_OPAQUE4_VALUES
,
META_INT32_VALUES
,
META_FLOAT32_VALUES
,
META_OPAQUE8_VALUES
,
META_INT64_VALUES
,
META_FLOAT64_VALUES
,
META_OPAQUE12_VALUES
,
META_OPAQUE16_VALUES
public int getMeta()
META_COMPLEX_TLV_MIN
,
META_COMPLEX_TLV_MAX
,
META_OPAQUE_VALUE
,
META_STRING_VALUE
,
META_OPAQUE1_VALUES
,
META_INT8_VALUES
,
META_BOOLEAN_VALUES
,
META_OPAQUE2_VALUES
,
META_INT16_VALUES
,
META_OPAQUE4_VALUES
,
META_INT32_VALUES
,
META_FLOAT32_VALUES
,
META_OPAQUE8_VALUES
,
META_INT64_VALUES
,
META_FLOAT64_VALUES
,
META_OPAQUE12_VALUES
,
META_OPAQUE16_VALUES
public static boolean isComplex(int type)
type
- the TLV Type to be queried
true
if the TLV Type is a Complex one or
false
if it is a Simple one.public boolean isComplex()
true
if this TLV is a Complex one or
false
if it is a Simple onepublic static int getSubtype(int type)
type
- the TLV Type to be queried
public int getSubtype()
public int getLength()
getPaddedLength()
public static int getPadding(int length)
length
- the Length of the TLV to be aligned
public int getPadding()
public int getPaddedLength()
public Object getValues()
null
value.
public static String toHex(byte b)
b
- the byte value to be represented in hexadecimal.
public static String toHex(short s)
s
- the short value to be represented in hexadecimal
public static String toHex(int i)
i
- the int value to be represented in hexadecimal
public static String toHex(long l)
l
- the long value to be represented in hexadecimal
public static String toHex(byte[] a)
a
- the byte array to be represented in hexadecimal
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |