public class ToAttributedValueConverter extends 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.Constructor and Description |
---|
ToAttributedValueConverter(Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup)
Creates a new ToAttributedValueConverter instance.
|
ToAttributedValueConverter(Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup,
String valueFieldName)
Creates a new ToAttributedValueConverter instance.
|
ToAttributedValueConverter(Class type,
Mapper mapper,
ReflectionProvider reflectionProvider,
ConverterLookup lookup,
String valueFieldName,
Class valueDefinedIn)
Creates a new ToAttributedValueConverter instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canConvert(Class type)
Determines whether the converter can marshall a particular type.
|
void |
marshal(Object source,
HierarchicalStreamWriter writer,
MarshallingContext context)
Convert an object to textual data.
|
Object |
unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context)
Convert textual data back into an object.
|
public ToAttributedValueConverter(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(Class type, Mapper mapper, ReflectionProvider reflectionProvider, ConverterLookup lookup, 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(Class type, Mapper mapper, ReflectionProvider reflectionProvider, ConverterLookup lookup, String valueFieldName, 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(Class type)
ConverterMatcher
canConvert
in interface ConverterMatcher
type
- the Class representing the object type to be convertedpublic void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Converter
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Converter
Copyright © 2004–2017 XStream. All rights reserved.