Class ClassFileWorkingCopy

All Implemented Interfaces:
IBufferChangedListener, ICodeAssist, ICompilationUnit, IJavaElement, IOpenable, IParent, ISourceManipulation, ISourceReference, ITypeRoot, IWorkingCopy, ICompilationUnit, IDependent, SuffixConstants, org.eclipse.core.runtime.IAdaptable

public class ClassFileWorkingCopy extends CompilationUnit
A working copy on an IClassFile.
  • Field Details

  • Constructor Details

  • Method Details

    • commitWorkingCopy

      public void commitWorkingCopy(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Description copied from interface: ICompilationUnit
      Commits the contents of this working copy to its underlying resource.

      It is possible that the contents of the original resource have changed since this working copy was created, in which case there is an update conflict. The value of the force parameter affects the resolution of such a conflict:

      • true - in this case the contents of this working copy are applied to the underlying resource even though this working copy was created before a subsequent change in the resource
      • false - in this case a JavaModelException is thrown

      Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.

      Specified by:
      commitWorkingCopy in interface ICompilationUnit
      Overrides:
      commitWorkingCopy in class CompilationUnit
      Parameters:
      force - a flag to handle the cases when the contents of the original resource have changed since this working copy was created
      monitor - the given progress monitor
      Throws:
      JavaModelException - if this working copy could not commit. Reasons include:
      • A CoreException occurred while updating an underlying resource
      • This element is not a working copy (INVALID_ELEMENT_TYPES)
      • A update conflict (described above) (UPDATE_CONFLICT)
      See Also:
      ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
    • getBuffer

      public IBuffer getBuffer() throws JavaModelException
      Description copied from class: Openable
      Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time. If this is the first time a request is being made for the buffer, an attempt is made to create and fill this element's buffer. If the buffer has been closed since it was first opened, the buffer is re-created.
      Specified by:
      getBuffer in interface IOpenable
      Overrides:
      getBuffer in class Openable
      Returns:
      the buffer opened for this element, or null if this element does not have a buffer
      Throws:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      See Also:
      IOpenable
    • getContents

      public char[] getContents()
      Description copied from interface: ICompilationUnit
      Answer the contents of the compilation unit. In normal use, the contents are requested twice. Once during the initial lite parsing step, then again for the more detailed parsing step. Implementors must never return null - return an empty char[] instead, CharOperation.NO_CHAR being the candidate of choice.
      Specified by:
      getContents in interface ICompilationUnit
      Overrides:
      getContents in class CompilationUnit
      See Also:
      ICompilationUnit.getContents()
    • getPath

      public org.eclipse.core.runtime.IPath getPath()
      Description copied from interface: IJavaElement
      Returns the path to the innermost resource enclosing this element. If this element is not included in an external library, the path returned is the full, absolute path to the underlying resource, relative to the workbench. If this element is included in an external library, the path returned is the absolute path to the archive or to the folder in the file system. This is a handle-only method.
      Specified by:
      getPath in interface IJavaElement
      Overrides:
      getPath in class CompilationUnit
      Returns:
      the path to the innermost resource enclosing this element
      See Also:
      IJavaElement.getPath()
    • getPrimaryElement

      public JavaElement getPrimaryElement(boolean checkOwner)
      Overrides:
      getPrimaryElement in class CompilationUnit
    • resource

      public org.eclipse.core.resources.IResource resource(PackageFragmentRoot root)
      Overrides:
      resource in class CompilationUnit
    • openBuffer

      protected IBuffer openBuffer(org.eclipse.core.runtime.IProgressMonitor pm, Object info) throws JavaModelException
      Description copied from class: Openable
      Opens a buffer on the contents of this element, and returns the buffer, or returns null if opening fails. By default, do nothing - subclasses that have buffers must override as required.
      Overrides:
      openBuffer in class CompilationUnit
      Throws:
      JavaModelException
      See Also:
      Openable.openBuffer(IProgressMonitor, Object)
    • toStringName

      protected void toStringName(StringBuffer buffer)
      Description copied from class: JavaElement
      Debugging purposes
      Overrides:
      toStringName in class JavaElement