001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kns.web.ui;
017
018import org.kuali.rice.core.web.format.Formatter;
019import org.kuali.rice.kns.lookup.HtmlData;
020import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
021import org.kuali.rice.kns.lookup.HtmlData.MultipleAnchorHtmlData;
022
023import java.util.ArrayList;
024import java.util.Comparator;
025import java.util.List;
026
027/**
028 * Represents a Column in a result table
029 * 
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032@Deprecated
033public class Column implements java.io.Serializable, PropertyRenderingConfigElement {
034    private static final long serialVersionUID = -5916942413570667803L;
035    private String columnTitle;
036    private String sortable = "true";
037    private String propertyName;
038    private String propertyValue;
039    private Object unformattedPropertyValue;
040    private String propertyURL;
041    private HtmlData columnAnchor;
042    private Formatter formatter;
043    private Comparator comparator;
044    private boolean escapeXMLValue=true;
045    
046    private String alternateDisplayPropertyName;
047    private String additionalDisplayPropertyName;
048    
049    private boolean total;
050    
051    /**
052     * A comparator used to compare the propertyValue values
053     */
054    private Comparator valueComparator;
055    
056    /**
057     * Represents the maximum column length.  If propertyValue's length exceeds this value, then 
058     * it will be truncated to this length when displayed
059     */
060    private int maxLength;
061    
062    public Column() {
063    }
064    
065    public Column(String columnTitle, String propertyName) {
066        this.columnTitle = columnTitle;
067        this.propertyName = propertyName;
068    }
069    
070    public Column(String columnTitle, String sortable, String propertyName) {
071        this.columnTitle = columnTitle;
072        this.sortable = sortable;
073        this.propertyName = propertyName;
074    }
075
076    public Column(String columnTitle, String sortable, String propertyName, Comparator comparator) {
077        this(columnTitle, sortable, propertyName);
078        this.comparator = comparator;
079    }
080
081    public Column(String columnTitle, String propertyName, Formatter formatter) {
082        this.columnTitle = columnTitle;
083        this.propertyName = propertyName;
084        this.formatter = formatter;
085    }
086
087    /**
088     * @return Returns the comparator.
089     */
090    public Comparator getComparator() {
091        return comparator;
092    }
093
094
095    /**
096     * @param comparator The comparator to set.
097     */
098    public void setComparator(Comparator comparator) {
099        this.comparator = comparator;
100    }
101
102
103    /**
104     * @return Returns the columnTitle.
105     */
106    public String getColumnTitle() {
107        return columnTitle;
108    }
109
110
111    /**
112     * @param columnTitle The columnTitle to set.
113     */
114    public void setColumnTitle(String columnTitle) {
115        this.columnTitle = columnTitle;
116    }
117
118
119    /**
120     * @return Returns the propertyName.
121     */
122    public String getPropertyName() {
123        return propertyName;
124    }
125
126
127    /**
128     * @param propertyName The propertyName to set.
129     */
130    public void setPropertyName(String propertyName) {
131        this.propertyName = propertyName;
132    }
133
134
135    /**
136     * @return Returns the sortable.
137     */
138    public String getSortable() {
139        return sortable;
140    }
141
142
143    /**
144     * @param sortable The sortable to set.
145     */
146    public void setSortable(String sortable) {
147        this.sortable = sortable;
148    }
149
150
151    /**
152     * @return Returns the propertyURL.
153     */
154    public String getPropertyURL() {
155        return propertyURL;
156    }
157
158
159    /**
160     * @param propertyURL The propertyURL to set.
161     */
162    public void setPropertyURL(String propertyURL) {
163        this.propertyURL = propertyURL;
164    }
165
166        /**
167         * @return the columnAnchor
168         */
169        public HtmlData getColumnAnchor() {
170                return this.columnAnchor;
171        }
172
173        public boolean isMultipleAnchors(){
174                return this.columnAnchor instanceof MultipleAnchorHtmlData;
175        }
176
177        public List<AnchorHtmlData> getColumnAnchors(){
178                if(isMultipleAnchors())
179                        return ((MultipleAnchorHtmlData)this.columnAnchor).getAnchorHtmlData();
180                List<AnchorHtmlData> htmlData = new ArrayList<AnchorHtmlData>();
181                htmlData.add((AnchorHtmlData)columnAnchor);
182                return htmlData;
183        }
184
185        public int getNumberOfColumnAnchors(){
186                return getColumnAnchors().size();
187        }
188
189        /**
190         * @param columnAnchor the columnAnchor to set
191         */
192        public void setColumnAnchor(HtmlData columnAnchor) {
193                this.columnAnchor = columnAnchor;
194                if(columnAnchor!=null) 
195                        setPropertyURL(((AnchorHtmlData)columnAnchor).getHref());
196        }
197
198        /**
199     * @return Returns the propertyValue.
200     */
201    public String getPropertyValue() {
202        return propertyValue;
203    }
204
205
206    /**
207     * @param propertyValue The propertyValue to set.
208     */
209    public void setPropertyValue(String propertyValue) {
210        this.propertyValue = propertyValue;
211    }
212    
213    /**
214     * @return Returns the formatter.
215     */
216    public Formatter getFormatter() {
217        return formatter;
218    }
219
220
221    /**
222     * @param formatter The formatter to set.
223     */
224    public void setFormatter(Formatter formatter) {
225        this.formatter = formatter;
226    }
227
228    public Comparator getValueComparator() {
229        return valueComparator;
230    }
231
232    public void setValueComparator(Comparator valueComparator) {
233        this.valueComparator = valueComparator;
234    }
235
236    /**
237     * Returns the maximum column length.  If propertyValue's length exceeds this value, then 
238     * it will be truncated to this length when displayed
239     * @return
240     */
241    public int getMaxLength() {
242        return maxLength;
243    }
244
245    /**
246     * Sets the maximum column length.  If propertyValue's length exceeds this value, then 
247     * it will be truncated to this length when displayed
248     * @param maxColumnLength
249     */
250    public void setMaxLength(int maxColumnLength) {
251        this.maxLength = maxColumnLength;
252    }
253
254        /**
255         * @return the escapeXMLValue
256         */
257        public boolean isEscapeXMLValue() {
258                return this.escapeXMLValue;
259        }
260
261        /**
262         * @param escapeXMLValue the escapeXMLValue to set
263         */
264        public void setEscapeXMLValue(boolean escapeXMLValue) {
265                this.escapeXMLValue = escapeXMLValue;
266        }
267
268        public String getAlternateDisplayPropertyName() {
269                return this.alternateDisplayPropertyName;
270        }
271
272        public void setAlternateDisplayPropertyName(String alternateDisplayPropertyName) {
273                this.alternateDisplayPropertyName = alternateDisplayPropertyName;
274        }
275
276        public String getAdditionalDisplayPropertyName() {
277                return this.additionalDisplayPropertyName;
278        }
279
280        public void setAdditionalDisplayPropertyName(String additionalDisplayPropertyName) {
281                this.additionalDisplayPropertyName = additionalDisplayPropertyName;
282        }
283
284        public boolean isTotal() {
285                return this.total;
286        }
287
288        public void setTotal(boolean total) {
289                this.total = total;
290        }
291
292        public Object getUnformattedPropertyValue() {
293                return this.unformattedPropertyValue;
294        }
295
296        public void setUnformattedPropertyValue(Object unformattedPropertyValue) {
297                this.unformattedPropertyValue = unformattedPropertyValue;
298        }
299        
300}