Modifier and Type | Field and Description |
---|---|
static ResourceFactory |
FACTORY
ResourceFactory suitable for creating a BinaryResource
|
Constructor and Description |
---|
BinaryResource(AbstractResourceCollection.InputDetails in)
Create a binary resource
|
BinaryResource(java.lang.String href,
java.lang.String contentType,
byte[] content) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContentType()
Get the media type (MIME type) of the resource if known
|
byte[] |
getData()
Get the content of the resource as an array of bytes
|
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(AbstractResourceCollection.InputDetails in)
in
- details about the resourcepublic BinaryResource(java.lang.String href, java.lang.String contentType, byte[] content)
public void setData(byte[] data)
data
- the content of the resourcepublic byte[] getData()
public java.lang.String getResourceURI()
getResourceURI
in interface Resource
public 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 diagnosticsXPathException
- if a failure occurs obtaining a connection or reading the streampublic Item getItem(XPathContext context) throws XPathException
Resource
getItem
in interface Resource
context
- the XPath evaluation contextXPathException
- if a failure occurs materializing the resourcepublic java.lang.String getContentType()
Resource
getContentType
in interface Resource
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.