| Modifier and Type | Field and Description |
|---|---|
static ResourceFactory |
FACTORY
ResourceFactory suitable for creating a BinaryResource
|
| Constructor and Description |
|---|
BinaryResource(java.lang.String href,
java.lang.String contentType,
java.io.InputStream in)
Create a binary resource
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getContentType()
Get the media type (MIME type) of the resource if known
|
Item |
getItem(XPathContext context)
Get an XDM Item holding the contents of this resource.
|
java.lang.String |
getResourceURI()
Get the URI of the resource
|
static byte[] |
readBinaryFromStream(java.io.InputStream in,
java.lang.String path)
Utility method to construct an array of bytes from the content of an InputStream
|
void |
setData(byte[] data)
Set the content of the resource as an array of bytes
|
public static final ResourceFactory FACTORY
public BinaryResource(java.lang.String href,
java.lang.String contentType,
java.io.InputStream in)
href - the URI of the resourcecontentType - the media type of the resourcein - inputStream containing the binary content of the resource. Note that the InputStream
is not consumed by this method, but is retained for use by the getItem() method.public void setData(byte[] data)
data - the content of the resourcepublic java.lang.String getResourceURI()
getResourceURI in interface Resourcepublic static byte[] readBinaryFromStream(java.io.InputStream in,
java.lang.String path)
throws XPathException
in - the input stream. The method consumes the input stream but does not close it.path - file name or URI used only for diagnosticsXPathExceptionpublic Item getItem(XPathContext context) throws XPathException
ResourcegetItem in interface Resourcecontext - the XPath evaluation contextXPathException - if a failure occurs materializing the resourcepublic java.lang.String getContentType()
ResourcegetContentType in interface ResourceCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.