korat.finitization.impl
Class StateSpace

java.lang.Object
  extended by korat.finitization.impl.StateSpace

public class StateSpace
extends Object

Represents the state space scheme required by ITestCaseGenerator. Provides operations required by Korat testing engine.

Author:
korat.team

Field Summary
protected  boolean initialized
           
protected static StateSpace lastInstance
           
protected  Map<Object,int[]> objFields
           
protected  Object rootObject
           
protected  CVElem[] structureList
           
private static int[] zeroSizeInt
           
 
Constructor Summary
StateSpace()
           
 
Method Summary
 CVElem getCVElem(int candidateVectorIndex)
          Returns ICVElem corresponding to the given index.
protected  CVElem getCVElem(Object obj, String fieldName)
           
 FieldDomain getFieldDomain(int candidateVectorIndex)
          Returns FieldDomain connected with the given index in candidate vector.
 FieldDomain getFieldDomain(Object obj, String fieldName)
          Helper, returns IFieldIndex connected with the given field in the given object.
 int[] getFieldIndicesFor(Object obj)
           
 String getFieldName(int candidateVectorIndex)
          Returns field name connected with the given index in candidate vector.
protected  int getIndex(Object obj, String fieldName)
           
 int getIndexInCandidateVector(Object obj, String fieldName)
          Returns the index of the field fieldName of the Object obj in scheme.
 int getIndexInCandidateVector(Object obj, String fld, Setter setter)
          Returns the index of the field fieldName of the Object obj in scheme.
static StateSpace getLastInstance()
           
 Object getObject(int candidateVectorIndex)
          Returns Object connected with the given index in candidate vector.
 Object getRootObject()
          Returns root object of this structure (previously set by IFinitization ).
 CVElem[] getStructureList()
           
 int getTotalNumberOfFields()
          Returns total number of fields for all objects included in finitization
 void initialize()
          Initializes the state space
private  void initializeFieldMap()
           
 void setRootObject(Object root)
          Finitization should set the root object of the structure, after it creates the StateSpace.
 void setStructureList(CVElem[] structureList)
          Feature that will be used by Finitization object to build StateSpace.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rootObject

protected Object rootObject

initialized

protected boolean initialized

structureList

protected CVElem[] structureList

lastInstance

protected static StateSpace lastInstance

objFields

protected Map<Object,int[]> objFields

zeroSizeInt

private static final int[] zeroSizeInt
Constructor Detail

StateSpace

public StateSpace()
Method Detail

getIndex

protected int getIndex(Object obj,
                       String fieldName)

getCVElem

protected CVElem getCVElem(Object obj,
                           String fieldName)

getCVElem

public CVElem getCVElem(int candidateVectorIndex)
Returns ICVElem corresponding to the given index.

Parameters:
candidateVectorIndex - - index in candidate vector
Returns:
an entry in the candidate vector

getLastInstance

public static StateSpace getLastInstance()

getStructureList

public CVElem[] getStructureList()

setStructureList

public void setStructureList(CVElem[] structureList)
Feature that will be used by Finitization object to build StateSpace.

For example, structureList can contain structures like (Object, String, IFieldDomain), where the Object parameter is the object, String represents field name of that object, and IFieldDomain is the the domain assigned to that field.


getRootObject

public Object getRootObject()
Returns root object of this structure (previously set by IFinitization ). This object is the one that is actualy being tested.

Returns:
root object of this structure
See Also:
setRootObject(Object)

setRootObject

public void setRootObject(Object root)
Finitization should set the root object of the structure, after it creates the StateSpace.

Parameters:
root - represents the test case object, the one that is being tested.
See Also:
getRootObject()

getFieldName

public String getFieldName(int candidateVectorIndex)
Returns field name connected with the given index in candidate vector.

Parameters:
candidateVectorIndex - - index in candidate vector
Returns:
requested field name

getObject

public Object getObject(int candidateVectorIndex)
Returns Object connected with the given index in candidate vector.

Parameters:
candidateVectorIndex - - index in candidate vector
Returns:
requested object

getIndexInCandidateVector

public int getIndexInCandidateVector(Object obj,
                                     String fieldName)
Returns the index of the field fieldName of the Object obj in scheme.
Required for the Korat search algorithm.

Parameters:
obj - object of interest
fieldName - name of the field of the given object
Returns:
requested index

getFieldDomain

public FieldDomain getFieldDomain(int candidateVectorIndex)
Returns FieldDomain connected with the given index in candidate vector.
Required for the Korat search algorithm.

Parameters:
candidateVectorIndex - - index in candidate vector
Returns:
requested IFieldDomain

getFieldDomain

public FieldDomain getFieldDomain(Object obj,
                                  String fieldName)
Helper, returns IFieldIndex connected with the given field in the given object. Calls getFieldDomain(getIndexInCandidateVector(obj, filedName))
Should be implemented as final template method.

Parameters:
obj -
fieldName - - name of the field of the given object
Returns:
requested IFieldInformation

getTotalNumberOfFields

public int getTotalNumberOfFields()
Returns total number of fields for all objects included in finitization

Returns:
total number of fields.

toString

public String toString()
Overrides:
toString in class Object

getIndexInCandidateVector

public int getIndexInCandidateVector(Object obj,
                                     String fld,
                                     Setter setter)
Returns the index of the field fieldName of the Object obj in scheme. At the same time, if the returned index is greater than or equal to zero (meaning that there is a valid CVElem associated with the given object and its field named fieldName), the given setter object will be set for that CVElem.
Required for the korat search algorithm.

Parameters:
obj - object of interest
fld - name of the field of the given object
setter -
Returns:
requested index

initialize

public void initialize()
Initializes the state space


initializeFieldMap

private void initializeFieldMap()

getFieldIndicesFor

public int[] getFieldIndicesFor(Object obj)