Composite Refactoring
v1.0

compositeRefactoring.codemanipulation
Class Inherit

java.lang.Object
  |
  +--org.eclipse.jdt.internal.core.JavaModelOperation
        |
        +--compositeRefactoring.codemanipulation.Inherit
All Implemented Interfaces:
IProgressMonitor, IWorkspaceRunnable

public class Inherit
extends JavaModelOperation

This class creates an inheritence dependency between two classes. To determine whether one class may inherit from another, some conditions can be checked in this class according to Lance Tokuda (Univeristy of Texas at Austin)


Fields inherited from class org.eclipse.jdt.internal.core.JavaModelOperation
fDeltas, fElementsToProcess, fForce, fgEmptyResult, fMonitor, fNested, fParentElements, fResultElements, hasModifiedResource
 
Fields inherited from interface org.eclipse.core.runtime.IProgressMonitor
UNKNOWN
 
Constructor Summary
Inherit(ICompilationUnit base, ICompilationUnit derived)
          creates an Inherit object.
 
Method Summary
 RefactoringStatus checkAbstractMethods()
          checks if all abstract methods from Derived are implemented in Base.
 RefactoringStatus checkBaseSuperclass()
          checks if Base already has a superclass.
 RefactoringStatus checkCycle()
          checks if Base is superclass of Derived.
 void executeOperation()
          executes the inherit operation.
 void executeUndoOperation()
          executes the undo operation.
 ICompilationUnit getBase()
          getter method for the modified language element, the base class.
 ICompilationUnit getDerived()
          getter method for the superclass, the derived class.
 
Methods inherited from class org.eclipse.jdt.internal.core.JavaModelOperation
addDelta, beginTask, checkCanceled, commonVerify, copyResources, createFile, createFolder, deleteEmptyPackageFragment, deleteResource, deleteResources, done, execute, executeNestedOperation, getCompilationUnitFor, getElementsToProcess, getElementToProcess, getJavaModel, getParentElement, getParentElements, getResultElements, getSubProgressMonitor, getWorkspace, hasModifiedResource, internalWorked, isCanceled, isReadOnly, makeWorkingCopiesConsistent, moveResources, newJavaElementDelta, registerDeltas, run, setCanceled, setNested, setTaskName, subTask, verify, walkDeltaMakingWorkingCopiesConsistent, worked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Inherit

public Inherit(ICompilationUnit base,
               ICompilationUnit derived)
creates an Inherit object.
Parameters:
base - the subclass in the inheritence dependency
derived - the superclass in the inheritence dependency
Method Detail

checkCycle

public RefactoringStatus checkCycle()
checks if Base is superclass of Derived. It also determines if Base and Derived are the same classes.
Returns:
true if Base is no superclass of Derived, false otherwise.

checkBaseSuperclass

public RefactoringStatus checkBaseSuperclass()
checks if Base already has a superclass.
Returns:
true if Base inherits from java.lang.Object, false otherwise.

checkAbstractMethods

public RefactoringStatus checkAbstractMethods()
checks if all abstract methods from Derived are implemented in Base.
Returns:
true if all abstract methods are implemented, false otherwise.

executeOperation

public void executeOperation()
                      throws JavaModelException
executes the inherit operation.
Overrides:
executeOperation in class JavaModelOperation

executeUndoOperation

public void executeUndoOperation()
                          throws JavaModelException
executes the undo operation. It can only be executed after running the executeOperation() method on this object. Otherwise it would not make much sense.

getBase

public ICompilationUnit getBase()
getter method for the modified language element, the base class.
Returns:
the base class

getDerived

public ICompilationUnit getDerived()
getter method for the superclass, the derived class.
Returns:
the derived class.

Composite Refactoring
v1.0