|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fudgemsg.FudgeTypeDictionary
public class FudgeTypeDictionary
The dictionary of all known Fudge types.
In order to efficiently send messages, Fudge needs to know the type of each piece of data. This dictionary keeps track of all the known types.
This class is mutable and thread-safe via concurrent collections.
Field Summary | |
---|---|
static byte |
BOOLEAN_TYPE_ID
Standard Fudge field type: boolean. |
static byte |
BYTE_ARR_128_TYPE_ID
Standard Fudge field type: byte array of length 128. |
static byte |
BYTE_ARR_16_TYPE_ID
Standard Fudge field type: byte array of length 16. |
static byte |
BYTE_ARR_20_TYPE_ID
Standard Fudge field type: byte array of length 20. |
static byte |
BYTE_ARR_256_TYPE_ID
Standard Fudge field type: byte array of length 256. |
static byte |
BYTE_ARR_32_TYPE_ID
Standard Fudge field type: byte array of length 32. |
static byte |
BYTE_ARR_4_TYPE_ID
Standard Fudge field type: byte array of length 4. |
static byte |
BYTE_ARR_512_TYPE_ID
Standard Fudge field type: byte array of length 512. |
static byte |
BYTE_ARR_64_TYPE_ID
Standard Fudge field type: byte array of length 64. |
static byte |
BYTE_ARR_8_TYPE_ID
Standard Fudge field type: byte array of length 8. |
static byte |
BYTE_ARRAY_TYPE_ID
Standard Fudge field type: byte array. |
static byte |
BYTE_TYPE_ID
Standard Fudge field type: 8-bit signed integer. |
static byte |
DATE_TYPE_ID
Standard Fudge field type: date. |
static byte |
DATETIME_TYPE_ID
Standard Fudge field type: combined date and time. |
static byte |
DOUBLE_ARRAY_TYPE_ID
Standard Fudge field type: array of 64-bit floating point. |
static byte |
DOUBLE_TYPE_ID
Standard Fudge field type: 64-bit floating point. |
static byte |
FLOAT_ARRAY_TYPE_ID
Standard Fudge field type: array of 32-bit floating point. |
static byte |
FLOAT_TYPE_ID
Standard Fudge field type: 32-bit floating point. |
static byte |
FUDGE_MSG_TYPE_ID
Standard Fudge field type: embedded Fudge sub-message. |
static byte |
INDICATOR_TYPE_ID
Standard Fudge field type: unsized indicator value. |
static byte |
INT_ARRAY_TYPE_ID
Standard Fudge field type: array of 32-bit signed integers. |
static byte |
INT_TYPE_ID
Standard Fudge field type: 32-bit signed integer. |
static byte |
LONG_ARRAY_TYPE_ID
Standard Fudge field type: array of 64-bit signed integers. |
static byte |
LONG_TYPE_ID
Standard Fudge field type: 64-bit signed integer. |
static byte |
SHORT_ARRAY_TYPE_ID
Standard Fudge field type: array of 16-bit signed integers. |
static byte |
SHORT_TYPE_ID
Standard Fudge field type: 16-bit signed integer. |
static byte |
STRING_TYPE_ID
Standard Fudge field type: string. |
static byte |
TIME_TYPE_ID
Standard Fudge field type: time. |
Constructor Summary | |
---|---|
|
FudgeTypeDictionary()
Creates a new dictionary configured with the default types from the Fudge specification. |
protected |
FudgeTypeDictionary(FudgeTypeDictionary other)
Creates a new dictionary as a clone of another. |
Method Summary | ||
---|---|---|
void |
addAllAnnotatedSecondaryTypes()
Scans all files available to common classpath loading system heuristics to determine which ones have the FudgeSecondaryType annotation, and registers those as appropriate
secondary types. |
|
void |
addAnnotatedSecondaryTypeClass(String className)
Add a class which is known to have a FudgeBuilderFor annotation as an
object or message builder (or both). |
|
void |
addType(FudgeFieldType<?> type,
Class<?>... alternativeTypes)
Register a new type with the dictionary. |
|
void |
addTypeConverter(FudgeTypeConverter<?,?> converter,
Class<?>... types)
Registers a new type conversion with the dictionary. |
|
|
canConvertField(Class<T> clazz,
FudgeField field)
Type conversion test for secondary types. |
|
FudgeFieldType<?> |
getByJavaType(Class<?> javaType)
Resolves a Java class to a FudgeFieldType registered with this dictionary. |
|
FudgeFieldType<?> |
getByTypeId(int typeId)
Obtain a known type by the type ID specified. |
|
|
getFieldValue(Class<T> clazz,
FudgeField field)
Type conversion for secondary types. |
|
protected
|
getTypeConverter(Class<T> javaType)
Resolves a Java class to a FudgeTypeConverter . |
|
UnknownFudgeFieldType |
getUnknownType(int typeId)
Obtain an unknown type wrapper for the type ID specified. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte INDICATOR_TYPE_ID
public static final byte BOOLEAN_TYPE_ID
public static final byte BYTE_TYPE_ID
public static final byte SHORT_TYPE_ID
public static final byte INT_TYPE_ID
public static final byte LONG_TYPE_ID
public static final byte BYTE_ARRAY_TYPE_ID
public static final byte SHORT_ARRAY_TYPE_ID
public static final byte INT_ARRAY_TYPE_ID
public static final byte LONG_ARRAY_TYPE_ID
public static final byte FLOAT_TYPE_ID
public static final byte DOUBLE_TYPE_ID
public static final byte FLOAT_ARRAY_TYPE_ID
public static final byte DOUBLE_ARRAY_TYPE_ID
public static final byte STRING_TYPE_ID
public static final byte FUDGE_MSG_TYPE_ID
public static final byte BYTE_ARR_4_TYPE_ID
public static final byte BYTE_ARR_8_TYPE_ID
public static final byte BYTE_ARR_16_TYPE_ID
public static final byte BYTE_ARR_20_TYPE_ID
public static final byte BYTE_ARR_32_TYPE_ID
public static final byte BYTE_ARR_64_TYPE_ID
public static final byte BYTE_ARR_128_TYPE_ID
public static final byte BYTE_ARR_256_TYPE_ID
public static final byte BYTE_ARR_512_TYPE_ID
public static final byte DATE_TYPE_ID
public static final byte TIME_TYPE_ID
public static final byte DATETIME_TYPE_ID
Constructor Detail |
---|
public FudgeTypeDictionary()
protected FudgeTypeDictionary(FudgeTypeDictionary other)
other
- the dictionary to copy data fromMethod Detail |
---|
public void addTypeConverter(FudgeTypeConverter<?,?> converter, Class<?>... types)
A converter will be used by getFieldValue(java.lang.Class
to expand a non-matching type.
The secondary type mechanism will register the appropriate conversion
automatically when addType(org.fudgemsg.FudgeFieldType>, java.lang.Class>...)
is called.
converter
- the converter to registertypes
- the types to register againstpublic void addType(FudgeFieldType<?> type, Class<?>... alternativeTypes)
Custom types that are not part of the Fudge specification should use IDs allocated downwards from 255 for compatibility with future versions that might include additional standard types.
type
- the FudgeFieldType
definition of the type, not nullalternativeTypes
- any additional Java classes that are synonymous with this typepublic FudgeFieldType<?> getByJavaType(Class<?> javaType)
FudgeFieldType
registered with this dictionary.
javaType
- the class to resolve
protected <T> FudgeTypeConverter<Object,T> getTypeConverter(Class<T> javaType)
FudgeTypeConverter
.
A converter may be derived from registration of a SecondaryFieldType
,
a default conversion between the Java classes that represent the Fudge primitive
types, or explicitly registered with addTypeConverter(org.fudgemsg.types.FudgeTypeConverter, ?>, java.lang.Class>...)
.
T
- Java type of the class to look upjavaType
- the class to look up
public FudgeFieldType<?> getByTypeId(int typeId)
For processing unhandled variable-width field types, this method will return
null
, and getUnknownType(int)
should be used if unhandled-type
processing is desired.
typeId
- the numeric type identifier
public UnknownFudgeFieldType getUnknownType(int typeId)
Unknown types allow data to be preserved within a Fudge message even if the application is unable to process it.
typeId
- the numeric type identifier
public <T> T getFieldValue(Class<T> clazz, FudgeField field) throws IllegalArgumentException
T
- type to convert toclazz
- the target class for the converted value, not nullfield
- the field containing the value to convert, null returns null
IllegalArgumentException
- if the parameters are not valid for conversionpublic <T> boolean canConvertField(Class<T> clazz, FudgeField field)
Returns true
if getFieldValue(java.lang.Class
would return an object instance.
T
- type to convert toclazz
- the target class for the converted value, not nullfield
- the field containing the value to convert, null returns false
true
if a conversion is possible, false
otherwise
(when getFieldValue(java.lang.Class, org.fudgemsg.FudgeField)
might return null
or throw an exception)public void addAllAnnotatedSecondaryTypes()
FudgeSecondaryType
annotation, and registers those as appropriate
secondary types.
This is potentially a very expensive operation, and as such is optional.
public void addAnnotatedSecondaryTypeClass(String className)
FudgeBuilderFor
annotation as an
object or message builder (or both).
className
- the fully qualified name of the builder class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |