com.marklogic.xdmp
Class XDMPDocInsertStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bycom.marklogic.xdmp.XDMPDocInsertStream

public class XDMPDocInsertStream
extends OutputStream

Use XDMPDocInsertStream to insert a document into a Mark Logic Content Interaction Server database.

When using XDMPDocInsertStream, it is good coding practice to catch XQuery exceptions and retry them if the exceptions are retryable (using the XDBCXQueryException.getRetryable() method).

See Also:
XDMPConnection.openDocInsertStream(java.lang.String), XDMPConnection.openDocInsertStream(java.lang.String, java.util.Locale), XDMPConnection.openDocInsertStream(java.lang.String, java.util.Locale, boolean, com.marklogic.xdmp.XDMPPermission[]), XDMPConnection.openDocInsertStream(java.lang.String, java.util.Locale, boolean, java.lang.String[]), XDMPConnection.openDocInsertStream(java.lang.String, java.util.Locale, boolean, com.marklogic.xdmp.XDMPPermission[], java.lang.String[]), XDBCXQueryException.getRetryable()

Field Summary
static int XDMP_DOC_FORMAT_BINARY
           
static int XDMP_DOC_FORMAT_NONE
          Document insert format.
static int XDMP_DOC_FORMAT_TEXT
           
static int XDMP_DOC_FORMAT_XML
           
static int XDMP_ERROR_CORRECTION_FULL
          Document insert error correction level: indicates that the MarkCIS server attempts to insert missing tags and ignore extraneous tags if necessary to make the loaded document be well-formed.
static int XDMP_ERROR_CORRECTION_NONE
          Document insert error correction level: indicates that an error is signaled by the MarkCIS server if a non- well-formed document is loaded.
 
Method Summary
 void abort()
          Aborts the document insert.
 void close()
          Closes this output stream and releases any system resources associated with it.
 void commit()
          Commits the document insert to the database.
protected  void finalize()
           
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
 void newDocument(String uri, XDMPDocOptions docOpts)
          Starts a new document on this document insert stream.
 String toString()
          Returns a string representation of this XDMPDocInsertStream object.
 void write(byte[] b)
          Writes b.length bytes from the specified byte array to this output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XDMP_ERROR_CORRECTION_NONE

public static final int XDMP_ERROR_CORRECTION_NONE
Document insert error correction level: indicates that an error is signaled by the MarkCIS server if a non- well-formed document is loaded.

See Also:
Constant Field Values

XDMP_ERROR_CORRECTION_FULL

public static final int XDMP_ERROR_CORRECTION_FULL
Document insert error correction level: indicates that the MarkCIS server attempts to insert missing tags and ignore extraneous tags if necessary to make the loaded document be well-formed.

See Also:
Constant Field Values

XDMP_DOC_FORMAT_NONE

public static final int XDMP_DOC_FORMAT_NONE
Document insert format. Specifies the format to use for treating the document to be inserted via an XDMPDocInsertStream.

See Also:
Constant Field Values

XDMP_DOC_FORMAT_BINARY

public static final int XDMP_DOC_FORMAT_BINARY
See Also:
Constant Field Values

XDMP_DOC_FORMAT_TEXT

public static final int XDMP_DOC_FORMAT_TEXT
See Also:
Constant Field Values

XDMP_DOC_FORMAT_XML

public static final int XDMP_DOC_FORMAT_XML
See Also:
Constant Field Values
Method Detail

finalize

protected void finalize()
                 throws Throwable
Throws:
Throwable

newDocument

public void newDocument(String uri,
                        XDMPDocOptions docOpts)
                 throws XDBCException
Starts a new document on this document insert stream. This allows multiple documents to be inserted using the same XDMPDocInsertStream object. None of the documents are committed until commit() is called.

Parameters:
uri - A URI by which the new document will be known to the database after it is inserted.
docOpts - An XDMPDocOptions object used to specify the options for the document when it is loaded.
Throws:
XDBCException - If a database error occurs.
See Also:
XDMPDocOptions

commit

public void commit()
            throws XDBCException
Commits the document insert to the database. The document will appear in the database with the URI specified when the document insert stream was created, provided that the document text is well-formed. Either commit() or abort() should be called on the document insert stream after the document text has been completely inserted.

Throws:
XDBCException - if a database error occurs.

abort

public void abort()
           throws XDBCException
Aborts the document insert. The document will not appear in the database. Either commit() or abort() should be called on the document insert stream after the document text has been completely inserted.

Throws:
XDBCException - if a database error occurs.

close

public void close()
           throws IOException
Closes this output stream and releases any system resources associated with it. Either commit() or abort() should be called on the document insert stream after the document text has been completely inserted. If neither commit() nor abort() has been called then close() assumes abort().

Throws:
IOException - if an IO exception occurs on the stream.

flush

public void flush()
           throws IOException
Flushes this output stream and forces any buffered output bytes to be written out.

Throws:
IOException - if an IO exception occurs on the stream.

write

public void write(byte[] b)
           throws IOException
Writes b.length bytes from the specified byte array to this output stream.

Parameters:
b - a byte array to be written.
Throws:
IOException - if an IO exception occurs on the stream.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters:
b - a byte array to be written.
off - the integer offset into the array at which writing begins
len - the integer length of bytes to write to the array.
Throws:
IOException - if an IO exception occurs on the stream.

write

public void write(int b)
           throws IOException
Writes the specified byte to this output stream.

Parameters:
b - a single byte to be written to the stream.
Throws:
IOException - if an IO exception occurs on the stream.

toString

public String toString()
Returns a string representation of this XDMPDocInsertStream object.

Returns:
a string representation of this XDMPDocInsertStream.