org.acm.seguin.refactor
Class Refactoring

java.lang.Object
  extended by org.acm.seguin.refactor.Refactoring
Direct Known Subclasses:
AddClassRefactoring, ExtractInterfaceRefactoring, ExtractMethodRefactoring, MoveClass, MoveMethodRefactoring, PushDownFieldRefactoring, PushDownMethodRefactoring, PushUpFieldRefactoring, PushUpMethodRefactoring, RemoveEmptyClassRefactoring, RenameClassRefactoring, RenameFieldRefactoring, RenameMethodRefactoring, RenameParameterRefactoring

public abstract class Refactoring
extends java.lang.Object

Adds a class that is either a parent or a child of an existing class.

Author:
Chris Seguin

Field Summary
static int ADD_CHILD
          The add child refactoring
static int ADD_PARENT
          The add parent refactoring
static int EXTRACT_INTERFACE
          Extracts the interface
static int EXTRACT_METHOD
          Extracts code from one method to create a new method
static int MOVE_METHOD
          Moves the method into another class
static int PUSH_DOWN_FIELD
          Pushes the field into the parent class
static int PUSH_DOWN_METHOD
          Pushes the method into the child classes
static int PUSH_UP_ABSTRACT_METHOD
          Pushes the method signature into the parent class
static int PUSH_UP_FIELD
          Pushes the field into the child classes
static int PUSH_UP_METHOD
          Pushes the method into the parent class
static int REMOVE_CLASS
          The remove class refactoring
static int RENAME_CLASS
          The rename class refactoring
static int RENAME_FIELD
          Renames the field
static int RENAME_METHOD
          Extracts code from one method to create a new method
static int RENAME_PARAMETER
          Renames a parameter
static int REPACKAGE
          The repackage refactoring
 
Constructor Summary
Refactoring()
          Constructor for the Refactoring object
 
Method Summary
protected  void checkDestinationFile(Summary loop, java.lang.String message)
          Check that we are allowed to adjust the destination
protected  ComplexTransform getComplexTransform()
          Gets a complex transform object for this refactoring
abstract  java.lang.String getDescription()
          Gets the description of the refactoring
abstract  int getID()
          Gets the id for this refactoring to track which refactorings are used.
protected abstract  void preconditions()
          Describes the preconditions that must be true for this refactoring to be applied
 void run()
          Main program that performst the transformation
static void setComplexTransform(java.lang.Class complexTransform)
          This sets the class that does complex transforms.
protected abstract  void transform()
          Performs the transform on the rest of the classes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPACKAGE

public static final int REPACKAGE
The repackage refactoring

See Also:
Constant Field Values

RENAME_CLASS

public static final int RENAME_CLASS
The rename class refactoring

See Also:
Constant Field Values

ADD_CHILD

public static final int ADD_CHILD
The add child refactoring

See Also:
Constant Field Values

ADD_PARENT

public static final int ADD_PARENT
The add parent refactoring

See Also:
Constant Field Values

REMOVE_CLASS

public static final int REMOVE_CLASS
The remove class refactoring

See Also:
Constant Field Values

EXTRACT_INTERFACE

public static final int EXTRACT_INTERFACE
Extracts the interface

See Also:
Constant Field Values

PUSH_DOWN_FIELD

public static final int PUSH_DOWN_FIELD
Pushes the field into the parent class

See Also:
Constant Field Values

PUSH_UP_FIELD

public static final int PUSH_UP_FIELD
Pushes the field into the child classes

See Also:
Constant Field Values

RENAME_FIELD

public static final int RENAME_FIELD
Renames the field

See Also:
Constant Field Values

PUSH_UP_METHOD

public static final int PUSH_UP_METHOD
Pushes the method into the parent class

See Also:
Constant Field Values

PUSH_UP_ABSTRACT_METHOD

public static final int PUSH_UP_ABSTRACT_METHOD
Pushes the method signature into the parent class

See Also:
Constant Field Values

PUSH_DOWN_METHOD

public static final int PUSH_DOWN_METHOD
Pushes the method into the child classes

See Also:
Constant Field Values

MOVE_METHOD

public static final int MOVE_METHOD
Moves the method into another class

See Also:
Constant Field Values

EXTRACT_METHOD

public static final int EXTRACT_METHOD
Extracts code from one method to create a new method

See Also:
Constant Field Values

RENAME_METHOD

public static final int RENAME_METHOD
Extracts code from one method to create a new method

See Also:
Constant Field Values

RENAME_PARAMETER

public static final int RENAME_PARAMETER
Renames a parameter

See Also:
Constant Field Values
Constructor Detail

Refactoring

public Refactoring()
Constructor for the Refactoring object

Method Detail

getDescription

public abstract java.lang.String getDescription()
Gets the description of the refactoring

Returns:
the description

getID

public abstract int getID()
Gets the id for this refactoring to track which refactorings are used.

Returns:
the id

run

public void run()
         throws RefactoringException
Main program that performst the transformation

Throws:
RefactoringException - Description of Exception

setComplexTransform

public static void setComplexTransform(java.lang.Class complexTransform)
                                throws java.lang.IllegalArgumentException
This sets the class that does complex transforms. If not called the org.acm.seguin.refactor.ComplexTransform class is used.

Parameters:
complexTransform - a class that implements org.acm.seguin.refactor.ComplexTransform
Throws:
java.lang.IllegalArgumentException - if the class cannot be instantiated or does not implement ComplexTransform

getComplexTransform

protected ComplexTransform getComplexTransform()
Gets a complex transform object for this refactoring

Returns:
The ComplexTransform value

preconditions

protected abstract void preconditions()
                               throws RefactoringException
Describes the preconditions that must be true for this refactoring to be applied

Throws:
RefactoringException - thrown if one or more of the preconditions is not satisfied. The text of the exception provides a hint of what went wrong.

transform

protected abstract void transform()
Performs the transform on the rest of the classes


checkDestinationFile

protected void checkDestinationFile(Summary loop,
                                    java.lang.String message)
                             throws RefactoringException
Check that we are allowed to adjust the destination

Parameters:
loop - the summary
message - the message
Throws:
RefactoringException - problem report