Module com.sun.xml.bind
Class TransducedAccessor<BeanT>
- java.lang.Object
-
- org.glassfish.jaxb.runtime.v2.runtime.reflect.TransducedAccessor<BeanT>
-
- Direct Known Subclasses:
DefaultTransducedAccessor,TransducedAccessor.CompositeTransducedAccessorImpl
public abstract class TransducedAccessor<BeanT> extends Object
AccessorandTransducercombined 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
TransducedAccessorimplicitly holds a field of theBeanTthat the accessors access.- Author:
- Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransducedAccessor.CompositeTransducedAccessorImpl<BeanT,ValueT>
-
Constructor Summary
Constructors Constructor Description TransducedAccessor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddeclareNamespace(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 theTransducedAccessorappropriately configured for the given property.abstract booleanhasValue(BeanT o)Checks if the field has a value.abstract voidparse(BeanT o, CharSequence lexical)Parses the text value into the responsible field of the given bean.abstract CharSequenceprint(BeanT o)Prints the responsible field of the given bean to the writer.booleanuseNamespace()abstract voidwriteLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName)Convenience method to write the value as a text inside an element without any attributes.abstract voidwriteText(XMLSerializer w, BeanT o, String fieldName)Invokes one of theXMLSerializer.text(String, String)method with the representation of data bested suited for this transduced accessor.
-
-
-
Method Detail
-
useNamespace
public boolean useNamespace()
- See Also:
Transducer.useNamespace()
-
declareNamespace
public void declareNamespace(BeanT o, XMLSerializer w) throws AccessorException, SAXException
Obtain the value of the field and declares the namespace URIs used in the value.- Throws:
AccessorExceptionSAXException- See Also:
Transducer.declareNamespace(Object, XMLSerializer)
-
print
@Nullable public abstract CharSequence print(@NotNull BeanT o) throws AccessorException, SAXException
Prints the responsible field of the given bean to the writer.Use
XMLSerializer.getInstance()to access to the namespace bindings- Returns:
- if the accessor didn't yield a value, return null.
- Throws:
AccessorExceptionSAXException
-
parse
public abstract void parse(BeanT o, CharSequence lexical) throws AccessorException, SAXException
Parses the text value into the responsible field of the given bean.Use
UnmarshallingContext.getInstance()to access to the namespace bindings- Throws:
AccessorException- if the transducer is used to parse an user bean that usesXmlValue, 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.
-
hasValue
public abstract boolean hasValue(BeanT o) throws AccessorException
Checks if the field has a value.- Throws:
AccessorException
-
get
public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonElementRef ref)
Gets theTransducedAccessorappropriately configured for the given property.This allows the implementation to use an optimized code.
-
writeLeafElement
public abstract void writeLeafElement(XMLSerializer w, Name tagName, BeanT o, String fieldName) throws SAXException, AccessorException, IOException, XMLStreamException
Convenience method to write the value as a text inside an element without any attributes. Can be overridden for improved performance.The callee assumes that there's an associated value in the field. No @xsi:type handling is expected.
-
writeText
public abstract void writeText(XMLSerializer w, BeanT o, String fieldName) throws AccessorException, SAXException, IOException, XMLStreamException
Invokes one of theXMLSerializer.text(String, String)method with the representation of data bested suited for this transduced accessor.
-
-