Package net.sf.eBus.messages.type
Class EnumType
- java.lang.Object
 - 
- net.sf.eBus.messages.type.DataType
 - 
- net.sf.eBus.messages.type.EnumType
 
 
 
- 
- All Implemented Interfaces:
 java.lang.Comparable<DataType>
public final class EnumType extends DataType
Provides binary serialization/de-serialization ofjava.lang.Enuminstances.- Author:
 - Charles Rapp
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static intBYTESAnenumrequires 2 bytes for encoding.- 
Fields inherited from class net.sf.eBus.messages.type.DataType
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 
 - 
 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateDeserializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output, boolean useBuilder)Generates the code to de-serialize the enum instance from aByteBufferbased on the enum ordinal value.protected voidcreateSerializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output)Adds the Java code used to serialize the enum ordinal value to aByteBuffer.java.lang.Objectdeserialize(MessageType.MessageField field, java.nio.ByteBuffer buffer)Returns the de-serializedEnuminbuffer.booleanisInstance(java.lang.Object o)Returnstrueifois a non-nullenum instance andfalseotherwise.voidserialize(java.lang.Object o, MessageType.MessageField field, java.nio.ByteBuffer buffer)Serializes thisEnumordinal to the givenbuffer.- 
Methods inherited from class net.sf.eBus.messages.type.DataType
compareTo, dataClass, dataClassName, defaultValue, equals, fields, findCharset, findType, hashCode, isArray, isBoolean, isBoolean, isBuiltin, isEnum, isField, isFixedSize, isLocalOnly, isMessage, isPrimitive, maxAllowedTextSize, replyClasses, size, toString 
 - 
 
 - 
 
- 
- 
Field Detail
- 
BYTES
public static final int BYTES
Anenumrequires 2 bytes for encoding.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
isInstance
public boolean isInstance(java.lang.Object o)
Returnstrueifois a non-nullenum instance andfalseotherwise.- Overrides:
 isInstancein classDataType- Parameters:
 o- Check this object's type.- Returns:
 trueifois a non-nullenum instance andfalseotherwise.
 
- 
serialize
public void serialize(java.lang.Object o, MessageType.MessageField field, java.nio.ByteBuffer buffer)Serializes thisEnumordinal to the givenbuffer.- Specified by:
 serializein classDataType- Parameters:
 o- AEnumobject. May benull.field- contains external information needed to serialize this message field.buffer- serialize to this buffer.- Throws:
 java.nio.BufferOverflowException- ifbufferoverflows.- See Also:
 deserialize(net.sf.eBus.messages.type.MessageType.MessageField, java.nio.ByteBuffer)
 
- 
deserialize
public java.lang.Object deserialize(MessageType.MessageField field, java.nio.ByteBuffer buffer)
Returns the de-serializedEnuminbuffer.- Specified by:
 deserializein classDataType- Parameters:
 field- contains information needed to de-serialize this message field.buffer- de-serialize theEnumobject from thisByteBuffer.- Returns:
 - the de-serialized 
Enum. - Throws:
 java.nio.BufferUnderflowException- ifbuffercontains an incomplete serialized enum.- See Also:
 serialize(java.lang.Object, net.sf.eBus.messages.type.MessageType.MessageField, java.nio.ByteBuffer)
 
- 
createSerializer
protected void createSerializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output)
Adds the Java code used to serialize the enum ordinal value to aByteBuffer.- Specified by:
 createSerializerin classDataType- Parameters:
 field- message field.fieldName- the message field name.indent- indent the code by this amount.output- write the code to this formatter.
 
- 
createDeserializer
protected void createDeserializer(MessageType.MessageField field, java.lang.String fieldName, java.lang.String indent, java.util.Formatter output, boolean useBuilder)
Generates the code to de-serialize the enum instance from aByteBufferbased on the enum ordinal value.- Specified by:
 createDeserializerin classDataType- Parameters:
 field- 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- iftruethenfieldNameis a builder method name; otherwise a local variable.
 
 - 
 
 -