|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
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. |
IResource |
getCorrespondingResource()
Returns the resource that corresponds directly to this element, or null if there is no resource that corresponds to
this element. |
String |
getElementName()
Returns the name of this element. |
int |
getElementType()
Returns this element's kind encoded as an integer. |
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. |
IPath |
getPath()
Returns the path to the innermost resource enclosing this element. |
IResource |
getResource()
Returns the innermost resource enclosing this element. |
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 |
public static final int JAVA_MODEL
IJavaModel
.
public static final int JAVA_PROJECT
IJavaProject
.
public static final int PACKAGE_FRAGMENT_ROOT
IPackageFragmentRoot
.
public static final int PACKAGE_FRAGMENT
IPackageFragment
.
public static final int COMPILATION_UNIT
ICompilationUnit
.
public static final int CLASS_FILE
IClassFile
.
public static final int TYPE
IType
.
public static final int FIELD
IField
.
public static final int METHOD
IMethod
.
public static final int INITIALIZER
IInitializer
.
public static final int PACKAGE_DECLARATION
IPackageDeclaration
.
public static final int IMPORT_CONTAINER
IImportContainer
.
public static final int IMPORT_DECLARATION
IImportDeclaration
.
Method Detail |
public boolean exists()
true
if this element exists in the Java modelpublic IJavaElement getAncestor(int ancestorType)
null
if no such an ancestor can be found.
This is a handle-only method.
ancestorType
- the given type
public IResource getCorrespondingResource() throws JavaModelException
null
if there is no resource that corresponds to
this element.
For example, the corresponding resource for an ICompilationUnit
is its underlying IFile
. The corresponding resource for
an IPackageFragment
that is not contained in an archive
is its underlying IFolder
. An IPackageFragment
contained in an archive has no corresponding resource. Similarly, there
are no corresponding resources for IMethods
,
IFields
, etc.
null
if none
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic String getElementName()
public int getElementType()
IJavaElement
IJavaElement
public String getHandleIdentifier()
JavaCore.create(String)
method.
JavaCore.create(java.lang.String)
public IJavaModel getJavaModel()
public IJavaProject getJavaProject()
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.
null
if this element is
not contained in a Java projectpublic IOpenable getOpenable()
null
if this element doesn't have
an openable parent.
This is a handle-only method.
null
if this element doesn't have
an openable parent.public IJavaElement getParent()
null
if this element has no parent.
This is a handle-only method.
null
if this element has no parentpublic IPath getPath()
public IResource getResource()
null
is returned.
If this element is a working copy, null
is returned.
This is a handle-only method.
null
if this
element is a working copy or is included in an external archivepublic IResource getUnderlyingResource() throws JavaModelException
null
if this element is not contained
in a resource.
null
if none
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its underlying resourcepublic boolean isReadOnly()
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.
true
if this element is read-onlypublic boolean isStructureKnown() throws JavaModelException
false
is returned.
If the structure of an element is unknown, navigations will return reasonable
defaults. For example, getChildren
will return an empty collection.
Note: This does not imply anything about consistency with the underlying resource/buffer contents.
true
if the structure of this element is known
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource
|
Eclipse JDT 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |