Package de.tsenger.vdstools
Class DataParser
- java.lang.Object
-
- de.tsenger.vdstools.DataParser
-
public class DataParser extends Object
Created by Tobias Senger on 18.01.2017.
-
-
Constructor Summary
Constructors Constructor Description DataParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decodeBase256(String s)static StringdecodeC40(byte[] bytes)static LocalDatedecodeDate(byte[] dateBytes)static LocalDateTimedecodeDateTime(byte[] dateTimeBytes)Decodes a byte[] encoded datetime as described in ICAO TR "Datastructure for Barcode".static StringdecodeMaskedDate(byte[] maskedDateBytes)Decodes a byte[] encoded masked date as described in ICAO TR "Datastructure for Barcode".static byte[]getFromByteBuffer(ByteBuffer buffer, int size)Returns a byte array of the requested size which contains the number of bytes from the given ByteBuffer beginning at the current pointer of the ByteBuffer.static List<DerTlv>parseDerTLvs(byte[] rawBytes)static byte[]unzip(byte[] bytesToDecompress)
-
-
-
Method Detail
-
getFromByteBuffer
public static byte[] getFromByteBuffer(ByteBuffer buffer, int size)
Returns a byte array of the requested size which contains the number of bytes from the given ByteBuffer beginning at the current pointer of the ByteBuffer.- Parameters:
buffer- The ByteBuffer to get the number of bytes from.size- Number of bytes to get from ByteBuffer. Starting from the internal ByteBuffers pointer- Returns:
- byte array of length 'size' with bytes from ByteBuffer
-
decodeMaskedDate
public static String decodeMaskedDate(byte[] maskedDateBytes) throws IllegalArgumentException
Decodes a byte[] encoded masked date as described in ICAO TR "Datastructure for Barcode". Returns a date string in format yyyy-MM-dd where unknown parts of the date are marked with an 'x'. e.g. 19xx-10-xx- Parameters:
maskedDateBytes- byte array that contains a encoded masked date- Returns:
- date string where unknown parts of the date are marked with an 'x'
- Throws:
IllegalArgumentException
-
decodeDate
public static LocalDate decodeDate(byte[] dateBytes)
-
decodeDateTime
public static LocalDateTime decodeDateTime(byte[] dateTimeBytes)
Decodes a byte[] encoded datetime as described in ICAO TR "Datastructure for Barcode". Returns a LocalDateTime object- Parameters:
dateTimeBytes- byte array with length 6 which contains encoded datetime- Returns:
- LocalDateTime object
-
decodeC40
public static String decodeC40(byte[] bytes)
-
decodeBase256
public static byte[] decodeBase256(String s)
-
unzip
public static byte[] unzip(byte[] bytesToDecompress) throws IOException- Throws:
IOException
-
-