Package es.gob.jmulticard.asn1
Class Tlv
- java.lang.Object
-
- es.gob.jmulticard.asn1.Tlv
-
public final class Tlv extends java.lang.ObjectRepresentación de un TLV (Tipo-Longitud-Valor) binario en forma ASN.1 DER.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bytesEstructura binaria completa del TLV.private intlengthLongitud del valor.private bytetagOcteto de tipo (etiqueta).private intvalueOffset
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Tlvdecode(java.io.ByteArrayInputStream recordOfTlv)Obtiene un TLV de un flujo de entrada, leyendo del mismo únicamente los octetos correspondientes al TLV en cuestión.byte[]getBytes()Devuelve el TLV directamente en binario.intgetLength()Devuelve la longitud del valor del TLV.bytegetTag()Devuelve el tipo (etiqueta) del TLV.byte[]getValue()Devuelve el valor del TLV.java.lang.StringtoString()
-
-
-
Constructor Detail
-
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 TlvExceptionConstruye 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 Detail
-
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(java.io.ByteArrayInputStream recordOfTlv) throws java.io.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:
java.io.IOException- Si ocurre un error durante la lectura del TLV.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-