|
|||||||||
| Home >> All >> org >> eclipse >> jdt >> [ core overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.jdt.core
Interface IJavaElement

- All Superinterfaces:
- org.eclipse.core.runtime.IAdaptable
- All Known Subinterfaces:
- IClassFile, ICompilationUnit, IField, IImportContainer, IImportDeclaration, IInitializer, IJavaModel, IJavaProject, ILocalVariable, IMember, IMethod, IPackageDeclaration, IPackageFragment, IPackageFragmentRoot, IType
- public interface IJavaElement
- extends org.eclipse.core.runtime.IAdaptable
Common protocol for all elements provided by the Java model. Java model elements are exposed to clients as handles to the actual underlying element. The Java model may hand out any number of handles for each element. Handles that refer to the same element are guaranteed to be equal, but not necessarily identical.
Methods annotated as "handle-only" do not require underlying elements to exist.
Methods that require underlying elements to exist throw
a JavaModelException when an underlying element is missing.
JavaModelException.isDoesNotExist can be used to recognize
this common special case.
This interface is not intended to be implemented by clients.
| Field Summary | |
static int |
CLASS_FILE
Constant representing a class file. |
static int |
COMPILATION_UNIT
Constant representing a Java compilation unit. |
static int |
FIELD
Constant representing a field. |
static int |
IMPORT_CONTAINER
Constant representing all import declarations within a compilation unit. |
static int |
IMPORT_DECLARATION
Constant representing an import declaration within a compilation unit. |
static int |
INITIALIZER
Constant representing a stand-alone instance or class initializer. |
static int |
JAVA_MODEL
Constant representing a Java model (workspace level object). |
static int |
JAVA_PROJECT
Constant representing a Java project. |
static int |
LOCAL_VARIABLE
Constant representing a local variable declaration. |
static int |
METHOD
Constant representing a method or constructor. |
static int |
PACKAGE_DECLARATION
Constant representing a package declaration within a compilation unit. |
static int |
PACKAGE_FRAGMENT
Constant representing a package fragment. |
static int |
PACKAGE_FRAGMENT_ROOT
Constant representing a package fragment root. |
static int |
TYPE
Constant representing a type (a class or interface). |
| Method Summary | |
boolean |
exists()
Returns whether this Java element exists in the model. |
IJavaElement |
getAncestor(int ancestorType)
Returns the first ancestor of this Java element that has the given type. |
org.eclipse.core.resources.IResource |
getCorrespondingResource()
Returns the resource that corresponds directly to this element, or null if there is no resource that corresponds to
this element. |
java.lang.String |
getElementName()
Returns the name of this element. |
int |
getElementType()
Returns this element's kind encoded as an integer. |
java.lang.String |
getHandleIdentifier()
Returns a string representation of this element handle. |
IJavaModel |
getJavaModel()
Returns the Java model. |
IJavaProject |
getJavaProject()
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). |
IOpenable |
getOpenable()
Returns the first openable parent. |
IJavaElement |
getParent()
Returns the element directly containing this element, or null if this element has no parent. |
org.eclipse.core.runtime.IPath |
getPath()
Returns the path to the innermost resource enclosing this element. |
IJavaElement |
getPrimaryElement()
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. |
org.eclipse.core.resources.IResource |
getResource()
Returns the innermost resource enclosing this element. |
org.eclipse.core.runtime.jobs.ISchedulingRule |
getSchedulingRule()
Returns the scheduling rule associated with this Java element. |
org.eclipse.core.resources.IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
boolean |
isReadOnly()
Returns whether this Java element is read-only. |
boolean |
isStructureKnown()
Returns whether the structure of this element is known. |
| Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
| Field Detail |
JAVA_MODEL
public static final int JAVA_MODEL
- Constant representing a Java model (workspace level object).
A Java element with this type can be safely cast to
IJavaModel.- See Also:
- Constant Field Values
JAVA_PROJECT
public static final int JAVA_PROJECT
- Constant representing a Java project.
A Java element with this type can be safely cast to
IJavaProject.- See Also:
- Constant Field Values
PACKAGE_FRAGMENT_ROOT
public static final int PACKAGE_FRAGMENT_ROOT
- Constant representing a package fragment root.
A Java element with this type can be safely cast to
IPackageFragmentRoot.- See Also:
- Constant Field Values
PACKAGE_FRAGMENT
public static final int PACKAGE_FRAGMENT
- Constant representing a package fragment.
A Java element with this type can be safely cast to
IPackageFragment.- See Also:
- Constant Field Values
COMPILATION_UNIT
public static final int COMPILATION_UNIT
- Constant representing a Java compilation unit.
A Java element with this type can be safely cast to
ICompilationUnit.- See Also:
- Constant Field Values
CLASS_FILE
public static final int CLASS_FILE
- Constant representing a class file.
A Java element with this type can be safely cast to
IClassFile.- See Also:
- Constant Field Values
TYPE
public static final int TYPE
- Constant representing a type (a class or interface).
A Java element with this type can be safely cast to
IType.- See Also:
- Constant Field Values
FIELD
public static final int FIELD
- Constant representing a field.
A Java element with this type can be safely cast to
IField.- See Also:
- Constant Field Values
METHOD
public static final int METHOD
- Constant representing a method or constructor.
A Java element with this type can be safely cast to
IMethod.- See Also:
- Constant Field Values
INITIALIZER
public static final int INITIALIZER
- Constant representing a stand-alone instance or class initializer.
A Java element with this type can be safely cast to
IInitializer.- See Also:
- Constant Field Values
PACKAGE_DECLARATION
public static final int PACKAGE_DECLARATION
- Constant representing a package declaration within a compilation unit.
A Java element with this type can be safely cast to
IPackageDeclaration.- See Also:
- Constant Field Values
IMPORT_CONTAINER
public static final int IMPORT_CONTAINER
- Constant representing all import declarations within a compilation unit.
A Java element with this type can be safely cast to
IImportContainer.- See Also:
- Constant Field Values
IMPORT_DECLARATION
public static final int IMPORT_DECLARATION
- Constant representing an import declaration within a compilation unit.
A Java element with this type can be safely cast to
IImportDeclaration.- See Also:
- Constant Field Values
LOCAL_VARIABLE
public static final int LOCAL_VARIABLE
- Constant representing a local variable declaration.
A Java element with this type can be safely cast to
ILocalVariable.- Since:
- 3.0
- See Also:
- Constant Field Values
| Method Detail |
exists
public boolean exists()
- 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 (withIWorkingCopy.destroy). Unlike regular Java elements, a working copy never shows up among the children of its parent element (which may or may not exist).
getAncestor
public IJavaElement getAncestor(int ancestorType)
- Returns the first ancestor of this Java element that has the given type.
Returns
nullif no such an ancestor can be found. This is a handle-only method.- Since:
- 2.0
getCorrespondingResource
public org.eclipse.core.resources.IResource getCorrespondingResource() throws JavaModelException
- Returns the resource that corresponds directly to this element,
or
nullif there is no resource that corresponds to this element.For example, the corresponding resource for an
ICompilationUnitis its underlyingIFile. The corresponding resource for anIPackageFragmentthat is not contained in an archive is its underlyingIFolder. AnIPackageFragmentcontained in an archive has no corresponding resource. Similarly, there are no corresponding resources forIMethods,IFields, etc.
getElementName
public java.lang.String getElementName()
- Returns the name of this element. This is a handle-only method.
getElementType
public int getElementType()
- Returns this element's kind encoded as an integer.
This is a handle-only method.
getHandleIdentifier
public java.lang.String getHandleIdentifier()
- 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.
getJavaModel
public IJavaModel getJavaModel()
- Returns the Java model.
This is a handle-only method.
getJavaProject
public IJavaProject getJavaProject()
- Returns the Java project this element is contained in,
or
nullif this element is not contained in any Java project (for instance, theIJavaModelis not contained in any Java project). This is a handle-only method.
getOpenable
public IOpenable getOpenable()
- Returns the first openable parent. If this element is openable, the element
itself is returned. Returns
nullif this element doesn't have an openable parent. This is a handle-only method.- Since:
- 2.0
getParent
public IJavaElement getParent()
- Returns the element directly containing this element,
or
nullif this element has no parent. This is a handle-only method.
getPath
public org.eclipse.core.runtime.IPath getPath()
- Returns the path to the innermost resource enclosing this element.
If this element is not included in an external archive,
the path returned is the full, absolute path to the underlying resource,
relative to the workbench.
If this element is included in an external archive,
the path returned is the absolute path to the archive in the file system.
This is a handle-only method.
- Since:
- 2.0
getPrimaryElement
public IJavaElement getPrimaryElement()
- 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.
- Since:
- 3.0
getResource
public org.eclipse.core.resources.IResource getResource()
- 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 archive,
nullis returned. This is a handle-only method.- Since:
- 2.0
getSchedulingRule
public org.eclipse.core.runtime.jobs.ISchedulingRule getSchedulingRule()
- Returns the scheduling rule associated with this Java element.
This is a handle-only method.
- Since:
- 3.0
getUnderlyingResource
public org.eclipse.core.resources.IResource getUnderlyingResource() throws JavaModelException
- Returns the smallest underlying resource that contains
this element, or
nullif this element is not contained in a resource.
isReadOnly
public boolean isReadOnly()
- 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.
isStructureKnown
public boolean isStructureKnown()
throws JavaModelException
- Returns whether the structure of this element is known. For example, for a
compilation unit that could not be parsed,
falseis returned. If the structure of an element is unknown, navigations will return reasonable defaults. For example,getChildrenwill return an empty collection.Note: This does not imply anything about consistency with the underlying resource/buffer contents.
|
|||||||||
| Home >> All >> org >> eclipse >> jdt >> [ core overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC