javanet.staxutils
public class XMLEventPipe extends Object
XMLEvent
s written to one
XMLEventWriter
to be read from a XMLEventReader
. The
implementation is based on a bounded-buffer with a specifiable maximum
capacity. When that capacity is reached, the write end of the pipe will
block until events are read from the read end. Similarly, when an attempt is
made to read from an empty queue, the operation will block until more events
are written to the buffer. The write end of the pipe will repair namespaces
and buffer attribute/namespace events as defined in the specification of
the XMLEventWriter
interface.
XMLEventReader
and
XMLStreamWriter
, methods such as
XMLEventReader.peek()
and XMLEventReader.hasNext()
may block.
This is necessary to prevent XMLEventReader.hasNext()
from returning
true
just before the write end is closed, or false
just before additional events are added. If the read end is closed before the
writer, then the write end will silently discard all elements written to it
until it is closed.Modifier and Type | Field and Description |
---|---|
static int |
QUEUE_CAPACITY
Default maximum number of events that may be stored by this pipe until
the write end blocks.
|
Constructor and Description |
---|
XMLEventPipe()
Constructs a new XMLEventPipe with the default capacity.
|
XMLEventPipe(int capacity)
Constructs a new XMLEventPipe with the specified capacity.
|
Modifier and Type | Method and Description |
---|---|
XMLEventReader |
getReadEnd()
Returns the read end of the pipe, from which events written to the write
end of the pipe will be available.
|
XMLEventWriter |
getWriteEnd()
Returns the write end of the pipe, whose events will be available from
the read end of this pipe.
|
public static final int QUEUE_CAPACITY
public XMLEventPipe()
public XMLEventPipe(int capacity)
capacity
- The number of events to buffer until the pipe will block.
A number less than or equal to 0 means the pipe will buffer an
unbounded number of events.public XMLEventReader getReadEnd()
public XMLEventWriter getWriteEnd()