sofya.mutator
Class MutationGroup

java.lang.Object
  extended by sofya.mutator.MutationGroup
All Implemented Interfaces:
Mutation

public class MutationGroup
extends java.lang.Object
implements Mutation

A group of related mutations that can be applied together.

A mutation group also has an associated ID. When selecting mutations by ID, mutations in a mutation group can only be selected if the ID of the mutation group is also selected. However, selecting a mutation group does not automatically cause all member mutations to be selected (mutations in the group can be selectively applied).

Version:
05/12/2006
Author:
Alex Kinneer

Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.mutator.Mutation
Mutation.Variant
 
Constructor Summary
MutationGroup(java.lang.String className)
          Creates a new mutation group for mutations that apply to a given class.
MutationGroup(java.lang.String className, java.lang.String methodName, java.lang.String signature)
          Creates a new mutation group for mutations that apply to a given method in a class.
 
Method Summary
 void accept(MutationVisitor visitor)
          Accepts a mutation visitor to perform some operation using this mutation.
 void addMutation(GroupableMutation mutation)
          Adds a mutation to this mutation group.
 void apply(org.apache.bcel.generic.ClassGen cg, Mutation.Variant variant)
          The mutations contained in this group can be selected and applied individually, therefore this method does nothing.
static MutationGroup deserialize(java.io.DataInput in)
           
 java.lang.String getClassName()
          Gets the class name to which the contained mutants apply.
 Mutation.Variant getDefaultVariant()
          Gets the default variant selected by the mutation generator when the mutation table was generated.
 MutationID getID()
          Gets the ID associated with this mutation.
 java.lang.String getMethodName()
          Gets the method name to which the contained mutants apply.
 java.lang.String getSignature()
          Gets the signature of the method to which the contained mutants apply.
 java.lang.String getType()
          Gets the type string associated with a mutation group.
 Mutation.Variant[] getVariants()
          Gets all of the possible variants of this mutation.
 java.util.Iterator iterator()
          Returns an iterator over the mutations in this group.
 java.lang.String print()
          Prints this mutation in a format suitable for display.
 void serialize(java.io.DataOutput out)
          Serializes this mutation.
 void setID(MutationID id)
          Sets the ID associated with this mutation.
 int size()
          Gets the number of mutations in this group.
 java.lang.String toString()
           
 void undo(org.apache.bcel.generic.ClassGen cg)
          The mutations contained in this group can be selected and applied individually, therefore this method does nothing.
 void visitMembers(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutationGroup

public MutationGroup(java.lang.String className)
Creates a new mutation group for mutations that apply to a given class.

Parameters:
className - Name of the class to which the contained mutants will apply.

MutationGroup

public MutationGroup(java.lang.String className,
                     java.lang.String methodName,
                     java.lang.String signature)
Creates a new mutation group for mutations that apply to a given method in a class.

Parameters:
className - Name of the class to which the contained mutants will apply.
methodName - Name of the method to which the contained mutants will apply.
signature - Signature of the method to which the contained mutants will apply.
Method Detail

addMutation

public void addMutation(GroupableMutation mutation)
Adds a mutation to this mutation group.

Parameters:
mutation - Mutation to be added to this group.

getClassName

public java.lang.String getClassName()
Gets the class name to which the contained mutants apply.

Returns:
The name of the class to which the mutations in this group are applied.

getMethodName

public java.lang.String getMethodName()
Gets the method name to which the contained mutants apply.

Returns:
The name of the method to which the mutations in this group are applied.

getSignature

public java.lang.String getSignature()
Gets the signature of the method to which the contained mutants apply.

Returns:
The signature of the method to which the mutations in this group are applied.

size

public int size()
Gets the number of mutations in this group.

Returns:
The number of mutation in this group.

iterator

public java.util.Iterator iterator()
Returns an iterator over the mutations in this group.

Returns:
An iterator over the mutations in this group.

getType

public java.lang.String getType()
Gets the type string associated with a mutation group.

Specified by:
getType in interface Mutation
Returns:
The string "group".

getID

public MutationID getID()
Description copied from interface: Mutation
Gets the ID associated with this mutation.

Mutation IDs are automatically assigned and managed by the framework.

Specified by:
getID in interface Mutation
Returns:
The ID of this mutation.

setID

public void setID(MutationID id)
Description copied from interface: Mutation
Sets the ID associated with this mutation.

This method is called automatically by the framework, and should not be called anywhere else.

Specified by:
setID in interface Mutation
Parameters:
id - ID to be assigned to this mutation.

visitMembers

public void visitMembers(boolean b)

accept

public void accept(MutationVisitor visitor)
            throws MutationException
Description copied from interface: Mutation
Accepts a mutation visitor to perform some operation using this mutation.

Specified by:
accept in interface Mutation
Parameters:
visitor - Mutation visitor that is visiting this mutation.
Throws:
MutationException - If an action performed on this mutation by the visitor fails (this permits the exception to propagate).

getDefaultVariant

public Mutation.Variant getDefaultVariant()
Description copied from interface: Mutation
Gets the default variant selected by the mutation generator when the mutation table was generated.

A default variant ensures that a mutation can be applied without requiring user intervention. The policy for selecting an initial default is determined by the generating mutation operator, and is typically random.

Specified by:
getDefaultVariant in interface Mutation
Returns:
A variant of this mutation selected during mutation table generation. Mutations that do not support variants may return null from this method.

getVariants

public Mutation.Variant[] getVariants()
Description copied from interface: Mutation
Gets all of the possible variants of this mutation.

A variant is one of set of mutually exclusive mutations that can be applied at the same code location. The simplest example of this is an operator mutation, where mutliple alternate operators can be substituted to produce a mutant.

Specified by:
getVariants in interface Mutation
Returns:
An array of the possible variants of this mutation.

apply

public void apply(org.apache.bcel.generic.ClassGen cg,
                  Mutation.Variant variant)
           throws MutationException
The mutations contained in this group can be selected and applied individually, therefore this method does nothing.

Specified by:
apply in interface Mutation
Parameters:
cg - BCEL classfile object for the class being mutated.
variant - Variant of the mutation to be applied.
Throws:
MutationException - Never.

undo

public void undo(org.apache.bcel.generic.ClassGen cg)
The mutations contained in this group can be selected and applied individually, therefore this method does nothing.

Specified by:
undo in interface Mutation
Parameters:
cg - BCEL classfile object for the class being mutated.

serialize

public void serialize(java.io.DataOutput out)
               throws java.io.IOException
Description copied from interface: Mutation
Serializes this mutation.

A mutation class should also provide a static method named deserialize that takes a single parameter of type DataInput and returns a Mutation. This method is used by the framework to provide transparent automatic support for new mutation operators, though it cannot be enforced by the interface due to the need for a static method.

Specified by:
serialize in interface Mutation
Parameters:
out - Data output sink to which the mutation should be serialized.
Throws:
java.io.IOException - If serialization of this mutation fails for any I/O related reason.

deserialize

public static MutationGroup deserialize(java.io.DataInput in)
                                 throws java.io.IOException
Throws:
java.io.IOException

print

public java.lang.String print()
Description copied from interface: Mutation
Prints this mutation in a format suitable for display.

Specified by:
print in interface Mutation
Returns:
A string giving information about the mutation in a format suitable for display.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object