hypercast
Class ObjectPool

java.lang.Object
  |
  +--hypercast.ObjectPool
Direct Known Subclasses:
FSMPool

public class ObjectPool
extends java.lang.Object

This class defines an object pool which stores predefined certain types object instances. When a new object is needed, it can be obtained from this object pool instead of creating a new object on demand. The type of an object in the pool is identified by an object ID. By default, there is no limit on the amount of object with certain type that can be stored in the pool.


Constructor Summary
ObjectPool()
          Constructor.
 
Method Summary
 void addObjInstance(java.lang.Object objInstance, short objid)
          Add a Object instance with specified object id to the pool.
 void addObjVector(java.util.Vector v, short objid)
          Add a vector of object instances with specified Object id to the pool.
 int getMaxNumOfObjInstances(short objid)
          Get the maximum number of a certain type object instances that the pool can store.
 java.lang.Object getObjInstance(short objid)
          Return a Object instances with specified object id from the pool.
 java.util.Vector getObjVector(short objid)
          Get the vector of object instances with specified object id in the pool.
 void setMaxNumOfObjInstances(short objid, int num)
          Set the maximum number of a certain type object instances that the pool can store.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool()
Constructor.

Method Detail

addObjVector

public void addObjVector(java.util.Vector v,
                         short objid)
Add a vector of object instances with specified Object id to the pool.


getObjVector

public java.util.Vector getObjVector(short objid)
Get the vector of object instances with specified object id in the pool.


addObjInstance

public void addObjInstance(java.lang.Object objInstance,
                           short objid)
Add a Object instance with specified object id to the pool.


getObjInstance

public java.lang.Object getObjInstance(short objid)
Return a Object instances with specified object id from the pool. If no required object instance is found, return null.


setMaxNumOfObjInstances

public void setMaxNumOfObjInstances(short objid,
                                    int num)
Set the maximum number of a certain type object instances that the pool can store.


getMaxNumOfObjInstances

public int getMaxNumOfObjInstances(short objid)
Get the maximum number of a certain type object instances that the pool can store.