Klasse JavaElement

java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.aspectj.org.eclipse.jdt.internal.core.JavaElement
Alle implementierten Schnittstellen:
IJavaElement, org.eclipse.core.runtime.IAdaptable
Bekannte direkte Unterklassen:
Openable, SourceRefElement

public abstract class JavaElement extends org.eclipse.core.runtime.PlatformObject implements IJavaElement
Root of Java element handle hierarchy.
Siehe auch:
  • Felddetails

    • JEM_ESCAPE

      public static final char JEM_ESCAPE
      Siehe auch:
    • JEM_JAVAPROJECT

      public static final char JEM_JAVAPROJECT
      Siehe auch:
    • JEM_PACKAGEFRAGMENTROOT

      public static final char JEM_PACKAGEFRAGMENTROOT
      Siehe auch:
    • JEM_PACKAGEFRAGMENT

      public static final char JEM_PACKAGEFRAGMENT
      Siehe auch:
    • JEM_FIELD

      public static final char JEM_FIELD
      Siehe auch:
    • JEM_METHOD

      public static final char JEM_METHOD
      Siehe auch:
    • JEM_INITIALIZER

      public static final char JEM_INITIALIZER
      Siehe auch:
    • JEM_COMPILATIONUNIT

      public static final char JEM_COMPILATIONUNIT
      Siehe auch:
    • JEM_CLASSFILE

      public static final char JEM_CLASSFILE
      Siehe auch:
    • JEM_MODULAR_CLASSFILE

      public static final char JEM_MODULAR_CLASSFILE
      Siehe auch:
    • JEM_TYPE

      public static final char JEM_TYPE
      Siehe auch:
    • JEM_PACKAGEDECLARATION

      public static final char JEM_PACKAGEDECLARATION
      Siehe auch:
    • JEM_IMPORTDECLARATION

      public static final char JEM_IMPORTDECLARATION
      Siehe auch:
    • JEM_COUNT

      public static final char JEM_COUNT
      Siehe auch:
    • JEM_LOCALVARIABLE

      public static final char JEM_LOCALVARIABLE
      Siehe auch:
    • JEM_TYPE_PARAMETER

      public static final char JEM_TYPE_PARAMETER
      Siehe auch:
    • JEM_ANNOTATION

      public static final char JEM_ANNOTATION
      Siehe auch:
    • JEM_LAMBDA_EXPRESSION

      public static final char JEM_LAMBDA_EXPRESSION
      Siehe auch:
    • JEM_LAMBDA_METHOD

      public static final char JEM_LAMBDA_METHOD
      Siehe auch:
    • JEM_STRING

      public static final char JEM_STRING
      Siehe auch:
    • JEM_MODULE

      public static final char JEM_MODULE
      Siehe auch:
    • JEM_DELIMITER_ESCAPE

      public static final char JEM_DELIMITER_ESCAPE
      Before ')', 'Ungültige Eingabe: "&"' and '"' became the newest additions as delimiters, the former two were allowed as part of element attributes and possibly stored. Trying to recreate elements from such memento would cause undesirable results. Consider the following valid project name: (abc) If we were to use ')' alone as the delimiter and decode the above name, the memento would be wrongly identified to contain a lambda expression. In order to differentiate delimiters from characters that are part of element attributes, the following escape character is being introduced and all the new delimiters must be escaped with this. So, a lambda expression would be written as: "=)..."
      Siehe auch:
    • NO_STRINGS

      protected static final String[] NO_STRINGS
    • NO_ELEMENTS

      protected static final JavaElement[] NO_ELEMENTS
    • NO_INFO

      protected static final Object NO_INFO
  • Konstruktordetails

    • JavaElement

      protected JavaElement(JavaElement parent) throws IllegalArgumentException
      Constructs a handle for a java element with the given parent element.
      Parameter:
      parent - The parent of java element
      Löst aus:
      IllegalArgumentException - if the type is not one of the valid Java element type constants
  • Methodendetails

    • close

      public void close() throws JavaModelException
      Löst aus:
      JavaModelException
      Siehe auch:
    • closing

      protected abstract void closing(Object info) throws JavaModelException
      This element is being closed. Do any necessary cleanup.
      Löst aus:
      JavaModelException
    • createElementInfo

      protected abstract Object createElementInfo()
    • equals

      public boolean equals(Object o)
      Returns true if this handle represents the same Java element as the given handle. By default, two handles represent the same element if they are identical or if they represent the same type of element, have equal names, parents, and occurrence counts.

      If a subclass has other requirements for equality, this method must be overridden.

      Setzt außer Kraft:
      equals in Klasse Object
      Siehe auch:
    • appendEscapedDelimiter

      protected void appendEscapedDelimiter(StringBuffer buffer, char delimiter)
      Siehe auch:
    • escapeMementoName

      protected void escapeMementoName(StringBuffer buffer, String mementoName)
    • 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
      Gibt zurück:
      true if this element exists in the Java model, and false if this element does not exist
      Siehe auch:
    • findNode

      public ASTNode findNode(CompilationUnit ast)
      Returns the ASTNode that corresponds to this JavaElement or null if there is no corresponding node.
    • generateInfos

      protected abstract void generateInfos(Object info, HashMap newElements, org.eclipse.core.runtime.IProgressMonitor pm) throws JavaModelException
      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.
      Löst aus:
      JavaModelException
    • getAncestor

      public IJavaElement getAncestor(int ancestorType)
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns this Java element or the first ancestor of this element that has the given type. Returns null if no such element can be found. This is a handle-only method.
      Angegeben von:
      getAncestor in Schnittstelle IJavaElement
      Parameter:
      ancestorType - the given type
      Gibt zurück:
      this Java element or the first ancestor of this element that has the given type, or null if no such element can be found
      Siehe auch:
    • getChildren

      public IJavaElement[] getChildren() throws JavaModelException
      Löst aus:
      JavaModelException
      Siehe auch:
    • getChildrenOfType

      public ArrayList getChildrenOfType(int type) throws JavaModelException
      Returns a collection of (immediate) children of this node of the specified type.
      Parameter:
      type - - one of the JEM_* constants defined by JavaElement
      Löst aus:
      JavaModelException
    • getClassFile

      public IClassFile getClassFile()
      Siehe auch:
    • getCompilationUnit

      public ICompilationUnit getCompilationUnit()
      Siehe auch:
    • getElementInfo

      public Object getElementInfo() throws JavaModelException
      Returns the info for this handle. If this element is not already open, it and all of its parents are opened. Does not return null. NOTE: BinaryType infos are NOT rooted under JavaElementInfo.
      Löst aus:
      JavaModelException - if the element is not present or not accessible
    • getElementInfo

      public Object getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Returns the info for this handle. If this element is not already open, it and all of its parents are opened. Does not return null. NOTE: BinaryType infos are NOT rooted under JavaElementInfo.
      Löst aus:
      JavaModelException - if the element is not present or not accessible
    • getElementName

      public String getElementName()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the name of this element. This is a handle-only method.
      Angegeben von:
      getElementName in Schnittstelle IJavaElement
      Gibt zurück:
      the element name
      Siehe auch:
      • IAdaptable
    • getHandleFromMemento

      public abstract IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner)
    • getHandleFromMemento

      public IJavaElement getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner)
    • getHandleIdentifier

      public String getHandleIdentifier()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns a string representation of this element handle. The format of the string is not specified; however, the identifier is stable across workspace sessions, and can be used to recreate this handle via the JavaCore.create(String) method.
      Angegeben von:
      getHandleIdentifier in Schnittstelle IJavaElement
      Gibt zurück:
      the string handle identifier
      Siehe auch:
    • getHandleMemento

      public String getHandleMemento()
      Siehe auch:
    • getHandleMemento

      protected void getHandleMemento(StringBuffer buff)
    • getHandleMementoDelimiter

      protected abstract char getHandleMementoDelimiter()
      Returns the char that marks the start of this handles contribution to a memento.
    • getJavaModel

      public JavaModel getJavaModel()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the Java model. This is a handle-only method.
      Angegeben von:
      getJavaModel in Schnittstelle IJavaElement
      Gibt zurück:
      the Java model
      Siehe auch:
    • getJavaProject

      public JavaProject getJavaProject()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the Java project this element is contained in, or null if this element is not contained in any Java project (for instance, the IJavaModel is not contained in any Java project). This is a handle-only method.
      Angegeben von:
      getJavaProject in Schnittstelle IJavaElement
      Gibt zurück:
      the containing Java project, or null if this element is not contained in a Java project
      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
      Gibt zurück:
      the first openable parent or null if this element doesn't have an openable parent.
    • getOpenableParent

      public IOpenable getOpenableParent()
      Return the first instance of IOpenable in the parent hierarchy of this element.

      Subclasses that are not IOpenable's must override this method.

    • getParent

      public JavaElement getParent()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the element directly containing this element, or null if this element has no parent. This is a handle-only method.
      Angegeben von:
      getParent in Schnittstelle IJavaElement
      Gibt zurück:
      the parent element, or null if this element has no parent
      Siehe auch:
    • setParent

      protected void setParent(JavaElement parent)
    • getPrimaryElement

      public JavaElement getPrimaryElement()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the primary element (whose compilation unit is the primary compilation unit) this working copy element was created from, or this element if it is a descendant of a primary compilation unit or if it is not a descendant of a working copy (e.g. it is a binary member). The returned element may or may not exist.
      Angegeben von:
      getPrimaryElement in Schnittstelle IJavaElement
      Gibt zurück:
      the primary element this working copy element was created from, or this element.
    • getPrimaryElement

      public JavaElement getPrimaryElement(boolean checkOwner)
    • 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
      Gibt zurück:
      the innermost resource enclosing this element, null if this element is included in an external archive
    • resource

      public abstract org.eclipse.core.resources.IResource resource()
    • getSourceElementAt

      protected IJavaElement getSourceElementAt(int position) throws JavaModelException
      Returns the element that is located at the given source position in this element. This is a helper method for ICompilationUnit#getElementAt, and only works on compilation units and types. The position given is known to be within this element's source range already, and if no finer grained element is found at the position, this element is returned.
      Löst aus:
      JavaModelException
    • getSourceMapper

      public SourceMapper getSourceMapper()
      Returns the SourceMapper facility for this element, or null if this element does not have a SourceMapper.
    • getSchedulingRule

      public org.eclipse.core.runtime.jobs.ISchedulingRule getSchedulingRule()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns the scheduling rule associated with this Java element. This is a handle-only method.
      Angegeben von:
      getSchedulingRule in Schnittstelle IJavaElement
      Gibt zurück:
      the scheduling rule associated with this Java element
    • hasChildren

      public boolean hasChildren() throws JavaModelException
      Löst aus:
      JavaModelException
      Siehe auch:
    • hashCode

      public int hashCode()
      Returns the hash code for this Java element. By default, the hash code for an element is a combination of its name and parent's hash code. Elements with other requirements must override this method.
      Setzt außer Kraft:
      hashCode in Klasse Object
    • isAncestorOf

      public boolean isAncestorOf(IJavaElement e)
      Returns true if this element is an ancestor of the given element, otherwise false.
    • isReadOnly

      public boolean isReadOnly()
      Beschreibung aus Schnittstelle kopiert: IJavaElement
      Returns whether this Java element is read-only. An element is read-only if its structure cannot be modified by the java model.

      Note this is different from IResource.isReadOnly(). For example, .jar files are read-only as the java model doesn't know how to add/remove elements in this file, but the underlying IFile can be writable.

      This is a handle-only method.

      Angegeben von:
      isReadOnly in Schnittstelle IJavaElement
      Gibt zurück:
      true if this element is read-only
      Siehe auch:
    • newNotPresentException

      public JavaModelException newNotPresentException()
      Creates and returns a new not present exception for this element.
    • newDoesNotExistStatus

      protected JavaModelStatus newDoesNotExistStatus()
    • newJavaModelException

      public JavaModelException newJavaModelException(org.eclipse.core.runtime.IStatus status)
      Creates and returns a new Java model exception for this element with the given status.
    • openWhenClosed

      protected Object openWhenClosed(Object info, boolean forceAdd, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Löst aus:
      JavaModelException
    • readableName

      public String readableName()
    • resolved

      public JavaElement resolved(Binding binding)
    • unresolved

      public JavaElement unresolved()
    • tabString

      protected String tabString(int tab)
    • toDebugString

      public String toDebugString()
      Debugging purposes
    • toString

      public String toString()
      Debugging purposes
      Setzt außer Kraft:
      toString in Klasse Object
    • toString

      protected void toString(int tab, StringBuffer buffer)
      Debugging purposes
    • toStringWithAncestors

      public String toStringWithAncestors()
      Debugging purposes
    • toStringWithAncestors

      public String toStringWithAncestors(boolean showResolvedInfo)
      Debugging purposes
    • toStringAncestors

      protected void toStringAncestors(StringBuffer buffer)
      Debugging purposes
    • toStringChildren

      protected void toStringChildren(int tab, StringBuffer buffer, Object info)
      Debugging purposes
    • toStringInfo

      public Object toStringInfo(int tab, StringBuffer buffer)
      Debugging purposes
    • toStringInfo

      protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo)
      Debugging purposes
      Parameter:
      showResolvedInfo - TODO
    • toStringName

      protected void toStringName(StringBuffer buffer)
      Debugging purposes
    • getJavadocBaseLocation

      protected URL getJavadocBaseLocation() throws JavaModelException
      Löst aus:
      JavaModelException
    • getLibraryJavadocLocation

      protected static URL getLibraryJavadocLocation(IClasspathEntry entry) throws JavaModelException
      Löst aus:
      JavaModelException
    • getAttachedJavadoc

      public String getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
      Beschreibung aus Schnittstelle kopiert: IJavaElement

      Returns the Javadoc as HTML source if this element has attached Javadoc, null otherwise.

      This should be used only for binary elements. Source elements will always return null.

      The encoding used to read the Javadoc is the one defined by the content type of the file. If none is defined, then the project's encoding of this Java element is used. If the project's encoding cannot be retrieved, then the platform encoding is used.

      In case the Javadoc doesn't exist for this element, null is returned.

      The HTML is extracted from the attached Javadoc and provided as is. No transformation or validation is done.

      Angegeben von:
      getAttachedJavadoc in Schnittstelle IJavaElement
      Parameter:
      monitor - the given progress monitor, can be null
      Gibt zurück:
      the extracted javadoc from the attached javadoc, null if none
      Löst aus:
      JavaModelException - if:
      • this element does not exist
      • retrieving the attached javadoc fails (timed-out, invalid URL, ...)
      • the format of the javadoc doesn't match expected standards (different anchors,...)
      Siehe auch:
    • validateAndCache

      protected void validateAndCache(URL baseLoc, FileNotFoundException e) throws JavaModelException
      Löst aus:
      JavaModelException
    • getURLContents

      protected String getURLContents(URL baseLoc, String docUrlValue) throws JavaModelException
      Löst aus:
      JavaModelException