Top Description Inners Fields Constructors Methods
org.springframework.http.codec.xml

public Class XmlEventDecoder

extends AbstractDecoder<XMLEvent>
Class Inheritance
Imports
java.io.InputStream, java.util.ArrayList, .Iterator, .List, .Map, java.util.function.Function, javax.xml.stream.XMLInputFactory, .XMLStreamException, javax.xml.stream.events.XMLEvent, javax.xml.stream.util.XMLEventAllocator, com.fasterxml.aalto.AsyncByteBufferFeeder, .AsyncXMLInputFactory, .AsyncXMLStreamReader, com.fasterxml.aalto.evt.EventAllocatorImpl, com.fasterxml.aalto.stax.InputFactoryImpl, org.reactivestreams.Publisher, reactor.core.publisher.Flux, org.springframework.core.ResolvableType, org.springframework.core.codec.AbstractDecoder, .DecodingException, org.springframework.core.io.buffer.DataBuffer, .DataBufferLimitException, .DataBufferUtils, org.springframework.http.MediaType, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, .MimeType, .MimeTypeUtils, org.springframework.util.xml.StaxUtils

Decodes a DataBuffer stream into a stream of XMLEvents.

Given the following XML:

<root>
    <child>foo</child>
    <child>bar</child>
</root>
this decoder will produce a Flux with the following events:
  1. javax.xml.stream.events.StartDocument
  2. javax.xml.stream.events.StartElement root
  3. javax.xml.stream.events.StartElement child
  4. javax.xml.stream.events.Characters foo
  5. javax.xml.stream.events.EndElement child
  6. javax.xml.stream.events.StartElement child
  7. javax.xml.stream.events.Characters bar
  8. javax.xml.stream.events.EndElement child
  9. javax.xml.stream.events.EndElement root

Note that this decoder is not registered by default but is used internally by other decoders which are registered by default.

Authors
Arjen Poutsma, Sam Brannen
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final XMLInputFactory
private int
pack-priv boolean
Inherited from org.springframework.core.codec.AbstractDecoder:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Flux<XMLEvent>
decode(Publisher<DataBuffer>
the DataBuffer input stream to decode
input
,
ResolvableType
the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.
elementType
,
MimeType
the MIME type associated with the input stream (optional)
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Implements org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.
public int
getMaxInMemorySize()

Return the configured byte count limit.

public void
setMaxInMemorySize(int
the max number of bytes to buffer, or -1 for unlimited
byteCount
)

Set the max number of bytes that can be buffered by this decoder.

Inherited from org.springframework.core.codec.AbstractDecoder:
canDecodedecodeToMonogetDecodableMimeTypesgetLoggersetLogger

Field Detail

aaltoPresentback to summary
private static final boolean aaltoPresent
inputFactoryback to summary
private static final XMLInputFactory inputFactory
maxInMemorySizeback to summary
private int maxInMemorySize
useAaltoback to summary
pack-priv boolean useAalto

Constructor Detail

XmlEventDecoderback to summary
public XmlEventDecoder()

Method Detail

decodeback to summary
public Flux<XMLEvent> decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Implements org.springframework.core.codec.Decoder.decode.

Doc from org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.

Parameters
input:Publisher<DataBuffer>

the DataBuffer input stream to decode

elementType:ResolvableType

the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.

mimeType:MimeType

the MIME type associated with the input stream (optional)

hints:Map<String, Object>

additional information about how to do decode

Returns:Flux<XMLEvent>

the output stream with decoded elements

Annotations
@Override
getMaxInMemorySizeback to summary
public int getMaxInMemorySize()

Return the configured byte count limit.

Since
5.1.11
setMaxInMemorySizeback to summary
public void setMaxInMemorySize(int byteCount)

Set the max number of bytes that can be buffered by this decoder. This is either the size the entire input when decoding as a whole, or when using async parsing via Aalto XML, it is size one top-level XML tree. When the limit is exceeded, DataBufferLimitException is raised.

By default this is set to 256K.

Parameters
byteCount:int

the max number of bytes to buffer, or -1 for unlimited

Since
5.1.11
org.springframework.http.codec.xml back to summary

private Class XmlEventDecoder.AaltoDataBufferToXmlEvent

extends Object
implements Function<DataBuffer, List<? extends XMLEvent>>
Class Inheritance
  • java.lang.Object
  • org.springframework.http.codec.xml.XmlEventDecoder.AaltoDataBufferToXmlEvent
All Implemented Interfaces
java.util.function.Function

Field Summary

Modifier and TypeField and Description
private int
private int
private final XMLEventAllocator
private static final AsyncXMLInputFactory
private final int
private final AsyncXMLStreamReader<AsyncByteBufferFeeder>

Constructor Summary

AccessConstructor and Description
public
AaltoDataBufferToXmlEvent(int maxInMemorySize)

Method Summary

Modifier and TypeMethod and Description
public List<? extends XMLEvent>
apply(DataBuffer
the function argument
dataBuffer
)

Implements java.util.function.Function.apply.

Applies this function to the given argument.
private void
public void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteCountback to summary
private int byteCount
elementDepthback to summary
private int elementDepth
eventAllocatorback to summary
private final XMLEventAllocator eventAllocator
inputFactoryback to summary
private static final AsyncXMLInputFactory inputFactory
maxInMemorySizeback to summary
private final int maxInMemorySize
streamReaderback to summary
private final AsyncXMLStreamReader<AsyncByteBufferFeeder> streamReader

Constructor Detail

AaltoDataBufferToXmlEventback to summary
public AaltoDataBufferToXmlEvent(int maxInMemorySize)

Method Detail

applyback to summary
public List<? extends XMLEvent> apply(DataBuffer dataBuffer)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Parameters
dataBuffer:DataBuffer

the function argument

Returns:List<? extends XMLEvent>

the function result

Annotations
@Override
checkDepthAndResetByteCountback to summary
private void checkDepthAndResetByteCount(XMLEvent event)
endOfInputback to summary
public void endOfInput()
increaseByteCountback to summary
private void increaseByteCount(DataBuffer dataBuffer)
raiseLimitExceptionback to summary
private void raiseLimitException()