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.
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 |
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 unitsource
- the contents of the compilation unitforce
- indicates whether an existing compilation unit with the same name shall be overridden.
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:
- NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is
null
.
- INVALID_NAME - the compilation unit name provided to the operation
is
null
or has an invalid syntax
- INVALID_CONTENTS - the source specified for the compiliation unit is null
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