ContentDescriptor
,
AbstractReadHandle
,
AbstractWriteHandle
,
BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
,
BufferableHandle
,
ContentHandle<org.w3c.dom.Document>
,
CtsQueryWriteHandle
,
DocumentMetadataReadHandle
,
DocumentMetadataWriteHandle
,
DocumentPatchHandle
,
QueryOptionsListReadHandle
,
QueryOptionsReadHandle
,
QueryOptionsWriteHandle
,
ResendableContentHandle<org.w3c.dom.Document,java.io.InputStream>
,
RuleListReadHandle
,
RuleReadHandle
,
RuleWriteHandle
,
SearchReadHandle
,
SPARQLResultsReadHandle
,
StructureReadHandle
,
StructureWriteHandle
,
TriplesReadHandle
,
TriplesWriteHandle
,
TuplesReadHandle
,
ValuesListReadHandle
,
ValuesReadHandle
,
XMLReadHandle
,
XMLWriteHandle
,
OutputStreamSender
public class DOMHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements ResendableContentHandle<org.w3c.dom.Document,java.io.InputStream>, OutputStreamSender, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle
UNKNOWN_LENGTH
Constructor | Description |
---|---|
DOMHandle() |
Zero-argument constructor.
|
DOMHandle(org.w3c.dom.Document content) |
Initializes the handle with a DOM document for
the content.
|
Modifier and Type | Method | Description |
---|---|---|
org.w3c.dom.Document |
bytesToContent(byte[] buffer) |
Converts a byte serialization to the content
representation.
|
protected <T> T |
castAs(java.lang.Object result,
java.lang.Class<?> as) |
|
protected void |
checkContext(org.w3c.dom.Node context) |
|
javax.xml.xpath.XPathExpression |
compileXPath(java.lang.String xpathExpression) |
Compile an XPath string expression for efficient
evaluation later.
|
byte[] |
contentToBytes(org.w3c.dom.Document content) |
Converts the content representation to
bytes.
|
<T> T |
evaluateXPath(java.lang.String xpathExpression,
java.lang.Class<T> as) |
Evaluate a string XPath expression against the
retrieved document.
|
<T> T |
evaluateXPath(java.lang.String xpathExpression,
org.w3c.dom.Node context,
java.lang.Class<T> as) |
Evaluate a string XPath expression relative to a
node such as a node returned by a previous XPath expression.
|
<T> T |
evaluateXPath(javax.xml.xpath.XPathExpression xpathExpression,
java.lang.Class<T> as) |
Evaluate a compiled XPath expression against the
retrieved document.
|
<T> T |
evaluateXPath(javax.xml.xpath.XPathExpression xpathExpression,
org.w3c.dom.Node context,
java.lang.Class<T> as) |
Evaluate a compiled XPath expression relative to
a node such as a node returned by a previous XPath
expression.
|
void |
fromBuffer(byte[] buffer) |
Sets the content of the handle by copying from a
byte array buffer encoded in UTF-8.
|
org.w3c.dom.Document |
get() |
Returns the DOM document for the content.
|
java.lang.Class<org.w3c.dom.Document> |
getContentClass() |
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
javax.xml.parsers.DocumentBuilderFactory |
getFactory() |
Returns the factory for building DOM
documents.
|
org.w3c.dom.ls.LSResourceResolver |
getResolver() |
Returns the resolver for resolving references
while parsing the document.
|
javax.xml.xpath.XPath |
getXPathProcessor() |
Get the processor used to evaluate XPath
expressions.
|
protected
javax.xml.parsers.DocumentBuilderFactory |
makeDocumentBuilderFactory() |
|
protected
javax.xml.xpath.XPathFactory |
makeXPathProcessorFactory() |
|
org.w3c.dom.Document[] |
newArray(int length) |
Constructs an array for the handled content
representation
|
static ContentHandleFactory |
newFactory() |
Creates a factory to create a DOMHandle instance
for a DOM document.
|
DOMHandle |
newHandle() |
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
DOMHandle[] |
newHandleArray(int length) |
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
protected
java.lang.Class<java.io.InputStream> |
receiveAs() |
|
protected void |
receiveContent(java.io.InputStream content) |
|
protected
javax.xml.namespace.QName |
returnXPathConstant(java.lang.Class<?> as) |
|
protected OutputStreamSender |
sendContent() |
|
void |
set(org.w3c.dom.Document content) |
Assigns a DOM document as the content.
|
void |
setFactory(javax.xml.parsers.DocumentBuilderFactory factory) |
Specifies the factory for building DOM
documents.
|
void |
setFormat(Format format) |
Restricts the format to XML.
|
void |
setResolver(org.w3c.dom.ls.LSResourceResolver resolver) |
Specifies the resolver for resolving references
while parsing the document.
|
void |
setXPathProcessor(javax.xml.xpath.XPath xpathProcessor) |
Specifies the processor used to evaluate XPath
expressions against the document.
|
byte[] |
toBuffer() |
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
|
org.w3c.dom.Document |
toContent(java.io.InputStream serialization) |
Converts the serialization to the content
representation.
|
java.lang.String |
toString() |
Returns the DOM document as an XML string.
|
DOMHandle |
with(org.w3c.dom.Document content) |
Assigns a DOM document as the content and
returns the handle as a fluent convenience.
|
DOMHandle |
withMimetype(java.lang.String mimetype) |
Specifies the mime type of the content and
returns the handle as a fluent convenience.
|
void |
write(java.io.OutputStream out) |
Implements a callback to write content to the
provided output stream for sending to the database server.
|
getByteLength,
getFormat,
getMimetype,
getServerTimestamp,
setByteLength,
setMimetype,
setServerTimestamp
resendableHandleFor
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait
newHandle,
resendableHandleFor
public DOMHandle()
public DOMHandle(org.w3c.dom.Document content)
content
- a DOM documentpublic static ContentHandleFactory newFactory()
public org.w3c.dom.ls.LSResourceResolver getResolver()
public void setResolver(org.w3c.dom.ls.LSResourceResolver resolver)
resolver
- the reference resolverpublic org.w3c.dom.Document get()
get
in interface ContentHandle<org.w3c.dom.Document>
public void set(org.w3c.dom.Document content)
set
in interface ContentHandle<org.w3c.dom.Document>
content
- a DOM documentpublic DOMHandle with(org.w3c.dom.Document content)
content
- a DOM documentpublic java.lang.Class<org.w3c.dom.Document> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<org.w3c.dom.Document>
public DOMHandle newHandle()
ContentHandle
newHandle
in interface BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
newHandle
in interface ContentHandle<org.w3c.dom.Document>
newHandle
in interface ResendableContentHandle<org.w3c.dom.Document,java.io.InputStream>
public DOMHandle[] newHandleArray(int length)
BufferableContentHandle
newHandleArray
in interface BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
newHandleArray
in interface ResendableContentHandle<org.w3c.dom.Document,java.io.InputStream>
length
- the number of positions in the arraypublic org.w3c.dom.Document[] newArray(int length)
ContentHandle
newArray
in interface ContentHandle<org.w3c.dom.Document>
length
- the size of the array (zero or more)public void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<java.io.InputStream,OutputStreamSender>
format
- the format of the contentpublic DOMHandle withMimetype(java.lang.String mimetype)
mimetype
- the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandle
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public java.lang.String toString()
toString
in
class java.lang.Object
public javax.xml.parsers.DocumentBuilderFactory getFactory() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
-
if it occurs while initializing the new factorypublic void setFactory(javax.xml.parsers.DocumentBuilderFactory factory)
factory
- the document factoryprotected javax.xml.parsers.DocumentBuilderFactory makeDocumentBuilderFactory() throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
public javax.xml.xpath.XPath getXPathProcessor()
EditableNamespaceContext
public void setXPathProcessor(javax.xml.xpath.XPath xpathProcessor)
xpathProcessor
- the XPath expression
processorprotected javax.xml.xpath.XPathFactory makeXPathProcessorFactory()
public <T> T evaluateXPath(java.lang.String xpathExpression, java.lang.Class<T> as) throws javax.xml.xpath.XPathExpressionException
T
- the type to returnxpathExpression
- the XPath expression as a
stringas
- the type expected to be matched by the
xpathjavax.xml.xpath.XPathExpressionException
- if
xpathExpression cannot be evaluatedpublic <T> T evaluateXPath(java.lang.String xpathExpression, org.w3c.dom.Node context, java.lang.Class<T> as) throws javax.xml.xpath.XPathExpressionException
T
- the type to returnxpathExpression
- the XPath expression as a
stringcontext
- the node for evaluating the
expressionas
- the type expected to be matched by the
xpathjavax.xml.xpath.XPathExpressionException
- if
xpathExpression cannot be evaluatedpublic javax.xml.xpath.XPathExpression compileXPath(java.lang.String xpathExpression) throws javax.xml.xpath.XPathExpressionException
xpathExpression
- the XPath expression as a
stringjavax.xml.xpath.XPathExpressionException
- if
xpathExpression cannot be compiledpublic <T> T evaluateXPath(javax.xml.xpath.XPathExpression xpathExpression, java.lang.Class<T> as) throws javax.xml.xpath.XPathExpressionException
T
- the type to returnxpathExpression
- an XPath expression compiled
previouslyas
- the type expected to be matched by the
xpathjavax.xml.xpath.XPathExpressionException
- if
xpathExpression cannot be evaluatedpublic <T> T evaluateXPath(javax.xml.xpath.XPathExpression xpathExpression, org.w3c.dom.Node context, java.lang.Class<T> as) throws javax.xml.xpath.XPathExpressionException
T
- the type to returnxpathExpression
- an XPath expression compiled
previouslycontext
- the node for evaluating the
expressionas
- the type expected to be matched by the
xpathjavax.xml.xpath.XPathExpressionException
- if
xpathExpression cannot be evaluatedprotected void checkContext(org.w3c.dom.Node context)
protected javax.xml.namespace.QName returnXPathConstant(java.lang.Class<?> as)
protected <T> T castAs(java.lang.Object result, java.lang.Class<?> as)
public org.w3c.dom.Document bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
buffer
- the byte serializationpublic byte[] contentToBytes(org.w3c.dom.Document content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
content
- the contentpublic org.w3c.dom.Document toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<org.w3c.dom.Document,java.io.InputStream>
serialization
- a serialization of the
contentprotected java.lang.Class<java.io.InputStream> receiveAs()
receiveAs
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected void receiveContent(java.io.InputStream content)
receiveContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected OutputStreamSender sendContent()
sendContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
public void write(java.io.OutputStream out) throws java.io.IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentjava.io.IOException
- if io problems ariseCopyright © 2022 MarkLogic Corporation