/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package net.sourceforge.phpdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* 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.
*
null
is
* specified.
* * When switching to working copy mode, problems are reported to the given * {@link IProblemRequestor}. Note that once in working copy mode, the given * {@link IProblemRequestor} is ignored. Only the original {@link 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 {@link 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), {@link ICompilationUnit#discardWorkingCopy} must be call as many * times as {@link #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.
*
null
indicating
* that the client is not interested in problems.
* @param owner the given {@link WorkingCopyOwner}, or null
for the primary owner
* @param monitor a progress monitor used to report progress while opening this compilation unit
* or null
if no progress should be reported
* @return a working copy for this class file
* @throws JavaModelException if this compilation unit could not become a working copy.
* @see ICompilationUnit#discardWorkingCopy()
* @since 3.2
* @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead.
* Note that if this deprecated method is used, problems will be reported to the given problem requestor
* as well as the problem requestor returned by the working copy owner (if not null).
*/
ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
/**
* Returns the bytes contained in this class file.
*
* @return the bytes contained in this class file
*
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
* @since 3.3
*/
byte[] getBytes() throws JavaModelException;
/**
* Returns the type contained in this class file.
* This is a handle-only method. The type may or may not exist.
*
* @return the type contained in this class file
*/
IType getType();
/**
* 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
.
*
* @param monitor a progress monitor used to report progress while opening this compilation unit
* or null
if no progress should be reported
* @param 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
* @return a a working copy on the source associated with this class file
* @exception JavaModelException if the source of this class file can
* not be determined. Reasons include:
*
true
if the class file represents a class.
*
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
boolean isClass() throws JavaModelException;
/**
* Returns whether this type represents an interface. This is not guaranteed to
* be instantaneous, as it may require parsing the underlying file.
*
* @return true
if the class file represents an interface.
*
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
boolean isInterface() throws JavaModelException;
}