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.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.
|
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.
|
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
Copyright © 2004–2022 XStream. All rights reserved.