|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.helidb.lang.serializer.ConstantSizeStringSerializer
org.helidb.lang.serializer.ConstantSizeStringNullSerializer
public class ConstantSizeStringNullSerializer
This is a variant of the ConstantSizeStringSerializer
that can handle
null
values. null
values are encoded to a special string.
Other String
:s that happen to start with the special String
are escaped. This should be transparent to the client.
For more documentation on String
serialization, see
ConstantSizeStringSerializer
.
StringNullSerializer
Field Summary | |
---|---|
static String |
DEFAULT_NULL_VALUE
The default special null value. |
Constructor Summary | |
---|---|
ConstantSizeStringNullSerializer(Charset cs,
int length,
boolean truncateText)
Create a serializer that will use the default null value
"[null]"
. |
|
ConstantSizeStringNullSerializer(Charset cs,
int length,
boolean truncateText,
String nullValue)
Create a serializer that will use the supplied text for encoding null values. |
Method Summary | |
---|---|
String |
interpret(byte[] barr)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
String |
interpret(byte[] barr,
int offset,
int length)
Interpret the data in the byte array to an object of the type
handled by the Serializer implementation. |
boolean |
isNullValuesPermitted()
Does this serializer permit null values? |
byte[] |
serialize(String s)
Serialize the supplied object into a new byte array. |
int |
serialize(String s,
byte[] barr,
int offset)
Serialize the supplied object into the byte array. |
Methods inherited from class org.helidb.lang.serializer.ConstantSizeStringSerializer |
---|
getSerializedSize, read, read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_NULL_VALUE
null
value.
Constructor Detail |
---|
public ConstantSizeStringNullSerializer(Charset cs, int length, boolean truncateText) throws IllegalArgumentException
null
value
"[null]"
.
cs
- The Charset
to use for serializing text.length
- The length in bytes of the serialized data.truncateText
- Should text that is too long be truncated when
serializing? Otherwise serialize(String)
will throw an
exception.
IllegalArgumentException
- On invalid input parameters. See
ConstantSizeStringSerializer.ConstantSizeStringSerializer(Charset, int, boolean)
.ConstantSizeStringSerializer.ConstantSizeStringSerializer(Charset,
int, boolean)
public ConstantSizeStringNullSerializer(Charset cs, int length, boolean truncateText, String nullValue) throws IllegalArgumentException
null
values.
cs
- The Charset
to use for serializing text.length
- The length in bytes of the serialized data.truncateText
- Should text that is too long be truncated when
serializing? Otherwise serialize(String)
will throw an
exception.nullValue
- The text used for encoding null
values. It is
not verified by this constructor that the null value actually fits in the
maximum length.
IllegalArgumentException
- On invalid input parameters. See
ConstantSizeStringSerializer.ConstantSizeStringSerializer(Charset, int, boolean)
.ConstantSizeStringSerializer.ConstantSizeStringSerializer(Charset,
int, boolean)
Method Detail |
---|
public boolean isNullValuesPermitted()
Serializer
null
values?
isNullValuesPermitted
in interface Serializer<String>
isNullValuesPermitted
in class ConstantSizeStringSerializer
true
, always.public int serialize(String s, byte[] barr, int offset)
Serializer
byte
array.
serialize
in interface Serializer<String>
serialize
in class ConstantSizeStringSerializer
s
- The object to serialize.barr
- The byte array to serialize it to.offset
- The start position to write data at in the byte array.
public byte[] serialize(String s)
Serializer
byte
array.
serialize
in interface Serializer<String>
serialize
in class ConstantSizeStringSerializer
s
- The object to serialize.
byte
array.public String interpret(byte[] barr, int offset, int length)
Serializer
byte
array to an object of the type
handled by the Serializer
implementation.
interpret
in interface Serializer<String>
interpret
in class ConstantSizeStringSerializer
barr
- The byte
array containing the data.offset
- The start position of the data.length
- The length of the data.
Serializer.interpret(byte[])
public String interpret(byte[] barr)
Serializer
byte
array to an object of the type
handled by the Serializer
implementation.
interpret
in interface Serializer<String>
interpret
in class ConstantSizeStringSerializer
barr
- The byte
array containing the data.
Serializer.interpret(byte[], int, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |