KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > SingleTypeRequestor


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.internal.core;
12
13 import org.eclipse.jdt.core.IField;
14 import org.eclipse.jdt.core.IInitializer;
15 import org.eclipse.jdt.core.IMethod;
16 import org.eclipse.jdt.core.IPackageFragment;
17 import org.eclipse.jdt.core.IType;
18
19 /**
20  * The SingleTypeRequestor is an IJavaElementRequestor that
21  * only accepts one result element and then cancels.
22  */

23 /* package */ class SingleTypeRequestor implements IJavaElementRequestor {
24     /**
25      * The single accepted element
26      */

27     protected IType fElement= null;
28 /**
29  * @see IJavaElementRequestor
30  */

31 public void acceptField(IField field) {
32     // implements interface method
33
}
34 /**
35  * @see IJavaElementRequestor
36  */

37 public void acceptInitializer(IInitializer initializer) {
38     // implements interface method
39
}
40 /**
41  * @see IJavaElementRequestor
42  */

43 public void acceptMemberType(IType type) {
44     fElement= type;
45 }
46 /**
47  * @see IJavaElementRequestor
48  */

49 public void acceptMethod(IMethod method) {
50     // implements interface method
51
}
52 /**
53  * @see IJavaElementRequestor
54  */

55 public void acceptPackageFragment(IPackageFragment packageFragment) {
56     // implements interface method
57
}
58 /**
59  * @see IJavaElementRequestor
60  */

61 public void acceptType(IType type) {
62     fElement= type;
63 }
64 /**
65  * Returns the type accepted by this requestor, or <code>null</code>
66  * if no type has been accepted.
67  */

68 public IType getType() {
69     return fElement;
70 }
71 /**
72  * @see IJavaElementRequestor
73  */

74 public boolean isCanceled() {
75     return fElement != null;
76 }
77 /**
78  * Reset the state of this requestor
79  */

80 public void reset() {
81     fElement= null;
82 }
83 }
84
Popular Tags