Class DataParser


  • public class DataParser
    extends Object
    Created by Tobias Senger on 18.01.2017.
    • Constructor Detail

      • DataParser

        public DataParser()
    • 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
      • parseDerTLvs

        public static List<DerTlv> parseDerTLvs​(byte[] rawBytes)
      • decodeC40

        public static String decodeC40​(byte[] bytes)
      • decodeBase256

        public static byte[] decodeBase256​(String s)