public interface Transducer<ValueT>
An implementation of this interface hides how this conversion happens.
Transducer
s are immutable.
Modifier and Type | Method and Description |
---|---|
void |
declareNamespace(ValueT o,
XMLSerializer w)
Declares the namespace URIs used in the given value to
w . |
QName |
getTypeName(ValueT instance)
Transducers implicitly work against a single XML type,
but sometimes (most notably
XMLGregorianCalendar ,
an instance may choose different XML types. |
boolean |
isDefault()
If this
Transducer is the default transducer for the ValueT ,
this method returns true. |
ValueT |
parse(CharSequence lexical)
Converts the lexical representation to a value object.
|
CharSequence |
print(ValueT o)
Converts the given value to its lexical representation.
|
boolean |
useNamespace()
If true, this
Transducer doesn't declare any namespace,
and therefore declareNamespace(Object, XMLSerializer) is no-op. |
void |
writeLeafElement(XMLSerializer w,
Name tagName,
ValueT o,
String fieldName)
Sends the result of the
print(Object) operation
to one of the XMLSerializer.leafElement(Name, String, String) method. |
void |
writeText(XMLSerializer w,
ValueT o,
String fieldName)
Sends the result of the
print(Object) operation
to one of the XMLSerializer.text(String, String) method,
but with the best representation of the value, not necessarily String. |
boolean isDefault()
Transducer
is the default transducer for the ValueT
,
this method returns true.
Used exclusively by OptimizedTransducedAccessorFactory.get(RuntimePropertyInfo)
boolean useNamespace()
Transducer
doesn't declare any namespace,
and therefore declareNamespace(Object, XMLSerializer)
is no-op.
It also means that the parse(CharSequence)
method
won't use the context parameter.void declareNamespace(ValueT o, XMLSerializer w) throws AccessorException
w
.o
- never be null.w
- may be null if !{@link #useNamespace()}
.AccessorException
@NotNull CharSequence print(@NotNull ValueT o) throws AccessorException
o
- never be null.AccessorException
ValueT parse(CharSequence lexical) throws AccessorException, SAXException
lexical
- never be null.AccessorException
- if the transducer is used to parse an user bean that uses XmlValue
,
then this exception may occur when it tries to set the leaf value to the bean.SAXException
- if the lexical form is incorrect, the error should be reported
and SAXException may thrown (or it can return null to recover.)void writeText(XMLSerializer w, ValueT o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException
print(Object)
operation
to one of the XMLSerializer.text(String, String)
method,
but with the best representation of the value, not necessarily String.void writeLeafElement(XMLSerializer w, Name tagName, @NotNull ValueT o, String fieldName) throws IOException, SAXException, XMLStreamException, AccessorException
print(Object)
operation
to one of the XMLSerializer.leafElement(Name, String, String)
method.
but with the best representation of the value, not necessarily String.QName getTypeName(@NotNull ValueT instance)
XMLGregorianCalendar
,
an instance may choose different XML types.Copyright © 2017 JBoss by Red Hat. All rights reserved.