org.apache.chemistry.opencmis.jcr
Class JcrBinary

java.lang.Object
  extended by org.apache.chemistry.opencmis.jcr.JcrBinary
All Implemented Interfaces:
javax.jcr.Binary

public class JcrBinary
extends Object
implements javax.jcr.Binary

JcrBinary implements the JCR Binary interface. This is mostly a copy from org.apache.jackrabbit.value.BinaryImpl in Apache Jackrabbit's jcr-commons module.


Field Summary
static javax.jcr.Binary EMPTY
           
 
Constructor Summary
JcrBinary(byte[] buffer)
          Creates a new JcrBinary instance from a byte[] array.
JcrBinary(InputStream in)
          Creates a new JcrBinary instance from an InputStream.
 
Method Summary
 void dispose()
           
 long getSize()
           
 InputStream getStream()
           
 int read(byte[] b, long position)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final javax.jcr.Binary EMPTY
Constructor Detail

JcrBinary

public JcrBinary(InputStream in)
          throws IOException
Creates a new JcrBinary 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. The input stream is closed by this implementation.

Parameters:
in - stream to be represented as a JcrBinary instance
Throws:
IOException - if an error occurs while reading from the stream or writing to the temporary file

JcrBinary

public JcrBinary(byte[] buffer)
Creates a new JcrBinary instance from a byte[] array.

Parameters:
buffer - byte array to be represented as a JcrBinary instance
Method Detail

getStream

public InputStream getStream()
                      throws javax.jcr.RepositoryException
Specified by:
getStream in interface javax.jcr.Binary
Throws:
javax.jcr.RepositoryException

read

public int read(byte[] b,
                long position)
         throws IOException,
                javax.jcr.RepositoryException
Specified by:
read in interface javax.jcr.Binary
Throws:
IOException
javax.jcr.RepositoryException

getSize

public long getSize()
             throws javax.jcr.RepositoryException
Specified by:
getSize in interface javax.jcr.Binary
Throws:
javax.jcr.RepositoryException

dispose

public void dispose()
Specified by:
dispose in interface javax.jcr.Binary


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