org.apache.jackrabbit.api.jsr283
Interface Binary


public interface Binary

A Binary object holds a JCR property value of type BINARY. The Binary interface and the related methods in Property, Value and ValueFactory replace the deprecated Value.getStream() and Property.getStream() methods.

Since:
JCR 2.0

Method Summary
 long getSize()
          Returns the size of this Binary value in bytes.
 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.
 

Method Detail

getStream

InputStream getStream()
                      throws RepositoryException
Returns an 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.

Returns:
A stream representation of this value.
Throws:
RepositoryException - if an error occurs.

read

int read(byte[] b,
         long position)
         throws IOException,
                RepositoryException
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.

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:
IOException - if an I/O error occurs.
NullPointerException - if b is null.
IllegalArgumentException - if offset is negative.
RepositoryException - if another error occurs.

getSize

long getSize()
             throws RepositoryException
Returns the size of this Binary value in bytes.

Returns:
the size of this value in bytes.
Throws:
RepositoryException - if an error occurs.


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.