| 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 |
|---|---|
static java.lang.String |
decode(byte[] value,
int offset,
int len,
java.lang.String encoding) |
static java.lang.String |
decode(byte[] value,
java.lang.String encoding) |
static byte[] |
encode(java.lang.String s,
java.lang.String encoding) |
static void |
error(java.lang.String message)
Throw an error
|
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()
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 static byte[] encode(java.lang.String s,
java.lang.String encoding)
throws XPathException
XPathExceptionpublic static java.lang.String decode(byte[] value,
java.lang.String encoding)
throws XPathException
XPathExceptionpublic static java.lang.String decode(byte[] value,
int offset,
int len,
java.lang.String encoding)
throws XPathException
XPathExceptionpublic static void error(java.lang.String message)
throws XPathException
message - the error messageXPathException - alwayspublic 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() throws XPathException
getItem in interface ResourceBase64BinaryValue. 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-2022 Saxonica Limited. All rights reserved.