1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.api.search;
17
18 import org.apache.commons.lang.StringUtils;
19
20
21
22
23 public class Range {
24 private String lowerBoundValue;
25 private String upperBoundValue;
26 private boolean lowerBoundInclusive = true;
27 private boolean upperBoundInclusive = true;
28
29 public String getLowerBoundValue() {
30 return lowerBoundValue;
31 }
32
33 public void setLowerBoundValue(String lowerBoundValue) {
34 this.lowerBoundValue = lowerBoundValue;
35 }
36
37 public String getUpperBoundValue() {
38 return upperBoundValue;
39 }
40
41 public void setUpperBoundValue(String upperBoundValue) {
42 this.upperBoundValue = upperBoundValue;
43 }
44
45 public boolean isLowerBoundInclusive() {
46 return lowerBoundInclusive;
47 }
48
49 public void setLowerBoundInclusive(boolean lowerBoundInclusive) {
50 this.lowerBoundInclusive = lowerBoundInclusive;
51 }
52
53 public boolean isUpperBoundInclusive() {
54 return upperBoundInclusive;
55 }
56
57 public void setUpperBoundInclusive(boolean upperBoundInclusive) {
58 this.upperBoundInclusive = upperBoundInclusive;
59 }
60
61 public String toString() {
62 if (StringUtils.isNotEmpty(lowerBoundValue) && StringUtils.isNotEmpty(upperBoundValue)) {
63 SearchOperator op;
64 if (lowerBoundInclusive && upperBoundInclusive) {
65 op = SearchOperator.BETWEEN;
66 } else if (lowerBoundInclusive && !upperBoundInclusive) {
67 op = SearchOperator.BETWEEN_EXCLUSIVE_UPPER2;
68 } else if (!lowerBoundInclusive && upperBoundInclusive) {
69 op = SearchOperator.BETWEEN_EXCLUSIVE_LOWER;
70 } else {
71 op = SearchOperator.BETWEEN_EXCLUSIVE;
72 }
73 return lowerBoundValue + op.op() + upperBoundValue;
74 } else if (StringUtils.isNotEmpty(lowerBoundValue) && StringUtils.isEmpty(upperBoundValue)) {
75 SearchOperator op = lowerBoundInclusive ? SearchOperator.GREATER_THAN_EQUAL : SearchOperator.GREATER_THAN;
76 return op.op() + lowerBoundValue;
77 } else if (StringUtils.isNotEmpty(upperBoundValue) && StringUtils.isEmpty(lowerBoundValue)) {
78 SearchOperator op = upperBoundInclusive ? SearchOperator.LESS_THAN_EQUAL : SearchOperator.LESS_THAN;
79 return op.op() + upperBoundValue;
80 } else {
81 return "";
82 }
83 }
84 }