public class OutputStreamContent extends java.lang.Object implements Content
This is a specialized implementation of the Content interface which allows you to write
your content to an OutputStream.
Click here for the source code for this class
This class creates a piped pair of streams. The source (InputStream) is passed to the
standard factory method
ContentFactory.newUnBufferedContent(String, java.io.InputStream, com.marklogic.xcc.ContentCreateOptions)
. The sink (OutputStream) can be retrieved with the getOutputStream() method.
NOTE: You must write to the OutputStream in a different thread than the
one in which you invoke Session.insertContent(com.marklogic.xcc.Content) or your program may
deadlock. The OutputStreamInserter class shows an example of how to use this class.
OutputStreamInserter| Constructor and Description |
|---|
OutputStreamContent(java.lang.String uri,
ContentCreateOptions options)
Construct an instance with the usual URI and options parameters, the actual content will be
read from the other end of the pipe provided by
getOutputStream(). |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method will be called after successfully consuming the content from the InputStream
returned by
Content.openDataStream(). |
ContentCreateOptions |
getCreateOptions()
Return the
ContentCreateOptions object which should be applied to this object. |
java.io.OutputStream |
getOutputStream()
Return the end of the pipe to which you will write your content (the sink).
|
java.lang.String |
getUri()
The URI with which this content should be inserted.
|
boolean |
isRewindable()
The answer is "no".
|
java.io.InputStream |
openDataStream()
Passes the read end (source) of the pipe to the content insertion framework.
|
void |
rewind()
This streaming-only implementation is not rewindable.
|
long |
size()
Unknown size.
|
public OutputStreamContent(java.lang.String uri,
ContentCreateOptions options)
throws java.io.IOException
getOutputStream().uri - The URI by which the content (document) will be known in the contentbase.options - An instance of ContentCreateOptions.java.io.IOException - If there is a problem creating the pipe (unlikely).public java.io.OutputStream getOutputStream()
OutputStream. Be sure to close this object when you've written
all the data.public java.lang.String getUri()
Contentpublic java.io.InputStream openDataStream()
throws java.io.IOException
openDataStream in interface ContentInputStream.java.io.IOException - Will never happen in this implementation.public ContentCreateOptions getCreateOptions()
ContentContentCreateOptions object which should be applied to this object. Note
that if none was provided to the factory method that created this Content instance, one may
have been created with appropriate defaults for the content provided.getCreateOptions in interface ContentContentCreateOptions.public boolean isRewindable()
isRewindable in interface Contentpublic void rewind()
throws java.io.IOException
public long size()
public void close()
ContentContent.openDataStream(). This method need not close the stream, that is the
responsibility of the client, but it may invalidate the stream. This method is to inform the
implementation that any resources it may be holding can be released.Copyright © 2025 MarkLogic Corporation. All Rights Reserved.
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com