Class ByteArrayScanner

    • Constructor Detail

      • ByteArrayScanner

        public ByteArrayScanner​(byte[] bytes)
        Builds a ByteArrayScanner object that will read from the supplied byte array.
        Parameters:
        bytes - the byte array input that will be read from
    • Method Detail

      • nextBoolean

        public boolean nextBoolean()
                            throws DataFormatException
        Reads the next boolean.
        Returns:
        the next boolean
        Throws:
        DataFormatException - if no more data can be read from the input
      • nextIntUTF8

        public int nextIntUTF8()
                        throws DataFormatException
        Reads the next int that was encoded as a UTF8 string.
        Returns:
        the next int that was encoded as a UTF8 string.
        Throws:
        DataFormatException - if no more data can be read from the input
      • nextLongUTF8

        public long nextLongUTF8()
                          throws DataFormatException
        Reads the next long that was encoded as a UTF8 string.
        Returns:
        the next long that was encoded as a UTF8 string.
        Throws:
        DataFormatException - if no more data can be read from the input
      • nextString

        public String nextString()
                          throws DataFormatException
        Reads the next UTF8-encoded string.
        Returns:
        the next UTF8-encoded string or null if the string length is zero
        Throws:
        DataFormatException - if no more data can be read from the input
      • nextStrings

        public <TCol extends Collection<String>> TCol nextStrings​(TCol output)
                                                           throws DataFormatException
        Reads the next UTF8-encoded strings in the provided collection.
        Type Parameters:
        TCol - the collection's concrete type
        Parameters:
        output - the collection where to add the next UTF8-encoded strings
        Returns:
        the provided collection where the next UTF8-encoded strings have been added.
        Throws:
        DataFormatException - if no more data can be read from the input
      • nextCSN

        public CSN nextCSN()
                    throws DataFormatException
        Reads the next CSN.
        Returns:
        the next CSN.
        Throws:
        DataFormatException - if CSN was incorrectly encoded or no more data can be read from the input
      • nextCSNUTF8

        public CSN nextCSNUTF8()
                        throws DataFormatException
        Reads the next CSN that was encoded as a UTF8 string.
        Returns:
        the next CSN that was encoded as a UTF8 string.
        Throws:
        DataFormatException - if legacy CSN was incorrectly encoded or no more data can be read from the input
      • nextDN

        public DN nextDN()
                  throws DataFormatException
        Reads the next DN.
        Returns:
        the next DN.
        Throws:
        DataFormatException - if DN was incorrectly encoded or no more data can be read from the input
      • remainingBytes

        public byte[] remainingBytes()
        Return a new byte array containing all remaining bytes in this ByteArrayScanner.
        Returns:
        new byte array containing all remaining bytes
      • remainingBytesZeroTerminated

        public byte[] remainingBytesZeroTerminated()
        Return a new byte array containing all remaining bytes in this ByteArrayScanner bar the last one which is a zero terminated byte (compatible with legacy code).
        Returns:
        new byte array containing all remaining bytes bar the last one
      • nextByteArray

        public byte[] nextByteArray​(int length)
        Return a new byte array containing the requested number of bytes.
        Parameters:
        length - the number of bytes to be read and copied to the new byte array.
        Returns:
        new byte array containing the requested number of bytes.
      • skipZeroSeparator

        public void skipZeroSeparator()
                               throws DataFormatException
        Skips the next byte and verifies it is effectively the zero separator.
        Throws:
        DataFormatException - if the next byte is not the zero separator.
      • getASN1Reader

        public ASN1Reader getASN1Reader()
        Returns a new ASN1Reader that will read bytes from this ByteArrayScanner.
        Returns:
        a new ASN1Reader that will read bytes from this ByteArrayScanner.
      • isEmpty

        public boolean isEmpty()
        Returns whether the scanner has more bytes to consume.
        Returns:
        true if the scanner has more bytes to consume, false otherwise.