Package de.gsi.serializer.spi
Class ClassFieldDescription
- java.lang.Object
-
- de.gsi.serializer.spi.ClassFieldDescription
-
- All Implemented Interfaces:
FieldDescription
public class ClassFieldDescription extends java.lang.Object implements FieldDescription
- Author:
- rstein
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClassFieldDescription.FieldAccess
-
Constructor Summary
Constructors Modifier Constructor Description ClassFieldDescription(java.lang.Class<?> referenceClass, boolean fullScan)This should be called only once with the root class as an argumentprotectedClassFieldDescription(java.lang.Class<?> referenceClass, java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel)ClassFieldDescription(java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel, boolean fullScan)This should be called for individual class field members
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectallocateMemberClassField(java.lang.Object fieldParent)booleanequals(java.lang.Object obj)protected static voidexploreClass(java.lang.Class<?> classType, ClassFieldDescription parent, int recursionLevel, boolean fullScan)FieldDescriptionfindChildField(int fieldNameHashCode, java.lang.String fieldName)FieldDescriptionfindChildField(java.lang.String fieldName)java.util.List<java.lang.String>getActualTypeArgumentNames()java.util.List<java.lang.reflect.Type>getActualTypeArguments()java.util.List<FieldDescription>getChildren()intgetDataSize()intgetDataStartOffset()intgetDataStartPosition()DataTypegetDataType()ClassFieldDescription.FieldAccessgetField()java.lang.StringgetFieldDescription()java.lang.StringgetFieldDirection()Return optional meta data tag describing the 'direction' of this data field.java.util.List<java.lang.String>getFieldGroups()java.lang.StringgetFieldName()intgetFieldNameHashCode()java.lang.StringgetFieldNameRelative()FieldSerialisergetFieldSerialiser()intgetFieldStart()java.lang.StringgetFieldUnit()java.lang.StringgetGenericFieldTypeString()java.lang.StringgetGenericFieldTypeStringSimple()java.lang.reflect.TypegetGenericType()intgetHierarchyDepth()intgetModifierID()java.lang.StringgetModifierString()FieldDescriptiongetParent()FieldDescriptiongetParent(FieldDescription field, int hierarchyLevel)java.lang.reflect.TypegetType()java.lang.StringgetTypeName()inthashCode()booleanisAbstract()booleanisAnnotationPresent()booleanisClass()booleanisEnum()booleanisFinal()booleanisInterface()booleanisNative()booleanisPrimitive()booleanisPrivate()booleanisProtected()booleanisPublic()booleanisRoot()booleanisSerializable()booleanisStatic()booleanisStrict()booleanisSynchronized()booleanisTransient()booleanisVolatile()protected static voidprintClassStructure(ClassFieldDescription field, boolean fullView, int recursionLevel)voidprintFieldStructure()Prints the class field structure to the logging output for diagnostics purposes starting from this element as a root.voidsetFieldSerialiser(FieldSerialiser<?> fieldSerialiser)java.lang.StringtoString()
-
-
-
Constructor Detail
-
ClassFieldDescription
public ClassFieldDescription(java.lang.Class<?> referenceClass, boolean fullScan)This should be called only once with the root class as an argument- Parameters:
referenceClass- the root node containing further Field childrenfullScan-trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
ClassFieldDescription
protected ClassFieldDescription(java.lang.Class<?> referenceClass, java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel)
-
ClassFieldDescription
public ClassFieldDescription(java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel, boolean fullScan)This should be called for individual class field members- Parameters:
field- Field reference for the given class memberparent- pointer to the root/parent reference class field descriptionrecursionLevel- hierarchy level (i.e. '0' being the root class, '1' the sub-class etc.fullScan-trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
-
Method Detail
-
allocateMemberClassField
public java.lang.Object allocateMemberClassField(java.lang.Object fieldParent)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
findChildField
public FieldDescription findChildField(java.lang.String fieldName)
- Specified by:
findChildFieldin interfaceFieldDescription
-
findChildField
public FieldDescription findChildField(int fieldNameHashCode, java.lang.String fieldName)
- Specified by:
findChildFieldin interfaceFieldDescription
-
getActualTypeArgumentNames
public java.util.List<java.lang.String> getActualTypeArgumentNames()
- Returns:
- generic type argument name of the class (e.g. for List<String> this would return 'java.lang.String')
-
getActualTypeArguments
public java.util.List<java.lang.reflect.Type> getActualTypeArguments()
- Returns:
- generic type argument objects of the class (e.g. for List<String> this would return 'String.class')
-
getChildren
public java.util.List<FieldDescription> getChildren()
- Specified by:
getChildrenin interfaceFieldDescription- Returns:
- the children (if any) from the super classes
-
getDataSize
public int getDataSize()
- Specified by:
getDataSizein interfaceFieldDescription- Returns:
- the data size in bytes stored after the field header
-
getDataStartOffset
public int getDataStartOffset()
- Specified by:
getDataStartOffsetin interfaceFieldDescription- Returns:
- the offset in bytes from the field start position until the first data object can be read. (N.B. equals to 'getFieldstart() + getDataOffset()', the data ends at 'getDataStartOffset() + getDataSize()'
-
getDataStartPosition
public int getDataStartPosition()
- Specified by:
getDataStartPositionin interfaceFieldDescription- Returns:
- the buffer byte position from where the first data object can be read
-
getDataType
public DataType getDataType()
- Specified by:
getDataTypein interfaceFieldDescription- Returns:
- the DataType (if known) for the detected Field,
DataType.OTHERin all other cases
-
getField
public ClassFieldDescription.FieldAccess getField()
- Returns:
- the underlying Field type or
nullif it's a root node
-
getFieldDescription
public java.lang.String getFieldDescription()
- Specified by:
getFieldDescriptionin interfaceFieldDescription- Returns:
- optional meta data tag describing the purpose of this data field (N.B. can be empty String)
-
getFieldDirection
public java.lang.String getFieldDirection()
Description copied from interface:FieldDescriptionReturn optional meta data tag describing the 'direction' of this data field. The information encodes the source servicedevelopers intend to the receiving user whether the field can be, for example, modified (get/set), set-only, or read-only, or attach any other similar information. Encoding/interpretation is left ad-lib to the source service developer.- Specified by:
getFieldDirectionin interfaceFieldDescription- Returns:
- optional meta data (N.B. can be empty String).
-
getFieldGroups
public java.util.List<java.lang.String> getFieldGroups()
- Specified by:
getFieldGroupsin interfaceFieldDescription- Returns:
- optional meta data tag describing the group/set this data field belongs to (N.B. can be empty String, corresponding to 'all')
-
getFieldName
public java.lang.String getFieldName()
- Specified by:
getFieldNamein interfaceFieldDescription- Returns:
- the underlying field name
-
getFieldNameHashCode
public int getFieldNameHashCode()
- Specified by:
getFieldNameHashCodein interfaceFieldDescription- Returns:
- the data field name's hashcode (N.B. used for faster identification of the field)
-
getFieldNameRelative
public java.lang.String getFieldNameRelative()
- Returns:
- relative field name within class hierarchy (ie. field_level0.field_level1.variable_0)
-
getFieldSerialiser
public FieldSerialiser getFieldSerialiser()
-
getFieldStart
public int getFieldStart()
- Specified by:
getFieldStartin interfaceFieldDescription- Returns:
- buffer position in byte where the data field header starts
-
getFieldUnit
public java.lang.String getFieldUnit()
- Specified by:
getFieldUnitin interfaceFieldDescription- Returns:
- optional meta data tag describing the field's SI unit or similar (N.B. can be empty String)
-
getGenericFieldTypeString
public java.lang.String getGenericFieldTypeString()
- Returns:
- field type strings (e.g. for the class Map<Integer,String> this returns '<java.lang.Integer,java.lang.String>'
-
getGenericFieldTypeStringSimple
public java.lang.String getGenericFieldTypeStringSimple()
- Returns:
- field type strings (e.g. for the class Map<Integer,String> this returns '<java.lang.Integer,java.lang.String>'
-
getGenericType
public java.lang.reflect.Type getGenericType()
-
getHierarchyDepth
public int getHierarchyDepth()
- Returns:
- hierarchy level depth w.r.t. root object (ie. '0' being a variable in the root object)
-
getModifierID
public int getModifierID()
- Returns:
- the modifierID
-
getModifierString
public java.lang.String getModifierString()
- Returns:
- the full modifier string (cached)
-
getParent
public FieldDescription getParent()
- Specified by:
getParentin interfaceFieldDescription- Returns:
- the parent
-
getParent
public FieldDescription getParent(FieldDescription field, int hierarchyLevel)
- Parameters:
field- class Field description for whichhierarchyLevel- the recursion level of the parent (e.g. '1' yields the immediate parent, '2' the parent of the parent etc.)- Returns:
- the parent field reference description for the provided field
-
getType
public java.lang.reflect.Type getType()
- Specified by:
getTypein interfaceFieldDescription- Returns:
- field class type
-
getTypeName
public java.lang.String getTypeName()
- Returns:
- field class type name
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isAbstract
public boolean isAbstract()
- Returns:
- the isAbstract
-
isAnnotationPresent
public boolean isAnnotationPresent()
- Specified by:
isAnnotationPresentin interfaceFieldDescription
-
isClass
public boolean isClass()
- Returns:
- the isClass
-
isEnum
public boolean isEnum()
- Returns:
- whether class is an Enum type
-
isFinal
public boolean isFinal()
- Returns:
trueif the class field includes thefinalmodifier;falseotherwise.
-
isInterface
public boolean isInterface()
- Returns:
trueif the class field is an interface
-
isNative
public boolean isNative()
- Returns:
- the isNative
-
isPrimitive
public boolean isPrimitive()
- Returns:
trueif the class field is a primitive type (ie. boolean, byte, ..., int, float, double)
-
isPrivate
public boolean isPrivate()
- Returns:
trueif the class field includes theprivatemodifier;falseotherwise.
-
isProtected
public boolean isProtected()
- Returns:
- the isProtected
-
isPublic
public boolean isPublic()
- Returns:
trueif the class field includes thepublicmodifier;falseotherwise.
-
isRoot
public boolean isRoot()
- Returns:
- the isRoot
-
isSerializable
public boolean isSerializable()
- Returns:
trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
isStatic
public boolean isStatic()
- Returns:
trueif the class field includes thestaticmodifier;falseotherwise.
-
isStrict
public boolean isStrict()
- Returns:
trueif the class field includes thestrictfpmodifier;falseotherwise.
-
isSynchronized
public boolean isSynchronized()
- Returns:
trueif the class field includes thesynchronizedmodifier;falseotherwise.
-
isTransient
public boolean isTransient()
- Returns:
trueif the class field includes thetransientmodifier;falseotherwise.
-
isVolatile
public boolean isVolatile()
- Returns:
trueif the class field includes thevolatilemodifier;falseotherwise.
-
printFieldStructure
public void printFieldStructure()
Description copied from interface:FieldDescriptionPrints the class field structure to the logging output for diagnostics purposes starting from this element as a root. N.B. regarding formatting/parsing The indentation depth is controlled viaClassUtils.setIndentationNumberOfSpace(int). The max recursion depth during the class structure parsing is controlled viaClassUtils.setMaxRecursionDepth(int).- Specified by:
printFieldStructurein interfaceFieldDescription
-
setFieldSerialiser
public void setFieldSerialiser(FieldSerialiser<?> fieldSerialiser)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
exploreClass
protected static void exploreClass(java.lang.Class<?> classType, ClassFieldDescription parent, int recursionLevel, boolean fullScan)
-
printClassStructure
protected static void printClassStructure(ClassFieldDescription field, boolean fullView, int recursionLevel)
-
-