public class ToAttributedValueConverter extends java.lang.Object implements Converter
SingleValueConverter
. The
value field is defined using the name of the type that declares the field and the field name
itself. Therefore it is possible to define an inherited field as value. It is also possible
to provide no value field at all, so that all fields are written as attributes.Modifier and Type | Field and Description |
---|---|
private Mapper |
enumMapper |
private ConverterLookup |
lookup |
private Mapper |
mapper |
private ReflectionProvider |
reflectionProvider |
private static java.lang.String |
STRUCTURE_MARKER |
private java.lang.Class |
type |
private java.lang.reflect.Field |
valueField |
Constructor and Description |
---|
ToAttributedValueConverter(java.lang.Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup)
Creates a new ToAttributedValueConverter instance.
|
ToAttributedValueConverter(java.lang.Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup,
java.lang.String valueFieldName)
Creates a new ToAttributedValueConverter instance.
|
ToAttributedValueConverter(java.lang.Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup,
java.lang.String valueFieldName,
java.lang.Class valueDefinedIn)
Creates a new ToAttributedValueConverter instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canConvert(java.lang.Class type)
Determines whether the converter can marshall a particular type.
|
private boolean |
fieldIsEqual(FastField field) |
void |
marshal(java.lang.Object source,
HierarchicalStreamWriter writer,
MarshallingContext context)
Convert an object to textual data.
|
java.lang.Object |
unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context)
Convert textual data back into an object.
|
private static final java.lang.String STRUCTURE_MARKER
private final java.lang.Class type
private final Mapper mapper
private final Mapper enumMapper
private final ReflectionProvider reflectionProvider
private final ConverterLookup lookup
private final java.lang.reflect.Field valueField
public ToAttributedValueConverter(java.lang.Class type, Mapper mapper, ReflectionProvider reflectionProvider, ConverterLookup lookup)
type
- the type that is handled by this converter instancemapper
- the mapper in usereflectionProvider
- the reflection provider in uselookup
- the converter lookup in usepublic ToAttributedValueConverter(java.lang.Class type, Mapper mapper, ReflectionProvider reflectionProvider, ConverterLookup lookup, java.lang.String valueFieldName)
type
- the type that is handled by this converter instancemapper
- the mapper in usereflectionProvider
- the reflection provider in uselookup
- the converter lookup in usevalueFieldName
- the field defining the tag's value (may be null)public ToAttributedValueConverter(java.lang.Class type, Mapper mapper, ReflectionProvider reflectionProvider, ConverterLookup lookup, java.lang.String valueFieldName, java.lang.Class valueDefinedIn)
type
- the type that is handled by this converter instancemapper
- the mapper in usereflectionProvider
- the reflection provider in uselookup
- the converter lookup in usevalueFieldName
- the field defining the tag's value (may be null)valueDefinedIn
- the type defining the fieldpublic boolean canConvert(java.lang.Class type)
ConverterMatcher
canConvert
in interface ConverterMatcher
type
- the Class representing the object type to be convertedpublic void marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Converter
public java.lang.Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Converter
private boolean fieldIsEqual(FastField field)