zinger.util.recycling
Class ArrayGenerator

java.lang.Object
  extended by zinger.util.recycling.ArrayGenerator
All Implemented Interfaces:
ObjectGenerator

public class ArrayGenerator
extends java.lang.Object
implements ObjectGenerator


Field Summary
static int CHECK_TYPE
           
protected  java.lang.Class componentType
           
protected  int length
           
static int NO_PREPARATION
           
protected  int preparationType
           
static int RESET_COMPONENTS
           
 
Constructor Summary
ArrayGenerator(java.lang.Class componentType, int length)
           
ArrayGenerator(java.lang.Class componentType, int length, int preparationType)
           
 
Method Summary
 java.lang.Object newObject()
          Creates a new instance.
 boolean prepareObject(java.lang.Object obj, java.lang.Object arg)
          Prepares the instance for use (reuse) according to the argument passed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_PREPARATION

public static final int NO_PREPARATION
See Also:
Constant Field Values

CHECK_TYPE

public static final int CHECK_TYPE
See Also:
Constant Field Values

RESET_COMPONENTS

public static final int RESET_COMPONENTS
See Also:
Constant Field Values

componentType

protected final java.lang.Class componentType

length

protected final int length

preparationType

protected final int preparationType
Constructor Detail

ArrayGenerator

public ArrayGenerator(java.lang.Class componentType,
                      int length,
                      int preparationType)

ArrayGenerator

public ArrayGenerator(java.lang.Class componentType,
                      int length)
Method Detail

newObject

public java.lang.Object newObject()
Description copied from interface: ObjectGenerator
Creates a new instance.

Specified by:
newObject in interface ObjectGenerator

prepareObject

public boolean prepareObject(java.lang.Object obj,
                             java.lang.Object arg)
                      throws java.lang.IllegalArgumentException
Description copied from interface: ObjectGenerator
Prepares the instance for use (reuse) according to the argument passed. Since we can't absolutely be sure that the object being worked on is in valid state or even that it was generated by this instance, we have a chance to refuse to prepare it by returning false.

Specified by:
prepareObject in interface ObjectGenerator
Returns:
true if the preparation succeeded
false if there is something wrong with the object passed
Throws:
java.lang.IllegalArgumentException - if the argument passed for preparation is inappropriate