| 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)
Create a binary resource supplying the actual content as a byte array
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getContentType()
Get the media type (MIME type) of the resource if known,
for example "image/jpeg".
|
byte[] |
getData()
Get the content of the resource as an array of bytes
|
Base64BinaryValue |
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)
href - the URI of the resourcecontentType - the media typecontent - the actual content as a byte arraypublic void setData(byte[] data)
data - the content of the resourcepublic byte[] getData()
public 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 diagnosticsXPathException - if a failure occurs obtaining a connection or reading the streampublic Base64BinaryValue getItem(XPathContext context) throws XPathException
getItem in interface Resourcecontext - the XPath evaluation contextBase64BinaryValue. This does not mean that the
content is actually encoded in Base64 internally; rather it means that when converted
to a string, the content is presented in Base64 encoding.XPathException - if a failure occurs materializing the resourcepublic java.lang.String getContentType()
getContentType in interface ResourceCopyright (c) 2004-2021 Saxonica Limited. All rights reserved.