|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectSequence
public final class Sequence extends Object implements Serializable, WeightedElement
Immutable.
A sequence of statements. Each element in the sequence represents a particular Statement, like a method call "Foo f = m(i1...iN)" or a declaration "int x = 0".
This class represents only the structure of a well-formed sequence of statements, and does not contain any information about the runtime behavior of the sequence. The class randoop.ExecutableSequence adds functionality that executes the sequence.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
Sequence.RelativeNegativeIndex
|
| Modifier and Type | Field and Description |
|---|---|
BitSet |
activeFlags
|
double |
lastTimeUsed
|
protected int |
savedHashCode
|
SimpleList<Statement> |
statements
|
| Constructor and Description |
|---|
Sequence()
Create a new, empty sequence. |
Sequence(SimpleList<Statement> statements)
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkIndex(int i)
|
void |
clearActiveFlag(int i)
|
void |
clearAllActiveFlags()
|
static Sequence |
concatenate(List<Sequence> sequences)
Create a new sequence that is the concatenation of the given sequences. |
static Sequence |
create(PrimitiveOrStringOrNullDecl info)
Returns a sequence that consists of a single primitive declaration statement (e.g. |
boolean |
equals(Object o)
Two sequences are equal if their statements(+inputs) are element-wise equal. |
Sequence |
extend(StatementKind statement,
List<Variable> inputVariables)
Returns a new sequence that is equivalent to this sequence plus the given statement appended at the end. |
Sequence |
extend(StatementKind statement,
Variable... inputs)
Returns a new sequence that is equivalent to this sequence plus the given statement appended at the end. |
List<Variable> |
getAllVariables()
The values associated with this sequence. |
StatementKind |
getCreatingStatement(Variable value)
The statement that created this value. |
Variable |
getFirstVariableFromLastStatementVariables()
|
List<Variable> |
getInputs(int statementIndex)
The inputs for the ith statement. |
List<Integer> |
getInputsAsAbsoluteIndices(int i)
The inputs for the ith statement, as indices. |
StatementKind |
getLastStatement()
The last Statement in the sequence. |
List<Class<?>> |
getLastStatementTypes()
The types of all the variables involved in the last statement. |
List<Variable> |
getLastStatementVariables()
The variables involved in the last statement. |
Variable |
getLastVariable()
The value created by the last statement in the sequence. |
int |
getNetSize()
|
static Sequence.RelativeNegativeIndex |
getRelativeIndexForVariable(int statementPosition,
Variable v)
Returns the relative negative index that would result if we use the given value as an input to the statement at position statementPosition. |
StatementKind |
getStatementKind(int index)
The statement for the statement at the given index. |
protected Statement |
getStatementWithInputs(int index)
The statement(+inputs) at the given index. |
Variable |
getVariable(int i)
The value created by the ith statement. |
Variable |
getVariableForInput(int statementPosition,
Sequence.RelativeNegativeIndex input)
Returns the Variable corresponding to the given input, which is an input to the statement at position statementPosition. |
List<Variable> |
getVariablesOfType(Class<?> clazz,
Reflection.Match match)
All the variables declared in this sequences whose type matches the given class. |
double |
getWeight()
|
boolean |
hasActiveFlags()
|
int |
hashCode()
|
boolean |
isActive(int i)
|
boolean |
isOwnerOf(Variable v)
|
boolean |
isPrimitive()
A sequence representing a single primitive values, like "Foo var0 = null" or "int var0 = 1". |
int |
lastUseBefore(int idx,
Variable var)
|
static Sequence |
parse(List<String> statements)
Parse a sequence encoded as a list of strings, each string corresponding to one statement. |
static Sequence |
parse(String string)
Parse a sequence encoded as a strings. |
void |
printStatement(StringBuilder b,
int index)
|
Variable |
randomVariableForType(Class<?> t,
Reflection.Match match)
|
Variable |
randomVariableForTypeLastStatement(Class<?> t,
Reflection.Match match)
|
Variable |
randomVariableOfTypeLastStatement(Class<?> clazz,
Reflection.Match match)
A value declared in this sequence whose type matches the given class. |
static void |
readTextSequences(String file,
Collection<Sequence> collection)
Reads a file containing a collection of sequences in textual representation. |
Sequence |
repeatLast(int times)
|
void |
setActiveFlag(int i)
|
void |
setAllActiveFlags()
|
int |
size()
The number of statements in the sequence. |
String |
toCodeString()
A Java source code representation of this sequence. |
MSequence |
toModifiableSequence()
|
String |
toParseableString()
Returns a string representing this sequence. |
String |
toParseableString(String statementSep)
Like toParseableString, but the client can specify a string that will be used a separator between statements. |
String |
toString()
Equivalent to toParseableString(). |
List<Variable> |
valuesAppearingInLastStatement(Class<?> clazz,
Reflection.Match match)
All the values declared in this sequences whose type matches the given class. |
static Sequence |
zero(Class<?> c)
Returns a sequence that is of the form "Foo f = null;" where Foo is the given class. |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public double lastTimeUsed
public final SimpleList<Statement> statements
public BitSet activeFlags
protected final int savedHashCode
| Constructor Detail |
|---|
public Sequence()
public Sequence(SimpleList<Statement> statements)
| Method Detail |
|---|
public double getWeight()
getWeight in interface WeightedElementpublic final StatementKind getStatementKind(int index)
public final int size()
public Variable getVariable(int i)
public List<Variable> getAllVariables()
public List<Variable> getLastStatementVariables()
public List<Class<?>> getLastStatementTypes()
public Variable getLastVariable()
public StatementKind getLastStatement()
public StatementKind getCreatingStatement(Variable value)
public List<Variable> getInputs(int statementIndex)
public String toCodeString()
public String toString()
toString in class Objectpublic boolean hasActiveFlags()
public boolean isActive(int i)
public void setAllActiveFlags()
public void clearAllActiveFlags()
public void setActiveFlag(int i)
public void clearActiveFlag(int i)
public static Sequence.RelativeNegativeIndex getRelativeIndexForVariable(int statementPosition,
Variable v)
public Variable getVariableForInput(int statementPosition,
Sequence.RelativeNegativeIndex input)
public static Sequence create(PrimitiveOrStringOrNullDecl info)
public static Sequence zero(Class<?> c)
public final boolean equals(Object o)
equals in class Objectpublic final int getNetSize()
public final int hashCode()
hashCode in class Objectprotected final Statement getStatementWithInputs(int index)
public Variable randomVariableForTypeLastStatement(Class<?> t,
Reflection.Match match)
public Variable randomVariableForType(Class<?> t,
Reflection.Match match)
public final Variable randomVariableOfTypeLastStatement(Class<?> clazz,
Reflection.Match match)
public final List<Variable> valuesAppearingInLastStatement(Class<?> clazz,
Reflection.Match match)
public List<Variable> getVariablesOfType(Class<?> clazz,
Reflection.Match match)
protected void checkIndex(int i)
public final Sequence extend(StatementKind statement,
List<Variable> inputVariables)
public final Sequence extend(StatementKind statement,
Variable... inputs)
public static Sequence concatenate(List<Sequence> sequences)
public Variable getFirstVariableFromLastStatementVariables()
public List<Integer> getInputsAsAbsoluteIndices(int i)
public void printStatement(StringBuilder b,
int index)
public Sequence repeatLast(int times)
public MSequence toModifiableSequence()
public boolean isOwnerOf(Variable v)
public String toParseableString()
st.equals(parse(st.toParseableCode()))See the
parse for the
required format of a String representing a Sequence.
public String toParseableString(String statementSep)
public static Sequence parse(List<String> statements)
throws SequenceParseException
SequenceParseException
public static Sequence parse(String string)
throws SequenceParseException
SequenceParseException
public static void readTextSequences(String file,
Collection<Sequence> collection)
public int lastUseBefore(int idx,
Variable var)
public boolean isPrimitive()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||