Berkeley DB XML
version 2.5.16

com.sleepycat.dbxml
Class XmlEventReaderToWriter

java.lang.Object
  extended by com.sleepycat.dbxml.XmlEventReaderToWriter

public class XmlEventReaderToWriter
extends Object

Used to connect XmlEventReader and XmlEventWriter objects, pushing the events from XmlEventReader to the writer. You can obtain an instance of XmlEventWriter using XmlContainer.putDocumentAsEventWriter(com.sleepycat.dbxml.XmlDocument). You can obtain an instance of XmlEventReader using a combination of XmlContainer.getDocument(java.lang.String) and XmlDocument.getContentAsEventReader().

This class provides an efficient mechanism to copy the content from one document to another, directly.


Constructor Summary
XmlEventReaderToWriter(XmlEventReader reader, XmlEventWriter writer, boolean ownsReader)
          Construct an XmlEventReaderToWriter instance from the parameters.
XmlEventReaderToWriter(XmlEventReader reader, XmlEventWriter writer, boolean ownsReader, boolean ownsWriter)
          Construct an XmlEventReaderToWriter instance from the parameters.
 
Method Summary
 void start()
          Perform the operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlEventReaderToWriter

public XmlEventReaderToWriter(XmlEventReader reader,
                              XmlEventWriter writer,
                              boolean ownsReader)
                       throws XmlException
Construct an XmlEventReaderToWriter instance from the parameters.

Parameters:
reader - The XmlEventReader from which events are read.
writer - The XmlEventWriter to which events are written. This object is always donated, and the caller can no longer use it.
ownsReader - Set to true if the reader is donated to the object, which means the constructed object is responsible for calling XmlEventReader.close().
Throws:
XmlException

XmlEventReaderToWriter

public XmlEventReaderToWriter(XmlEventReader reader,
                              XmlEventWriter writer,
                              boolean ownsReader,
                              boolean ownsWriter)
                       throws XmlException
Construct an XmlEventReaderToWriter instance from the parameters.

Parameters:
reader - The XmlEventReader from which events are read.
writer - The XmlEventWriter to which events are written. This object is always donated, and the caller can no longer use it.
ownsReader - Set to true if the reader is donated to the object, which means the constructed object is responsible for calling XmlEventReader.close().
ownsWriter - Set to true if the writer is donated to the object, which means the constructed object is responsible for calling XmlEventWriter.close().
Throws:
XmlException
Method Detail

start

public void start()
           throws XmlException
Perform the operation. This method will read events from the reader, writing them to the writer, until there are no further events available. When complete, if ownsWriter was true during construction, it will call XmlEventWriter.close() and, if ownsReader was true during construction, XmlEventReader.close().

Throws:
XmlException

Berkeley DB XML
version 2.5.16

Copyright (c) 1996,2009 Oracle. All rights reserved.