Class Tlv

java.lang.Object
es.gob.jmulticard.asn1.Tlv

public final class Tlv extends Object
Representación de un TLV (Tipo-Longitud-Valor) binario en forma ASN.1 DER.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    Estructura binaria completa del TLV.
    private final int
    Longitud del valor.
    private final byte
    Octeto de tipo (etiqueta).
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tlv(byte[] buffer)
    Construye un TLV simple a partir de su representación binaria directa.
    Tlv(byte t, byte[] value)
    Construye un TLV simple con etiqueta y longitud de un solo octeto cada uno.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Tlv
    Obtiene un TLV de un flujo de entrada, leyendo del mismo únicamente los octetos correspondientes al TLV en cuestión.
    byte[]
    Devuelve el TLV directamente en binario.
    int
    Devuelve la longitud del valor del TLV.
    byte
    Devuelve el tipo (etiqueta) del TLV.
    byte[]
    Devuelve el valor del TLV.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • tag

      private final byte tag
      Octeto de tipo (etiqueta).
    • length

      private final int length
      Longitud del valor.
    • bytes

      private final byte[] bytes
      Estructura binaria completa del TLV.
    • valueOffset

      private final transient int valueOffset
  • Constructor Details

    • Tlv

      public Tlv(byte t, byte[] value)
      Construye un TLV simple con etiqueta y longitud de un solo octeto cada uno.
      Parameters:
      t - Etiqueta (tipo) del TLV.
      value - Valor del TLV.
    • Tlv

      public Tlv(byte[] buffer) throws TlvException
      Construye un TLV simple a partir de su representación binaria directa.
      Parameters:
      buffer - Representación binaria del TLV.
      Throws:
      TlvException - En caso de error analizando el TLV.
  • Method Details

    • getBytes

      public byte[] getBytes()
      Devuelve el TLV directamente en binario.
      Returns:
      Valor binario completo del TLV.
    • getLength

      public int getLength()
      Devuelve la longitud del valor del TLV.
      Returns:
      Longitud del valor del TLV.
    • getTag

      public byte getTag()
      Devuelve el tipo (etiqueta) del TLV.
      Returns:
      Tipo (etiqueta) del TLV.
    • getValue

      public byte[] getValue()
      Devuelve el valor del TLV.
      Returns:
      Valor del del TLV.
    • decode

      public static Tlv decode(ByteArrayInputStream recordOfTlv) throws IOException
      Obtiene un TLV de un flujo de entrada, leyendo del mismo únicamente los octetos correspondientes al TLV en cuestión.
      Parameters:
      recordOfTlv - Flujo de entrada.
      Returns:
      TLV recuperado del flujo.
      Throws:
      IOException - Si ocurre un error durante la lectura del TLV.
    • toString

      public String toString()
      Overrides:
      toString in class Object