|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fudgemsg.FudgeFieldType<SecondaryType>
org.fudgemsg.types.SecondaryFieldTypeBase<SecondaryType,ConversionType,PrimitiveType>
SecondaryType
- secondary typePrimitiveType
- type there is a primary FudgeFieldType
forConversionType
- base type to support mappings from, e.g. use Object to convert from any of the Fudge primitivespublic abstract class SecondaryFieldTypeBase<SecondaryType,ConversionType,PrimitiveType extends ConversionType>
The base type definition for a secondary field type that converts Java objects
to/from more fundamental Fudge types. This approach is more lightweight than
the tools available in the mapping package, but also limited as there is
no access to the FudgeContext
when the conversion takes place. The
SecondaryFieldType
class provides a simpler interface to use for most
extensions.
Constructor Summary | |
---|---|
protected |
SecondaryFieldTypeBase(FudgeFieldType<PrimitiveType> type,
Class<SecondaryType> javaType)
Creates a new secondary type on top of an existing Fudge type. |
Method Summary | |
---|---|
FudgeFieldType<PrimitiveType> |
getPrimaryType()
Returns the underlying (primary) Fudge type. |
int |
getVariableSize(SecondaryType value,
FudgeTaxonomy taxonomy)
Calculates the resultant size by converting to the primary object and invoking the delegate. |
SecondaryType |
readValue(DataInput input,
int dataSize)
Reads a value of this type to the output. |
abstract PrimitiveType |
secondaryToPrimary(SecondaryType object)
Converts an object from the secondary type to a primitive Fudge type for writing. |
void |
writeValue(DataOutput output,
SecondaryType value)
Writes a value of this type to the output. |
Methods inherited from class org.fudgemsg.FudgeFieldType |
---|
equals, getFixedSize, getJavaType, getTypeId, hashCode, isVariableSize, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.fudgemsg.types.FudgeTypeConverter |
---|
canConvertPrimary, primaryToSecondary |
Constructor Detail |
---|
protected SecondaryFieldTypeBase(FudgeFieldType<PrimitiveType> type, Class<SecondaryType> javaType)
type
- existing Fudge primitive typejavaType
- Java type for conversionMethod Detail |
---|
public FudgeFieldType<PrimitiveType> getPrimaryType()
public abstract PrimitiveType secondaryToPrimary(SecondaryType object)
object
parameter is not null
.
object
- the secondary instance
public int getVariableSize(SecondaryType value, FudgeTaxonomy taxonomy)
getVariableSize
in class FudgeFieldType<SecondaryType>
value
- the value to convert (if it will not be a fixed width type)taxonomy
- the taxonomy used to encode
public void writeValue(DataOutput output, SecondaryType 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
.
writeValue
in class FudgeFieldType<SecondaryType>
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 SecondaryType 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.
readValue
in class FudgeFieldType<SecondaryType>
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 caller
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |