org.apache.jackrabbit.oak.spi.blob
Interface BlobStore

All Known Subinterfaces:
GarbageCollectableBlobStore
All Known Implementing Classes:
AbstractBlobStore, FileBlobStore, MemoryBlobStore

public interface BlobStore

An interface to store and read large binary objects.


Method Summary
 String getBlobId(String reference)
          Returns the blobId that referred by the given binary reference.
 long getBlobLength(String blobId)
          Get the length of the blob.
 InputStream getInputStream(String blobId)
          Returns a new stream for given blobId.
 String getReference(String blobId)
          Returns a secure reference to blob referred by blobid, or null if no such reference is available.
 int readBlob(String blobId, long pos, byte[] buff, int off, int length)
          Read a number of bytes from a blob.
 String writeBlob(InputStream in)
          Write a blob from an input stream.
 

Method Detail

writeBlob

String writeBlob(InputStream in)
                 throws IOException
Write a blob from an input stream. This method closes the input stream.

Parameters:
in - the input stream
Returns:
the blob id
Throws:
IOException

readBlob

int readBlob(String blobId,
             long pos,
             byte[] buff,
             int off,
             int length)
             throws IOException
Read a number of bytes from a blob.

Parameters:
blobId - the blob id
pos - the position within the blob
buff - the target byte array
off - the offset within the target array
length - the number of bytes to read
Returns:
the number of bytes read
Throws:
IOException

getBlobLength

long getBlobLength(String blobId)
                   throws IOException
Get the length of the blob.

Parameters:
blobId - the blob id
Returns:
the length
Throws:
IOException

getInputStream

InputStream getInputStream(String blobId)
                           throws IOException
Returns a new stream for given blobId. The streams returned from multiple calls to this method are byte wise equals. That is, subsequent calls to read return the same sequence of bytes as long as neither call throws an exception.

Parameters:
blobId - the blob id
Returns:
a new stream for given blobId
Throws:
IOException

getBlobId

@CheckForNull
String getBlobId(@Nonnull
                              String reference)
Returns the blobId that referred by the given binary reference. Returns null if the reference is invalid, for example if it points to a blob that does not exist.

Parameters:
reference - binary reference
Returns:
matching blobId, or null

getReference

@CheckForNull
String getReference(@Nonnull
                                 String blobId)
Returns a secure reference to blob referred by blobid, or null if no such reference is available.

Parameters:
blobId - blobId referring the blob for which reference is required
Returns:
binary reference, or null


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.