Grabba Driver for Android
Unified driver for Grabba devices on the Android operating system
BER_TLV Class Reference

Description

Encapsulation of Basic Encoding Rule: Type, Length, Value (BER-TLV) data structures.

This class implements a BER-TLV structure as per the X.690 standard.

Note that this structure is hierarchical - a BER-TLV object may encode a collection of other BER-TLV structures, or it may encode primitive data.

Additional information may be found at:

Invariant
Always contains a valid type structure, a valid length structure, and a value field consistent with the type and length.

Thread safety:

  • The current version of this class is immutable, and thus fully thread-safe
  • Future updates to this class will guarantee safety only to the following level:
    • Concurrent accesses to distinct hierarchies: safe
    • Concurrent accesses to distinct objects within same hierarchy: safe, providing no objects are added to or removed from the hierarchy
    • Concurrent accesses to the same object: unsafe, unless all accesses are read-only (query functions, get(), getPrimitive(), getConstructed())
See also
MRTD_API, which provides API functions utilising this class

Classes

enum  BER_ID_Class
 Representation of the ID class field within BER-TLV structures. More...
 

Public Member Functions

boolean constructed ()
 Query whether the stored value is constructed (opposite of primitive()) More...
 
long constructedSize ()
 Size in BER-TLV objects of the constructed data, if there is any. More...
 
boolean definiteLength ()
 Query whether the stored length for this structure is definite. More...
 
byte [] get ()
 Extract the data, in raw BER-TLV binary format. More...
 
BER_TLV [] getConstructed ()
 Copy the constructed data, if there is any. More...
 
byte [] getPrimitive ()
 Copy the primitive data, if there is any. More...
 
BER_ID_Class idClass ()
 Query the type ID class for this structure. More...
 
long length ()
 Query the length field for this structure. More...
 
boolean primitive ()
 Query whether the stored value is primitive (opposite of constructed()) More...
 
long primitiveSize ()
 Size in bytes of the primitive data, if there is any. More...
 
long size ()
 Query the overall size of this structure. More...
 
long tag ()
 Query the type ID tag for this structure.
 

Member Function Documentation

◆ constructed()

boolean constructed ( )

Query whether the stored value is constructed (opposite of primitive())

Returns
True for a constructed BER-TLV; false for a primitive one

◆ constructedSize()

long constructedSize ( )

Size in BER-TLV objects of the constructed data, if there is any.

Returns
Size of getConstructed() output if this is a constructed BER-TLV; zero for a primitive BER-TLV

◆ definiteLength()

boolean definiteLength ( )

Query whether the stored length for this structure is definite.

Returns
True if length is definite; false if it is indefinite

◆ get()

byte [] get ( )

Extract the data, in raw BER-TLV binary format.

Returns
Raw representation of the entire structure, of length equal to the output of size()

◆ getConstructed()

BER_TLV [] getConstructed ( )

Copy the constructed data, if there is any.

Returns
For constructed BER-TLV objects, this returns a copy of the nested BER-TLV structures, with length given by constructedSize(); for primitive BER-TLV objects it returns an empty list

◆ getPrimitive()

byte [] getPrimitive ( )

Copy the primitive data, if there is any.

Returns
Copy of the value (content) data if this is a primitive BER-TLV, with length given by the output of primitiveSize(); empty array for a constructed BER-TLV

◆ idClass()

BER_ID_Class idClass ( )

Query the type ID class for this structure.

Returns
ID class; see BER_ID_Class for details

◆ length()

long length ( )

Query the length field for this structure.

See also
size() for the full size of the TLV structure
Returns
Stored length (of value field) if definite, or zero if indefinite

◆ primitive()

boolean primitive ( )

Query whether the stored value is primitive (opposite of constructed())

Returns
True for a primitive BER-TLV, false for a constructed one

◆ primitiveSize()

long primitiveSize ( )

Size in bytes of the primitive data, if there is any.

Returns
Size of getPrimitive() output if this is a primitive BER-TLV; zero for a constructed BER-TLV

◆ size()

long size ( )

Query the overall size of this structure.

See also
length() for the stored length field (size of value part of BER-TLV, not including type or length parts)
Returns
Size in bytes - i.e. length of the array returned by get()