public interface StringCodec<T> extends Serializable
Type | usually encoded as | but as | under this condition |
---|---|---|---|
GenericDigits | BCD | ASCII | encodingScheme == IA5 |
SMSAddress | BCD | GSM7PACKED | nature == ALPHANUMERIC |
NSAPAddress.DomainSpecificPart | BCD | or Binary or ASCII | depending on AFI |
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.
Modifier and Type | Method and 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.
|
byte[] encodeString(String string, StringIndicators indicators)
string
- the String to be encoded to a byte arrayindicators
- the StringIndicators object in which to set the indicatorsUnsupportedDigitException
- if any character of the given String is not supported by this codecbyte[] encodeString(String string)
string
- the String to be encoded to a byte arrayUnsupportedDigitException
- if any character of the given String is not supported by this codecString decodeString(byte[] encoded, StringIndicators indicators)
encoded
- the byte array to be decoded to a Stringindicators
- indicator values needed for decodingUnsupportedDigitException
- if any encoded content cannot be decoded by this codecString decodeString(byte[] encoded)
encoded
- the byte array to be decoded to a StringUnsupportedDigitException
- if any encoded content cannot be decoded by this codecStringCodec<T> getLaxDecoder()