1 11 package org.eclipse.jdt.internal.core; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.jdt.core.IField; 16 import org.eclipse.jdt.core.IInitializer; 17 import org.eclipse.jdt.core.IMethod; 18 import org.eclipse.jdt.core.IPackageFragment; 19 import org.eclipse.jdt.core.IType; 20 21 24 25 public class JavaElementRequestor implements IJavaElementRequestor { 26 30 protected boolean fCanceled= false; 31 32 36 protected ArrayList fFields= null; 37 38 42 protected ArrayList fInitializers= null; 43 44 48 protected ArrayList fMemberTypes= null; 49 50 54 protected ArrayList fMethods= null; 55 56 60 protected ArrayList fPackageFragments= null; 61 62 66 protected ArrayList fTypes= null; 67 68 71 protected static IField[] fgEmptyFieldArray= new IField[0]; 72 protected static IInitializer[] fgEmptyInitializerArray= new IInitializer[0]; 73 protected static IType[] fgEmptyTypeArray= new IType[0]; 74 protected static IPackageFragment[] fgEmptyPackageFragmentArray= new IPackageFragment[0]; 75 protected static IMethod[] fgEmptyMethodArray= new IMethod[0]; 76 79 public void acceptField(IField field) { 80 if (fFields == null) { 81 fFields= new ArrayList (); 82 } 83 fFields.add(field); 84 } 85 88 public void acceptInitializer(IInitializer initializer) { 89 if (fInitializers == null) { 90 fInitializers= new ArrayList (); 91 } 92 fInitializers.add(initializer); 93 } 94 97 public void acceptMemberType(IType type) { 98 if (fMemberTypes == null) { 99 fMemberTypes= new ArrayList (); 100 } 101 fMemberTypes.add(type); 102 } 103 106 public void acceptMethod(IMethod method) { 107 if (fMethods == null) { 108 fMethods = new ArrayList (); 109 } 110 fMethods.add(method); 111 } 112 115 public void acceptPackageFragment(IPackageFragment packageFragment) { 116 if (fPackageFragments== null) { 117 fPackageFragments= new ArrayList (); 118 } 119 fPackageFragments.add(packageFragment); 120 } 121 124 public void acceptType(IType type) { 125 if (fTypes == null) { 126 fTypes= new ArrayList (); 127 } 128 fTypes.add(type); 129 } 130 133 public IField[] getFields() { 134 if (fFields == null) { 135 return fgEmptyFieldArray; 136 } 137 int size = fFields.size(); 138 IField[] results = new IField[size]; 139 fFields.toArray(results); 140 return results; 141 } 142 145 public IInitializer[] getInitializers() { 146 if (fInitializers == null) { 147 return fgEmptyInitializerArray; 148 } 149 int size = fInitializers.size(); 150 IInitializer[] results = new IInitializer[size]; 151 fInitializers.toArray(results); 152 return results; 153 } 154 157 public IType[] getMemberTypes() { 158 if (fMemberTypes == null) { 159 return fgEmptyTypeArray; 160 } 161 int size = fMemberTypes.size(); 162 IType[] results = new IType[size]; 163 fMemberTypes.toArray(results); 164 return results; 165 } 166 169 public IMethod[] getMethods() { 170 if (fMethods == null) { 171 return fgEmptyMethodArray; 172 } 173 int size = fMethods.size(); 174 IMethod[] results = new IMethod[size]; 175 fMethods.toArray(results); 176 return results; 177 } 178 181 public IPackageFragment[] getPackageFragments() { 182 if (fPackageFragments== null) { 183 return fgEmptyPackageFragmentArray; 184 } 185 int size = fPackageFragments.size(); 186 IPackageFragment[] results = new IPackageFragment[size]; 187 fPackageFragments.toArray(results); 188 return results; 189 } 190 193 public IType[] getTypes() { 194 if (fTypes== null) { 195 return fgEmptyTypeArray; 196 } 197 int size = fTypes.size(); 198 IType[] results = new IType[size]; 199 fTypes.toArray(results); 200 return results; 201 } 202 205 public boolean isCanceled() { 206 return fCanceled; 207 } 208 211 public void reset() { 212 fCanceled = false; 213 fFields = null; 214 fInitializers = null; 215 fMemberTypes = null; 216 fMethods = null; 217 fPackageFragments = null; 218 fTypes = null; 219 } 220 223 public void setCanceled(boolean b) { 224 fCanceled= b; 225 } 226 } 227 | Popular Tags |