|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.PlatformObject
org.eclipse.jdt.internal.core.JavaElement
public abstract class JavaElement
Root of Java element handle hierarchy.
IJavaElement
Field Summary | |
---|---|
static char |
JEM_ANNOTATION
|
static char |
JEM_CLASSFILE
|
static char |
JEM_COMPILATIONUNIT
|
static char |
JEM_COUNT
|
static char |
JEM_ESCAPE
|
static char |
JEM_FIELD
|
static char |
JEM_IMPORTDECLARATION
|
static char |
JEM_INITIALIZER
|
static char |
JEM_JAVAPROJECT
|
static char |
JEM_LOCALVARIABLE
|
static char |
JEM_METHOD
|
static char |
JEM_PACKAGEDECLARATION
|
static char |
JEM_PACKAGEFRAGMENT
|
static char |
JEM_PACKAGEFRAGMENTROOT
|
static char |
JEM_TYPE
|
static char |
JEM_TYPE_PARAMETER
|
Fields inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER |
Method Summary | |
---|---|
void |
close()
|
boolean |
equals(java.lang.Object o)
Returns true if this handle represents the same Java element as the given handle. |
boolean |
exists()
Returns whether this Java element exists in the model. |
ASTNode |
findNode(CompilationUnit ast)
Returns the ASTNode that corresponds to this JavaElement
or null if there is no corresponding node. |
IJavaElement |
getAncestor(int ancestorType)
Returns the first ancestor of this Java element that has the given type. |
java.lang.String |
getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the Javadoc as an html source if this element has an attached javadoc, null otherwise. |
IJavaElement[] |
getChildren()
|
java.util.ArrayList |
getChildrenOfType(int type)
Returns a collection of (immediate) children of this node of the specified type. |
IClassFile |
getClassFile()
|
ICompilationUnit |
getCompilationUnit()
|
java.lang.Object |
getElementInfo()
Returns the info for this handle. |
java.lang.Object |
getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the info for this handle. |
java.lang.String |
getElementName()
Returns the name of this element. |
IJavaElement |
getHandleFromMemento(MementoTokenizer memento,
WorkingCopyOwner owner)
|
abstract IJavaElement |
getHandleFromMemento(java.lang.String token,
MementoTokenizer memento,
WorkingCopyOwner owner)
|
java.lang.String |
getHandleIdentifier()
Returns a string representation of this element handle. |
java.lang.String |
getHandleMemento()
|
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. |
IOpenable |
getOpenableParent()
Return the first instance of IOpenable in the parent hierarchy of this element. |
IJavaElement |
getParent()
Returns the element directly containing this element, or null if this element has no parent. |
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. |
IJavaElement |
getPrimaryElement(boolean checkOwner)
|
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. |
SourceMapper |
getSourceMapper()
Returns the SourceMapper facility for this element, or null if this element does not have a
SourceMapper. |
boolean |
hasChildren()
|
int |
hashCode()
Returns the hash code for this Java element. |
boolean |
isAncestorOf(IJavaElement e)
Returns true if this element is an ancestor of the given element, otherwise false. |
boolean |
isReadOnly()
Returns whether this Java element is read-only. |
JavaModelException |
newJavaModelException(org.eclipse.core.runtime.IStatus status)
Creates and returns a new Java model exception for this element with the given status. |
JavaModelException |
newNotPresentException()
Creates and returns a new not present exception for this element. |
java.lang.String |
readableName()
|
JavaElement |
resolved(Binding binding)
|
abstract IResource |
resource()
|
java.lang.String |
toDebugString()
Debugging purposes |
java.lang.String |
toString()
Debugging purposes |
java.lang.Object |
toStringInfo(int tab,
java.lang.StringBuffer buffer)
Debugging purposes |
java.lang.String |
toStringWithAncestors()
Debugging purposes |
java.lang.String |
toStringWithAncestors(boolean showResolvedInfo)
Debugging purposes |
JavaElement |
unresolved()
|
Methods inherited from class org.eclipse.core.runtime.PlatformObject |
---|
getAdapter |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
getCorrespondingResource, getElementType, getPath, getUnderlyingResource, isStructureKnown |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Field Detail |
---|
public static final char JEM_ESCAPE
public static final char JEM_JAVAPROJECT
public static final char JEM_PACKAGEFRAGMENTROOT
public static final char JEM_PACKAGEFRAGMENT
public static final char JEM_FIELD
public static final char JEM_METHOD
public static final char JEM_INITIALIZER
public static final char JEM_COMPILATIONUNIT
public static final char JEM_CLASSFILE
public static final char JEM_TYPE
public static final char JEM_PACKAGEDECLARATION
public static final char JEM_IMPORTDECLARATION
public static final char JEM_COUNT
public static final char JEM_LOCALVARIABLE
public static final char JEM_TYPE_PARAMETER
public static final char JEM_ANNOTATION
Method Detail |
---|
public void close() throws JavaModelException
JavaModelException
IOpenable
public boolean equals(java.lang.Object o)
If a subclass has other requirements for equality, this method must be overridden.
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public boolean exists()
IJavaElement
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).
exists
in interface IJavaElement
true
if this element exists in the Java model, and
false
if this element does not existIJavaElement
public ASTNode findNode(CompilationUnit ast)
ASTNode
that corresponds to this JavaElement
or null
if there is no corresponding node.
public IJavaElement getAncestor(int ancestorType)
IJavaElement
null
if no such an ancestor can be found.
This is a handle-only method.
getAncestor
in interface IJavaElement
ancestorType
- the given type
IJavaElement
public IJavaElement[] getChildren() throws JavaModelException
JavaModelException
IParent
public java.util.ArrayList getChildrenOfType(int type) throws JavaModelException
type
- - one of the JEM_* constants defined by JavaElement
JavaModelException
public IClassFile getClassFile()
IMember
public ICompilationUnit getCompilationUnit()
IMember
public java.lang.Object getElementInfo() throws JavaModelException
JavaModelException
- if the element is not present or not accessiblepublic java.lang.Object getElementInfo(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
JavaModelException
- if the element is not present or not accessiblepublic java.lang.String getElementName()
IJavaElement
getElementName
in interface IJavaElement
IAdaptable
public abstract IJavaElement getHandleFromMemento(java.lang.String token, MementoTokenizer memento, WorkingCopyOwner owner)
public IJavaElement getHandleFromMemento(MementoTokenizer memento, WorkingCopyOwner owner)
public java.lang.String getHandleIdentifier()
IJavaElement
JavaCore.create(String)
method.
getHandleIdentifier
in interface IJavaElement
IJavaElement
public java.lang.String getHandleMemento()
getHandleMemento()
public IJavaModel getJavaModel()
IJavaElement
getJavaModel
in interface IJavaElement
IJavaElement
public IJavaProject getJavaProject()
IJavaElement
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.
getJavaProject
in interface IJavaElement
null
if this element is
not contained in a Java projectIJavaElement
public IOpenable getOpenable()
IJavaElement
null
if this element doesn't have
an openable parent.
This is a handle-only method.
getOpenable
in interface IJavaElement
null
if this element doesn't have
an openable parent.public IOpenable getOpenableParent()
Subclasses that are not IOpenable's must override this method.
public IJavaElement getParent()
IJavaElement
null
if this element has no parent.
This is a handle-only method.
getParent
in interface IJavaElement
null
if this element has no parentIJavaElement
public IJavaElement getPrimaryElement()
IJavaElement
getPrimaryElement
in interface IJavaElement
public IJavaElement getPrimaryElement(boolean checkOwner)
public IResource getResource()
IJavaElement
null
is returned.
This is a handle-only method.
getResource
in interface IJavaElement
null
if this
element is included in an external archivepublic abstract IResource resource()
public SourceMapper getSourceMapper()
null
if this element does not have a
SourceMapper.
public org.eclipse.core.runtime.jobs.ISchedulingRule getSchedulingRule()
IJavaElement
getSchedulingRule
in interface IJavaElement
public boolean hasChildren() throws JavaModelException
JavaModelException
IParent
public int hashCode()
hashCode
in class java.lang.Object
public boolean isAncestorOf(IJavaElement e)
public boolean isReadOnly()
IJavaElement
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.
isReadOnly
in interface IJavaElement
true
if this element is read-onlyIJavaElement
public JavaModelException newNotPresentException()
public JavaModelException newJavaModelException(org.eclipse.core.runtime.IStatus status)
public java.lang.String readableName()
public JavaElement resolved(Binding binding)
public JavaElement unresolved()
public java.lang.String toDebugString()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringWithAncestors()
public java.lang.String toStringWithAncestors(boolean showResolvedInfo)
public java.lang.Object toStringInfo(int tab, java.lang.StringBuffer buffer)
public java.lang.String getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
IJavaElement
Returns the Javadoc as an html source if this element has an 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 of 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.
getAttachedJavadoc
in interface IJavaElement
monitor
- the given progress monitor
JavaModelException
- if:IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |