View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.services.fieldquery;
20  
21  /**
22   * Represents a single sort criteria for sorting query results.
23   * Each MCRSortBy defines one field to sort by, and the order
24   * (ascending or descending).
25   *  
26   * @author Frank Lützenkirchen
27   */
28  public class MCRSortBy {
29      /** Sort this field in ascending order */
30      public static final boolean ASCENDING = true;
31  
32      /** Sort this field in descending order */
33      public static final boolean DESCENDING = false;
34  
35      /** The field to sort by */
36      private String fieldName;
37  
38      /** Sort order of this field */
39      private boolean order = ASCENDING;
40  
41      /** 
42       * Creates a new sort criteria
43       * 
44       * @param fieldName the field to sort by
45       * @param order the sort order (ascending or descending)
46       * 
47       * @see #ASCENDING
48       * @see #DESCENDING
49       */
50      public MCRSortBy(String fieldName, boolean order) {
51          this.fieldName = fieldName;
52          this.order = order;
53      }
54  
55      public String getFieldName() {
56          return fieldName;
57      }
58  
59      /**
60       * Returns the sort order for this field.
61       * 
62       * @see #ASCENDING
63       * @see #DESCENDING
64       * 
65       * @return true when order is {@link MCRSortBy#ASCENDING} or false whenorder is {@link MCRSortBy#DESCENDING} 
66       */
67      public boolean getSortOrder() {
68          return order;
69      }
70  }