KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > ISourceReference


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 org.eclipse.jdt.core;
12
13 /**
14  * Common protocol for Java elements that have associated source code.
15  * This set consists of <code>IClassFile</code>, <code>ICompilationUnit</code>,
16  * <code>IPackageDeclaration</code>, <code>IImportDeclaration</code>,
17  * <code>IImportContainer</code>, <code>IType</code>, <code>IField</code>,
18  * <code>IMethod</code>, and <code>IInitializer</code>.
19  * <p>
20  * Note: For <code>IClassFile</code>, <code>IType</code> and other members
21  * derived from a binary type, the implementation returns source iff the
22  * element has attached source code.
23  * </p>
24  * <p>
25  * Source reference elements may be working copies if they were created from
26  * a compilation unit that is a working copy.
27  * </p>
28  * <p>
29  * This interface is not intended to be implemented by clients.
30  * </p>
31  *
32  * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
33  */

34 public interface ISourceReference {
35 /**
36  * Returns whether this element exists in the model.
37  *
38  * @return <code>true</code> if this element exists in the Java model
39  * @since 2.0
40  */

41 boolean exists();
42     
43 /**
44  * Returns the source code associated with this element.
45  * This extracts the substring from the source buffer containing this source
46  * element. This corresponds to the source range that would be returned by
47  * <code>getSourceRange</code>.
48  * <p>
49  * For class files, this returns the source of the entire compilation unit
50  * associated with the class file (if there is one).
51  * </p>
52  *
53  * @return the source code, or <code>null</code> if this element has no
54  * associated source code
55  * @exception JavaModelException if an exception occurs while accessing its corresponding resource
56  */

57 String JavaDoc getSource() throws JavaModelException;
58 /**
59  * Returns the source range associated with this element.
60  * <p>
61  * For class files, this returns the range of the entire compilation unit
62  * associated with the class file (if there is one).
63  * </p>
64  *
65  * @return the source range, or <code>null</code> if this element has no
66  * associated source code
67  * @exception JavaModelException if an exception occurs while accessing its corresponding resource
68  */

69 ISourceRange getSourceRange() throws JavaModelException;
70 }
71
Popular Tags