Class GSM7PACKEDStringCodec<T>

    • Method Detail

      • getStandardCodec

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

        public GSM7PACKEDStringCodec<T> getLaxDecoder()
        Gets the standard GSM7PACKEDStringCodec. This method is required by interface StringCodec, but it needn't return a different GSM7PACKEDStringCodec as all encodings can be decoded.
        Specified by:
        getLaxDecoder in interface StringCodec<T>
        Returns:
        GSM7PACKEDStringCodec
      • encodeString

        public byte[] encodeString​(String string,
                                   StringIndicators indicators)
        Encodes a String of characters to a byte array, accepting only GSM7 characters and encoding them in 7-bit packed format. Sets indicators to assist decoding by this or 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 GSM7 character
      • encodeString

        public byte[] encodeString​(String string)
        Encodes a String of characters to a byte array, accepting only GSM7 characters and encoding them in 7-bit packed format.
        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 GSM7 character
      • decodeString

        public String decodeString​(byte[] encoded,
                                   StringIndicators indicators)
        Decodes a String of characters from a byte array, expecting 7-bit packed format of GSM7 characters, using the given indicators to distinguish whether 1 or 8 bits are used in the last octet.
        Specified by:
        decodeString in interface StringCodec<T>
        Parameters:
        encoded - the byte array to be decoded to a String
        indicators - indicator values needed for decoding
        Returns:
        the decoded String
      • decodeString

        public String decodeString​(byte[] encoded)
        Decodes a String of characters from a byte array, expecting 7-bit packed format of GSM7 characters, deciding whether there are 1 or 8 bits used in the last octet based on whether its index is a multiple of 7 and the 7 bits are all 0.
        Specified by:
        decodeString in interface StringCodec<T>
        Parameters:
        encoded - the byte array to be decoded to a String
        Returns:
        the decoded String