01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.uilib.list.structure.order;
16:
17: import java.util.Comparator;
18: import org.araneaframework.Environment;
19: import org.araneaframework.backend.list.memorybased.ComparatorExpression;
20: import org.araneaframework.backend.list.memorybased.compexpr.VariableComparatorExpression;
21: import org.araneaframework.uilib.list.OrderInfo;
22:
23: /**
24: * @author Rein Raudjärv
25: */
26: public class SimpleFieldOrder implements FieldOrder {
27:
28: private static final long serialVersionUID = 1L;
29:
30: private String fieldId;
31: private Comparator comparator;
32:
33: public SimpleFieldOrder(String fieldId, Comparator comparator) {
34: setFieldId(fieldId);
35: setComparator(comparator);
36: }
37:
38: public SimpleFieldOrder(String fieldId) {
39: this (fieldId, null);
40: }
41:
42: public String getFieldId() {
43: return this .fieldId;
44: }
45:
46: public void setFieldId(String id) {
47: this .fieldId = id;
48: }
49:
50: public Comparator getComparator() {
51: return comparator;
52: }
53:
54: public void setComparator(Comparator comparator) {
55: this .comparator = comparator;
56: }
57:
58: public void init(Environment env) {
59: }
60:
61: public void destroy() {
62: }
63:
64: public ComparatorExpression buildComparatorExpression(
65: OrderInfo orderInfo) {
66: if (this .fieldId == null) {
67: throw new RuntimeException("Column Id must be provided");
68: }
69: return new VariableComparatorExpression(getFieldId(),
70: getComparator());
71: }
72: }
|