| java.lang.Object javanet.staxutils.XMLEventPipe
XMLEventPipe | public class XMLEventPipe (Code) | | Provides the ability to pipe the
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.
Both the read and write ends of this pipe are fully synchronized to allow
multiple threads to read or write events to the pipe. However, care must be
taken that the order of events is consistent, and that the stream is properly
closed when writing is complete. If the write end is never closed the read
end may block indefinitely, waiting for further events. To help prevent
this, the write end will automatically close when an END_DOCUMENT event is
written.
To properly obey the expected behaviour of
XMLEventReader and
javax.xml.stream.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.
author: Christian Niles version: $Revision: 1.2 $ |
Field Summary | |
final public static int | QUEUE_CAPACITY Default maximum number of events that may be stored by this pipe until
the write end blocks. |
Constructor Summary | |
public | XMLEventPipe() Constructs a new XMLEventPipe with the default capacity. | public | XMLEventPipe(int capacity) Constructs a new XMLEventPipe with the specified capacity. |
Method Summary | |
public synchronized XMLEventReader | getReadEnd() Returns the read end of the pipe, from which events written to the write
end of the pipe will be available. | public synchronized XMLEventWriter | getWriteEnd() Returns the write end of the pipe, whose events will be available from
the read end of this pipe. |
QUEUE_CAPACITY | final public static int QUEUE_CAPACITY(Code) | | Default maximum number of events that may be stored by this pipe until
the write end blocks.
|
XMLEventPipe | public XMLEventPipe()(Code) | | Constructs a new XMLEventPipe with the default capacity.
|
XMLEventPipe | public XMLEventPipe(int capacity)(Code) | | Constructs a new XMLEventPipe with the specified capacity.
Parameters: 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 anunbounded number of events. |
getReadEnd | public synchronized XMLEventReader getReadEnd()(Code) | | Returns the read end of the pipe, from which events written to the write
end of the pipe will be available.
The read end of the pipe. |
getWriteEnd | public synchronized XMLEventWriter getWriteEnd()(Code) | | Returns the write end of the pipe, whose events will be available from
the read end of this pipe.
The write end of the pipe. |
|
|