View Javadoc
1   /*
2    * ObjectLab, http://www.objectlab.co.uk/open is supporting FlatPack.
3    *
4    * Based in London, we are world leaders in the design and development
5    * of bespoke applications for the securities financing markets.
6    *
7    * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8    *           ___  _     _           _   _          _
9    *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
10   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
11   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
12   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13   *                   |__/
14   *
15   *                     www.ObjectLab.co.uk
16   *
17   * $Id: ColorProvider.java 74 2006-10-24 22:19:05Z benoitx $
18   *
19   * Copyright 2006 the original author or authors.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22   * use this file except in compliance with the License. You may obtain a copy of
23   * the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations under
31   * the License.
32   */
33  package net.sf.flatpack.ordering;
34  
35  /**
36   * @author paul zepernick
37   *
38   * Used in conjunction with the OrderBy class. Holds the name of the column to
39   * order by and the direction the order should go, ASC, DESC.
40   *
41   * @version 2.0
42   */
43  public class OrderColumn {
44  
45      /**Specifies descending sort order*/
46      public static final boolean DESC = true;
47  
48      /**Specifies Ascending sort order*/
49      public static final boolean ASC = false;
50  
51      /**string sort indicator*/
52      public static final int COLTYPE_STRING = 0;
53  
54      /**date sort indicator*/
55      public static final int COLTYPE_DATE = 1;
56  
57      /**numeric sort indicator*/
58      public static final int COLTYPE_NUMERIC = 2;
59  
60      // property name to sort by
61      private String columnName;
62  
63      // 1 = ASC -1 = DESC
64      private int sortIndicator = 1;
65  
66      private int selectedColType;
67  
68      private String dateFormatPattern = "yyyyMMdd";
69  
70      /**
71       * Constructs a new order by element
72       *
73       * @param columnName
74       *            column to sort by
75       * @param desc
76       *            boolean sort DESC.  OrderColumn.DESC, OrderColumn.ASC
77       * @param colType
78       *            Type of column to be sorted: OrderColumn.COLTYPE_STRING,OrderColumn.COLTYPE_DATE, OrderColum.COLTYPE_NUMERIC
79       */
80      public OrderColumn(final String columnName, final boolean desc, final int colType) {
81          this.columnName = columnName;
82          this.selectedColType = colType;
83  
84          if (desc) {
85              this.sortIndicator = -1;
86          }
87      }
88  
89      /**
90       * Constructs a new order by element
91       *
92       * @param columnName
93       *            column to sort by
94       * @param desc
95       *            boolean sort DESC.  OrderColumn.DESC, OrderColumn.ASC
96       */
97      public OrderColumn(final String columnName, final boolean desc) {
98          this(columnName, desc, OrderColumn.COLTYPE_STRING);
99      }
100 
101     /**
102      * @return Returns the propertyName.
103      */
104     public String getColumnName() {
105         return columnName;
106     }
107 
108     /**
109      * @param columnName
110      *            The columnName to set.
111      */
112     public void setColumnName(final String columnName) {
113         this.columnName = columnName;
114     }
115 
116     /**
117      * @return Returns the sortIndicator.
118      */
119     public int getSortIndicator() {
120         return sortIndicator;
121     }
122 
123     /**
124      * @return the selectedColType
125      */
126     public int getSelectedColType() {
127         return selectedColType;
128     }
129 
130     /**
131      * @param selectedColType the selectedColType to set
132      */
133     public void setSelectedColType(final int selectedColType) {
134         this.selectedColType = selectedColType;
135     }
136 
137     /**
138      * Format pattern to use to parse dates for sorting.  Default is yyyyMMdd
139      *
140      * @return the dateFormatPattern
141      */
142     public String getDateFormatPattern() {
143         return dateFormatPattern;
144     }
145 
146     /**
147      * Format pattern to use to parse dates for sorting.  Default is yyyyMMdd
148      *
149      * @param dateFormatPattern the dateFormatPattern to set
150      * @see java.text.SimpleDateFormat
151 
152      */
153     public void setDateFormatPattern(final String dateFormatPattern) {
154         this.dateFormatPattern = dateFormatPattern;
155     }
156 }