Package javax.jcr
Interface Binary
-
- All Known Subinterfaces:
BinaryDownload,ReferenceBinary
- All Known Implementing Classes:
BinaryImpl,SimpleReferenceBinary
public interface BinaryABinaryobject holds a JCR property value of typeBINARY. TheBinaryinterface and the related methods inProperty,ValueandValueFactoryreplace the deprecatedValue.getStream()andProperty.getStream()methods.- Since:
- JCR 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddispose()Releases all resources associated with thisBinaryobject and informs the repository that these resources may now be reclaimed.longgetSize()Returns the size of thisBinaryvalue in bytes.java.io.InputStreamgetStream()Returns anInputStreamrepresentation of this value.intread(byte[] b, long position)Reads successive bytes from the specifiedpositionin thisBinaryinto the passed byte array until either the byte array is full or the end of theBinaryis encountered.
-
-
-
Method Detail
-
getStream
java.io.InputStream getStream() throws RepositoryExceptionReturns anInputStreamrepresentation of this value. Each call togetStream()returns a new stream. The API consumer is responsible for callingclose()on the returned stream.If
dispose()has been called on thisBinaryobject, then this method will throw the runtime exceptionIllegalStateException.- Returns:
- A stream representation of this value.
- Throws:
RepositoryException- if an error occurs.
-
read
int read(byte[] b, long position) throws java.io.IOException, RepositoryExceptionReads successive bytes from the specifiedpositionin thisBinaryinto the passed byte array until either the byte array is full or the end of theBinaryis encountered.If
dispose()has been called on thisBinaryobject, then this method will throw the runtime exceptionIllegalStateException.- Parameters:
b- the buffer into which the data is read.position- the position in this Binary from which to start reading bytes.- Returns:
- the number of bytes read into the buffer, or -1 if there is no more data because the end of the Binary has been reached.
- Throws:
java.io.IOException- if an I/O error occurs.java.lang.NullPointerException- if b is null.java.lang.IllegalArgumentException- if offset is negative.RepositoryException- if another error occurs.
-
getSize
long getSize() throws RepositoryExceptionReturns the size of thisBinaryvalue in bytes.If
dispose()has been called on thisBinaryobject, then this method will throw the runtime exceptionIllegalStateException.- Returns:
- the size of this value in bytes.
- Throws:
RepositoryException- if an error occurs.
-
dispose
void dispose()
Releases all resources associated with thisBinaryobject and informs the repository that these resources may now be reclaimed. An application should call this method when it is finished with theBinaryobject.
-
-