001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.uilib.list.structure.filter.advanced;
016:
017: import java.util.Map;
018: import org.apache.commons.lang.Validate;
019: import org.araneaframework.backend.list.memorybased.expression.constant.ValueExpression;
020: import org.araneaframework.backend.list.memorybased.expression.variable.VariableExpression;
021: import org.araneaframework.uilib.list.structure.filter.BaseFilter;
022: import org.araneaframework.uilib.list.util.ExpressionUtil;
023:
024: public abstract class BaseRangeInRangeFilter extends BaseFilter {
025:
026: private static final long serialVersionUID = 1L;
027:
028: // Fields
029: private String lowFieldId;
030: private String highFieldId;
031:
032: // Values
033: private String lowValueId;
034: private String highValueId;
035:
036: public String getLowFieldId() {
037: return this .lowFieldId;
038: }
039:
040: public void setLowFieldId(String lowFieldId) {
041: Validate.notNull(lowFieldId);
042: this .lowFieldId = lowFieldId;
043: }
044:
045: public String getHighFieldId() {
046: return highFieldId;
047: }
048:
049: public void setHighFieldId(String highFieldId) {
050: Validate.notNull(highFieldId);
051: this .highFieldId = highFieldId;
052: }
053:
054: public String getHighValueId() {
055: return this .highValueId;
056: }
057:
058: public void setHighValueId(String highValueId) {
059: this .highValueId = highValueId;
060: }
061:
062: public String getLowValueId() {
063: return this .lowValueId;
064: }
065:
066: public void setLowValueId(String lowValueId) {
067: this .lowValueId = lowValueId;
068: }
069:
070: // Building expressions
071:
072: protected boolean isActive(Map filterInfo) {
073: return filterInfo.containsKey(getLowValueId())
074: || filterInfo.containsKey(getHighValueId());
075: }
076:
077: protected VariableExpression buildLowVariableExpression() {
078: return ExpressionUtil.var(getLowFieldId());
079: }
080:
081: protected VariableExpression buildHighVariableExpression() {
082: return ExpressionUtil.var(getHighFieldId());
083: }
084:
085: protected ValueExpression buildLowValueExpression(Map filterInfo) {
086: Object value = filterInfo.get(getLowValueId());
087: if (value == null) {
088: return null;
089: }
090: value = convertLowValue(value);
091: return ExpressionUtil.value(getLowValueId(), value);
092: }
093:
094: protected ValueExpression buildHighValueExpression(Map filterInfo) {
095: Object value = filterInfo.get(getHighValueId());
096: if (value == null) {
097: return null;
098: }
099: value = convertHighValue(value);
100: return ExpressionUtil.value(getHighValueId(), value);
101: }
102:
103: protected Object convertLowValue(Object value) {
104: return value;
105: }
106:
107: protected Object convertHighValue(Object value) {
108: return value;
109: }
110: }
|