public class BCDStringCodec<T> extends Object implements StringCodec<T>
Modifier | Constructor and Description |
---|---|
protected |
BCDStringCodec(CharCodec charCodec,
boolean packed,
int filler,
boolean swapped,
int factor) |
|
BCDStringCodec(String digitMapping,
boolean packed,
int filler,
boolean swapped,
int factor)
Constructs a 3GPP standards-based BCDStringCodec
customised to the given digit mapping, packing, filler, semi-octet ordering and factor.
|
Modifier and Type | Method and Description |
---|---|
String |
decodeString(byte[] encoded)
Decodes a String of characters from a byte array,
rejecting any value marked as invalid (?) in the digit mapping.
|
String |
decodeString(byte[] encoded,
StringIndicators indicators)
Decodes a String of characters from a byte array,
rejecting any value marked as invalid (?) in the digit mapping.
|
byte[] |
encodeString(String string)
Encodes a String of characters to a byte array,
accepting only characters present in the 16-character digit mapping,
and encoding each in a semi-octet as [0,15].
|
byte[] |
encodeString(String string,
StringIndicators indicators)
Encodes a String of characters to a byte array,
accepting only characters present in the 16-character digit mapping,
and encoding each in a semi-octet as [0,15].
|
int |
getFactor()
Gets the value of the factor.
|
BCDStringCodec<T> |
getHexVariant()
Gets a BCDStringCodec like this one but that decodes to and
encodes from hexadecimal characters, excepting 'F' if that
is this codec's filler.
|
BCDStringCodec<T> |
getLaxDecoder()
Gets a BCDStringCodec that decodes like this one for valid digits
and like the hex variant for invalid digits.
|
protected final CharCodec charCodec
public BCDStringCodec(String digitMapping, boolean packed, int filler, boolean swapped, int factor)
digitMapping
- String of 16 address characters, where index is value for semi-octetpacked
- whether to fill every semi-octet, or only one per octetfiller
- semi-octet value for padding an odd-length addressswapped
- whether to save address characters into semi-octets right-to-leftfactor
- of the number of octets to be allocatedprotected BCDStringCodec(CharCodec charCodec, boolean packed, int filler, boolean swapped, int factor)
public BCDStringCodec<T> getHexVariant()
public BCDStringCodec<T> getLaxDecoder()
getLaxDecoder
in interface StringCodec<T>
public byte[] encodeString(String string, StringIndicators indicators)
encodeString
in interface StringCodec<T>
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 encodablepublic byte[] encodeString(String string)
encodeString
in interface StringCodec<T>
string
- the String to be encoded to a byte arrayUnsupportedDigitException
- if any character of the given String is not encodablepublic String decodeString(byte[] encoded, StringIndicators indicators) throws UnsupportedDigitException
decodeString
in interface StringCodec<T>
encoded
- the byte array to be decoded to a Stringindicators
- indicator values needed for decodingUnsupportedDigitException
- if any encoded content cannot be decoded by this codecpublic String decodeString(byte[] encoded) throws UnsupportedDigitException
decodeString
in interface StringCodec<T>
encoded
- the byte array to be decoded to a StringUnsupportedDigitException
- if any encoded content cannot be decoded by this codecpublic int getFactor()