01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.databinding.datagrid.api.sort;
20:
21: /**
22: * <p>
23: * The Sort class is a JavaBean that abstractly represents the data needed to calculate a sort
24: * on some data set. A sort consists of some {@link String} expression and a {@link SortDirection}.
25: * The mechanism for performing the sort is not provided here.
26: * </p>
27: * <p>
28: * A Sort object can be used by some sorting infrastructure to either parameterise a SQL or XQuery
29: * query or to simply sort in-memory Java objects. For example, when converting a Sort into
30: * a SQL fragment, a Sort with sortExpression "foo" and sortDirection {@link SortDirection#DESCENDING} could
31: * be converted into:
32: * <pre>
33: * ORDER BY FOO DESC
34: * </pre>
35: * </p>
36: */
37: public class Sort implements java.io.Serializable {
38:
39: private String _sortExpression;
40: private SortDirection _sortDirection;
41:
42: /**
43: * Empty constructor.
44: */
45: public Sort() {
46: }
47:
48: /**
49: * Constructs a Sort with the given <code>sortExpression</code> and <code>sortDirection</code>.
50: *
51: * @param sortExpression the Sort's sort expression
52: * @param sortDirection the Sort's sort direction
53: */
54: public Sort(String sortExpression, SortDirection sortDirection) {
55: this ();
56: _sortExpression = sortExpression;
57: _sortDirection = sortDirection;
58: }
59:
60: /**
61: * Get the sort expression
62: * @return the sort expression
63: */
64: public String getSortExpression() {
65: return _sortExpression;
66: }
67:
68: /**
69: * Set the sort expression
70: * @param expression the sort expression
71: */
72: public void setSortExpression(String expression) {
73: _sortExpression = expression;
74: }
75:
76: /**
77: * Get the {@link SortDirection}
78: * @return the sort direction
79: */
80: public SortDirection getDirection() {
81: return _sortDirection;
82: }
83:
84: /**
85: * Set the {@link SortDirection}
86: * @param sortDirection the sort direction
87: */
88: public void setDirection(SortDirection sortDirection) {
89: _sortDirection = sortDirection;
90: }
91: }
|