|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| package edu.rice.cs.drjava.config; |
|
38 |
| |
|
39 |
| import edu.rice.cs.plt.lambda.Lambda4; |
|
40 |
| import edu.rice.cs.plt.lambda.Lambda; |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| public class QuaternaryOpProperty<N,O,P,Q,R> extends EagerProperty { |
|
46 |
| |
|
47 |
| protected Lambda4<N,O,P,Q,R> _op; |
|
48 |
| |
|
49 |
| protected String _op1Name; |
|
50 |
| |
|
51 |
| protected String _op1Default; |
|
52 |
| |
|
53 |
| protected String _op2Name; |
|
54 |
| |
|
55 |
| protected String _op2Default; |
|
56 |
| |
|
57 |
| protected String _op3Name; |
|
58 |
| |
|
59 |
| protected String _op3Default; |
|
60 |
| |
|
61 |
| protected String _op4Name; |
|
62 |
| |
|
63 |
| protected String _op4Default; |
|
64 |
| |
|
65 |
| protected Lambda<String,N> _parse1; |
|
66 |
| |
|
67 |
| protected Lambda<String,O> _parse2; |
|
68 |
| |
|
69 |
| protected Lambda<String,P> _parse3; |
|
70 |
| |
|
71 |
| protected Lambda<String,Q> _parse4; |
|
72 |
| |
|
73 |
| protected Lambda<R,String> _format; |
|
74 |
| |
|
75 |
| |
|
76 |
46
| public QuaternaryOpProperty(String name,
|
|
77 |
| String help, |
|
78 |
| Lambda4<N,O,P,Q,R> op, |
|
79 |
| String op1Name, |
|
80 |
| String op1Default, |
|
81 |
| Lambda<String,N> parse1, |
|
82 |
| String op2Name, |
|
83 |
| String op2Default, |
|
84 |
| Lambda<String,O> parse2, |
|
85 |
| String op3Name, |
|
86 |
| String op3Default, |
|
87 |
| Lambda<String,P> parse3, |
|
88 |
| String op4Name, |
|
89 |
| String op4Default, |
|
90 |
| Lambda<String,Q> parse4, |
|
91 |
| Lambda<R,String> format) { |
|
92 |
46
| super(name, help);
|
|
93 |
46
| _op = op;
|
|
94 |
46
| _op1Name = op1Name;
|
|
95 |
46
| _op1Default = op1Default;
|
|
96 |
46
| _parse1 = parse1;
|
|
97 |
46
| _op2Name = op2Name;
|
|
98 |
46
| _op2Default = op2Default;
|
|
99 |
46
| _parse2 = parse2;
|
|
100 |
46
| _op3Name = op3Name;
|
|
101 |
46
| _op3Default = op3Default;
|
|
102 |
46
| _parse3 = parse3;
|
|
103 |
46
| _op4Name = op4Name;
|
|
104 |
46
| _op4Default = op4Default;
|
|
105 |
46
| _parse4 = parse4;
|
|
106 |
46
| _format = format;
|
|
107 |
46
| resetAttributes();
|
|
108 |
| } |
|
109 |
| |
|
110 |
| |
|
111 |
0
| public QuaternaryOpProperty(String name,
|
|
112 |
| String help, |
|
113 |
| Lambda4<N,O,P,Q,R> op, |
|
114 |
| Lambda<String,N> parse1, |
|
115 |
| Lambda<String,O> parse2, |
|
116 |
| Lambda<String,P> parse3, |
|
117 |
| Lambda<String,Q> parse4, |
|
118 |
| Lambda<R,String> format) { |
|
119 |
0
| this(name,help,op,"op1",null,parse1,"op2",null,parse2,"op3",null,parse3,"op4",null,parse4,format);
|
|
120 |
| } |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
51
| public void update(PropertyMaps pm) {
|
|
125 |
51
| N op1;
|
|
126 |
51
| if (_attributes.get(_op1Name) == null) {
|
|
127 |
2
| _value = "(" + _name + " Error...)";
|
|
128 |
2
| return;
|
|
129 |
| } |
|
130 |
| else { |
|
131 |
49
| try {
|
|
132 |
49
| op1 = _parse1.value(_attributes.get(_op1Name));
|
|
133 |
| } |
|
134 |
| catch(Exception e) { |
|
135 |
0
| _value = "(" + _name + " Error...)";
|
|
136 |
0
| return;
|
|
137 |
| } |
|
138 |
| } |
|
139 |
49
| O op2;
|
|
140 |
49
| if (_attributes.get(_op2Name) == null) {
|
|
141 |
1
| _value = "(" + _name + " Error...)";
|
|
142 |
1
| return;
|
|
143 |
| } |
|
144 |
| else { |
|
145 |
48
| try {
|
|
146 |
48
| op2 = _parse2.value(_attributes.get(_op2Name));
|
|
147 |
| } |
|
148 |
| catch(Exception e) { |
|
149 |
0
| _value = "(" + _name + " Error...)";
|
|
150 |
0
| return;
|
|
151 |
| } |
|
152 |
| } |
|
153 |
48
| P op3;
|
|
154 |
48
| if (_attributes.get(_op3Name) == null) {
|
|
155 |
0
| _value = "(" + _name + " Error...)";
|
|
156 |
0
| return;
|
|
157 |
| } |
|
158 |
| else { |
|
159 |
48
| try {
|
|
160 |
48
| op3 = _parse3.value(_attributes.get(_op3Name));
|
|
161 |
| } |
|
162 |
| catch(Exception e) { |
|
163 |
0
| _value = "(" + _name + " Error...)";
|
|
164 |
0
| return;
|
|
165 |
| } |
|
166 |
| } |
|
167 |
48
| Q op4;
|
|
168 |
48
| if (_attributes.get(_op4Name) == null) {
|
|
169 |
0
| _value = "(" + _name + " Error...)";
|
|
170 |
0
| return;
|
|
171 |
| } |
|
172 |
| else { |
|
173 |
48
| try {
|
|
174 |
48
| op4 = _parse4.value(_attributes.get(_op4Name));
|
|
175 |
| } |
|
176 |
| catch(Exception ee) { |
|
177 |
0
| _value = "(" + _name + " Error...)";
|
|
178 |
0
| return;
|
|
179 |
| } |
|
180 |
| } |
|
181 |
48
| _value = _format.value(_op.value(op1,op2,op3,op4));
|
|
182 |
| } |
|
183 |
| |
|
184 |
96
| public void resetAttributes() {
|
|
185 |
96
| _attributes.clear();
|
|
186 |
96
| _attributes.put(_op1Name, _op1Default);
|
|
187 |
96
| _attributes.put(_op2Name, _op2Default);
|
|
188 |
96
| _attributes.put(_op3Name, _op3Default);
|
|
189 |
96
| _attributes.put(_op4Name, _op4Default);
|
|
190 |
| } |
|
191 |
| } |