org.apache.xml.utils
Class ObjectPool

java.lang.Object
  extended byorg.apache.xml.utils.ObjectPool
All Implemented Interfaces:
Serializable

public class ObjectPool
extends Object
implements Serializable

Pool of object of a given type to pick from to help memory usage

See Also:
Serialized Form

Field Summary
private  Vector freeStack
          Vector of given objects this points to.
private  Class objectType
          Type of objects in this pool.
 
Constructor Summary
ObjectPool()
          Constructor ObjectPool
ObjectPool(Class type)
          Constructor ObjectPool
ObjectPool(Class type, int size)
          Constructor ObjectPool
ObjectPool(String className)
          Constructor ObjectPool
 
Method Summary
 void freeInstance(Object obj)
          Add an instance of the given object to the pool
 Object getInstance()
          Get an instance of the given object in this pool
 Object getInstanceIfFree()
          Get an instance of the given object in this pool if available
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectType

private final Class objectType
Type of objects in this pool.


freeStack

private final Vector freeStack
Vector of given objects this points to.

Constructor Detail

ObjectPool

public ObjectPool(Class type)
Constructor ObjectPool

Parameters:
type - Type of objects for this pool

ObjectPool

public ObjectPool(String className)
Constructor ObjectPool

Parameters:
className - Fully qualified name of the type of objects for this pool.

ObjectPool

public ObjectPool(Class type,
                  int size)
Constructor ObjectPool

Parameters:
type - Type of objects for this pool
size - Size of vector to allocate

ObjectPool

public ObjectPool()
Constructor ObjectPool

Method Detail

getInstanceIfFree

public Object getInstanceIfFree()
Get an instance of the given object in this pool if available

Returns:
an instance of the given object if available or null

getInstance

public Object getInstance()
Get an instance of the given object in this pool

Returns:
An instance of the given object

freeInstance

public void freeInstance(Object obj)
Add an instance of the given object to the pool

Parameters:
obj - Object to add.