edu.ksu.cis.projects.bogor.module.value
Class DefaultArrayValue

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.module.value.DefaultArrayValue
All Implemented Interfaces:
IArrayValue, INonPrimitiveValue, IRecordValue, IValue, Disposable, Serializable, Comparable<IValue>

public class DefaultArrayValue
extends Object
implements IArrayValue

The default implementation of IArrayValue.

Version:
CVS $Revision: 1.16 $ $Date: 2005/06/06 19:15:31 $
Author:
Robby , Matt Hoosier
See Also:
Serialized Form

Field Summary
protected  IValueArray elementValues
          Holds the element values of this array value.
protected  IValueArray fieldValues
          Holds the field values of this array value.
protected  ILockValue lockValue
          Holds the lock value of this array value.
protected  int referenceId
          Holds the reference id of this array.
protected  ArrayType type
          The array type of this array value.
protected  IValueFactory vf
          Holds the value factory of this array value.
 
Constructor Summary
protected DefaultArrayValue()
          Private constructor for cloning purposes.
protected DefaultArrayValue(IValueFactory vf, int referenceId, ArrayType type, IValueArray elementValues, IValueArray fieldValues, ILockValue lockValue)
          Default constructor.
 
Method Summary
 IArrayValue clone(Map<Object,Object> cloneMap)
          Override to specialize return type.
 int compareTo(IValue o)
           
 void dispose()
          Remove references.
 boolean equals(Object o)
          Classes implementing IValue should provide their own equality tests.
 IValue getElementValue(int elementIndex)
          Gets an array element's value.
 IValueArray getElementValues()
          Gets the element values.
 int getFieldCount()
          Gets the number of fields in this record.
 IValue getFieldValue(int fieldIndex)
          Gets a record field's value.
 IValueArray getFieldValues()
           
 int getLength()
          Gets the length of this array.
 ILockValue getLockValue()
          Gets the lock value of this record.
 int getReferenceId()
          Gets this non-primitive value reference id.
 Type getType()
          Gets the type of this value.
 int getTypeId()
          Gets the type id of this value.
 int hashCode()
          Classes implementing IValue should provide their own hashing method.
 byte[][] linearize(int bitsPerNonPrimitiveValue, ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap, int bitsPerThreadId, IntIntTable threadOrderMap)
          Linearizes this record value.
 void setElementValue(int elementIndex, IValue elementValue)
          Sets an array element's value.
 void setFieldValue(int fieldIndex, IValue fieldValue)
          Sets a record field's value.
 String toString()
          Gets the string representation of this value.
 String toVerboseString()
          Returns the verbose string representation of this array.
 void validate(IBogorConfiguration bc)
           Freshen references to Bogor model checking components and other non-serializable objects.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

vf

protected transient IValueFactory vf
Holds the value factory of this array value. Non-null.


fieldValues

protected IValueArray fieldValues
Holds the field values of this array value. Non-null.


elementValues

protected IValueArray elementValues
Holds the element values of this array value. Non-null.


lockValue

protected ILockValue lockValue
Holds the lock value of this array value. Non-null.


type

protected ArrayType type
The array type of this array value. Non-null.


referenceId

protected int referenceId
Holds the reference id of this array. Must be greater than 0.

Constructor Detail

DefaultArrayValue

protected DefaultArrayValue(IValueFactory vf,
                            int referenceId,
                            ArrayType type,
                            IValueArray elementValues,
                            IValueArray fieldValues,
                            ILockValue lockValue)
Default constructor.

Parameters:
vf - The value factory of this array value. Must be non-null.
referenceId - The reference id for this array value. Must be greater than 0.
type - The array type for this array value. Must be non-null.
elementValues - The element values for this array value. Must be non-null.
fieldValues - The field values for this array value. Must be non-null.
lockValue - The lock value for this array value. Must be non-null.
See Also:
SymbolTable.getArrayFieldIndex(String)

DefaultArrayValue

protected DefaultArrayValue()
Private constructor for cloning purposes.

Method Detail

setElementValue

public void setElementValue(int elementIndex,
                            IValue elementValue)
Description copied from interface: IArrayValue
Sets an array element's value.

Specified by:
setElementValue in interface IArrayValue
Parameters:
elementIndex - The index of the element in this array. Must be greater than zero and less than the length of this array.
elementValue - The new value of the element. Must be non-null.

getElementValue

public IValue getElementValue(int elementIndex)
Description copied from interface: IArrayValue
Gets an array element's value.

Specified by:
getElementValue in interface IArrayValue
Parameters:
elementIndex - The index of the element in this array. Must be greater than zero and less than the length of this array.
Returns:
The element's value. Non-null.

getElementValues

public IValueArray getElementValues()
Description copied from interface: IArrayValue
Gets the element values.

Specified by:
getElementValues in interface IArrayValue
Returns:
The element values. Non-null.

getFieldCount

public int getFieldCount()
Description copied from interface: IRecordValue
Gets the number of fields in this record.

Specified by:
getFieldCount in interface IRecordValue
Returns:
The number of fields in this record. At least zero.

setFieldValue

public void setFieldValue(int fieldIndex,
                          IValue fieldValue)
Description copied from interface: IRecordValue
Sets a record field's value.

Specified by:
setFieldValue in interface IRecordValue
Parameters:
fieldIndex - The index of the field in this record. Must be greater than zero and less than the field count of this record.
fieldValue - The new value of the field. Must be non-null.
See Also:
RecordType.getFieldIndex(String)

getFieldValue

public IValue getFieldValue(int fieldIndex)
Description copied from interface: IRecordValue
Gets a record field's value.

Specified by:
getFieldValue in interface IRecordValue
Parameters:
fieldIndex - The index of the field in this record. Must be greater than zero and less than the field count of this record.
Returns:
The field's value. Non-null.
See Also:
RecordType.getFieldIndex(String)

getFieldValues

public IValueArray getFieldValues()
Specified by:
getFieldValues in interface IRecordValue

getLength

public int getLength()
Description copied from interface: IArrayValue
Gets the length of this array.

Specified by:
getLength in interface IArrayValue
Returns:
The length of this array. At least zero.

getLockValue

public ILockValue getLockValue()
Description copied from interface: IRecordValue
Gets the lock value of this record.

Specified by:
getLockValue in interface IRecordValue
Returns:
The lock value of this record. Non-null.

getReferenceId

public int getReferenceId()
Description copied from interface: INonPrimitiveValue
Gets this non-primitive value reference id.

Specified by:
getReferenceId in interface INonPrimitiveValue
Returns:
This value reference id.

getType

public Type getType()
Description copied from interface: IValue
Gets the type of this value.

Specified by:
getType in interface IValue
Returns:
The type of this value. Non-null.
See Also:
Type.getTypeId()

getTypeId

public int getTypeId()
Description copied from interface: IValue
Gets the type id of this value.

Specified by:
getTypeId in interface IValue
Returns:
The type id of this value.
See Also:
Type.getTypeId()

clone

public IArrayValue clone(Map<Object,Object> cloneMap)
Description copied from interface: IArrayValue
Override to specialize return type.

Specified by:
clone in interface IArrayValue
Specified by:
clone in interface INonPrimitiveValue
Specified by:
clone in interface IRecordValue
Specified by:
clone in interface IValue
Parameters:
cloneMap - Original values (IValue) to their clones ( IValue) mapping. The clone map to solve circular references in values. If this value is a key in the map, then this method returns the value of the key in the map. Must be non-null.
Returns:
The clone of this value. Non-null.

compareTo

public int compareTo(IValue o)
Specified by:
compareTo in interface Comparable<IValue>

dispose

public void dispose()
Description copied from interface: Disposable
Remove references. Once called, avoid using this object.

Specified by:
dispose in interface Disposable

equals

public boolean equals(Object o)
Description copied from interface: IValue
Classes implementing IValue should provide their own equality tests.

Specified by:
equals in interface IValue
Overrides:
equals in class Object

hashCode

public int hashCode()
Description copied from interface: IValue
Classes implementing IValue should provide their own hashing method.

Specified by:
hashCode in interface IValue
Overrides:
hashCode in class Object

linearize

public byte[][] linearize(int bitsPerNonPrimitiveValue,
                          ObjectIntTable<INonPrimitiveValue> nonPrimitiveValueIdMap,
                          int bitsPerThreadId,
                          IntIntTable threadOrderMap)
Description copied from interface: IRecordValue
Linearizes this record value.

Specified by:
linearize in interface IRecordValue
Parameters:
bitsPerNonPrimitiveValue - The number of bits used to encode a non-primitive value.
nonPrimitiveValueIdMap - A mapping of non-primitive values to their unique id. Must be non-null.
bitsPerThreadId - The number of bits used to encode a thread descriptor.
threadOrderMap - A mapping of thread descriptors to their order number. Must be non-null.
Returns:
The bit-vectors representation of this record value. Non-null. Each element is non-null.

toString

public String toString()
Description copied from interface: IValue
Gets the string representation of this value.

Specified by:
toString in interface IValue
Overrides:
toString in class Object
Returns:
The string representation of this value. Non-null.

toVerboseString

public String toVerboseString()
Description copied from interface: IArrayValue
Returns the verbose string representation of this array.

Specified by:
toVerboseString in interface IArrayValue
Specified by:
toVerboseString in interface IRecordValue
Returns:
The verbose string representation of this array. Non-null. The string contains the string representations of this array's elements and fields.

validate

public void validate(IBogorConfiguration bc)
Description copied from interface: IValue

Freshen references to Bogor model checking components and other non-serializable objects. Generally, this can be done in a few steps:

Model checking components (IModule implementations) should be reacquired by fetching them from the parameter, bc:

     valueFactory = bc.getValueFactory();
     scheduler = bc.getSchedulingStrategist();
 

Any fields storing Type objects should be treated as stale, but still uniquely identifier by their integer typeId field. This can be used as a key to look up the correct Type instances in the new symbol table's typeId-to-type table:

     typeField = bc.getSymbolTable().getTypeIdTypeTable().get(typeField.getTypeId());
 

Any IValueArray objects contained can simply be "chained" by their IValueArray.validate(IBogorConfiguration) method:

     someValueArray.validate(bc);
 

IValue objects contained directly should not be handled manually by this method; they will be dealt with directly when they are visited later

Specified by:
validate in interface IValue
Parameters:
bc - The Bogor configuration to validate to.