KickJava   Java API By Example, From Geeks To Geeks.

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


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 can be members of types.
15  * This set consists of <code>IType</code>, <code>IMethod</code>,
16  * <code>IField</code>, and <code>IInitializer</code>.
17  * <p>
18  * This interface is not intended to be implemented by clients.
19  * </p>
20  */

21 public interface IMember extends IJavaElement, ISourceReference, ISourceManipulation, IParent {
22 /**
23  * Returns the categories defined by this member's Javadoc. A category is the identifier
24  * following the tag <code>@category</code> in the member's Javadoc.
25  * Returns an empty array if no category is defined in this member's Javadoc.
26  *
27  * @return the categories defined by this member's doc
28  * @exception JavaModelException if this element does not exist or if an
29  * exception occurs while accessing its corresponding resource.
30  * @since 3.2
31  */

32 String JavaDoc[] getCategories() throws JavaModelException;
33 /**
34  * Returns the class file in which this member is declared, or <code>null</code>
35  * if this member is not declared in a class file (for example, a source type).
36  * This is a handle-only method.
37  *
38  * @return the class file in which this member is declared, or <code>null</code>
39  * if this member is not declared in a class file (for example, a source type)
40  */

41 IClassFile getClassFile();
42 /**
43  * Returns the compilation unit in which this member is declared, or <code>null</code>
44  * if this member is not declared in a compilation unit (for example, a binary type).
45  * This is a handle-only method.
46  *
47  * @return the compilation unit in which this member is declared, or <code>null</code>
48  * if this member is not declared in a compilation unit (for example, a binary type)
49  */

50 ICompilationUnit getCompilationUnit();
51 /**
52  * Returns the type in which this member is declared, or <code>null</code>
53  * if this member is not declared in a type (for example, a top-level type).
54  * This is a handle-only method.
55  *
56  * @return the type in which this member is declared, or <code>null</code>
57  * if this member is not declared in a type (for example, a top-level type)
58  */

59 IType getDeclaringType();
60 /**
61  * Returns the modifier flags for this member. The flags can be examined using class
62  * <code>Flags</code>.
63  * <p>
64  * Note that only flags as indicated in the source are returned. Thus if an interface
65  * defines a method <code>void myMethod();</code> the flags don't include the
66  * 'public' flag.
67  *
68  * @exception JavaModelException if this element does not exist or if an
69  * exception occurs while accessing its corresponding resource.
70  * @return the modifier flags for this member
71  * @see Flags
72  */

73 int getFlags() throws JavaModelException;
74 /**
75  * Returns the Javadoc range if this element is from source or if this element
76  * is a binary element with an attached source, null otherwise.
77  *
78  * <p>If this element is from source, the javadoc range is
79  * extracted from the corresponding source.</p>
80  * <p>If this element is from a binary, the javadoc is extracted from the
81  * attached source if present.</p>
82  * <p>If this element's openable is not consistent, then null is returned.</p>
83  *
84  * @exception JavaModelException if this element does not exist or if an
85  * exception occurs while accessing its corresponding resource.
86  * @return a source range corresponding to the javadoc source or <code>null</code>
87  * if no source is available, this element has no javadoc comment or
88  * this element's openable is not consistent
89  * @see IOpenable#isConsistent()
90  * @since 3.2
91  */

92 ISourceRange getJavadocRange() throws JavaModelException;
93 /**
94  * Returns the source range of this member's simple name,
95  * or <code>null</code> if this member does not have a name
96  * (for example, an initializer), or if this member does not have
97  * associated source code (for example, a binary type).
98  *
99  * @exception JavaModelException if this element does not exist or if an
100  * exception occurs while accessing its corresponding resource.
101  * @return the source range of this member's simple name,
102  * or <code>null</code> if this member does not have a name
103  * (for example, an initializer), or if this member does not have
104  * associated source code (for example, a binary type)
105  */

106 ISourceRange getNameRange() throws JavaModelException;
107 /**
108  * Returns the position relative to the order this member is defined in the source.
109  * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).
110  * <p>
111  * Two members m1 and m2 that are equal (e.g. 2 fields with the same name in
112  * the same type) can be distinguished using their occurrence counts. If member
113  * m1 appears first in the source, it will have an occurrence count of 1. If member
114  * m2 appears right after member m1, it will have an occurrence count of 2.
115  * </p><p>
116  * The occurrence count can be used to distinguish initializers inside a type
117  * or anonymous types inside a method.
118  * </p><p>
119  * This is a handle-only method. The member may or may not be present.
120  * </p>
121  *
122  * @return the position relative to the order this member is defined in the source
123  * @since 3.2
124  */

125 int getOccurrenceCount();
126 /**
127  * Returns the Java type root in which this member is declared.
128  * This is a handle-only method.
129  *
130  * @return the Java type root in which this member is declared.
131  * @since 3.3
132  */

133 ITypeRoot getTypeRoot();
134 /**
135  * Returns the local or anonymous type declared in this source member with the given simple name and/or
136  * with the specified position relative to the order they are defined in the source.
137  * The name is empty if it is an anonymous type.
138  * Numbering starts at 1 (thus the first occurrence is occurrence 1, not occurrence 0).
139  * This is a handle-only method. The type may or may not exist.
140  * Throws a <code>RuntimeException</code> if this member is not a source member.
141  *
142  * @param name the given simple name
143  * @param occurrenceCount the specified position
144  * @return the type with the given name and/or with the specified position relative to the order they are defined in the source
145  * @since 3.0
146  */

147 IType getType(String JavaDoc name, int occurrenceCount);
148 /**
149  * Returns whether this member is from a class file.
150  * This is a handle-only method.
151  *
152  * @return <code>true</code> if from a class file, and <code>false</code> if
153  * from a compilation unit
154  */

155 boolean isBinary();
156 }
157
Popular Tags