m.c.m.proxyma.buffers
Interface ByteBuffer

All Known Implementing Classes:
FileBuffer, RamBuffer, SmartBuffer

public interface ByteBuffer

This is a common interface for my Buffer classes. This allows me to change the implementation as needed

NOTE: this software is released under GPL License. See the LICENSE of this distribution for more informations.

Version:
$Id: ByteBuffer.java 138 2010-06-20 13:53:32Z marcolinuz $
Author:
Marco Casavecchia Morganti (marcolinuz) [marcolinuz-at-gmail.com]

Method Summary
 long appendByte(int data)
          Append the passed byte to the buffer.
 long appendBytes(byte[] data, int size)
          Append the passed byte array to the buffer making an internal copy of it.
 java.lang.Object clone()
          Returns a separate but inentical instance of the object
 long getSize()
          Returns the size (in bytes) of the data stored into the buffer.
 boolean isLocked()
          check if the buffer is still writable
 void lock()
          Sets the buffer as ReadOnly.. no more data can be written into it.
 

Method Detail

appendBytes

long appendBytes(byte[] data,
                 int size)
                 throws java.io.IOException,
                        java.lang.IllegalStateException
Append the passed byte array to the buffer making an internal copy of it.

Parameters:
data - a byte array that countains the data to store
size - the number of bytes to copy.
Returns:
the total size of the buffer (total number of introduced bytes).
Throws:
IOException, - IllegalStateException
java.io.IOException
java.lang.IllegalStateException

appendByte

long appendByte(int data)
                throws java.io.IOException,
                       java.lang.IllegalStateException
Append the passed byte to the buffer.

Parameters:
data - an integer that rappresents the byte data.
Returns:
the total size of the buffer (total number of introduced bytes).
Throws:
IOException, - IllegalStateException
java.io.IOException
java.lang.IllegalStateException

lock

void lock()
Sets the buffer as ReadOnly.. no more data can be written into it. If so, an IllegalStateException is raised.


getSize

long getSize()
Returns the size (in bytes) of the data stored into the buffer.

Returns:
the size of the buffer in bytes.

isLocked

boolean isLocked()
check if the buffer is still writable

Returns:
the current status.

clone

java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a separate but inentical instance of the object

Returns:
a clone of the object
Throws:
java.lang.CloneNotSupportedException


Copyright © 2010. All Rights Reserved.