Class Base

    • Constructor Detail

      • Base

        public Base​(String alphabet)
        The constructor.
        Parameters:
        alphabet - the alphabet.
    • Method Detail

      • getAlphabet

        public String getAlphabet()
        Returns:
        the alphabet of characters used to encode/decode the data. It shall only contain visible and regular ASCII characters and no duplicates. It is expected that characters are in a logical order (e.g. "0123456789" or "abcdef" rather than "5192" or "xazb").
      • isCaseSensitive

        public abstract boolean isCaseSensitive()
        Returns:
        true if case-sensitive (e.g. both 'a' and 'A' are used with different meanings), false otherwise (the case of Latin Ascii letters will be ignored).
      • encode

        public final String encode​(byte[] data)
        Specified by:
        encode in interface BinaryCodec
        Parameters:
        data - the binary data to encode.
        Returns:
        the given data encoded as String.
      • doEncode

        protected abstract String doEncode​(byte[] data,
                                           BaseFormat format)
        Parameters:
        data - the binary data to encode. Neither null nor empty.
        format - the BaseFormat to configure the encoding.
        Returns:
        the given data encoded as String.
      • decode

        public final byte[] decode​(String encodedData)
        Specified by:
        decode in interface BinaryCodec
        Parameters:
        encodedData - the encoded String.
        Returns:
        the decoded data as byte array.
      • doDecode

        protected abstract byte[] doDecode​(String encodedData,
                                           BaseFormat format)
        Parameters:
        encodedData - the encoded String. Neither null nor empty.
        format - the BaseFormat to configure the decoding.
        Returns:
        the decoded data as byte array.