public class DOMHandle extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<Document>, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle
UNKNOWN_LENGTH| Constructor and Description |
|---|
DOMHandle()
Zero-argument constructor.
|
DOMHandle(Document content)
Initializes the handle with a DOM document for the content.
|
| Modifier and Type | Method and Description |
|---|---|
XPathExpression |
compileXPath(String xpathExpression)
Compile an XPath string expression for efficient evaluation later.
|
<T> T |
evaluateXPath(String xpathExpression,
Class<T> as)
Evaluate a string XPath expression against the retrieved document.
|
<T> T |
evaluateXPath(String xpathExpression,
Node context,
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(XPathExpression xpathExpression,
Class<T> as)
Evaluate a compiled XPath expression against the retrieved document.
|
<T> T |
evaluateXPath(XPathExpression xpathExpression,
Node context,
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.
|
Document |
get()
Returns the DOM document for the content.
|
DocumentBuilderFactory |
getFactory()
Returns the factory for building DOM documents.
|
LSResourceResolver |
getResolver()
Returns the resolver for resolving references while parsing the document.
|
XPath |
getXPathProcessor()
Get the processor used to evaluate XPath expressions.
|
static ContentHandleFactory |
newFactory()
Creates a factory to create a DOMHandle instance for a DOM document.
|
void |
set(Document content)
Assigns a DOM document as the content.
|
void |
setFactory(DocumentBuilderFactory factory)
Specifies the factory for building DOM documents.
|
void |
setFormat(Format format)
Restricts the format to XML.
|
void |
setResolver(LSResourceResolver resolver)
Specifies the resolver for resolving references while parsing the document.
|
void |
setXPathProcessor(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.
|
String |
toString()
Returns the DOM document as an XML string.
|
DOMHandle |
with(Document content)
Assigns a DOM document as the content and returns the handle
as a fluent convenience.
|
DOMHandle |
withMimetype(String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
void |
write(OutputStream out)
Implements a callback to write content to the provided output stream
for sending to the database server.
|
getByteLength, getFormat, getMimetype, setByteLength, setMimetypepublic DOMHandle()
public DOMHandle(Document content)
content - a DOM documentpublic static ContentHandleFactory newFactory()
public LSResourceResolver getResolver()
public void setResolver(LSResourceResolver resolver)
resolver - the reference resolverpublic Document get()
get in interface ContentHandle<Document>public void set(Document content)
set in interface ContentHandle<Document>content - a DOM documentpublic DOMHandle with(Document content)
content - a DOM documentpublic void setFormat(Format format)
setFormat in interface ContentDescriptorsetFormat in class BaseHandle<InputStream,OutputStreamSender>format - the format of the contentpublic DOMHandle withMimetype(String mimetype)
mimetype - the mime type of the contentpublic void fromBuffer(byte[] buffer)
BufferableHandlefromBuffer in interface BufferableHandlebuffer - the byte arraypublic byte[] toBuffer()
BufferableHandletoBuffer in interface BufferableHandlepublic String toString()
public DocumentBuilderFactory getFactory() throws ParserConfigurationException
ParserConfigurationException - if it occurs while initializing the new factorypublic void setFactory(DocumentBuilderFactory factory)
factory - the document factorypublic XPath getXPathProcessor()
EditableNamespaceContextpublic void setXPathProcessor(XPath xpathProcessor)
xpathProcessor - the XPath expression processorpublic <T> T evaluateXPath(String xpathExpression, Class<T> as) throws XPathExpressionException
T - the type to returnxpathExpression - the XPath expression as a stringas - the type expected to be matched by the xpathXPathExpressionException - if xpathExpression cannot be evaluatedpublic <T> T evaluateXPath(String xpathExpression, Node context, Class<T> as) throws 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 xpathXPathExpressionException - if xpathExpression cannot be evaluatedpublic XPathExpression compileXPath(String xpathExpression) throws XPathExpressionException
xpathExpression - the XPath expression as a stringXPathExpressionException - if xpathExpression cannot be compiledpublic <T> T evaluateXPath(XPathExpression xpathExpression, Class<T> as) throws XPathExpressionException
T - the type to returnxpathExpression - an XPath expression compiled previouslyas - the type expected to be matched by the xpathXPathExpressionException - if xpathExpression cannot be evaluatedpublic <T> T evaluateXPath(XPathExpression xpathExpression, Node context, Class<T> as) throws 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 xpathXPathExpressionException - if xpathExpression cannot be evaluatedpublic void write(OutputStream out) throws IOException
OutputStreamSenderwrite in interface OutputStreamSenderout - the output stream receiving the contentIOException - if io problems ariseCopyright © 2013-2016 MarkLogic Corporation.