public class Jaxb2XmlDecoder extends AbstractDecoder<java.lang.Object>
Object
s (POJOs).Jaxb2XmlEncoder
Modifier and Type | Class and Description |
---|---|
private static class |
Jaxb2XmlDecoder.SplitFunction |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
JAXB_DEFAULT_ANNOTATION_VALUE
The default value for JAXB annotations.
|
private JaxbContextContainer |
jaxbContexts |
private java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> |
unmarshallerProcessor |
private XmlEventDecoder |
xmlEventDecoder |
logger
Constructor and Description |
---|
Jaxb2XmlDecoder() |
Jaxb2XmlDecoder(MimeType... supportedMimeTypes)
Create a
Jaxb2XmlDecoder with the specified MIME types. |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecode(ResolvableType elementType,
MimeType mimeType)
Whether the decoder supports the given target element type and the MIME
type of the source stream.
|
<any> |
decode(<any> inputStream,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
Decode a
DataBuffer input stream into a Flux of T . |
<any> |
decodeToMono(<any> inputStream,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
Decode a
DataBuffer input stream into a Mono of T . |
java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> |
getUnmarshallerProcessor()
Return the configured processor for customizing Unmarshaller instances.
|
private javax.xml.bind.Unmarshaller |
initUnmarshaller(java.lang.Class<?> outputClass) |
void |
setUnmarshallerProcessor(java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> processor)
Configure a processor function to customize Unmarshaller instances.
|
(package private) <any> |
split(<any> xmlEventFlux,
javax.xml.namespace.QName desiredName)
Split a flux of
XMLEvents into a flux of XMLEvent lists, one list
for each branch of the tree that starts with the given qualified name. |
(package private) javax.xml.namespace.QName |
toQName(java.lang.Class<?> outputClass)
Returns the qualified name for the given class, according to the mapping rules
in the JAXB specification.
|
private java.lang.Object |
unmarshal(java.util.List<javax.xml.stream.events.XMLEvent> events,
java.lang.Class<?> outputClass) |
getDecodableMimeTypes, getLogger, setLogger
private static final java.lang.String JAXB_DEFAULT_ANNOTATION_VALUE
XmlRootElement.name()
,
XmlRootElement.namespace()
,
XmlType.name()
,
XmlType.namespace()
,
Constant Field Valuesprivate final XmlEventDecoder xmlEventDecoder
private final JaxbContextContainer jaxbContexts
private java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> unmarshallerProcessor
public Jaxb2XmlDecoder()
public Jaxb2XmlDecoder(MimeType... supportedMimeTypes)
Jaxb2XmlDecoder
with the specified MIME types.supportedMimeTypes
- supported MIME typespublic void setUnmarshallerProcessor(java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> processor)
processor
- the function to usepublic java.util.function.Function<javax.xml.bind.Unmarshaller,javax.xml.bind.Unmarshaller> getUnmarshallerProcessor()
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
Decoder
canDecode
in interface Decoder<java.lang.Object>
canDecode
in class AbstractDecoder<java.lang.Object>
elementType
- the target element type for the output streammimeType
- the mime type associated with the stream to decode
(can be null
if not specified)true
if supported, false
otherwisepublic <any> decode(<any> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable java.util.Map<java.lang.String,java.lang.Object> hints)
Decoder
DataBuffer
input stream into a Flux of T
.inputStream
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do encodepublic <any> decodeToMono(<any> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable java.util.Map<java.lang.String,java.lang.Object> hints)
Decoder
DataBuffer
input stream into a Mono of T
.decodeToMono
in interface Decoder<java.lang.Object>
decodeToMono
in class AbstractDecoder<java.lang.Object>
inputStream
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do encodeprivate java.lang.Object unmarshal(java.util.List<javax.xml.stream.events.XMLEvent> events, java.lang.Class<?> outputClass)
private javax.xml.bind.Unmarshaller initUnmarshaller(java.lang.Class<?> outputClass) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
javax.xml.namespace.QName toQName(java.lang.Class<?> outputClass)
<any> split(<any> xmlEventFlux, javax.xml.namespace.QName desiredName)
XMLEvents
into a flux of XMLEvent lists, one list
for each branch of the tree that starts with the given qualified name.
That is, given the XMLEvents shown here,
and the desiredName
"child
", this method returns a flux
of two lists, each of which containing the events of a particular branch
of the tree that starts with "child
".
StartElement
child
Characters
foo
EndElement
child
StartElement
child
Characters
bar
EndElement
child