Class BinaryStringCodec<T>
- java.lang.Object
-
- com.opencloud.slee.resources.in.datatypes.BinaryStringCodec<T>
-
- All Implemented Interfaces:
StringCodec<T>,Serializable
public class BinaryStringCodec<T> extends Object implements StringCodec<T>
Implements a StringCodec for the case of decimal digits encoded in binary octets.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdecodeString(byte[] encoded)Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].StringdecodeString(byte[] encoded, StringIndicators indicators)Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].byte[]encodeCharArray(char[] chars)Encodes an array of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].byte[]encodeString(String string)Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].byte[]encodeString(String string, StringIndicators indicators)Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].BinaryStringCodec<T>getLaxDecoder()Gets a BinaryStringCodec that decodes invalid characters to ? characters instead of throwing an exception.static <T> BinaryStringCodec<T>getStandardCodec()Gets the standard BinaryStringCodec.
-
-
-
Method Detail
-
getStandardCodec
public static <T> BinaryStringCodec<T> getStandardCodec()
Gets the standard BinaryStringCodec.- Returns:
- BinaryStringCodec
-
getLaxDecoder
public BinaryStringCodec<T> getLaxDecoder()
Gets a BinaryStringCodec that decodes invalid characters to ? characters instead of throwing an exception. Its encodeString() method does nothing useful. The lax decoder of a lax decoder is itself (idempotent).- Specified by:
getLaxDecoderin interfaceStringCodec<T>- Returns:
- StringCodec
-
encodeString
public byte[] encodeString(String string, StringIndicators indicators)
Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9]. Sets indicators to assist decoding by other StringCodecs.- Specified by:
encodeStringin interfaceStringCodec<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 a decimal digit
-
encodeString
public byte[] encodeString(String string)
Encodes a String of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].- Specified by:
encodeStringin interfaceStringCodec<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 a decimal digit
-
encodeCharArray
public byte[] encodeCharArray(char[] chars)
Encodes an array of characters to a byte array, accepting only decimal digit characters ['0','9'], and encoding each digit in an octet as [0,9].- Parameters:
chars- the character array to be encoded to a byte array- Returns:
- the encoded byte array
- Throws:
UnsupportedDigitException- if any character of the given String is not a decimal digit
-
decodeString
public String decodeString(byte[] encoded, StringIndicators indicators)
Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].- Specified by:
decodeStringin interfaceStringCodec<T>- Parameters:
encoded- the byte array to be decoded to a Stringindicators- indicator values needed for decoding (ignored)- Returns:
- the decoded String
- Throws:
UnsupportedDigitException- if any encoded content is not in range [0,9]
-
decodeString
public String decodeString(byte[] encoded)
Decodes a String of characters from a byte array, taking length values from octets, rejecting any value that isn't in range [0,9], and decoding to characters ['0','9'].- Specified by:
decodeStringin interfaceStringCodec<T>- Parameters:
encoded- the byte array to be decoded to a String- Returns:
- the decoded String
- Throws:
UnsupportedDigitException- if any encoded content is not in range [0,9]
-
-