Class Base16

    • Field Detail

      • BITS_PER_ENCODED_BYTE

        private static final int BITS_PER_ENCODED_BYTE
        BASE16 characters are 4 bits in length. They are formed by taking an 8-bit group, which is converted into two BASE16 characters.
        See Also:
        Constant Field Values
      • BYTES_PER_ENCODED_BLOCK

        private static final int BYTES_PER_ENCODED_BLOCK
        See Also:
        Constant Field Values
      • BYTES_PER_UNENCODED_BLOCK

        private static final int BYTES_PER_UNENCODED_BLOCK
        See Also:
        Constant Field Values
      • UPPER_CASE_DECODE_TABLE

        private static final byte[] UPPER_CASE_DECODE_TABLE
        This array is a lookup table that translates Unicode characters drawn from the "Base16 Alphabet" (as specified in Table 5 of RFC 4648) into their 4-bit positive integer equivalents. Characters that are not in the Base16 alphabet but fall within the bounds of the array are translated to -1.
      • UPPER_CASE_ENCODE_TABLE

        private static final byte[] UPPER_CASE_ENCODE_TABLE
        This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" equivalents as specified in Table 5 of RFC 4648.
      • LOWER_CASE_DECODE_TABLE

        private static final byte[] LOWER_CASE_DECODE_TABLE
        This array is a lookup table that translates Unicode characters drawn from the a lower-case "Base16 Alphabet" into their 4-bit positive integer equivalents. Characters that are not in the Base16 alphabet but fall within the bounds of the array are translated to -1.
      • LOWER_CASE_ENCODE_TABLE

        private static final byte[] LOWER_CASE_ENCODE_TABLE
        This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" lower-case equivalents.
      • MASK_4_BITS

        private static final int MASK_4_BITS
        Mask used to extract 4 bits, used when decoding character.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Base16

        public Base16()
        Constructs a Base16 codec used for decoding and encoding.
      • Base16

        @Deprecated
        public Base16​(boolean lowerCase)
        Deprecated.
        Constructs a Base16 codec used for decoding and encoding.
        Parameters:
        lowerCase - true to use the lower-case Base16 alphabet.
      • Base16

        @Deprecated
        public Base16​(boolean lowerCase,
                      CodecPolicy decodingPolicy)
        Deprecated.
        Constructs a Base16 codec used for decoding and encoding.
        Parameters:
        lowerCase - true to use the lower-case Base16 alphabet.
        decodingPolicy - Decoding policy.
    • Method Detail

      • builder

        public static Base16.Builder builder()
        Constructs a new builder.
        Returns:
        a new builder.
        Since:
        1.20.0
      • decodeOctet

        private int decodeOctet​(byte octet)
      • isInAlphabet

        public boolean isInAlphabet​(byte octet)
        Returns whether or not the octet is in the Base16 alphabet.
        Specified by:
        isInAlphabet in class BaseNCodec
        Parameters:
        octet - The value to test.
        Returns:
        true if the value is defined in the Base16 alphabet false otherwise.
      • validateTrailingCharacter

        private void validateTrailingCharacter()
        Validates whether decoding allows an entire final trailing character that cannot be used for a complete byte.
        Throws:
        java.lang.IllegalArgumentException - if strict decoding is enabled.