|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.problets.domain.model.DomainModel
org.problets.domain.model.variable.AbstractVarModel
org.problets.domain.model.variable.aggregate.AggregateVarModel
org.problets.domain.model.variable.aggregate.ArrayModel
public class ArrayModel
Class: ArrayModel Purpose: Represents an array of AbstractVarModel objects
| Field Summary | |
|---|---|
static java.lang.String |
NOT_ALLOCATED
Error to occur when a reference is made to unallocated array |
static java.lang.String |
NOT_DECLARED
Error to occur when array is accessed before it is declared |
static java.lang.String |
NOT_INITIALIZED
Error to occur when array is referenced before it is initialized |
static java.lang.String |
OUT_OF_BOUNDS
Error to occur in case of out of bounds access. |
static java.lang.String |
OUT_OF_SCOPE
Error to occur when array is accessed out of it's scope |
| Constructor Summary | |
|---|---|
ArrayModel(int index,
java.lang.String inputType)
Used for null activationRecords. |
|
ArrayModel(int index,
java.lang.String inputType,
java.lang.String sizeString,
java.lang.String initializationList,
ActivationRecord activationRecord)
Creates an array with a random name |
|
| Method Summary | |
|---|---|
void |
assignAll(Value value)
Assigns each of the elements in the array to a value |
java.lang.Object |
clone()
Clones the array |
static void |
cloneElementValues(ArrayModel toModel,
ArrayModel fromModel)
Sets the elements of the array to clones of the given array's values |
static java.util.Vector |
createSubscriptExprVector(java.lang.String subscriptString,
ActivationRecord activationRecord)
Creates an expression for each subscript and returns them in a vector |
boolean |
equalElementValues(ArrayModel a_model)
Determines if this array has the same values as the to compare against |
void |
explainObject(StackModel stack,
HeapModel heap,
Behavior behavior,
java.lang.String statement,
int event,
int lineNumber,
boolean abbreviated)
To generate error messages for arrays after execution. |
void |
explainProcess(RunEnv runEnv,
Behavior behavior,
java.lang.String statement,
int event,
int lineNumber)
Executes a statement and provides an explanation based on what type of statement was executed. |
java.util.Vector |
getArrayDimensions()
Returns the dimensions of the array in a vector. |
static java.util.Vector |
getAskAndTells(java.lang.String template)
Returns a vector of variables in a template that contain an #ask# or #tell# command |
void |
getCode(java.util.Vector codeText,
java.lang.String codeType,
java.lang.String template,
int lineNumber)
Generates code for the template before execution |
java.lang.Object |
getElement(int index)
Gets an element in the array at a specified index |
AbstractVarModel |
getElement(java.lang.String subscriptStringTemplate,
ActivationRecord activationRecord)
returns the element at the given string of subscripts. |
static java.lang.String |
getLHSSubscripts(java.lang.String statement,
int startPosition)
Returns the bracket string on the left side of an assignment statement. |
java.lang.String[] |
getPossibleErrors()
Returns the possible errors for arrays. |
int |
getSize()
Returns the size of the array |
int |
getTotalElementCount()
Returns the number of elements in an array, whether it is one or multi-dimensional |
java.util.Vector |
getValueDifference(AbstractVarModel currentModel,
int line)
Returns a vector of ValueDifference objects containing the corresponding elements of this array and the currentModel array. |
static void |
main(java.lang.String[] args)
Method for debugging |
void |
print()
Prints to standard output the elements of the array |
java.lang.String |
printArrayElements(java.lang.String elementDelimiter)
Returns a string containing the names of the elements in the array followed by their values. |
java.lang.String |
printArrayTable()
Prints the array's elements in a table format. |
void |
resetAllocated()
Overrides super resetAllocated to reset allocation for entire array |
void |
resetDeclared()
Overrides super resetAllocated to reset allocation for entire array |
void |
resetFlags()
Overrides super.resetFlags to reset the array recursively |
void |
setAllocated()
Overrides super setAllocated to allocate entire array |
void |
setDeclared()
Overrides super setDeclared to declare entire array |
void |
setValue(Value value)
Overrides super setValue to set the value to each element in the array |
java.lang.String |
toString()
|
| Methods inherited from class org.problets.domain.model.variable.AbstractVarModel |
|---|
getAllocated, getAssigned, getDeclared, getMetaDataType, getName, getType, getValue, setValue |
| Methods inherited from class org.problets.domain.model.DomainModel |
|---|
getId, getIdName, grade |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String NOT_ALLOCATED
public static final java.lang.String NOT_DECLARED
public static final java.lang.String OUT_OF_SCOPE
public static final java.lang.String NOT_INITIALIZED
public static final java.lang.String OUT_OF_BOUNDS
| Constructor Detail |
|---|
public ArrayModel(int index,
java.lang.String inputType)
index - used to get the random name of the arrayinputType - the template data type of the array
public ArrayModel(int index,
java.lang.String inputType,
java.lang.String sizeString,
java.lang.String initializationList,
ActivationRecord activationRecord)
index - index to the symbol table - used to get the random name of the arrayinputType - the template data type of the arraysizeString - holds a consecutive string of sizes enclosed in square-bracketsinitializationList - holds initializers for the array elements in the form of a
comma seperated list enclosed in curly-braces. This is a C-style array initializer list,
and should be left empty if there is no initializer list.activationRecord - the activation record for the current scope| Method Detail |
|---|
public java.lang.Object clone()
clone in class AggregateVarModel
public static void cloneElementValues(ArrayModel toModel,
ArrayModel fromModel)
toModel - the ArrayModel to set it's values to the clones of fromModelfromModel - the ArrayModel that will have it's values clonedpublic final boolean equalElementValues(ArrayModel a_model)
a_model - the array to compare against
public int getTotalElementCount()
public int getSize()
public AbstractVarModel getElement(java.lang.String subscriptStringTemplate,
ActivationRecord activationRecord)
subscriptStringTemplate - the string of subscriptsactivationRecord - the activation record for the current scope
public java.lang.Object getElement(int index)
index - the index of the element requested
public java.lang.String[] getPossibleErrors()
getPossibleErrors in class AbstractVarModel
public java.util.Vector getValueDifference(AbstractVarModel currentModel,
int line)
getValueDifference in class AbstractVarModelcurrentModel - the array containing all the current values.line - the line number of the value difference
public java.util.Vector getArrayDimensions()
public void setDeclared()
setDeclared in class AbstractVarModelpublic void setAllocated()
setAllocated in class AbstractVarModelpublic void resetDeclared()
resetDeclared in class AbstractVarModelpublic void resetAllocated()
resetAllocated in class AbstractVarModelpublic void resetFlags()
resetFlags in class AbstractVarModelpublic void setValue(Value value)
public void assignAll(Value value)
value - the value to set each element to
public void getCode(java.util.Vector codeText,
java.lang.String codeType,
java.lang.String template,
int lineNumber)
getCode in class AbstractVarModelcodeText - the actual codecodeType - the type of codetemplate - the template to create the code forlineNumber - the line number of the statement
public static java.util.Vector createSubscriptExprVector(java.lang.String subscriptString,
ActivationRecord activationRecord)
subscriptString - the string of subscriptsactivationRecord - the activation record for the current scope
public void explainProcess(RunEnv runEnv,
Behavior behavior,
java.lang.String statement,
int event,
int lineNumber)
explainProcess in class AbstractVarModelrunEnv - The run time environmentbehavior - The current behaviorstatement - The statement to executeevent - The event of execution (ex. initialization, assignment, referencing,...)lineNumber - The line number of the statement
public void explainObject(StackModel stack,
HeapModel heap,
Behavior behavior,
java.lang.String statement,
int event,
int lineNumber,
boolean abbreviated)
explainObject in class AbstractVarModelstack - the runtime stackheap - the runtime heapbehavior - the current behaviorstatement - the statementevent - the execution eventlineNumber - the line number of the statementabbreviated - switch for abreviated explanations
public static java.lang.String getLHSSubscripts(java.lang.String statement,
int startPosition)
statement - The assignment statementstartPosition - The index to begin searching from
public void print()
print in class AbstractVarModelpublic java.lang.String printArrayElements(java.lang.String elementDelimiter)
elementDelimiter - the string to put between elements
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String printArrayTable()
public static java.util.Vector getAskAndTells(java.lang.String template)
template - the template to search
public static void main(java.lang.String[] args)
args - arguments
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||