Package com.mckoi.store
Interface AreaWriter
-
public interface AreaWriter
The interface used for setting up an area initially in a store. This method is intended to optimize the area creation process. Typically an area is created at a specified size and filled with data. This area should be used as follows;AreaWriter writer = store.createArea(16); writer.putInt(3); writer.putLong(100030); writer.putByte(1); writer.putShort(0); writer.putByte(2); writer.finish();
When the 'finish' method is called, the AreaWriter object is invalidated and the area can then be accessed in the store by the 'getArea' method.Note that an area may only be written sequentially using this object. This is by design and allows for the area initialization process to be optimized.
- Author:
- Tobias Downer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
capacity()
Returns the size of this area.void
finish()
Finishes the area writer object.long
getID()
Returns the unique identifier that represents this area in the store.java.io.OutputStream
getOutputStream()
Returns an OutputStream that can be used to write to this area.void
put(byte b)
void
put(byte[] buf)
void
put(byte[] buf, int off, int len)
void
putChar(char c)
void
putInt(int i)
void
putLong(long l)
void
putShort(short s)
-
-
-
Method Detail
-
getID
long getID()
Returns the unique identifier that represents this area in the store.
-
getOutputStream
java.io.OutputStream getOutputStream()
Returns an OutputStream that can be used to write to this area. This stream is backed by this area writer, so if 10 bytes area written to the output stream then the writer position is also incremented by 10 bytes.
-
capacity
int capacity()
Returns the size of this area.
-
finish
void finish() throws java.io.IOException
Finishes the area writer object. This must be called when the area is completely initialized. After this method is called the object is invalidated and the area can be accessed in the store.- Throws:
java.io.IOException
-
put
void put(byte b) throws java.io.IOException
- Throws:
java.io.IOException
-
put
void put(byte[] buf, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
put
void put(byte[] buf) throws java.io.IOException
- Throws:
java.io.IOException
-
putShort
void putShort(short s) throws java.io.IOException
- Throws:
java.io.IOException
-
putInt
void putInt(int i) throws java.io.IOException
- Throws:
java.io.IOException
-
putLong
void putLong(long l) throws java.io.IOException
- Throws:
java.io.IOException
-
putChar
void putChar(char c) throws java.io.IOException
- Throws:
java.io.IOException
-
-