01: package org.drools.brms.client.modeldriven.brl;
02:
03: /**
04: * This class is the parent for field setting or assertion actions.
05: *
06: * Contains the list of fields and their values to be set.
07: *
08: * @author Michael Neale
09: *
10: */
11: public abstract class ActionFieldList implements IAction {
12:
13: public ActionFieldValue[] fieldValues = new ActionFieldValue[0];
14:
15: public void removeField(final int idx) {
16: //Unfortunately, this is kinda duplicate code with other methods,
17: //but with typed arrays, and GWT, its not really possible to do anything "better"
18: //at this point in time.
19: final ActionFieldValue[] newList = new ActionFieldValue[this .fieldValues.length - 1];
20: int newIdx = 0;
21: for (int i = 0; i < this .fieldValues.length; i++) {
22:
23: if (i != idx) {
24: newList[newIdx] = this .fieldValues[i];
25: newIdx++;
26: }
27:
28: }
29: this .fieldValues = newList;
30: }
31:
32: public void addFieldValue(final ActionFieldValue val) {
33: if (this .fieldValues == null) {
34: this .fieldValues = new ActionFieldValue[1];
35: this .fieldValues[0] = val;
36: } else {
37: final ActionFieldValue[] newList = new ActionFieldValue[this .fieldValues.length + 1];
38: for (int i = 0; i < this.fieldValues.length; i++) {
39: newList[i] = this.fieldValues[i];
40: }
41: newList[this.fieldValues.length] = val;
42: this.fieldValues = newList;
43: }
44: }
45:
46: }
|