01: package net.sf.jdec.lookup;
02:
03: /*
04: * FinderFactory.java Copyright (c) 2006,07 Swaroop Belur
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10:
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15:
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19: *
20: */
21:
22: public class FinderFactory {
23:
24: private static final String UNKNOWN_FINDER_TYPE = "No Finder for the passed finder type";
25:
26: public static IFinder getFinder(int finderType) {
27:
28: IFinder finder = null;
29:
30: switch (finderType) {
31:
32: case IFinder.LOAD:
33: finder = LoadInstrFinder.loadFinder;
34: break;
35:
36: case IFinder.STORE:
37: finder = StoreInstrFinder.storeFinder;
38: break;
39:
40: case IFinder.BRANCH:
41: finder = BranchInstrFinder.branchFinder;
42: break;
43:
44: case IFinder.TRY:
45: finder = TryInstrFinder.tryFinder;
46: break;
47:
48: case IFinder.BASE:
49: finder = GenericFinder.genericFinder;
50: break;
51: default:
52: throw new IllegalArgumentException(UNKNOWN_FINDER_TYPE);
53: }
54:
55: return finder;
56:
57: }
58:
59: }
|