Class BCDPlacesStringCodec<T>
- java.lang.Object
-
- com.opencloud.slee.resources.in.datatypes.BCDStringCodec<T>
-
- com.opencloud.slee.resources.in.datatypes.BCDPlacesStringCodec<T>
-
- All Implemented Interfaces:
StringCodec<T>
,Serializable
public class BCDPlacesStringCodec<T> extends BCDStringCodec<T>
Implements a StringCodec for the case of decimal digits encoded in semi-octets, with the encoding being aligned around particular numbers of digits before and after the decimal point, which is elided from the encoding. Allows a lax variant to be obtained, for use when there are invalid digits.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.opencloud.slee.resources.in.datatypes.BCDStringCodec
charCodec
-
-
Constructor Summary
Constructors Constructor Description BCDPlacesStringCodec(int before, int after)
Constructs a 3GPP standards-based BCDPlacesStringCodec customised to the given numbers of digits before and after the decimal point.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
decodeString(byte[] encoded)
Decodes a String containing a decimal number from a byte array, positioning the decimal point between before and after numbers of digits, and eliding leading 0s.String
decodeString(byte[] encoded, StringIndicators indicators)
Decodes a String containing a decimal number from a byte array, positioning the decimal point between before and after numbers of digits, and eliding leading 0s.byte[]
encodeString(String string)
Encodes a String containing a decimal number to a byte array, with each digit being encoded in a semi-octet, aligning the encoding around particular numbers of digits before and after the decimal point, which itself is not explicitly encoded, padding with 0s before and after.byte[]
encodeString(String string, StringIndicators indicators)
Encodes a String containing a decimal number to a byte array, with each digit being encoded in a semi-octet, aligning the encoding around particular numbers of digits before and after the decimal point, which itself is not explicitly encoded, padding with 0s before and after.BCDPlacesStringCodec<T>
getLaxDecoder()
Gets a BCDPlacesStringCodec that decodes invalid characters to hex digits instead of throwing an exception.-
Methods inherited from class com.opencloud.slee.resources.in.datatypes.BCDStringCodec
getFactor, getHexVariant
-
-
-
-
Constructor Detail
-
BCDPlacesStringCodec
public BCDPlacesStringCodec(int before, int after)
Constructs a 3GPP standards-based BCDPlacesStringCodec customised to the given numbers of digits before and after the decimal point.- Parameters:
before
- number of digits before the decimal pointafter
- number of digits after the decimal point
-
-
Method Detail
-
getLaxDecoder
public BCDPlacesStringCodec<T> getLaxDecoder()
Gets a BCDPlacesStringCodec that decodes invalid characters to hex digits instead of throwing an exception. Its encodeString() method does nothing useful. The lax variant of a lax variant is itself (idempotent).- Specified by:
getLaxDecoder
in interfaceStringCodec<T>
- Overrides:
getLaxDecoder
in classBCDStringCodec<T>
- Returns:
- BCDPlacesStringCodec
-
encodeString
public byte[] encodeString(String string, StringIndicators indicators)
Encodes a String containing a decimal number to a byte array, with each digit being encoded in a semi-octet, aligning the encoding around particular numbers of digits before and after the decimal point, which itself is not explicitly encoded, padding with 0s before and after. Excess digits before or after the decimal point are ignored. Sets indicators to assist decoding by this or other StringCodecs.- Specified by:
encodeString
in interfaceStringCodec<T>
- Overrides:
encodeString
in classBCDStringCodec<T>
- 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 decimal or the '.'
-
encodeString
public byte[] encodeString(String string)
Encodes a String containing a decimal number to a byte array, with each digit being encoded in a semi-octet, aligning the encoding around particular numbers of digits before and after the decimal point, which itself is not explicitly encoded, padding with 0s before and after. Excess digits before or after the decimal point are ignored.- Specified by:
encodeString
in interfaceStringCodec<T>
- Overrides:
encodeString
in classBCDStringCodec<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 decimal or the '.'
-
decodeString
public String decodeString(byte[] encoded, StringIndicators indicators)
Decodes a String containing a decimal number from a byte array, positioning the decimal point between before and after numbers of digits, and eliding leading 0s. Trailing 0s are kept. The given indicators should include numSemiOctets, with odd being used if numSemiOctets is inconsistent with the length of the encoded form.- Specified by:
decodeString
in interfaceStringCodec<T>
- Overrides:
decodeString
in classBCDStringCodec<T>
- 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
public String decodeString(byte[] encoded)
Decodes a String containing a decimal number from a byte array, positioning the decimal point between before and after numbers of digits, and eliding leading 0s. Trailing 0s are kept.- Specified by:
decodeString
in interfaceStringCodec<T>
- Overrides:
decodeString
in classBCDStringCodec<T>
- 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
-
-