org.ops4j.store.intern
Class TemporaryStore

java.lang.Object
  extended by org.ops4j.store.intern.TemporaryStore
All Implemented Interfaces:
Store<InputStream>

public class TemporaryStore
extends Object
implements Store<InputStream>

Entity store like implementation. Stores incoming data (store) to disk at a temporary location. The handle is valid for use (load) only for this instance's lifetime. (tmp storage location) Uses an SHA-1 hash for indexing.


Constructor Summary
TemporaryStore(File folder, boolean flushStoreage)
           
 
Method Summary
 URI getLocation(Handle handle)
          Fixed location for a resource that has been stored before.
 String hash(InputStream is, OutputStream storeHere)
           
 InputStream load(Handle handle)
          Load a T after (successfully) stored it before.
 Handle store(InputStream inp)
          Read incoming object of type T (for example an InputSteam)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemporaryStore

public TemporaryStore(File folder,
                      boolean flushStoreage)
Method Detail

store

public Handle store(InputStream inp)
             throws IOException
Description copied from interface: Store
Read incoming object of type T (for example an InputSteam)

Specified by:
store in interface Store<InputStream>
Parameters:
inp - object to be stored. Implementations are usually bound to a certain T
Returns:
handle that can be shared. Validity of this handle may be different from implementation to implementation.
Throws:
IOException - in case incoming object cannot be read (if it involves IO)

load

public InputStream load(Handle handle)
                 throws IOException
Description copied from interface: Store
Load a T after (successfully) stored it before.

Specified by:
load in interface Store<InputStream>
Parameters:
handle - identifier that has been returned from a previous srore call.
Returns:
instance of type T that has been stored before.
Throws:
IOException - if loading resource involves IO, things can always go wrong.

getLocation

public URI getLocation(Handle handle)
                throws IOException
Description copied from interface: Store
Fixed location for a resource that has been stored before. Beware, not all BinaryStore implementations may have such thing. Tinybundles.Store is made for programs, not as an end-user library. If possible, use the BinaryHandle you get from store(..) operations. This also gives implementations of this interface greatest freedom and keeps you apps backend independent.

Specified by:
getLocation in interface Store<InputStream>
Parameters:
handle - must refer to a previously stored object.
Returns:
location that is equivalent to the given handle. If possible.
Throws:
IOException - if IO is involved, things may go mad.

hash

public String hash(InputStream is,
                   OutputStream storeHere)
            throws IOException
Throws:
IOException


Copyright © 2006-2013 OPS4J - Open Participation Software for Java. All Rights Reserved.