01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.casetool.patternimplementor;
12:
13: import java.util.ArrayList;
14:
15: public class PIParameters {
16:
17: ArrayList parameters;
18:
19: public PIParameters() {
20: parameters = new ArrayList();
21: }
22:
23: public void remove(int i) {
24: parameters.remove(i);
25: }
26:
27: public void set(int i, PIParameter pip) {
28: parameters.set(i, pip);
29: }
30:
31: public int size() {
32: return parameters.size();
33: }
34:
35: public void add(PIParameter pip) {
36: parameters.add(pip);
37: }
38:
39: public PIParameter get(int i) {
40: return (PIParameter) parameters.get(i);
41: }
42:
43: public PIParameter get(String internalName) {
44: for (int i = 0; i < size(); i++) {
45: //System.out.println("Comparing " +internalName + " with " +
46: // get(i).getInternalName());
47: if (get(i).getInternalName().equals(internalName)) {
48: //System.out.println("match!! "+internalName);
49: return get(i);
50: } else if (get(i) instanceof PIParameterGroup) {
51: //System.out.println(get(i)+" is PIParameterGroup
52: // "+internalName);
53: PIParameter tmp = ((PIParameterGroup) get(i))
54: .get(internalName);
55:
56: if (tmp == null) {
57: //System.out.println("group - no match!! " + internalName);
58: continue;
59: } else if (tmp.getInternalName().equals(internalName)) {
60: //System.out.println("group - match!! " +internalName);
61: return tmp;
62: }
63: }
64: }
65:
66: //System.out.println("couldn't find " + internalName);
67: return null;
68: }
69:
70: public void clear() {
71: parameters.clear();
72: }
73:
74: public String toString() {
75: String retval = new String();
76: retval = "{\n";
77:
78: for (int i = 0; i < size(); i++) {
79: retval = retval + /* get(i).getClass() +"\t"+ */
80: get(i).getInternalName() + get(i).getName() + "\n";
81:
82: if (get(i) instanceof PIParameterGroup) {
83: retval = retval
84: + ((PIParameterGroup) get(i)).toString();
85: }
86: }
87:
88: return retval + "}";
89: }
90: }
|