public class ContentFactory
extends java.lang.Object
A helper class for creating instances of Content
.
Modifier and Type | Method and Description |
---|---|
static Content |
newContent(java.lang.String uri,
byte[] documentBytes, ContentCreateOptions createOptions)
Create a new
Content object
from a byte array. |
static Content |
newContent(java.lang.String uri,
byte[] documentBytes, int offset, int length,
ContentCreateOptions createOptions)
Create a new
Content object
from a subset of a byte array. |
static Content |
newContent(java.lang.String uri,
org.w3c.dom.Document document, ContentCreateOptions createOptions)
Create a new
Content object
from a W3C DOM Document object. |
static Content |
newContent(java.lang.String uri,
java.io.File documentFile, ContentCreateOptions createOptions)
Create a new
Content object
from a File object. |
static Content |
newContent(java.lang.String uri,
java.io.InputStream documentStream, ContentCreateOptions createOptions)
Create a new
Content object by
consuming the given InputStream and buffereing it in memory. |
static Content |
newContent(java.lang.String uri,
org.w3c.dom.Node documentNode, ContentCreateOptions createOptions)
Create a new
Content object
from a W3C DOM Node object. |
static Content |
newContent(java.lang.String uri,
java.io.RandomAccessFile documentFile, ContentCreateOptions createOptions)
Create a new
Content object
from a RandomAccessFile object. |
static Content |
newContent(java.lang.String uri,
java.lang.String documentString, ContentCreateOptions createOptions)
Create a new
Content object
from a String. |
static Content |
newContent(java.lang.String uri,
java.net.URI documentUri, ContentCreateOptions createOptions)
Create a new
Content object
from a URI, buffering so that it's rewindable and only accesses the
URL one time. |
static Content |
newContent(java.lang.String uri,
java.net.URL documentUrl, ContentCreateOptions createOptions)
Create a new
Content object
from a URI, buffering so that it's rewindable and only accesses the
URL one time. |
static Content |
newContent(java.lang.String uri,
XdmNode documentNode,
ContentCreateOptions createOptions)
|
static Content |
newJsonContent(java.lang.String uri,
com.fasterxml.jackson.databind.JsonNode documentNode, ContentCreateOptions createOptions)
Create a new
Content object
from a Jackson Node object. |
static Content |
newUnBufferedContent(java.lang.String uri,
java.io.InputStream documentStream, ContentCreateOptions createOptions)
Create a new non-rewindable
Content object
for the given InputStream. |
static Content |
newUnBufferedContent(java.lang.String uri,
java.net.URI documentUri, ContentCreateOptions createOptions)
Create a new, non-rewindable
Content object
from a URI . |
static Content |
newUnBufferedContent(java.lang.String uri,
java.net.URL documentUrl, ContentCreateOptions createOptions)
Create a new, non-rewindable
Content object
from a URL . |
public static Content newContent(java.lang.String uri, org.w3c.dom.Document document, ContentCreateOptions createOptions)
Content
object
from a W3C DOM Document
object. If not explicitly
overridden, the document format will be set to XML. This factory
method makes use of the standard JAX
TransformerFactory
facility to serialize the DOM to a
UTF-8-encoded byte stream. See
TransformerFactory.newInstance()
for information on
how to customize the transformer implementation.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.document
- A W3C DOM Document
object
which is the content.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
public static Content newContent(java.lang.String uri, org.w3c.dom.Node documentNode, ContentCreateOptions createOptions)
Content
object
from a W3C DOM Node
object.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content. If not
explicitly overridden, the document format will be set to XML. This
factory method makes use of the standard JAX
TransformerFactory
facility to serialize the DOM to a
UTF-8-encoded byte stream. See
TransformerFactory.newInstance()
for information on
how to customize the transformer implementation.documentNode
- A W3C DOM Node
object
which is the content. Only Nodes of type Element or Text are
valid.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
public static Content newJsonContent(java.lang.String uri, com.fasterxml.jackson.databind.JsonNode documentNode, ContentCreateOptions createOptions)
Content
object
from a Jackson Node
object.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content. If not
explicitly overridden, the document format will be set to
JSON.documentNode
- A Jackson Node
object
which is the content. Only Nodes of type Array or Object are
valid.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
public static Content newContent(java.lang.String uri, XdmNode documentNode, ContentCreateOptions createOptions)
Content
object
from an XdmNode
.
This object may have been constructed locally or received as a
member of a ResultSequence
.
If not explicitly overridden, the document format will be set to
XML.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentNode
- An instance of XdmNode
which is the document content. Only nodes of type XdmElement
,
XdmText
or
XdmBinary
are valid.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
public static Content newContent(java.lang.String uri, java.io.File documentFile, ContentCreateOptions createOptions)
Create a new Content
object from a File object.
uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentFile
- A File object from which the
content will be read. If the createOptions argument selects
DocumentFormat.BINARY
, the content of the file will be
transfered as an opaque blob. Otherwise, the file is assumed to be
UTF-8 encoded text.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
public static Content newContent(java.lang.String uri, java.io.RandomAccessFile documentFile, ContentCreateOptions createOptions) throws java.io.IOException
Content
object
from a RandomAccessFile object.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentFile
- An open RandomAccessaFile object
from which the content will be read. File data will be read from
the current position to end-of-file. If the createOptions argument
selects DocumentFormat.BINARY
,
the content of the file will be transfered as an opaque blob.
Otherwise, the file is assumed to be UTF-8 encoded text.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
reading data from the file.public static Content newUnBufferedContent(java.lang.String uri, java.net.URL documentUrl, ContentCreateOptions createOptions) throws java.io.IOException
Content
object
from a URL
.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentUrl
- A URL
object that
represents the location from which the content can be fetched.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
creating a URL
or opening a data stream.public static Content newUnBufferedContent(java.lang.String uri, java.net.URI documentUri, ContentCreateOptions createOptions) throws java.io.IOException
Content
object
from a URI
.uri
- The URI
(name) with which the
document will be inserted into the content store. If the URI
already exists in the store, it will be replaced with the new
content.documentUri
- A URI object that represents the
location from which the content can be fetched.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
creating a URL
or opening a data stream.public static Content newContent(java.lang.String uri, java.net.URL documentUrl, ContentCreateOptions createOptions) throws java.io.IOException
Content
object
from a URI, buffering so that it's rewindable and only accesses the
URL one time.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentUrl
- A URL
object that
represents the location from which the content can be fetched.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
creating a URL
or reading the data from the
stream.public static Content newContent(java.lang.String uri, java.net.URI documentUri, ContentCreateOptions createOptions) throws java.io.IOException
Content
object
from a URI, buffering so that it's rewindable and only accesses the
URL one time.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentUri
- A URI
object that
represents the location from which the content can be fetched.
Unlike URL
s, URI
objects are not
validated when they are created. This method converts the
URI
to a URL
. If this parameter does not
represent a valid URL, an exception will be thrown.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
creating a URL
or reading the data from the
stream.java.lang.IllegalArgumentException
- If the URI is
not absolute.public static Content newContent(java.lang.String uri, java.lang.String documentString, ContentCreateOptions createOptions)
Content
object
from a String.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentString
- A String which will be stored as
the content of the document. If the createOptions argument selects
DocumentFormat.BINARY
,
the bytes representing the UTF-8 encoding of the String will be
stored.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
DocumentFormat
public static Content newContent(java.lang.String uri, byte[] documentBytes, ContentCreateOptions createOptions)
Content
object
from a byte array.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentBytes
- A byte array which will be stored
as the content of the document. If the createOptions argument is
null, then DocumentFormat.BINARY
will be assumed.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
DocumentFormat
public static Content newContent(java.lang.String uri, byte[] documentBytes, int offset, int length, ContentCreateOptions createOptions)
Content
object
from a subset of a byte array.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new content.documentBytes
- A byte array which will be stored
as the content of the document. If the createOptions argument is
null, then DocumentFormat.BINARY
will be assumed.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.offset
- The starting point of the content in the
array.length
- The length of the content in the
array.Content
object
suitable for passing to
Session.insertContent(Content)
DocumentFormat
public static Content newContent(java.lang.String uri, java.io.InputStream documentStream, ContentCreateOptions createOptions) throws java.io.IOException
Content
object by
consuming the given InputStream and buffereing it in memory. This
factory method immediately reads the stream to the end and buffers
it. This could result in an OutOfMemoryError if the stream contains
a large amount of data. The provided documentStream will be
closed.uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new value.documentStream
- The stream making up the document
content.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
java.io.IOException
- If there is a problem
reading the documentStream.public static Content newUnBufferedContent(java.lang.String uri, java.io.InputStream documentStream, ContentCreateOptions createOptions)
Create a new non-rewindable Content
object
for the given InputStream. Note that the Content
instance
returned is not rewindable ( Content.isRewindable()
== false) which means that auto-retry cannot be performed is there
is a problem inserting the content.
uri
- The URI (name) with which the document will
be inserted into the content store. If the URI already exists in
the store, it will be replaced with the new value.documentStream
- The stream making up the document
content.createOptions
- Creation meta-information to be
applied when the content is inserted into the contentbase. These
options control the document format (json, xml, text, binary) and
access permissions.Content
object
suitable for passing to
Session.insertContent(Content)
Copyright © 2024 MarkLogic
Corporation
Complete online documentation for MarkLogic Server,
XQuery and related components may
be found at
developer.marklogic.com