org.aspectj.org.eclipse.jdt.internal.core
Class CreateCompilationUnitOperation

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
      extended by org.aspectj.org.eclipse.jdt.internal.core.CreateCompilationUnitOperation

public class CreateCompilationUnitOperation
extends JavaModelOperation

This operation creates a compilation unit (CU). If the CU doesn't exist yet, a new compilation unit will be created with the content provided. Otherwise the operation will override the contents of an existing CU with the new content.

Note: It is possible to create a CU automatically when creating a class or interface. Thus, the preferred method of creating a CU is to perform a create type operation rather than first creating a CU and secondly creating a type inside the CU.

Required Attributes:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
JavaModelOperation.IPostAction
 
Field Summary
protected  java.lang.String name
          The name of the compilation unit being created.
protected  java.lang.String source
          The source code to use when creating the element.
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
actions, actionsEnd, actionsStart, APPEND, attributes, elementsToProcess, force, HAS_MODIFIED_RESOURCE_ATTR, isNested, KEEP_EXISTING, NO_ELEMENTS, OPERATION_STACKS, parentElements, POST_ACTION_VERBOSE, progressMonitor, REMOVEALL_APPEND, resultElements, TRUE
 
Constructor Summary
CreateCompilationUnitOperation(IPackageFragment parentElement, java.lang.String name, java.lang.String source, boolean force)
          When executed, this operation will create a compilation unit with the given name.
 
Method Summary
protected  void executeOperation()
          Creates a compilation unit.
protected  ICompilationUnit getCompilationUnit()
           
protected  ISchedulingRule getSchedulingRule()
           
 IJavaModelStatus verify()
          Possible failures: NO_ELEMENTS_TO_PROCESS - the package fragment supplied to the operation is null.
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
addAction, addDelta, addReconcileDelta, applyTextEdit, beginTask, canModifyRoots, checkCanceled, commonVerify, copyResources, createFile, createFolder, deleteEmptyPackageFragment, deleteResource, deleteResources, done, equalsOneOf, executeNestedOperation, firstActionWithID, getAttribute, getCompilationUnitFor, getCurrentOperationStack, getDocument, getElementToProcess, getJavaModel, getNestedFolders, getParentElement, getParentElements, getResultElements, getSubProgressMonitor, hasModifiedResource, internalWorked, isCanceled, isReadOnly, isTopLevelOperation, moveResources, newJavaElementDelta, popOperation, postAction, prefixesOneOf, pushOperation, removeAllPostAction, removeReconcileDelta, run, runOperation, runPostActions, setAttribute, setCanceled, setNested, setTaskName, subTask, worked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of the compilation unit being created.


source

protected java.lang.String source
The source code to use when creating the element.

Constructor Detail

CreateCompilationUnitOperation

public CreateCompilationUnitOperation(IPackageFragment parentElement,
                                      java.lang.String name,
                                      java.lang.String source,
                                      boolean force)
When executed, this operation will create a compilation unit with the given name. The name should have the ".java" suffix.

Method Detail

executeOperation

protected void executeOperation()
                         throws JavaModelException
Creates a compilation unit.

Specified by:
executeOperation in class JavaModelOperation
Throws:
JavaModelException - if unable to create the compilation unit.

getCompilationUnit

protected ICompilationUnit getCompilationUnit()
See Also:
CreateElementInCUOperation.getCompilationUnit()

getSchedulingRule

protected ISchedulingRule getSchedulingRule()
Overrides:
getSchedulingRule in class JavaModelOperation

verify

public IJavaModelStatus verify()
Possible failures:

Overrides:
verify in class JavaModelOperation
See Also:
IJavaModelStatus