01: package org.drools.brms.client.modeldriven.brl;
02:
03: /**
04: * A fact pattern is a declaration of a fact type, and its constraint,
05: * and perhaps a variable that is it bound to
06: * It is the equivalent of a "pattern" in drools terms.
07: * @author Michael Neale
08: *
09: */
10: public class FactPattern implements IPattern {
11:
12: public CompositeFieldConstraint constraintList;
13: public String factType;
14: public String boundName;
15:
16: public FactPattern() {
17: //this.constraints = new CompositeFieldConstraint();
18: }
19:
20: public FactPattern(final String factType) {
21: this .factType = factType;
22: //this.constraints = new CompositeFieldConstraint();
23: }
24:
25: /**
26: * This will add a top level constraint.
27: */
28: public void addConstraint(final FieldConstraint constraint) {
29: if (constraintList == null)
30: constraintList = new CompositeFieldConstraint();
31: this .constraintList.addConstraint(constraint);
32: }
33:
34: public void removeConstraint(final int idx) {
35: this .constraintList.removeConstraint(idx);
36: }
37:
38: /**
39: * Returns true if there is a variable bound to this fact.
40: */
41: public boolean isBound() {
42: if (this .boundName != null && !"".equals(this .boundName)) {
43: return true;
44: } else {
45: return false;
46: }
47: }
48:
49: /**
50: * This will return the list of field constraints that are in the root
51: * CompositeFieldConstraint object.
52: * If there is no root, then an empty array will be returned.
53: *
54: * @return an empty array, or the list of constraints (which may be composites).
55: */
56: public FieldConstraint[] getFieldConstraints() {
57: if (this .constraintList == null) {
58: return new FieldConstraint[0];
59: } else {
60: return this.constraintList.constraints;
61: }
62: }
63:
64: }
|