Constructor and Description |
---|
BinaryImpl(byte[] buffer)
Creates a new
BinaryImpl instance from a
byte[] array. |
BinaryImpl(java.io.InputStream in)
Creates a new
BinaryImpl instance from an
InputStream . |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases all resources associated with this
Binary object
and informs the repository that these resources may now be reclaimed. |
long |
getSize()
Returns the size of this
Binary value in bytes. |
java.io.InputStream |
getStream()
Returns an
InputStream representation of this value. |
int |
read(byte[] b,
long position)
Reads successive bytes from the specified
position in this
Binary into the passed byte array until either the byte
array is full or the end of the Binary is encountered. |
public BinaryImpl(java.io.InputStream in) throws java.io.IOException
BinaryImpl
instance from an
InputStream
. The contents of the stream is spooled
to a temporary file or to a byte buffer if its size is smaller than
MAX_BUFFER_SIZE
.
in
- stream to be represented as a BLOBFileValue
instancejava.io.IOException
- if an error occurs while reading from the stream or
writing to the temporary filepublic BinaryImpl(byte[] buffer)
BinaryImpl
instance from a
byte[]
array.buffer
- byte array to be represented as a BinaryImpl
instancepublic java.io.InputStream getStream() throws RepositoryException
InputStream
representation of this value. Each call to
getStream()
returns a new stream. The API consumer is
responsible for calling close()
on the returned stream.
If Binary.dispose()
has been called on this Binary
object, then this method will throw the runtime exception
IllegalStateException
.
getStream
in interface Binary
RepositoryException
- if an error occurs.public int read(byte[] b, long position) throws java.io.IOException, RepositoryException
position
in this
Binary
into the passed byte array until either the byte
array is full or the end of the Binary
is encountered.
If Binary.dispose()
has been called on this Binary
object, then this method will throw the runtime exception
IllegalStateException
.
read
in interface Binary
b
- the buffer into which the data is read.position
- the position in this Binary from which to start reading
bytes.java.io.IOException
- if an I/O error occurs.RepositoryException
- if another error occurs.public long getSize() throws RepositoryException
Binary
value in bytes.
If Binary.dispose()
has been called on this Binary
object, then this method will throw the runtime exception
IllegalStateException
.
getSize
in interface Binary
RepositoryException
- if an error occurs.Copyright © 2010 - 2019 Adobe. All Rights Reserved