public abstract class TransducedAccessor<BeanT> extends Object
Accessor
and Transducer
combined into one object.
This allows efficient conversions between primitive values and String without using boxing.
This abstraction only works for a single-value property.
An instance of TransducedAccessor
implicitly holds a
field of the BeanT
that the accessors access.
Modifier and Type | Class and Description |
---|---|
static class |
TransducedAccessor.CompositeTransducedAccessorImpl<BeanT,ValueT>
|
Constructor and Description |
---|
TransducedAccessor() |
Modifier and Type | Method and Description |
---|---|
void |
declareNamespace(BeanT o,
XMLSerializer w)
Obtain the value of the field and declares the namespace URIs used in
the value.
|
static <T> TransducedAccessor<T> |
get(JAXBContextImpl context,
RuntimeNonElementRef ref)
Gets the
TransducedAccessor appropriately configured for
the given property. |
abstract boolean |
hasValue(BeanT o)
Checks if the field has a value.
|
abstract void |
parse(BeanT o,
CharSequence lexical)
Parses the text value into the responsible field of the given bean.
|
abstract CharSequence |
print(BeanT o)
Prints the responsible field of the given bean to the writer.
|
boolean |
useNamespace() |
abstract void |
writeLeafElement(XMLSerializer w,
Name tagName,
BeanT o,
String fieldName)
Convenience method to write the value as a text inside an element
without any attributes.
|
abstract void |
writeText(XMLSerializer w,
BeanT o,
String fieldName)
Invokes one of the
XMLSerializer.text(String, String) method
with the representation of data bested suited for this transduced accessor. |
public boolean useNamespace()
Transducer.useNamespace()
public void declareNamespace(BeanT o, XMLSerializer w) throws AccessorException, SAXException
AccessorException
SAXException
Transducer.declareNamespace(Object, XMLSerializer)
@Nullable public abstract CharSequence print(@NotNull BeanT o) throws AccessorException, SAXException
Use XMLSerializer.getInstance()
to access to the namespace bindings
AccessorException
SAXException
public abstract void parse(BeanT o, CharSequence lexical) throws AccessorException, SAXException
Use UnmarshallingContext.getInstance()
to access to the namespace bindings
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.RuntimeException
- if the lexical form is incorrect. The method may throw a RuntimeException,
but it shouldn't cause the entire unmarshalling to fail.SAXException
- if the parse method found an error, the error is reported, and then
the processing is aborted.public abstract boolean hasValue(BeanT o) throws AccessorException
AccessorException
public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonElementRef ref)
TransducedAccessor
appropriately configured for
the given property.
This allows the implementation to use an optimized code.
public abstract void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException
The callee assumes that there's an associated value in the field. No @xsi:type handling is expected.
public abstract void writeText(XMLSerializer w, BeanT o, String fieldName) throws AccessorException, SAXException, IOException, XMLStreamException
XMLSerializer.text(String, String)
method
with the representation of data bested suited for this transduced accessor.Copyright © 2018 JBoss by Red Hat. All rights reserved.