com.gc.iotools.stream.store
Class MemoryStore

java.lang.Object
  extended by com.gc.iotools.stream.store.MemoryStore
All Implemented Interfaces:
SeekableStore, Store

public class MemoryStore
extends Object
implements SeekableStore

TODO: more efficient memory usage.

Since:
1.2.0
Version:
$Id: MemoryStore.java 527 2014-02-24 19:29:50Z gabriele.contini@gmail.com $
Author:
dvd.smnt

Constructor Summary
MemoryStore()
           
 
Method Summary
 void cleanup()
          Cleans up the Store.
 int get(byte[] bytes, int offset, int length)
          gets length bytes from the store.
 long getPosition()
          Getter for the field position.
 void put(byte[] bytes, int offset, int length)
          put
 void seek(long position)
          Reposition this Store on a previously read position.
 String toString()
           Provides a String representation of the state of the Store for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryStore

public MemoryStore()
Method Detail

cleanup

public void cleanup()
Cleans up the Store. Forget all the data previously stored.

Specified by:
cleanup in interface Store

get

public int get(byte[] bytes,
               int offset,
               int length)
gets length bytes from the store.

Specified by:
get in interface Store
Parameters:
bytes - array where to put the data in.
offset - offset in the array to start put the data.
length - length of the bytes got from the store.
Returns:
number of bytes effectively put in the array or -1 if the Store was empty.

getPosition

public long getPosition()

Getter for the field position.

Returns:
a long.

put

public void put(byte[] bytes,
                int offset,
                int length)

put

Specified by:
put in interface Store
Parameters:
bytes - an array of byte.
offset - a int.
length - a int.

seek

public void seek(long position)
Reposition this Store on a previously read position.

Specified by:
seek in interface SeekableStore
Parameters:
position - position to read the data from.

toString

public String toString()
Provides a String representation of the state of the Store for debugging purposes.

Overrides:
toString in class Object


Copyright © 2008–2014. All rights reserved.