public final class AbstractMessageType extends MessageType
abstract EMessageObject classes. This message type
allows an EMessage and EField types to
contains abstract message fields. This allows a single message
class to be used for a range of field types. The downside is
that message serialization and de-serialization is slowed due
to the need to place the concrete class name in the serialized
message.MessageType.MessageFieldBUILD_INNER_CLASS, BUILDER_METHOD, mFields, mReplyClasses, mSubject, PUBLIC_FINAL, PUBLIC_STATIC, SUBJECT_FIELDADDRESS_TYPE, ARRAY_SUFFIX, CHARSET, CLASS_TYPE, EMPTY_STRING, FIELD_MASK_SIZE, INDENT, INDENT1, KEY_TYPE, MAX_ARRAY_SIZE, MAX_FIELDS, MAX_FILE_NAME_LENGTH, MAX_STRING_LENGTH, mBuiltinFlag, mClass, mDefaultValue, mSize, sClasses, sCompiledClasses, STRING_TYPE, VARIABLE_SIZE| Modifier and Type | Method and Description |
|---|---|
protected void |
createDeserializer(MessageType.MessageField field,
String fieldName,
String indent,
Formatter output,
boolean useBuilder)
Generates the code to de-serialize the named field
from a
ByteBuffer. |
protected void |
createSerializer(MessageType.MessageField field,
String fieldName,
String indent,
Formatter output)
Adds the Java code used to serialize the named field to
a
ByteBuffer. |
Object |
deserialize(ByteBuffer buffer)
Returns a message object de-serialized from the given
buffer.
|
void |
serialize(Object o,
ByteBuffer buffer)
Serializes the message fields to the given the buffer,
setting the field mask.
|
deserializeFields, fields, findFields, isValidReply, numberFields, replyTypes, serializeFields, subject, valuescompareTo, dataClass, dataClassName, defaultValue, equals, fields, findCharset, findType, hashCode, isArray, isBuiltin, isEnum, isInstance, isLocalOnly, isMessage, isPrimitive, replyClasses, size, toStringpublic void serialize(Object o, ByteBuffer buffer) throws BufferOverflowException
Note: as of eBus 4.4.0, messages are
automatically compiled when first used for serialization
or de-serialization. This increases the time it takes to
send or receive a message the first time. When a message
is frequently transmitted, it is recommended that the
message class is "compiled" by calling
DataType.findType(java.lang.Class) for that
message class. So when a message is sent or received the
first time, the message compilation is already done.
serialize in class DataTypeo - serialize this message object.buffer - write to this buffer.BufferOverflowException - if buffer does not contain sufficient space to
store the message.public Object deserialize(ByteBuffer buffer) throws IllegalStateException, BufferUnderflowException, UnknownMessageException, ValidationException
Note: as of eBus 4.4.0, messages are
automatically compiled when first used for serialization
or de-serialization. This increases the time it takes to
send or receive a message the first time. When a message
is frequently transmitted, it is recommended that the
message class is "compiled" by calling
DataType.findType(java.lang.Class) for that
message class. So when a message is sent or received the
first time, the message compilation is already done.
deserialize in class DataTypebuffer - read in the message from this buffer.IllegalStateException - if MessageType.subject(String) was not called prior to
de-serializing.BufferUnderflowException - if buffer contains an incomplete message.UnknownMessageException - if the serialized message is unknown to this eBus.ValidationException - if the message is incorrectly serialized.protected void createSerializer(MessageType.MessageField field, String fieldName, String indent, Formatter output)
ByteBuffer.createSerializer in class DataTypefield - message field.fieldName - the message field name.indent - indent the code by this amount.output - write the code to this formatter.protected void createDeserializer(MessageType.MessageField field, String fieldName, String indent, Formatter output, boolean useBuilder)
ByteBuffer.createDeserializer in class DataTypefield - message field.fieldName - store the de-serialized field in this
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.Copyright © 2019. All rights reserved.