|
Eclipse JDT Release 3.2 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Represents an entire binary type (single .class
file).
A class file has a single child of type IType
.
Class file elements need to be opened before they can be navigated.
If a class file cannot be parsed, its structure remains unknown. Use
IJavaElement.isStructureKnown
to determine whether this is the
case.
Note: IClassFile
extends ISourceReference
.
Source can be obtained for a class file if and only if source has been attached to this
class file. The source associated with a class file is the source code of
the compilation unit it was (nominally) generated from.
This interface is not intended to be implemented by clients.
IPackageFragmentRoot.attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor)
Field Summary |
---|
Fields inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
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 | |
---|---|
ICompilationUnit |
becomeWorkingCopy(IProblemRequestor problemRequestor,
WorkingCopyOwner owner,
IProgressMonitor monitor)
Changes this class file handle into a working copy. |
IJavaElement |
getElementAt(int position)
Returns the smallest element within this class file that includes the given source position (a method, field, etc.), or null if there is no element other than the class file
itself at the given position, or if the given position is not
within the source range of this class file. |
IType |
getType()
Returns the type contained in this class file. |
IJavaElement |
getWorkingCopy(IProgressMonitor monitor,
IBufferFactory factory)
Deprecated. Use getWorkingCopy(WorkingCopyOwner, IProgressMonitor) instead |
ICompilationUnit |
getWorkingCopy(WorkingCopyOwner owner,
IProgressMonitor monitor)
Returns a working copy on the source associated with this class file using the given owner to create the buffer, or null if there is no source associated
with the class file.
|
boolean |
isClass()
Returns whether this type represents a class. |
boolean |
isInterface()
Returns whether this type represents an interface. |
Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementName, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Methods inherited from interface org.eclipse.jdt.core.IParent |
---|
getChildren, hasChildren |
Methods inherited from interface org.eclipse.jdt.core.IOpenable |
---|
close, findRecommendedLineSeparator, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save |
Methods inherited from interface org.eclipse.jdt.core.ISourceReference |
---|
exists, getSource, getSourceRange |
Methods inherited from interface org.eclipse.jdt.core.ICodeAssist |
---|
codeComplete, codeComplete, codeComplete, codeComplete, codeComplete, codeSelect, codeSelect |
Method Detail |
public ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException
IBuffer
is
created using the given owner. Uses the primary owner if null
is
specified.
When switching to working copy mode, problems are reported to the given
IProblemRequestor
. Note that once in working copy mode, the given
IProblemRequestor
is ignored. Only the original IProblemRequestor
is used to report subsequent problems.
Once in working copy mode, changes to this working copy or its children are done in memory. Only the new buffer is affected.
UsingICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
on the working copy
will throw a JavaModelException
as a class file is implicetly read-only.
If this class file was already in working copy mode, an internal counter is incremented and no
other action is taken on this working copy. To bring this working copy back into the original mode
(where it reflects the underlying resource), ICompilationUnit.discardWorkingCopy()
must be call as many
times as becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
.
The primary compilation unit of a class file's working copy does not exist if the class file is not
in working copy mode (classFileWorkingCopy.getPrimary().exists() == false
).
The resource of a class file's working copy is null
if the class file is in an external jar file.
problemRequestor
- a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null
indicating
that the client is not interested in problems.owner
- the given WorkingCopyOwner
, or null
for the primary ownermonitor
- a progress monitor used to report progress while opening this compilation unit
or null
if no progress should be reported
JavaModelException
- if this compilation unit could not become a working copy.ICompilationUnit.discardWorkingCopy()
public IJavaElement getElementAt(int position) throws JavaModelException
null
if there is no element other than the class file
itself at the given position, or if the given position is not
within the source range of this class file.
position
- a source position inside the class file
null
if none (excluding the class file).
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic IType getType() throws JavaModelException
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException
null
if there is no source associated
with the class file.
The buffer will be automatically initialized with the source of the class file upon creation.
The only valid operations on this working copy are getBuffer()
or getPrimary()
.
owner
- the owner that creates a buffer that is used to get the content of the working copy
or null
if the primary owner should be usedmonitor
- a progress monitor used to report progress while opening this compilation unit
or null
if no progress should be reported
JavaModelException
- if the source of this class file can
not be determined. Reasons include:
public IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws JavaModelException
null
if there is no source associated
with the class file.
The buffer will be automatically initialized with the source of the class file upon creation.
The only valid operations on this working copy are getBuffer()
or getOriginalElement
.
monitor
- a progress monitor used to report progress while opening this compilation unit
or null
if no progress should be reportedfactory
- the factory that creates a buffer that is used to get the content of the working copy
or null
if the internal factory should be used
JavaModelException
- if the source of this class file can
not be determined. Reasons include:
public boolean isClass() throws JavaModelException
true
if the class file represents a class.
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourcepublic boolean isInterface() throws JavaModelException
true
if the class file represents an interface.
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource
|
Eclipse JDT Release 3.2 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |