Class BinaryStringCodec<T>

    • Method Detail

      • getStandardCodec

        public static <T> BinaryStringCodec<T> getStandardCodec()
        Gets the standard BinaryStringCodec.
        Returns:
        BinaryStringCodec
      • getLaxDecoder

        public BinaryStringCodec<T> getLaxDecoder()
        Gets a BinaryStringCodec that decodes invalid characters to ? characters instead of throwing an exception. Its encodeString() method does nothing useful. The lax decoder of a lax decoder is itself (idempotent).
        Specified by:
        getLaxDecoder in interface StringCodec<T>
        Returns:
        StringCodec
      • encodeString

        public byte[] encodeString​(String string,
                                   StringIndicators indicators)
        Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9]. Sets indicators to assist decoding by other StringCodecs.
        Specified by:
        encodeString in interface StringCodec<T>
        Parameters:
        string - the String to be encoded to a byte array
        indicators - the StringIndicators object in which to set the indicators
        Returns:
        the encoded byte array
        Throws:
        UnsupportedDigitException - if any character of the given String is not a decimal digit
      • encodeString

        public byte[] encodeString​(String string)
        Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].
        Specified by:
        encodeString in interface StringCodec<T>
        Parameters:
        string - the String to be encoded to a byte array
        Returns:
        the encoded byte array
        Throws:
        UnsupportedDigitException - if any character of the given String is not a decimal digit
      • encodeCharArray

        public byte[] encodeCharArray​(char[] chars)
        Encodes an array of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].
        Parameters:
        chars - the character array to be encoded to a byte array
        Returns:
        the encoded byte array
        Throws:
        UnsupportedDigitException - if any character of the given String is not a decimal digit
      • decodeString

        public String decodeString​(byte[] encoded,
                                   StringIndicators indicators)
        Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].
        Specified by:
        decodeString in interface StringCodec<T>
        Parameters:
        encoded - the byte array to be decoded to a String
        indicators - indicator values needed for decoding (ignored)
        Returns:
        the decoded String
        Throws:
        UnsupportedDigitException - if any encoded content is not in range [0,9]
      • decodeString

        public String decodeString​(byte[] encoded)
        Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].
        Specified by:
        decodeString in interface StringCodec<T>
        Parameters:
        encoded - the byte array to be decoded to a String
        Returns:
        the decoded String
        Throws:
        UnsupportedDigitException - if any encoded content is not in range [0,9]