Another upgrade to Platform/JDT 3.4.1
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / IClassFile.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.core;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14
15 /**
16  * Represents an entire binary type (single <code>.class</code> file).
17  * A class file has a single child of type <code>IType</code>.
18  * Class file elements need to be opened before they can be navigated.
19  * If a class file cannot be parsed, its structure remains unknown. Use
20  * <code>IJavaElement.isStructureKnown</code> to determine whether this is the
21  * case.
22  * <p>
23  * Note: <code>IClassFile</code> extends <code>ISourceReference</code>.
24  * Source can be obtained for a class file if and only if source has been attached to this
25  * class file. The source associated with a class file is the source code of
26  * the compilation unit it was (nominally) generated from.
27  * </p>
28  *
29  * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor)
30  * @noimplement This interface is not intended to be implemented by clients.
31  */
32
33 public interface IClassFile extends ITypeRoot {
34
35 /**
36  * Changes this class file handle into a working copy. A new {@link IBuffer} is
37  * created using the given owner. Uses the primary owner if <code>null</code> is
38  * specified.
39  * <p>
40  * When switching to working copy mode, problems are reported to the given
41  * {@link IProblemRequestor}. Note that once in working copy mode, the given
42  * {@link IProblemRequestor} is ignored. Only the original {@link IProblemRequestor}
43  * is used to report subsequent problems.
44  * </p>
45  * <p>
46  * Once in working copy mode, changes to this working copy or its children are done in memory.
47  * Only the new buffer is affected.
48  * </p>
49  * <p>
50  * Using {@link ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor)} on the working copy
51  * will throw a <code>JavaModelException</code> as a class file is implicetly read-only.
52  * </p>
53  * <p>
54  * If this class file was already in working copy mode, an internal counter is incremented and no
55  * other action is taken on this working copy. To bring this working copy back into the original mode
56  * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many
57  * times as {@link #becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)}.
58  * </p>
59  * <p>
60  * The primary compilation unit of a class file's working copy does not exist if the class file is not
61  * in working copy mode (<code>classFileWorkingCopy.getPrimary().exists() == false</code>).
62  * </p>
63  * <p>
64  * The resource of a class file's working copy is <code>null</code> if the class file is in an external jar file.
65  * </p>
66  *
67  * @param problemRequestor a requestor which will get notified of problems detected during
68  *      reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
69  *      that the client is not interested in problems.
70  * @param owner the given {@link WorkingCopyOwner}, or <code>null</code> for the primary owner
71  * @param monitor a progress monitor used to report progress while opening this compilation unit
72  *      or <code>null</code> if no progress should be reported
73  * @return a working copy for this class file
74  * @throws JavaModelException if this compilation unit could not become a working copy.
75  * @see ICompilationUnit#discardWorkingCopy()
76  * @since 3.2
77  * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead.
78  *      Note that if this deprecated method is used, problems will be reported to the given problem requestor
79  *      as well as the problem requestor returned by the working copy owner (if not null).
80  */
81 ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
82 /**
83  * Returns the bytes contained in this class file.
84  *
85  * @return the bytes contained in this class file
86  *
87  * @exception JavaModelException if this element does not exist or if an
88  *      exception occurs while accessing its corresponding resource
89  * @since 3.3
90  */
91 byte[] getBytes() throws JavaModelException;
92 /**
93  * Returns the type contained in this class file.
94  * This is a handle-only method. The type may or may not exist.
95  *
96  * @return the type contained in this class file
97  */
98 IType getType();
99 /**
100  * Returns a working copy on the source associated with this class file using the given
101  * factory to create the buffer, or <code>null</code> if there is no source associated
102  * with the class file.
103  * <p>
104  * The buffer will be automatically initialized with the source of the class file
105  * upon creation.
106  * <p>
107  * The only valid operations on this working copy are <code>getBuffer()</code> or <code>getOriginalElement</code>.
108  *
109  * @param monitor a progress monitor used to report progress while opening this compilation unit
110  *                 or <code>null</code> if no progress should be reported
111  * @param factory the factory that creates a buffer that is used to get the content of the working copy
112  *                 or <code>null</code> if the internal factory should be used
113  * @return a  a working copy on the source associated with this class file
114  * @exception JavaModelException if the source of this class file can
115  *   not be determined. Reasons include:
116  * <ul>
117  * <li> This class file does not exist (ELEMENT_DOES_NOT_EXIST)</li>
118  * </ul>
119  * @since 2.0
120  * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead
121  */
122 IJavaElement getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws JavaModelException;
123 /**
124  * Returns whether this type represents a class. This is not guaranteed to be
125  * instantaneous, as it may require parsing the underlying file.
126  *
127  * @return <code>true</code> if the class file represents a class.
128  *
129  * @exception JavaModelException if this element does not exist or if an
130  *      exception occurs while accessing its corresponding resource
131  */
132 boolean isClass() throws JavaModelException;
133 /**
134  * Returns whether this type represents an interface. This is not guaranteed to
135  * be instantaneous, as it may require parsing the underlying file.
136  *
137  * @return <code>true</code> if the class file represents an interface.
138  *
139  * @exception JavaModelException if this element does not exist or if an
140  *      exception occurs while accessing its corresponding resource
141  */
142 boolean isInterface() throws JavaModelException;
143 }