1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.database.function.criteria;
17
18 public class SubcriteriaFunction extends AbstractCriteriaFunction {
19
20 private CriteriaFunction sequentialFunction_;
21
22 public SubcriteriaFunction() {
23 super();
24 }
25
26 public SubcriteriaFunction(String field) {
27 super(field);
28 }
29
30 public SubcriteriaFunction(String field, CriteriaFunction sequentialFunction) {
31 super(field);
32 setSequentialFunction(sequentialFunction);
33 }
34
35 public void setSequentialFunction(CriteriaFunction function) {
36 this.sequentialFunction_ = function;
37 }
38
39 public CriteriaFunction getSequentialFunction() {
40 return sequentialFunction_;
41 }
42
43 public Object evaluate(ICriteria criteria) {
44 ICriteria subcriteria = criteria.createCriteria(getField());
45 ((UnaryCriteriaFunction) sequentialFunction_).evaluate(subcriteria);
46 return criteria;
47 }
48
49 public Object evaluate(ICriteria criteria, Object value) {
50 if (value == null || "".equals(value)) {
51 return criteria;
52 }
53 ICriteria subcriteria = criteria.createCriteria(getField());
54 ((BinaryCriteriaFunction) sequentialFunction_).evaluate(subcriteria,
55 value);
56 return criteria;
57 }
58
59 public String getNestedAttrName() {
60 String childAttrName = null;
61 if (sequentialFunction_ instanceof SubcriteriaFunction) {
62 childAttrName = ((SubcriteriaFunction) sequentialFunction_)
63 .getNestedAttrName();
64 } else {
65 childAttrName = sequentialFunction_.getField();
66 }
67 return getField() + "." + childAttrName;
68 }
69 }