randoop
Class ArrayDeclaration

Object
  extended by ArrayDeclaration
All Implemented Interfaces:
Serializable, StatementKind

public final class ArrayDeclaration
extends Object
implements StatementKind, Serializable

Immutable. Represents a one-dimensional array creation statement, e.g. "int[] x = new int[2] { 3, 7 };"

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
static String ID
          ID for parsing purposes (see StatementKinds.parse method)
 
Constructor Summary
Constructor and Description
ArrayDeclaration(Class<?> elementType, int length)
           
 
Method Summary
Modifier and Type Method and Description
 void appendCode(Variable newVar, List<Variable> inputVars, StringBuilder b)
          Appends string representation of ArrayDeclarationInfo into b.
 boolean equals(Object o)
           
 ExecutionOutcome execute(Object[] statementInput, PrintStream out)
          Executes this statement, given the inputs to the statement.
 Class<?> getElementType()
          Returns the class of type of elements held in this ArrayDeclarationInfo
 List<Class<?>> getInputTypes()
          Extracts the input constraints for this ArrayDeclarationInfo
 Class<?> getOutputType()
          Returns constraint to represent new reference to this statement, namely the receiver that is generated.
 int hashCode()
           
static StatementKind parse(String str)
          A string representing this array declaration.
 String toParseableString()
          Returns a string representation of this StatementKind, which can subsequently be used in this class's parse method.
 String toString()
           
 String toStringShort()
           
 String toStringVerbose()
           
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
ID for parsing purposes (see StatementKinds.parse method)

See Also:
Constant Field Values
Constructor Detail

ArrayDeclaration

public ArrayDeclaration(Class<?> elementType,
                        int length)
Parameters:
elementType - type of objects in the array
length - number of objects allowed in the array
Method Detail

getElementType

public Class<?> getElementType()
Returns the class of type of elements held in this ArrayDeclarationInfo


getInputTypes

public List<Class<?>> getInputTypes()
Extracts the input constraints for this ArrayDeclarationInfo

Specified by:
getInputTypes in interface StatementKind
Returns:
list of input constraints

execute

public ExecutionOutcome execute(Object[] statementInput,
                                PrintStream out)
Executes this statement, given the inputs to the statement. Returns the results of execution as an ResultOrException object and can output results to specified PrintStream.

Specified by:
execute in interface StatementKind
Parameters:
statementInput - array containing appropriate inputs to statement
out - stream to output results of execution; can be null if you don't want to print.
Returns:
results of executing this statement

toString

public String toString()
Overrides:
toString in class Object

toStringShort

public String toStringShort()

toStringVerbose

public String toStringVerbose()

getOutputType

public Class<?> getOutputType()
Returns constraint to represent new reference to this statement, namely the receiver that is generated.

Specified by:
getOutputType in interface StatementKind

appendCode

public void appendCode(Variable newVar,
                       List<Variable> inputVars,
                       StringBuilder b)
Appends string representation of ArrayDeclarationInfo into b.

Specified by:
appendCode in interface StatementKind

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toParseableString

public String toParseableString()
Description copied from interface: StatementKind
Returns a string representation of this StatementKind, which can subsequently be used in this class's parse method. For a class C implementing the StatementKind interface, this method should return a String s such that parsing the string returns an object equivalent to this object, i.e. C.parse(this.s).equals(this).

Specified by:
toParseableString in interface StatementKind

parse

public static StatementKind parse(String str)
A string representing this array declaration. The string is of the form: TYPE[NUMELEMS] Where TYPE is the type of the array, and NUMELEMS is the number of elements. Example: int[3]