Package randoop.operation
Class InitializedArrayCreation
java.lang.Object
randoop.operation.CallableOperation
randoop.operation.InitializedArrayCreation
- All Implemented Interfaces:
Operation
InitializedArrayCreation is an
with the initializer list as inputs.
Operation
representing the construction of a
one-dimensional array with a given element type and length. The InitializedArrayCreation
operation requires a list of elements in an initializer. For instance, new int[2]
is the
InitializedArrayCreation
in the initializationint[] x = new int[2] { 3, 7 };
with the initializer list as inputs.
In terms of the notation used for the Operation
class, a creation of an array of
elements of type e with length n has a signature [ e,...,e] → t,
where [e,...,e] is a list of length n, and t is the array type.
InitializedArrayCreation objects are immutable.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInitializedArrayCreation
(ArrayType arrayType, int length) Creates an object representing the construction of an array that holds values of the element type and has the given length. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendCode
(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Produces a Java source code representation of this statement and appends it to the given StringBuilder.boolean
Performs this operation using the array of input values.int
Returns the length of created array.getName()
Returns the name for the operation.int
hashCode()
static TypedOperation
Parses an array declaration in a string descriptor in the form generated bytoParsableString(Type, TypeTuple, Type)
.toParsableString
(Type declaringType, TypeTuple inputTypes, Type outputType) Returns a string representation of this Operation, which can be read by static parse method for class.toString()
Methods inherited from class randoop.operation.CallableOperation
getArgumentString, getReflectionObject, getValue, isConstantField, isConstructorCall, isMessage, isMethodCall, isNonreceivingValue, isStatic, isUncheckedCast, satisfies
-
Field Details
-
length
private final int length -
elementType
-
-
Constructor Details
-
InitializedArrayCreation
InitializedArrayCreation(ArrayType arrayType, int length) Creates an object representing the construction of an array that holds values of the element type and has the given length.- Parameters:
length
- number of objects allowed in the arrayarrayType
- the type of array this operation creates
-
-
Method Details
-
getLength
public int getLength()Returns the length of created array.- Returns:
- length of array created by this object
-
execute
Performs this operation using the array of input values. Returns the results of execution as an ResultOrException object and can output results to specified PrintStream.- Specified by:
execute
in classCallableOperation
- Parameters:
statementInput
- array containing appropriate inputs to operation- Returns:
NormalExecution
object containing constructed array
-
toString
-
appendCode
public void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Produces a Java source code representation of this statement and appends it to the given StringBuilder.- Specified by:
appendCode
in classCallableOperation
- Parameters:
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operationinputVars
- the list of variables that are inputs to operationb
- theStringBuilder
to which code is added
-
hashCode
public int hashCode() -
equals
-
toParsableString
Returns a string representation of this Operation, which can be read by static parse method for class. For a class C implementing the Operation 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).Creates string of the form TYPE[NUMELEMS] where TYPE is the type of the array, and NUMELEMS is the number of elements.
Example: int[3]
- Specified by:
toParsableString
in classCallableOperation
- Parameters:
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operation- Returns:
- string descriptor for array creation
-
getName
Description copied from interface:Operation
Returns the name for the operation.- Returns:
- the name for this operation
-
parse
Parses an array declaration in a string descriptor in the form generated bytoParsableString(Type, TypeTuple, Type)
.- Parameters:
str
- the string to be parsed for theInitializedArrayCreation
- Returns:
- the array creation for the given string descriptor
- Throws:
OperationParseException
- if string does not have expected form- See Also:
-