org.eclipse.jdt.internal.core
Class ClassFile

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.eclipse.jdt.internal.core.JavaElement
          extended by org.eclipse.jdt.internal.core.Openable
              extended by org.eclipse.jdt.internal.core.ClassFile
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IBufferChangedListener, IClassFile, ICodeAssist, IJavaElement, IOpenable, IParent, ISourceReference, ITypeRoot, SuffixConstants

public class ClassFile
extends Openable
implements IClassFile, SuffixConstants

See Also:
IClassFile

Field Summary
 
Fields inherited from class org.eclipse.jdt.internal.core.JavaElement
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_TYPE, 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
 
Fields inherited from interface org.eclipse.jdt.internal.compiler.util.SuffixConstants
EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA
 
Method Summary
 ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor)
          Changes this class file handle into a working copy.
 void codeComplete(int offset, CompletionRequestor requestor)
          Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.
 void codeComplete(int offset, CompletionRequestor requestor, WorkingCopyOwner owner)
          Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor.
 void codeComplete(int offset, ICodeCompletionRequestor requestor)
          Deprecated. - should use codeComplete(int, ICompletionRequestor) instead
 void codeComplete(int offset, ICompletionRequestor requestor)
          Deprecated.  
 void codeComplete(int offset, ICompletionRequestor requestor, WorkingCopyOwner owner)
          Deprecated.  
 IJavaElement[] codeSelect(int offset, int length)
          Returns the Java elements corresponding to the given selected text in this compilation unit.
 IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner owner)
          Returns the Java elements corresponding to the given selected text in this compilation unit.
 boolean equals(java.lang.Object o)
          Returns true if this handle represents the same Java element as the given handle.
 boolean existsUsingJarTypeCache()
           
 IType findPrimaryType()
          Finds the primary type of this Java type root (that is, the type with the same name as the compilation unit, or the type of a class file), or null if no such a type exists.
 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.
 IBinaryType getBinaryTypeInfo(IFile file)
          Returns the ClassFileReaderspecific for this IClassFile, based on its underlying resource, or null if unable to create the diet class file.
 IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize)
           
 IBuffer getBuffer()
          Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time.
 byte[] getBytes()
          Returns the bytes contained in this class file.
 IClassFile getClassFile()
           
 IResource getCorrespondingResource()
          A class file has a corresponding resource unless it is contained in a jar.
 IJavaElement getElementAt(int position)
          Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), or null if there is no element other than the Java type root itself at the given position, or if the given position is not within the source range of the source of this Java type root.
 IJavaElement getElementAtConsideringSibling(int position)
           
 java.lang.String getElementName()
          Returns the name of this element.
 int getElementType()
          Returns this element's kind encoded as an integer.
 IJavaElement getHandleFromMemento(java.lang.String token, MementoTokenizer memento, WorkingCopyOwner owner)
           
 org.eclipse.core.runtime.IPath getPath()
          Returns the path to the innermost resource enclosing this element.
 java.lang.String getSource()
          Returns the source code associated with this element.
 ISourceRange getSourceRange()
          Returns the source range associated with this element.
 java.lang.String getTopLevelTypeName()
           
 IType getType()
          Returns the type contained in this class file.
 java.lang.String getTypeName()
           
 ITypeRoot getTypeRoot()
           
 IJavaElement getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory)
          Deprecated.  
 ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, org.eclipse.core.runtime.IProgressMonitor monitor)
          Returns a shared working copy on this compilation unit or class file using the given working copy owner to create the buffer.
 int hashCode()
          Returns the hash code for this Java element.
 boolean isClass()
          Returns whether this type represents a class.
 boolean isInterface()
          Returns whether this type represents an interface.
 boolean isReadOnly()
          Returns true - class files are always read only.
 IResource resource(PackageFragmentRoot root)
           
static char[] translatedName(char[] name)
          Returns the Java Model representation of the given name which is provided in diet class file format, or null if the given name is null.
 
Methods inherited from class org.eclipse.jdt.internal.core.Openable
bufferChanged, canBeRemovedFromCache, canBufferBeRemovedFromCache, exists, findRecommendedLineSeparator, getBufferFactory, getOpenable, getPackageFragmentRoot, getResource, getUnderlyingResource, hasUnsavedChanges, isConsistent, isOpen, isStructureKnown, makeConsistent, open, resource, save
 
Methods inherited from class org.eclipse.jdt.internal.core.JavaElement
close, findNode, getAncestor, getChildren, getChildrenOfType, getCompilationUnit, getElementInfo, getElementInfo, getHandleFromMemento, getHandleIdentifier, getHandleMemento, getJavaModel, getJavaProject, getOpenableParent, getParent, getPrimaryElement, getPrimaryElement, getSchedulingRule, getSourceMapper, hasChildren, isAncestorOf, newJavaModelException, newNotPresentException, readableName, resolved, toDebugString, toString, toStringInfo, toStringWithAncestors, toStringWithAncestors, 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
exists, getAncestor, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, 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, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, open, save
 
Methods inherited from interface org.eclipse.jdt.core.ISourceReference
exists
 

Method Detail

becomeWorkingCopy

public ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor,
                                          WorkingCopyOwner owner,
                                          org.eclipse.core.runtime.IProgressMonitor monitor)
                                   throws JavaModelException
Description copied from interface: IClassFile
Changes this class file handle into a working copy. A new 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.

Using ICompilationUnit.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 IClassFile.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.

Specified by:
becomeWorkingCopy in interface IClassFile
Parameters:
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 owner
monitor - a progress monitor used to report progress while opening this compilation unit or null if no progress should be reported
Returns:
a working copy for this class file
Throws:
JavaModelException - if this compilation unit could not become a working copy.
See Also:
ICompilationUnit.discardWorkingCopy()

codeComplete

public void codeComplete(int offset,
                         ICompletionRequestor requestor)
                  throws JavaModelException
Deprecated. 

Description copied from interface: ICodeAssist
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -1 indicates to code assist at the beginning of this compilation unit.

Specified by:
codeComplete in interface ICodeAssist
Parameters:
offset - the given offset position
requestor - the given completion requestor
Throws:
JavaModelException - if code assist could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
See Also:
ICodeAssist.codeComplete(int, ICompletionRequestor)

codeComplete

public void codeComplete(int offset,
                         ICompletionRequestor requestor,
                         WorkingCopyOwner owner)
                  throws JavaModelException
Deprecated. 

Description copied from interface: ICodeAssist
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -1 indicates to code assist at the beginning of this compilation unit. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.

Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.

Specified by:
codeComplete in interface ICodeAssist
Parameters:
offset - the given offset position
requestor - the given completion requestor
owner - the owner of working copies that take precedence over their original compilation units
Throws:
JavaModelException - if code assist could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
See Also:
ICodeAssist.codeComplete(int, ICompletionRequestor, WorkingCopyOwner)

codeComplete

public void codeComplete(int offset,
                         CompletionRequestor requestor)
                  throws JavaModelException
Description copied from interface: ICodeAssist
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -1 indicates to code assist at the beginning of this compilation unit.

Specified by:
codeComplete in interface ICodeAssist
Parameters:
offset - the given offset position
requestor - the given completion requestor
Throws:
JavaModelException - if code assist could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)

codeComplete

public void codeComplete(int offset,
                         CompletionRequestor requestor,
                         WorkingCopyOwner owner)
                  throws JavaModelException
Description copied from interface: ICodeAssist
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -1 indicates to code assist at the beginning of this compilation unit. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.

Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.

Specified by:
codeComplete in interface ICodeAssist
Parameters:
offset - the given offset position
requestor - the given completion requestor
owner - the owner of working copies that take precedence over their original compilation units
Throws:
JavaModelException - if code assist could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)

codeSelect

public IJavaElement[] codeSelect(int offset,
                                 int length)
                          throws JavaModelException
Description copied from interface: ICodeAssist
Returns the Java elements corresponding to the given selected text in this compilation unit. The offset is the 0-based index of the first selected character. The length is the number of selected characters.

Note that if the length is 0 and the offset is inside an identifier or the index just after an identifier then this identifier is considered as the selection.

Specified by:
codeSelect in interface ICodeAssist
Parameters:
offset - the given offset position
length - the number of selected characters
Returns:
the Java elements corresponding to the given selected text
Throws:
JavaModelException - if code resolve could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The range specified is not within this element's source range (INDEX_OUT_OF_BOUNDS)
See Also:
ICodeAssist.codeSelect(int, int)

codeSelect

public IJavaElement[] codeSelect(int offset,
                                 int length,
                                 WorkingCopyOwner owner)
                          throws JavaModelException
Description copied from interface: ICodeAssist
Returns the Java elements corresponding to the given selected text in this compilation unit. The offset is the 0-based index of the first selected character. The length is the number of selected characters. It considers types in the working copies with the given owner first. In other words, the owner's working copies will take precedence over their original compilation units in the workspace.

Note that if the length is 0 and the offset is inside an identifier or the index just after an identifier then this identifier is considered as the selection.

Note that if a working copy is empty, it will be as if the original compilation unit had been deleted.

Specified by:
codeSelect in interface ICodeAssist
Parameters:
offset - the given offset position
length - the number of selected characters
owner - the owner of working copies that take precedence over their original compilation units
Returns:
the Java elements corresponding to the given selected text
Throws:
JavaModelException - if code resolve could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The range specified is not within this element's source range (INDEX_OUT_OF_BOUNDS)
See Also:
ICodeAssist.codeSelect(int, int, WorkingCopyOwner)

equals

public boolean equals(java.lang.Object o)
Description copied from class: JavaElement
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.

Overrides:
equals in class JavaElement
See Also:
Object.equals(java.lang.Object)

existsUsingJarTypeCache

public boolean existsUsingJarTypeCache()

findPrimaryType

public IType findPrimaryType()
Description copied from interface: ITypeRoot
Finds the primary type of this Java type root (that is, the type with the same name as the compilation unit, or the type of a class file), or null if no such a type exists.

Specified by:
findPrimaryType in interface ITypeRoot
Returns:
the found primary type of this Java type root, or null if no such a type exists
See Also:
ITypeRoot.findPrimaryType()

getAttachedJavadoc

public java.lang.String getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor monitor)
                                    throws JavaModelException
Description copied from interface: 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.

Specified by:
getAttachedJavadoc in interface IJavaElement
Overrides:
getAttachedJavadoc in class JavaElement
Parameters:
monitor - the given progress monitor
Returns:
the extracted javadoc from the attached javadoc, null if none
Throws:
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,...)
See Also:
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME

getBinaryTypeInfo

public IBinaryType getBinaryTypeInfo(IFile file)
                              throws JavaModelException
Returns the ClassFileReaderspecific for this IClassFile, based on its underlying resource, or null if unable to create the diet class file. There are two cases to consider:

Throws:
JavaModelException - when the IFile resource or JAR is not available or when this class file is not present in the JAR

getBinaryTypeInfo

public IBinaryType getBinaryTypeInfo(IFile file,
                                     boolean fullyInitialize)
                              throws JavaModelException
Throws:
JavaModelException

getBytes

public byte[] getBytes()
                throws JavaModelException
Description copied from interface: IClassFile
Returns the bytes contained in this class file.

Specified by:
getBytes in interface IClassFile
Returns:
the bytes contained in this class file
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource

getBuffer

public IBuffer getBuffer()
                  throws JavaModelException
Description copied from class: Openable
Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time. If this is the first time a request is being made for the buffer, an attempt is made to create and fill this element's buffer. If the buffer has been closed since it was first opened, the buffer is re-created.

Specified by:
getBuffer in interface IOpenable
Overrides:
getBuffer in class Openable
Returns:
the buffer opened for this element, or null if this element does not have a buffer
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
See Also:
IOpenable

getClassFile

public IClassFile getClassFile()
Overrides:
getClassFile in class JavaElement
See Also:
IMember

getTypeRoot

public ITypeRoot getTypeRoot()
See Also:
IMember.getTypeRoot()

getCorrespondingResource

public IResource getCorrespondingResource()
                                   throws JavaModelException
A class file has a corresponding resource unless it is contained in a jar.

Specified by:
getCorrespondingResource in interface IJavaElement
Overrides:
getCorrespondingResource in class Openable
Returns:
the corresponding resource, or null if none
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IJavaElement

getElementAt

public IJavaElement getElementAt(int position)
                          throws JavaModelException
Description copied from interface: ITypeRoot
Returns the smallest element within this Java type root that includes the given source position (that is, a method, field, etc.), or null if there is no element other than the Java type root itself at the given position, or if the given position is not within the source range of the source of this Java type root.

Specified by:
getElementAt in interface ITypeRoot
Parameters:
position - a source position inside the Java type root
Returns:
the innermost Java element enclosing a given source position or null if none (excluding the Java type root).
Throws:
JavaModelException - if the Java type root does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IClassFile

getElementAtConsideringSibling

public IJavaElement getElementAtConsideringSibling(int position)
                                            throws JavaModelException
Throws:
JavaModelException

getElementName

public java.lang.String getElementName()
Description copied from interface: IJavaElement
Returns the name of this element. This is a handle-only method.

Specified by:
getElementName in interface IJavaElement
Overrides:
getElementName in class JavaElement
Returns:
the element name
See Also:
IAdaptable

getElementType

public int getElementType()
Description copied from interface: IJavaElement
Returns this element's kind encoded as an integer. This is a handle-only method.

Specified by:
getElementType in interface IJavaElement
Returns:
the kind of element; one of the constants declared in IJavaElement
See Also:
IJavaElement

getHandleFromMemento

public IJavaElement getHandleFromMemento(java.lang.String token,
                                         MementoTokenizer memento,
                                         WorkingCopyOwner owner)
Specified by:
getHandleFromMemento in class JavaElement

getPath

public org.eclipse.core.runtime.IPath getPath()
Description copied from interface: IJavaElement
Returns the path to the innermost resource enclosing this element. If this element is not included in an external library, the path returned is the full, absolute path to the underlying resource, relative to the workbench. If this element is included in an external library, the path returned is the absolute path to the archive in the file system. This is a handle-only method.

Specified by:
getPath in interface IJavaElement
Returns:
the path to the innermost resource enclosing this element

resource

public IResource resource(PackageFragmentRoot root)

getSource

public java.lang.String getSource()
                           throws JavaModelException
Description copied from interface: ISourceReference
Returns the source code associated with this element. This extracts the substring from the source buffer containing this source element. This corresponds to the source range that would be returned by getSourceRange.

For class files, this returns the source of the entire compilation unit associated with the class file (if there is one).

Specified by:
getSource in interface ISourceReference
Returns:
the source code, or null if this element has no associated source code
Throws:
JavaModelException - if an exception occurs while accessing its corresponding resource
See Also:
ISourceReference

getSourceRange

public ISourceRange getSourceRange()
                            throws JavaModelException
Description copied from interface: ISourceReference
Returns the source range associated with this element.

For class files, this returns the range of the entire compilation unit associated with the class file (if there is one).

If this element has no associated source code null is either returned, or a source range with a -1 offset and a 0 length.

Specified by:
getSourceRange in interface ISourceReference
Returns:
the source range, or either null or [-1, 0] if this element has no associated source code
Throws:
JavaModelException - if an exception occurs while accessing its corresponding resource
See Also:
ISourceReference

getTopLevelTypeName

public java.lang.String getTopLevelTypeName()

getType

public IType getType()
Description copied from interface: IClassFile
Returns the type contained in this class file. This is a handle-only method. The type may or may not exist.

Specified by:
getType in interface IClassFile
Returns:
the type contained in this class file
See Also:
IClassFile

getTypeName

public java.lang.String getTypeName()

getWorkingCopy

public ICompilationUnit getWorkingCopy(WorkingCopyOwner owner,
                                       org.eclipse.core.runtime.IProgressMonitor monitor)
                                throws JavaModelException
Description copied from interface: ITypeRoot
Returns a shared working copy on this compilation unit or class file using the given working copy owner to create the buffer. If this is already a working copy of the given owner, the element itself is returned. This API can only answer an already existing working copy if it is based on the same original Java type root AND was using the same working copy owner (that is, as defined by Object.equals(java.lang.Object)).

The life time of a shared working copy is as follows:

So users of this method must discard exactly once the working copy.

Note that the working copy owner will be used for the life time of the shared working copy, that is if the working copy is closed then reopened, this owner will be used. The buffer will be automatically initialized with the original's Java type root content upon creation.

When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.

A working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.

Note that possible problems of this working copy are reported using this method only if the given working copy owner returns a problem requestor for this working copy (see WorkingCopyOwner.getProblemRequestor(ICompilationUnit)).

Specified by:
getWorkingCopy in interface ITypeRoot
Parameters:
owner - the working copy owner that creates a buffer that is used to get the content of the working copy
monitor - a progress monitor used to report progress while opening this compilation unit or null if no progress should be reported
Returns:
a new working copy of this Java type root using the given owner to create the buffer, or this Java type root if it is already a working copy
Throws:
JavaModelException - if the contents of this element can not be determined.

getWorkingCopy

public IJavaElement getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor,
                                   IBufferFactory factory)
                            throws JavaModelException
Deprecated. 

Description copied from interface: IClassFile
Returns a working copy on the source associated with this class file using the given factory to create the buffer, or 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.

Specified by:
getWorkingCopy in interface IClassFile
Parameters:
monitor - a progress monitor used to report progress while opening this compilation unit or null if no progress should be reported
factory - 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
Returns:
a a working copy on the source associated with this class file
Throws:
JavaModelException - if the source of this class file can not be determined. Reasons include:
  • This class file does not exist (ELEMENT_DOES_NOT_EXIST)
See Also:
IClassFile

hashCode

public int hashCode()
Description copied from class: JavaElement
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.

Overrides:
hashCode in class JavaElement

isClass

public boolean isClass()
                throws JavaModelException
Description copied from interface: IClassFile
Returns whether this type represents a class. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.

Specified by:
isClass in interface IClassFile
Returns:
true if the class file represents a class.
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IClassFile

isInterface

public boolean isInterface()
                    throws JavaModelException
Description copied from interface: IClassFile
Returns whether this type represents an interface. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.

Specified by:
isInterface in interface IClassFile
Returns:
true if the class file represents an interface.
Throws:
JavaModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
See Also:
IClassFile

isReadOnly

public boolean isReadOnly()
Returns true - class files are always read only.

Specified by:
isReadOnly in interface IJavaElement
Overrides:
isReadOnly in class JavaElement
Returns:
true if this element is read-only
See Also:
IJavaElement

translatedName

public static char[] translatedName(char[] name)
Returns the Java Model representation of the given name which is provided in diet class file format, or null if the given name is null.

ClassFileReader format is similar to "java/lang/Object", and corresponding Java Model format is "java.lang.Object".


codeComplete

public void codeComplete(int offset,
                         ICodeCompletionRequestor requestor)
                  throws JavaModelException
Deprecated. - should use codeComplete(int, ICompletionRequestor) instead

Description copied from interface: ICodeAssist
Performs code completion at the given offset position in this compilation unit, reporting results to the given completion requestor. The offset is the 0-based index of the character, after which code assist is desired. An offset of -1 indicates to code assist at the beginning of this compilation unit.

Specified by:
codeComplete in interface ICodeAssist
Parameters:
offset - the given offset position
requestor - the given completion requestor
Throws:
JavaModelException - if code assist could not be performed. Reasons include:
  • This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
  • The position specified is < -1 or is greater than this compilation unit's source length (INDEX_OUT_OF_BOUNDS)
See Also:
ICodeAssist.codeComplete(int, ICodeCompletionRequestor)