|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fudgemsg.FudgeFieldType<T>
T
- underlying Java class this type representspublic class FudgeFieldType<T>
The type of a field as defined by Fudge.
In order to efficiently send messages, Fudge needs to know the type of each piece of data.
A standard set of types is supported by all Fudge-compliant systems.
This set may be extended with custom types within a closed Fudge implementation.
Custom types must be registered with FudgeTypeDictionary
.
This class is not final but is thread-safe in isolation. Subclasses must be immutable and thread-safe.
Constructor Summary | |
---|---|
FudgeFieldType(int typeId,
Class<T> javaType,
boolean isVariableSize,
int fixedSize)
Constructs a new type based on the underlying Java type. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Checks if this type equals another. |
int |
getFixedSize()
Gets the number of bytes used to encode a value if the type is fixed width. |
Class<T> |
getJavaType()
Gets the underlying Java type for values of this type. |
int |
getTypeId()
Gets the Fudge type identifier. |
int |
getVariableSize(T value,
FudgeTaxonomy taxonomy)
Gets the number of bytes used to encode a value. |
int |
hashCode()
Gets a suitable hash code. |
boolean |
isVariableSize()
Checks if the field may contain variable width data. |
T |
readValue(DataInput input,
int dataSize)
Reads a value of this type to the output. |
String |
toString()
Returns a description of the type. |
void |
writeValue(DataOutput output,
T value)
Writes a value of this type to the output. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FudgeFieldType(int typeId, Class<T> javaType, boolean isVariableSize, int fixedSize)
The Fudge type identifier must be unique within the FudgeTypeDictionary
.
typeId
- the type dictionary unique type identifier, from 0 to 255javaType
- the underlying Java type, not nullisVariableSize
- true if the field may contain variable width datafixedSize
- the size in bytes if fixed size, zero for variable widthMethod Detail |
---|
public final int getTypeId()
public final Class<T> getJavaType()
public final boolean isVariableSize()
public final int getFixedSize()
public int getVariableSize(T value, FudgeTaxonomy taxonomy)
A variable width type must override this method.
A fixed width type will return the fixed size
.
value
- the value to check, not used for fixed width typestaxonomy
- the taxonomy being used for the encoding, not used for fixed width types
public void writeValue(DataOutput output, T value) throws IOException
This is intended for use by variable width types and must write the given value.
The implementation must write exactly the number of bytes returned by the
size calculation
.
output
- the output target to write the value to, not nullvalue
- the value to write
IOException
- if an error occurs, which must be wrapped by the callerpublic T readValue(DataInput input, int dataSize) throws IOException
This is intended for use by variable width types and must read the given value. The implementation must read exactly the number of bytes passed into the method.
input
- the input source to read the value from, not nulldataSize
- the number of bytes of data to read
IOException
- if an error occurs, which must be wrapped by the callerpublic final boolean equals(Object obj)
For performance, this only checks the type identifier.
equals
in class Object
obj
- the object to compare to, null returns false
public final int hashCode()
hashCode
in class Object
public final String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |