|
|||||||||
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,PrimitiveType,PrimitiveType>
org.fudgemsg.types.SecondaryFieldType<SecondaryType,PrimitiveType>
SecondaryType
- secondary typePrimitiveType
- type there is a primary FudgeFieldType
forpublic abstract class SecondaryFieldType<SecondaryType,PrimitiveType>
The type definition for a secondary field type that converts Java objects
to a more fundamental Fudge type. 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.
Constructor Summary | |
---|---|
protected |
SecondaryFieldType(FudgeFieldType<PrimitiveType> type,
Class<SecondaryType> javaType)
Creates a new secondary type on top of an existing Fudge type. |
Method Summary | |
---|---|
boolean |
canConvertPrimary(Class<? extends PrimitiveType> clazz)
Returns true if this converter can manipulate the requested class. |
SecondaryType |
primaryToSecondary(PrimitiveType object)
Converts Fudge primitive data to the secondary type. |
SecondaryType |
readValue(DataInput input,
int dataSize)
Reads a value of this type to the output. |
void |
writeValue(DataOutput output,
SecondaryType value)
Writes a value of this type to the output. |
Methods inherited from class org.fudgemsg.types.SecondaryFieldTypeBase |
---|
getPrimaryType, getVariableSize, secondaryToPrimary |
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 |
Constructor Detail |
---|
protected SecondaryFieldType(FudgeFieldType<PrimitiveType> type, Class<SecondaryType> javaType)
type
- existing Fudge primitive typejavaType
- Java type for conversionMethod Detail |
---|
public SecondaryType primaryToSecondary(PrimitiveType object)
object
parameter is not null
.
object
- the Fudge data
public boolean canConvertPrimary(Class<? extends PrimitiveType> clazz)
clazz
- to query
true
if a call to FudgeTypeConverter.primaryToSecondary(Primary)
will succeed, false
if it would failpublic 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 SecondaryFieldTypeBase<SecondaryType,PrimitiveType,PrimitiveType>
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 SecondaryFieldTypeBase<SecondaryType,PrimitiveType,PrimitiveType>
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 |