01: package org.drools.brms.client.modeldriven.brl;
02:
03: /**
04: * This represents a contraint on a fact - involving a SINGLE FIELD.
05: *
06: * Can also include optional "connective constraints" that extend the options for matches.
07: * @author Michael Neale
08: */
09: public class SingleFieldConstraint extends ISingleFieldConstraint
10: implements FieldConstraint {
11:
12: public String fieldBinding;
13: public String fieldName;
14: public String operator;
15:
16: public ConnectiveConstraint[] connectives;
17:
18: public SingleFieldConstraint(final String field) {
19: this .fieldName = field;
20: }
21:
22: public SingleFieldConstraint() {
23: }
24:
25: /**
26: * This adds a new connective.
27: *
28: */
29: public void addNewConnective() {
30: if (this .connectives == null) {
31: this .connectives = new ConnectiveConstraint[] { new ConnectiveConstraint() };
32: } else {
33: final ConnectiveConstraint[] newList = new ConnectiveConstraint[this .connectives.length + 1];
34: for (int i = 0; i < this .connectives.length; i++) {
35: newList[i] = this .connectives[i];
36: }
37: newList[this .connectives.length] = new ConnectiveConstraint();
38: this .connectives = newList;
39: }
40: }
41:
42: /**
43: * Returns true of there is a field binding.
44: */
45: public boolean isBound() {
46: if (this .fieldBinding != null && !"".equals(this .fieldBinding)) {
47: return true;
48: } else {
49: return false;
50: }
51: }
52:
53: }
|