org.jppf.utils
Class JPPFBuffer

java.lang.Object
  extended by org.jppf.utils.JPPFBuffer

public class JPPFBuffer
extends Object

buffer for the data read from or written to a socket connection.

Author:
Laurent Cohen, Domingos Creado

Field Summary
 byte[] buffer
          The actual buffer, intended to contain a serialized object graph.
 int length
          The length of the buffer.
 int pos
          Current position in this buffer.
 
Constructor Summary
JPPFBuffer()
          Initialize this buffer.
JPPFBuffer(byte[] buffer, int length)
          Initialize this buffer with a specified buffer and buffer length.
JPPFBuffer(String str)
          Initialize this buffer with the specified String, using UTF-8 encoding.
 
Method Summary
 String asString()
          Transform this buffer into a string using UTF-8 encoding.
 byte[] getBuffer()
          Get the buffered data.
 int getLength()
          Get the length of the buffered data.
 int remaining()
          Return the number of bytes available for writing in this buffer.
 int remainingFromPos()
          Return the number of bytes available for reading in this buffer.
 void setBuffer(byte[] buffer)
          Set the buffered data.
 void setLength(int length)
          Set the length of the buffered data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

public byte[] buffer
The actual buffer, intended to contain a serialized object graph.


length

public int length
The length of the buffer.


pos

public int pos
Current position in this buffer.

Constructor Detail

JPPFBuffer

public JPPFBuffer()
Initialize this buffer.


JPPFBuffer

public JPPFBuffer(String str)
Initialize this buffer with the specified String, using UTF-8 encoding.

Parameters:
str - the string whose contents will be put into this buffer.

JPPFBuffer

public JPPFBuffer(byte[] buffer,
                  int length)
Initialize this buffer with a specified buffer and buffer length.

Parameters:
buffer - the buffer to use.
length - the number of bytes to use in the buffer.
Method Detail

setBuffer

public void setBuffer(byte[] buffer)
Set the buffered data.

Parameters:
buffer - an array of bytes containing the data.

getBuffer

public byte[] getBuffer()
Get the buffered data.

Returns:
an array of bytes containing the data.

setLength

public void setLength(int length)
Set the length of the buffered data.

Parameters:
length - the length as an int.

getLength

public int getLength()
Get the length of the buffered data.

Returns:
the length as an int.

remaining

public int remaining()
Return the number of bytes available for writing in this buffer.

Returns:
the available bytes as an int value.

remainingFromPos

public int remainingFromPos()
Return the number of bytes available for reading in this buffer.

Returns:
the available bytes as an int value.

asString

public String asString()
Transform this buffer into a string using UTF-8 encoding.

Returns:
the content of this buffer as a string.


Copyright © 2005-2010 JPPF Team.