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.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.
-
-
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 arrayindicators
- 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 Stringindicators
- 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
-
-