com.caucho.vfs
Class TempBuffer

java.lang.Object
  extended by com.caucho.vfs.TempBuffer
All Implemented Interfaces:
java.io.Serializable

public class TempBuffer
extends java.lang.Object
implements java.io.Serializable

Pooled temporary byte buffer.

See Also:
Serialized Form

Field Summary
static int LARGE_SIZE
           
static int SIZE
           
static int SMALL_SIZE
           
 
Constructor Summary
TempBuffer(int size)
          Create a new TempBuffer.
 
Method Summary
static TempBuffer allocate()
          Allocate a TempBuffer, reusing one if available.
static TempBuffer allocateLarge()
          Allocate a TempBuffer, reusing one if available.
static TempBuffer allocateSmall()
          Allocate a TempBuffer, reusing one if available.
 void clear()
          Clears the buffer.
static void free(TempBuffer buf)
          Frees a single buffer.
static void freeAll(TempBuffer buf)
           
static void freeAllLarge(TempBuffer buf)
           
static void freeAllSmall(TempBuffer buf)
           
static void freeLarge(TempBuffer buf)
          Frees a single buffer.
static void freeSmall(TempBuffer buf)
          Frees a single buffer.
 int getAvailable()
           
 byte[] getBuffer()
          Returns the buffer's underlying byte array.
 int getCapacity()
           
 int getLength()
          Returns the number of bytes in the buffer.
 TempBuffer getNext()
           
static boolean isSmallmem()
          Returns true for a smallmem configuration
 void setLength(int length)
          Sets the number of bytes used in the buffer.
 void setNext(TempBuffer next)
           
 int write(byte[] buf, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMALL_SIZE

public static final int SMALL_SIZE

LARGE_SIZE

public static final int LARGE_SIZE

SIZE

public static final int SIZE
Constructor Detail

TempBuffer

public TempBuffer(int size)
Create a new TempBuffer.

Method Detail

isSmallmem

public static boolean isSmallmem()
Returns true for a smallmem configuration


allocate

public static TempBuffer allocate()
Allocate a TempBuffer, reusing one if available.


allocateSmall

public static TempBuffer allocateSmall()
Allocate a TempBuffer, reusing one if available.


allocateLarge

public static TempBuffer allocateLarge()
Allocate a TempBuffer, reusing one if available.


clear

public void clear()
Clears the buffer.


getBuffer

public final byte[] getBuffer()
Returns the buffer's underlying byte array.


getLength

public final int getLength()
Returns the number of bytes in the buffer.


setLength

public final void setLength(int length)
Sets the number of bytes used in the buffer.


getCapacity

public final int getCapacity()

getAvailable

public int getAvailable()

getNext

public final TempBuffer getNext()

setNext

public final void setNext(TempBuffer next)

write

public int write(byte[] buf,
                 int offset,
                 int length)

free

public static void free(TempBuffer buf)
Frees a single buffer.


freeAll

public static void freeAll(TempBuffer buf)

freeSmall

public static void freeSmall(TempBuffer buf)
Frees a single buffer.


freeAllSmall

public static void freeAllSmall(TempBuffer buf)

freeLarge

public static void freeLarge(TempBuffer buf)
Frees a single buffer.


freeAllLarge

public static void freeAllLarge(TempBuffer buf)