01: /*
02: * LocalVariableHelper.java Copyright (c) 2006,07 Swaroop Belur
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08:
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13:
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17: *
18: */
19:
20: package net.sf.jdec.core;
21:
22: import java.util.ArrayList;
23:
24: import net.sf.jdec.commonutil.Objects;
25: import net.sf.jdec.main.ConsoleLauncher;
26:
27: /***
28: * TODO: Move all variabled utility methods over here.
29: * @author sbelur
30: *
31: */
32: public class LocalVariableHelper {
33:
34: public static boolean checkForVariableExistenceWithName(String name) {
35: ArrayList atfront = GlobalVariableStore.getVariablesatfront();
36: if (Objects.isNullOrEmpty(atfront)) {
37: return false;
38: }
39: for (int i = 0; i < atfront.size(); i++) {
40: DecompilerHelper.VariableAtFront v = (DecompilerHelper.VariableAtFront) atfront
41: .get(i);
42: if (v.getName().equals(name)) {
43: return true;
44: }
45: }
46: return false;
47: }
48:
49: public static boolean simpleTypeAlreadyAddedToImports(String type,
50: StringBuffer fulltype) {
51:
52: ArrayList list = ConsoleLauncher.getAllImportedClasses();
53: for (int s = 0; s < list.size(); s++) {
54: String str = (String) list.get(s);
55: if (str != null) {
56:
57: int index = str.lastIndexOf(".");
58: if (index != -1) {
59: String simple = str.substring(index + 1);
60: if (simple.trim().equals(type.trim())) {
61: fulltype.append(str);
62: return true;
63: }
64: }
65: }
66: }
67:
68: return false;
69: }
70: }
|