java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
org.aspectj.org.eclipse.jdt.internal.core.Openable
Alle implementierten Schnittstellen:
IBufferChangedListener, IJavaElement, IOpenable, org.eclipse.core.runtime.IAdaptable
Bekannte direkte Unterklassen:
AbstractClassFile, CompilationUnit, JavaModel, JavaProject, PackageFragment, PackageFragmentRoot

public abstract class Openable extends JavaElement implements IOpenable, IBufferChangedListener
Abstract class for implementations of java elements which are IOpenable.
Siehe auch:
  • Konstruktordetails

  • Methodendetails

    • bufferChanged

      public void bufferChanged(BufferChangedEvent event)
      The buffer associated with this element has changed. Registers this element as being out of synch with its buffer's contents. If the buffer has been closed, this element is set as NOT out of synch with the contents.
      Angegeben von:
      bufferChanged in Schnittstelle IBufferChangedListener
      Parameter:
      event - the change event
      Siehe auch:
    • buildStructure

      protected abstract boolean buildStructure(OpenableElementInfo info, org.eclipse.core.runtime.IProgressMonitor pm, Map newElements, org.eclipse.core.resources.IResource underlyingResource) throws JavaModelException
      Builds this element's structure and properties in the given info object, based on this element's current contents (reuse buffer contents if this element has an open buffer, or resource contents if this element does not have an open buffer). Children are placed in the given newElements table (note, this element has already been placed in the newElements table). Returns true if successful, or false if an error is encountered while determining the structure of this element.
      Löst aus:
      JavaModelException
    • canBeRemovedFromCache

      public boolean canBeRemovedFromCache()
    • canBufferBeRemovedFromCache

      public boolean canBufferBeRemovedFromCache(IBuffer buffer)
    • closeBuffer

      protected void closeBuffer()
      Close the buffer associated with this element, if any.
    • closing

      protected void closing(Object info)
      This element is being closed. Do any necessary cleanup.
      Angegeben von:
      closing in Klasse JavaElement
    • codeComplete

      protected void codeComplete(ICompilationUnit cu, ICompilationUnit unitToSkip, int position, CompletionRequestor requestor, WorkingCopyOwner owner, ITypeRoot typeRoot, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Löst aus:
      JavaModelException
    • codeSelect

      protected IJavaElement[] codeSelect(ICompilationUnit cu, int offset, int length, WorkingCopyOwner owner) throws JavaModelException
      Löst aus:
      JavaModelException
    • createElementInfo

      protected Object createElementInfo()
      Angegeben von:
      createElementInfo in Klasse JavaElement
    • exists

      public boolean exists()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns whether this Java element exists in the model.

      Java elements are handle objects that may or may not be backed by an actual element. Java elements that are backed by an actual element are said to "exist", and this method returns true. For Java elements that are not working copies, it is always the case that if the element exists, then its parent also exists (provided it has one) and includes the element as one of its children. It is therefore possible to navigated to any existing Java element from the root of the Java model along a chain of existing Java elements. On the other hand, working copies are said to exist until they are destroyed (with IWorkingCopy.destroy). Unlike regular Java elements, a working copy never shows up among the children of its parent element (which may or may not exist).

      Angegeben von:
      exists in Schnittstelle IJavaElement
      Setzt außer Kraft:
      exists in Klasse JavaElement
      Gibt zurück:
      true if this element exists in the Java model, and false if this element does not exist
      Siehe auch:
    • findRecommendedLineSeparator

      public String findRecommendedLineSeparator() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Finds and returns the recommended line separator for this element. The element's buffer is first searched and the first line separator in this buffer is returned if any. Otherwise the preference Platform.PREF_LINE_SEPARATOR on this element's project or workspace is returned. Finally if no such preference is set, the system line separator is returned.
      Angegeben von:
      findRecommendedLineSeparator in Schnittstelle IOpenable
      Gibt zurück:
      the recommended line separator for this element
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
    • generateInfos

      protected void generateInfos(Object info, HashMap newElements, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Klasse kopiert: JavaElement
      Generates the element infos for this element, its ancestors (if they are not opened) and its children (if it is an Openable). Puts the newly created element info in the given map.
      Angegeben von:
      generateInfos in Klasse JavaElement
      Löst aus:
      JavaModelException
    • ignoreErrorStatus

      protected boolean ignoreErrorStatus(org.eclipse.core.runtime.IStatus status)
    • getBuffer

      public IBuffer getBuffer() throws JavaModelException
      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.
      Angegeben von:
      getBuffer in Schnittstelle IOpenable
      Gibt zurück:
      the buffer opened for this element, or null if this element does not have a buffer
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • getBufferFactory

      public IBufferFactory getBufferFactory()
      Veraltet.
      Answers the buffer factory to use for creating new buffers
    • getBufferManager

      protected BufferManager getBufferManager()
      Returns the buffer manager for this element.
    • getCorrespondingResource

      public org.eclipse.core.resources.IResource getCorrespondingResource() throws JavaModelException
      Return my underlying resource. Elements that may not have a corresponding resource must override this method.
      Angegeben von:
      getCorrespondingResource in Schnittstelle IJavaElement
      Gibt zurück:
      the corresponding resource, or null if none
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
      Siehe auch:
    • getOpenable

      public IOpenable getOpenable()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the first openable parent. If this element is openable, the element itself is returned. Returns null if this element doesn't have an openable parent. This is a handle-only method.
      Angegeben von:
      getOpenable in Schnittstelle IJavaElement
      Setzt außer Kraft:
      getOpenable in Klasse JavaElement
      Gibt zurück:
      the first openable parent or null if this element doesn't have an openable parent.
    • getUnderlyingResource

      public org.eclipse.core.resources.IResource getUnderlyingResource() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the smallest underlying resource that contains this element, or null if this element is not contained in a resource.
      Angegeben von:
      getUnderlyingResource in Schnittstelle IJavaElement
      Gibt zurück:
      the underlying resource, or null if none
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its underlying resource
      Siehe auch:
    • hasBuffer

      protected boolean hasBuffer()
      Returns true if this element may have an associated source buffer, otherwise false. Subclasses must override as required.
    • hasUnsavedChanges

      public boolean hasUnsavedChanges() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Returns true if this element is open and:
      • its buffer has unsaved changes, or
      • one of its descendants has unsaved changes, or
      • a working copy has been created on one of this element's children and has not yet destroyed
      Angegeben von:
      hasUnsavedChanges in Schnittstelle IOpenable
      Gibt zurück:
      true if this element is open and:
      • its buffer has unsaved changes, or
      • one of its descendants has unsaved changes, or
      • a working copy has been created on one of this element's children and has not yet destroyed
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
      Siehe auch:
    • isConsistent

      public boolean isConsistent()
      Subclasses must override as required.
      Angegeben von:
      isConsistent in Schnittstelle IOpenable
      Gibt zurück:
      true if the element is consistent with its underlying resource or buffer, false otherwise.
      Siehe auch:
    • isOpen

      public boolean isOpen()
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Returns whether this openable is open. This is a handle-only method.

      Note: This method doesn't tell whether an IJavaProject's getProject() is open. It is not equivalent to IProject.isOpen()!

      Note: Although IOpenable.isOpen() is exposed in the API, clients rarely have a need to rely on this internal state of the Java model.

      Angegeben von:
      isOpen in Schnittstelle IOpenable
      Gibt zurück:
      true if this openable is open, false otherwise
      Siehe auch:
    • isSourceElement

      protected boolean isSourceElement()
      Returns true if this represents a source element. Openable source elements have an associated buffer created when they are opened.
    • isStructureKnown

      public boolean isStructureKnown() throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns whether the structure of this element is known. For example, for a compilation unit that has syntax errors, false is returned. If the structure of an element is unknown, navigations will return reasonable defaults. For example, getChildren for a compilation unit with syntax errors will return a collection of the children that could be parsed.

      Note: This does not imply anything about consistency with the underlying resource/buffer contents.

      Angegeben von:
      isStructureKnown in Schnittstelle IJavaElement
      Gibt zurück:
      true if the structure of this element is known
      Löst aus:
      JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
      Siehe auch:
    • makeConsistent

      public void makeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary.

      Note: Using this functionality on a working copy will interfere with any subsequent reconciling operation. Indeed, the next ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) or ICompilationUnit.reconcile(int, boolean, boolean, WorkingCopyOwner, IProgressMonitor) operation will not account for changes which occurred before an explicit use of IOpenable.makeConsistent(IProgressMonitor)

      Angegeben von:
      makeConsistent in Schnittstelle IOpenable
      Parameter:
      monitor - the given progress monitor
      Löst aus:
      JavaModelException - if the element is unable to access the contents of its underlying resource. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      Siehe auch:
    • open

      public void open(org.eclipse.core.runtime.IProgressMonitor pm) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Opens this element and all parent elements that are not already open. For compilation units, a buffer is opened on the contents of the underlying resource.

      Note: Although IOpenable.open(org.eclipse.core.runtime.IProgressMonitor) is exposed in the API, clients are not expected to open and close elements - the Java model does this automatically as elements are accessed.

      Angegeben von:
      open in Schnittstelle IOpenable
      Parameter:
      pm - the given progress monitor
      Löst aus:
      JavaModelException - if an error occurs accessing the contents of its underlying resource. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      Siehe auch:
    • openBuffer

      protected IBuffer openBuffer(org.eclipse.core.runtime.IProgressMonitor pm, Object info) throws JavaModelException
      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.
      Löst aus:
      JavaModelException
    • getResource

      public org.eclipse.core.resources.IResource getResource()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the innermost resource enclosing this element. If this element is included in an archive and this archive is not external, this is the underlying resource corresponding to the archive. If this element is included in an external library, null is returned. This is a handle-only method.
      Angegeben von:
      getResource in Schnittstelle IJavaElement
      Setzt außer Kraft:
      getResource in Klasse JavaElement
      Gibt zurück:
      the innermost resource enclosing this element, null if this element is included in an external archive
    • resource

      public org.eclipse.core.resources.IResource resource()
      Angegeben von:
      resource in Klasse JavaElement
    • resource

      protected abstract org.eclipse.core.resources.IResource resource(PackageFragmentRoot root)
    • resourceExists

      protected boolean resourceExists(org.eclipse.core.resources.IResource underlyingResource)
      Returns whether the corresponding resource or associated file exists
    • save

      public void save(org.eclipse.core.runtime.IProgressMonitor pm, boolean force) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IOpenable
      Saves any changes in this element's buffer to its underlying resource via a workspace resource operation. This has no effect if the element has no underlying buffer, or if there are no unsaved changed in the buffer.

      The force parameter controls how this method deals with cases where the workbench is not completely in sync with the local file system. If false is specified, this method will only attempt to overwrite a corresponding file in the local file system provided it is in sync with the workbench. This option ensures there is no unintended data loss; it is the recommended setting. However, if true is specified, an attempt will be made to write a corresponding file in the local file system, overwriting any existing one if need be. In either case, if this method succeeds, the resource will be marked as being local (even if it wasn't before).

      As a result of this operation, the element is consistent with its underlying resource or buffer.

      Angegeben von:
      save in Schnittstelle IOpenable
      Parameter:
      pm - the given progress monitor
      force - it controls how this method deals with cases where the workbench is not completely in sync with the local file system
      Löst aus:
      JavaModelException - if an error occurs accessing the contents of its underlying resource. Reasons include:
      • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
      • This Java element is read-only (READ_ONLY)
      Siehe auch:
    • getPackageFragmentRoot

      public PackageFragmentRoot getPackageFragmentRoot()
      Find enclosing package fragment root if any
    • validateExistence

      protected abstract org.eclipse.core.runtime.IStatus validateExistence(org.eclipse.core.resources.IResource underlyingResource)
    • openAncestors

      protected void openAncestors(HashMap newElements, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Löst aus:
      JavaModelException