ContentDescriptor
,
AbstractReadHandle
,
AbstractWriteHandle
,
BufferableHandle
,
ContentHandle<org.xml.sax.InputSource>
,
CtsQueryWriteHandle
,
DocumentMetadataReadHandle
,
DocumentMetadataWriteHandle
,
DocumentPatchHandle
,
QueryOptionsListReadHandle
,
QueryOptionsReadHandle
,
QueryOptionsWriteHandle
,
RuleListReadHandle
,
RuleReadHandle
,
RuleWriteHandle
,
SearchReadHandle
,
SPARQLResultsReadHandle
,
StructureReadHandle
,
StructureWriteHandle
,
TriplesReadHandle
,
TriplesWriteHandle
,
TuplesReadHandle
,
ValuesListReadHandle
,
ValuesReadHandle
,
XMLReadHandle
,
XMLWriteHandle
,
OutputStreamSender
,
java.io.Closeable
,
java.lang.AutoCloseable
public class InputSourceHandle extends BaseHandle<java.io.InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<org.xml.sax.InputSource>, XMLReadHandle, XMLWriteHandle, StructureReadHandle, StructureWriteHandle, CtsQueryWriteHandle, java.io.Closeable
An Input Source Handle represents XML content as an input source for reading or writing. When reading, the XML may be processed by a SAX content handler.
Always call
close()
when finished with this handle to release
the resources.
Modifier and Type | Class | Description |
---|---|---|
static class |
InputSourceHandle.DraconianErrorHandler |
DraconianErrorHandler treats SAX parse errors as
exceptions but ignores warnings (based on the JavaDoc for the
javax.xml.validation package).
|
UNKNOWN_LENGTH
Constructor | Description |
---|---|
InputSourceHandle() |
Zero-argument constructor.
|
InputSourceHandle(org.xml.sax.InputSource content) |
Initializes the handle with a SAX input source
for the content.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Always call close() when finished with this
handle -- it closes the underlying InputStream.
|
void |
fromBuffer(byte[] buffer) |
Sets the content of the handle by copying from a
byte array buffer encoded in UTF-8.
|
org.xml.sax.InputSource |
get() |
Returns the input source for the content.
|
java.lang.Class<org.xml.sax.InputSource> |
getContentClass() |
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
javax.xml.validation.Schema |
getDefaultWriteSchema() |
Returns the default schema for validating the
input source while writing to the database.
|
org.xml.sax.ErrorHandler |
getErrorHandler() |
Returns the error handler for errors discovered
while parsing the input source.
|
javax.xml.parsers.SAXParserFactory |
getFactory() |
Returns the factory for parsing SAX
events.
|
org.xml.sax.EntityResolver |
getResolver() |
Returns the resolver for resolving references
while parsing the input source.
|
protected
org.xml.sax.XMLReader |
makeReader(boolean isForWrite) |
|
protected
javax.xml.parsers.SAXParserFactory |
makeSAXParserFactory() |
|
static ContentHandleFactory |
newFactory() |
Creates a factory to create a InputSourceHandle
instance for a SAX InputSource.
|
void |
process(org.xml.sax.ContentHandler handler) |
Reads the input source, sending SAX events to
the supplied content handler.
|
protected
java.lang.Class<java.io.InputStream> |
receiveAs() |
|
protected void |
receiveContent(java.io.InputStream content) |
|
protected OutputStreamSender |
sendContent() |
|
void |
set(org.xml.sax.InputSource content) |
Assigns an input source as the content.
|
void |
setDefaultWriteSchema(javax.xml.validation.Schema schema) |
Specifies the default schema for validating the
input source.
|
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler) |
Specifies the error handler for errors
discovered while parsing the input source.
|
void |
setFactory(javax.xml.parsers.SAXParserFactory factory) |
Specifies the factory for parsing SAX
events.
|
void |
setFormat(Format format) |
Restricts the format to XML.
|
void |
setResolver(org.xml.sax.EntityResolver resolver) |
Specifies the resolver for resolving references
while parsing the input source.
|
byte[] |
toBuffer() |
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
|
java.lang.String |
toString() |
Buffers the SAX input source and returns the
buffer as an XML string.
|
InputSourceHandle |
with(org.xml.sax.InputSource content) |
Assigns an input source as the content and
returns the handle as a fluent convenience.
|
InputSourceHandle |
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
public InputSourceHandle()
public InputSourceHandle(org.xml.sax.InputSource content)
content
- a SAX input sourcepublic static ContentHandleFactory newFactory()
public org.xml.sax.EntityResolver getResolver()
public void setResolver(org.xml.sax.EntityResolver resolver)
resolver
- the reference resolverpublic org.xml.sax.ErrorHandler getErrorHandler()
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
errorHandler
- the error handlerpublic org.xml.sax.InputSource get()
get
in interface ContentHandle<org.xml.sax.InputSource>
public void set(org.xml.sax.InputSource content)
set
in interface ContentHandle<org.xml.sax.InputSource>
content
- an input sourcepublic InputSourceHandle with(org.xml.sax.InputSource content)
content
- an input sourcepublic java.lang.Class<org.xml.sax.InputSource> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<org.xml.sax.InputSource>
public void process(org.xml.sax.ContentHandler handler)
handler
- the SAX content handlerpublic void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<java.io.InputStream,OutputStreamSender>
format
- the format of the contentpublic InputSourceHandle 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.SAXParserFactory getFactory() throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- if such an error occurs
while initializing the new factoryjavax.xml.parsers.ParserConfigurationException
-
if such an error occurs while initializing the new factorypublic void setFactory(javax.xml.parsers.SAXParserFactory factory)
factory
- the SAX factoryprotected javax.xml.parsers.SAXParserFactory makeSAXParserFactory() throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public javax.xml.validation.Schema getDefaultWriteSchema()
public void setDefaultWriteSchema(javax.xml.validation.Schema schema)
InputSourceHandle.DraconianErrorHandler
and set the repair policy to NONE on the XMLDocumentManager. An
error on the root element can still result in an empty
document.schema
- the default schema for writing
documentsprotected org.xml.sax.XMLReader makeReader(boolean isForWrite)
protected 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 arisepublic void close()
close
in
interface java.lang.AutoCloseable
close
in
interface java.io.Closeable
Copyright © 2013-2019 MarkLogic Corporation.