Composite Refactoring
v1.0

compositeRefactoring.codemanipulation
Class CreateCompilationUnit

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

public class CreateCompilationUnit
extends CreateCompilationUnitOperation

This is a convenience class to make the CreateCompilatioinUnitOperation public. The class creates a compilation unit (which represents a .java file). It can also be used to create a new type by addinf sourcecode to the compilation unit.


Fields inherited from class org.eclipse.jdt.internal.core.CreateCompilationUnitOperation
fName, fSource
 
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
CreateCompilationUnit(IPackageFragment parentElement, String name, String source, boolean force)
          creates a new CreateCompilationUnit object.
 
Method Summary
 void executeOperation()
          creates the compilation unit.
 ICompilationUnit getCompilationUnit()
          getter method for the new created compilation unit
 IJavaModelStatus verify()
          checks whether a new compilation unit can be created.
 
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, walkDeltaMakingWorkingCopiesConsistent, worked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreateCompilationUnit

public CreateCompilationUnit(IPackageFragment parentElement,
                             String name,
                             String source,
                             boolean force)
creates a new CreateCompilationUnit object.
Parameters:
parentElement - the package in which the compilation unit is to be created.
name - the name of the compilation unit
source - the contents of the compilation unit
force - indicates whether an existing compilation unit with the same name shall be overridden.
Method Detail

executeOperation

public void executeOperation()
creates the compilation unit.
Overrides:
executeOperation in class CreateCompilationUnitOperation
Following copied from class: org.eclipse.jdt.internal.core.CreateCompilationUnitOperation
Throws:
JavaModelException - if unable to create the compilation unit.

getCompilationUnit

public ICompilationUnit getCompilationUnit()
getter method for the new created compilation unit
Overrides:
getCompilationUnit in class CreateCompilationUnitOperation
Returns:
the new created compilation unit

verify

public IJavaModelStatus verify()
checks whether a new compilation unit can be created. Possible failures: NOTE: When this method is called, the source of the compilation unit must not be empty!
Overrides:
verify in class CreateCompilationUnitOperation
Following copied from class: org.eclipse.jdt.internal.core.JavaModelOperation
See Also:
IJavaModelStatus

Composite Refactoring
v1.0