Interface StringCodec<T>

  • All Superinterfaces:
    Serializable
    All Known Implementing Classes:
    BCDPlacesStringCodec, BCDStringCodec, BinaryStringCodec, GSM7PACKEDStringCodec, IA5StringCodec, ISO646BCDStringCodec

    public interface StringCodec<T>
    extends Serializable
    Interface StringCodec is an abstraction of alternative encodings of Strings. It is intended for encoding and decoding address fields in OCTET STRINGS. The need for alternative encodings is shown by the examples in the following table.
    Typeusually encoded asbut asunder this condition
    GenericDigitsBCDASCIIencodingScheme == IA5
    SMSAddressBCDGSM7PACKEDnature == ALPHANUMERIC
    NSAPAddress.DomainSpecificPartBCDor Binary or ASCIIdepending on AFI
    Furthermore, StringCodec supports vendor-specific encoding and decoding of such address fields.

    An OCTET STRING type's class associates one or more StringCodecs with each String field. StringCodecs are not transmitted on the wire: they affect the encoded form, but are not part of it. If there is more than one StringCodec associated with a field, then which one is appropriate might be determined by the values of other fields. The setters and getters for a field can be given a StringCodec, otherwise they use the StringCodec that might be determined to be appropriate.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String decodeString​(byte[] encoded)
      Decodes a String of characters from a byte array.
      String decodeString​(byte[] encoded, StringIndicators indicators)
      Decodes a String of characters from a byte array, using the given indicators to distinguish encoded characters from padding.
      byte[] encodeString​(String string)
      Encodes a String of characters to a byte array.
      byte[] encodeString​(String string, StringIndicators indicators)
      Encodes a String of characters to a byte array, noting indicators that would be needed for decoding by this or other StringCodecs.
      StringCodec<T> getLaxDecoder()
      Gets a StringCodec that decodes like this one for valid digits but doesn't throw an exception on invalid digits.
    • Method Detail

      • encodeString

        byte[] encodeString​(String string,
                            StringIndicators indicators)
        Encodes a String of characters to a byte array, noting indicators that would be needed for decoding by this or other StringCodecs.
        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 supported by this codec
      • encodeString

        byte[] encodeString​(String string)
        Encodes a String of characters to a byte array. If the resulting byte array could not be decoded without additional indicators, then the encoding should instead be done by encodeString(String, StringIndicators).
        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 supported by this codec
      • decodeString

        String decodeString​(byte[] encoded,
                            StringIndicators indicators)
        Decodes a String of characters from a byte array, using the given indicators to distinguish encoded characters from padding.
        Parameters:
        encoded - the byte array to be decoded to a String
        indicators - indicator values needed for decoding
        Returns:
        the decoded String
        Throws:
        UnsupportedDigitException - if any encoded content cannot be decoded by this codec
      • decodeString

        String decodeString​(byte[] encoded)
        Decodes a String of characters from a byte array. This is for use only when no indicators are needed to assist the decoding.
        Parameters:
        encoded - the byte array to be decoded to a String
        Returns:
        the decoded String
        Throws:
        UnsupportedDigitException - if any encoded content cannot be decoded by this codec
      • getLaxDecoder

        StringCodec<T> getLaxDecoder()
        Gets a StringCodec that decodes like this one for valid digits but doesn't throw an exception on invalid digits. Its encodeString() method needn't do anything useful. The lax decoder of a lax decoder can be itself (idempotent).
        Returns:
        StringCodec