Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jdt.core
Interface IClassFile

All Superinterfaces:
  IAdaptable, ICodeAssist, IJavaElement, IOpenable, IParent, ISourceReference

public interface IClassFile
extends IJavaElement, IParent, IOpenable, ISourceReference, ICodeAssist

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.

See Also:
  `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`

Method Summary
`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, 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, 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

### getElementAt

    public IJavaElement getElementAt(int position)
                              throws JavaModelException

  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.

  Parameters:
    `position` - a source position inside the class file
  Returns:
    the innermost Java element enclosing a given source position or `null` if none (excluding the class file).
  Throws:
    `JavaModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

### getType

    public IType getType()
                  throws JavaModelException

  Returns the type contained in this class file.

  Returns:
    the type contained in this class file
  Throws:
    `JavaModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

### getWorkingCopy

    public ICompilationUnit getWorkingCopy(WorkingCopyOwner owner,
                                           IProgressMonitor monitor)
                                    throws JavaModelException

  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.

  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()`.

  Parameters:
    `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 used
    `monitor` - a progress monitor used to report progress while opening this compilation unit or `null` if no progress should be reported
  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)
  Since:
    3.0

### getWorkingCopy

    public IJavaElement getWorkingCopy(IProgressMonitor monitor,
                                       IBufferFactory factory)
                                throws JavaModelException

  Deprecated. Use getWorkingCopy(WorkingCopyOwner, IProgressMonitor) instead

  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`.

  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)
  Since:
    2.0

### isClass

    public boolean isClass()
                    throws JavaModelException

  Returns whether this type represents a class. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.

  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

### isInterface

    public boolean isInterface()
                        throws JavaModelException

  Returns whether this type represents an interface. This is not guaranteed to be instantaneous, as it may require parsing the underlying file.

  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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse JDT Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.