|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object m.c.m.proxyma.buffers.SmartBuffer
public class SmartBuffer
This class implements a generalyzed Buffer that can be used to store large and small binary data. It uses both a RamBuffer and a FileBuffer to mantain the data. If the data that comes into the buffer are more than its soft-limit, the buffer will store the exceding data into a temporary file to prevent high memory consumption. You can't write simultaneouusly from separate threads (write operations are not thread-safe).
NOTE: this software is released under GPL License. See the LICENSE of this distribution for more informations.
Constructor Summary | |
---|---|
SmartBuffer()
Create a smart buffer that can countain into RAM a maximum of 256Kb of data. |
|
SmartBuffer(int maxRamSize)
Create a smart buffer that can countain into RAM a specific amount of data. |
Method Summary | |
---|---|
long |
appendByte(int data)
Append the passed byte to the buffer. |
long |
appendBytes(byte[] data,
int toAppend)
Append the passed byte array to the buffer. |
java.lang.Object |
clone()
This method clones the current object. |
protected FileBuffer |
getFileBuffer()
Obtain the internal FileBuffer to read into it. |
protected RamBuffer |
getRamBuffer()
Obtain the internal RamBuffer to read into it. |
long |
getSize()
Returns the size (in bytes) of the data into the buffer. |
boolean |
isLocked()
return false if the buffer is still appendable |
void |
lock()
Sets the buffer as ReadOnly.. no more data can be written into it. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SmartBuffer()
public SmartBuffer(int maxRamSize)
maxRamSize
- Method Detail |
---|
public long appendBytes(byte[] data, int toAppend) throws java.io.IOException, java.lang.IllegalStateException
appendBytes
in interface ByteBuffer
data
- a byte array that countains the data to storesize
- the number of bytes to copy.
IOException,
- IllegalStateException
java.io.IOException
java.lang.IllegalStateException
public long appendByte(int data) throws java.io.IOException, java.lang.IllegalStateException
appendByte
in interface ByteBuffer
data
- an integer that rappresents the byte data.
IOException,
- IllegalStateException
java.io.IOException
java.lang.IllegalStateException
public void lock()
lock
in interface ByteBuffer
public long getSize()
getSize
in interface ByteBuffer
public boolean isLocked()
isLocked
in interface ByteBuffer
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface ByteBuffer
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if the clone operation is not supportedprotected FileBuffer getFileBuffer()
protected RamBuffer getRamBuffer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |