public final class ArrayType extends DataType
EMessageObject
objects of the
same class type.
Supports array sizes up to DataType.MAX_ARRAY_SIZE
items.
ADDRESS_TYPE, ARRAY_SUFFIX, CLASS_TYPE, DEFAULT_CHARSET, EMPTY_STRING, FIELD_MASK_SIZE, INDENT, INDENT1, KEY_TYPE, MAX_ARRAY_SIZE, MAX_BIG_INTEGER_SIZE, MAX_CLASS_NAME_LENGTH, MAX_FIELDS, MAX_FILE_NAME_LENGTH, MAX_STRING_LENGTH, MAX_ZONE_ID_LENGTH, mBuiltinFlag, mClass, mDefaultValue, mIsFixedSize, mSize, sClasses, sCompiledClasses, sTextTypes, STRING_TYPE, sVariableTypes, VARIABLE_SIZE
Constructor and Description |
---|
ArrayType(java.lang.Class<?> jClass,
DataType subtype)
Creates an array type which encapsulates the specified
data type.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createDeserializer(MessageType.MessageField field,
java.lang.String fieldName,
java.lang.String indent,
java.util.Formatter output,
boolean useBuilder)
Generates the Java code for de-serializing an array.
|
protected void |
createSerializer(MessageType.MessageField field,
java.lang.String fieldName,
java.lang.String indent,
java.util.Formatter output)
Generates the array serialization code.
|
java.lang.String |
dataClassName()
Returns the Java class name with "[]" appended.
|
java.lang.Object |
deserialize(MessageType.MessageField field,
java.nio.ByteBuffer buffer)
Returns the de-serialized collection as an
Object . |
boolean |
isInstance(java.lang.Object o)
Returns
true if o is either null
or a Collection instance; false otherwise. |
void |
serialize(java.lang.Object o,
MessageType.MessageField field,
java.nio.ByteBuffer buffer)
Serializes this list to the buffer.
|
DataType |
subtype()
Returns the array subtype.
|
java.lang.String |
toString()
Returns the subtype Java class name followed by "[]".
|
compareTo, dataClass, defaultValue, equals, fields, findCharset, findType, hashCode, isArray, isBoolean, isBoolean, isBuiltin, isEnum, isField, isFixedSize, isLocalOnly, isMessage, isPrimitive, maxAllowedTextSize, replyClasses, size
public ArrayType(java.lang.Class<?> jClass, DataType subtype)
jClass
- the Java array class.subtype
- the array element type.public boolean isInstance(java.lang.Object o)
true
if o
is either null
or a Collection
instance; false
otherwise.isInstance
in class DataType
o
- Check this object's type.true
if o
is either null
or a Collection
instance; false
otherwise.public void serialize(java.lang.Object o, MessageType.MessageField field, java.nio.ByteBuffer buffer)
serialize
in class DataType
o
- an object array.field
- contains external information needed to
serialize this message field.buffer
- serialize array to this buffer.java.nio.BufferOverflowException
- if buffer
overflows.deserialize(net.sf.eBus.messages.type.MessageType.MessageField, java.nio.ByteBuffer)
public java.lang.Object deserialize(MessageType.MessageField field, java.nio.ByteBuffer buffer)
Object
.
If the array size is zero, then returns an empty
collection. The returned value may be safely typecast to
java.util.Collection
.deserialize
in class DataType
field
- contains information needed to de-serialize
this message field.buffer
- de-serialize the list object from this
ByteBuffer
.Collection
.DeserializeException
- if encoded array size is either < zero or > maximum
allowed size.java.nio.BufferUnderflowException
- if buffer
contains an incomplete serialized array.serialize(java.lang.Object, net.sf.eBus.messages.type.MessageType.MessageField, java.nio.ByteBuffer)
protected void createSerializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output)
createSerializer
in class DataType
field
- message field.fieldName
- fully-qualified field name.indent
- indent generated code by this spacing.output
- place generated code into this formatter.protected void createDeserializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output, boolean useBuilder)
createDeserializer
in class DataType
field
- message field.fieldName
- the array message field name.indent
- indent the code by this amount.output
- append the code to this formatter.useBuilder
- if true
then fieldName
is a builder method name; otherwise a local variable.public java.lang.String toString()
public java.lang.String dataClassName()
dataClassName
in class DataType
public DataType subtype()
Copyright © 2001 - 2024. Charles W. Rapp. All rights reserved.