| Modifier and Type | Field and Description |
|---|---|
static ResourceFactory |
FACTORY
ResourceFactory suitable for creating a BinaryResource
|
| Constructor and Description |
|---|
BinaryResource(String href,
String contentType,
InputStream in)
Create a binary resource
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
String |
getResourceURI()
Get the URI of the resource
|
static byte[] |
readBinary(File file,
String path) |
static byte[] |
readBinaryFromStream(InputStream in,
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(String href, String contentType, 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 String getResourceURI()
getResourceURI in interface Resourcepublic static byte[] readBinaryFromStream(InputStream in, 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 static byte[] readBinary(File file, String path) throws XPathException
XPathExceptionpublic Item getItem(XPathContext context) throws XPathException
ResourcegetItem in interface Resourcecontext - the XPath evaluation contextXPathException - if a failure occurs materializing the resourcepublic String getContentType()
ResourcegetContentType in interface ResourceCopyright (c) 2004-2017 Saxonica Limited. All rights reserved.