randoop
Class ComponentManager

Object
  extended by ComponentManager

public class ComponentManager
extends Object

Stores and provides means to access the component sequences generated during a run of Randoop. "Component sequences" are sequences that Randoop uses to create larger sequences. This class manages different collections of component sequences:

SEED SEQUENCES. Seed sequences are sequences that were not created during the generation process but obtained via other means. They include (1) sequences passed via the constructor, (2) class literals, and (3) package literals. The only different treatment of seed sequences is during calls to the clearGeneratedSequences() method, which removes only general, non-seed components from the collection.


Constructor Summary
Constructor and Description
ComponentManager()
          Create an empty component manager, with an empty seed sequence set.
ComponentManager(Collection<Sequence> generalSeeds)
          Create a component manager, initially populated with the given sequences, which are considered seed sequences.
 
Method Summary
Modifier and Type Method and Description
 void addClassLevelLiteral(Class<?> cls, Sequence seq)
          Add a sequence representing a literal value that can be used when testing members of the given class.
 void addGeneratedSequence(Sequence sequence)
          Add a component sequence.
 void addPackageLevelLiteral(Package pkg, Sequence seq)
          Add a sequence representing a literal value that can be used when testing classes in the given package.
 void clearGeneratedSequences()
          Removes any components sequences added so far, except for seed sequences, which are preserved.
 Set<Sequence> getAllGeneratedSequences()
           
 Set<Sequence> getAllPrimitiveSequences()
          Returns all sequences that represent primitive values (e.g.
 SimpleList<Sequence> getSequencesForType(Class<?> cls, boolean exactMatch)
          Returns all the general component sequences that create values of the given class.
 SimpleList<Sequence> getSequencesForType(StatementKind statement, int i)
          Returns component sequences that create values of the type required by the i-th input value of the given statement.
 int numGeneratedSequences()
          Returns the number of (non-seed) sequences stored by the manager.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentManager

public ComponentManager()
Create an empty component manager, with an empty seed sequence set.


ComponentManager

public ComponentManager(Collection<Sequence> generalSeeds)
Create a component manager, initially populated with the given sequences, which are considered seed sequences.

Parameters:
generalSeeds - seed sequences. Can be null, in which case the seed sequences set is considered empty.
Method Detail

numGeneratedSequences

public int numGeneratedSequences()
Returns the number of (non-seed) sequences stored by the manager.


addClassLevelLiteral

public void addClassLevelLiteral(Class<?> cls,
                                 Sequence seq)
Add a sequence representing a literal value that can be used when testing members of the given class.


addPackageLevelLiteral

public void addPackageLevelLiteral(Package pkg,
                                   Sequence seq)
Add a sequence representing a literal value that can be used when testing classes in the given package.


addGeneratedSequence

public void addGeneratedSequence(Sequence sequence)
Add a component sequence.


clearGeneratedSequences

public void clearGeneratedSequences()
Removes any components sequences added so far, except for seed sequences, which are preserved.


getAllGeneratedSequences

public Set<Sequence> getAllGeneratedSequences()

getSequencesForType

public SimpleList<Sequence> getSequencesForType(Class<?> cls,
                                                boolean exactMatch)
Returns all the general component sequences that create values of the given class. If exactMatch==true returns only sequences that declare values of the exact class specified; if exactMatch==false returns sequences declaring values of cls or any other class that can be used as a cls (i.e. a subclass of cls).


getSequencesForType

public SimpleList<Sequence> getSequencesForType(StatementKind statement,
                                                int i)
Returns component sequences that create values of the type required by the i-th input value of the given statement. Any applicable class- or package-level literals, those are added to the collection as well.


getAllPrimitiveSequences

public Set<Sequence> getAllPrimitiveSequences()
Returns all sequences that represent primitive values (e.g. sequences like "Foo var0 = null" or "int var0 = 1"), including general components, class literals and package literals.