1 /***
2 Copyright (C) 2005 The Java Community
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place, Suite 330, Boston, MA 02111-1307 USA.
16
17 */
18 package org.bejug.javacareers.common.search;
19
20 /***
21 * Order-class which is used for adding ordering to our searchcriteria.
22 * @author Bart Meyers (last modified by $Author: shally $)
23 * @version $Revision: 1.2 $ $Date: 2005/12/20 15:36:43 $
24 *
25 */
26 public class Order {
27
28 /***
29 * constant for ascending ordering.
30 */
31 public static final String ASC = "ascending";
32
33 /***
34 * constant for descending ordering.
35 */
36 public static final String DESC = "descending";
37
38
39 /***
40 * the ordering to be used. Default is descending.
41 */
42 private String ordering = Order.DESC;
43
44 /***
45 * the field to order on.
46 */
47 private String field = null;
48
49
50 /***
51 * @return a String indicating the field to order on.
52 */
53 public String getField() {
54 return field;
55 }
56
57 /***
58 * @param field a String indicating the field to order on.
59 */
60 public void setField(String field) {
61 this.field = field;
62 }
63
64 /***
65 * @return the ordering used.
66 */
67 public String getOrdering() {
68 return ordering;
69 }
70
71 /***
72 * @param ordering the ordering to use.
73 */
74 public void setOrdering(String ordering) {
75 if ( Order.ASC.equals(ordering) || Order.DESC.equals(ordering)) {
76 this.ordering = ordering;
77 }
78 }
79
80
81 /***
82 * Constructor for descending ordering.
83 * @param field a String indicating the field to order on.
84 */
85 public Order(String field) {
86 this.field = field;
87 }
88
89 /***
90 * Constructor.
91 * If the ordering is not equal to the two defined constants, we use
92 * DESC.
93 * @param field a String indicating the field to order on.
94 * @param ordering the ordering to use.
95 */
96 public Order(String field, String ordering) {
97 if ( Order.ASC.equals(ordering) || Order.DESC.equals(ordering)) {
98 this.ordering = ordering;
99 }
100 this.field = field;
101 }
102
103
104 }
105 /***
106 * $Log: Order.java,v $
107 * Revision 1.2 2005/12/20 15:36:43 shally
108 * CheckStyle and PMD changes.
109 *
110 * Revision 1.1 2005/08/26 07:58:25 ge0ffrey
111 * split up the sources in service, serviceimpl and webclient
112 *
113 * Revision 1.1 2005/08/11 13:04:30 bme_jcs
114 * update searchCriteria to support ordering and paging
115 *
116 */