001/**
002 * Copyright 2005-2014 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 KNS Struts deprecated, use KRAD and the Spring MVC framework.
033 */
034@Deprecated
035public class Column implements java.io.Serializable, PropertyRenderingConfigElement {
036    private static final long serialVersionUID = -5916942413570667803L;
037    private String columnTitle;
038    private String sortable = "true";
039    private String propertyName;
040    private String propertyValue;
041    private Object unformattedPropertyValue;
042    private String propertyURL;
043    private HtmlData columnAnchor;
044    private Formatter formatter;
045    private Comparator comparator;
046    private boolean escapeXMLValue=true;
047    
048    private String alternateDisplayPropertyName;
049    private String additionalDisplayPropertyName;
050    
051    private boolean total;
052    
053    /**
054     * A comparator used to compare the propertyValue values
055     */
056    private Comparator valueComparator;
057    
058    /**
059     * Represents the maximum column length.  If propertyValue's length exceeds this value, then 
060     * it will be truncated to this length when displayed
061     */
062    private int maxLength;
063    
064    public Column() {
065    }
066    
067    public Column(String columnTitle, String propertyName) {
068        this.columnTitle = columnTitle;
069        this.propertyName = propertyName;
070    }
071    
072    public Column(String columnTitle, String sortable, String propertyName) {
073        this.columnTitle = columnTitle;
074        this.sortable = sortable;
075        this.propertyName = propertyName;
076    }
077
078    public Column(String columnTitle, String sortable, String propertyName, Comparator comparator) {
079        this(columnTitle, sortable, propertyName);
080        this.comparator = comparator;
081    }
082
083    public Column(String columnTitle, String propertyName, Formatter formatter) {
084        this.columnTitle = columnTitle;
085        this.propertyName = propertyName;
086        this.formatter = formatter;
087    }
088
089    /**
090     * @return Returns the comparator.
091     */
092    public Comparator getComparator() {
093        return comparator;
094    }
095
096
097    /**
098     * @param comparator The comparator to set.
099     */
100    public void setComparator(Comparator comparator) {
101        this.comparator = comparator;
102    }
103
104
105    /**
106     * @return Returns the columnTitle.
107     */
108    public String getColumnTitle() {
109        return columnTitle;
110    }
111
112
113    /**
114     * @param columnTitle The columnTitle to set.
115     */
116    public void setColumnTitle(String columnTitle) {
117        this.columnTitle = columnTitle;
118    }
119
120
121    /**
122     * @return Returns the propertyName.
123     */
124    public String getPropertyName() {
125        return propertyName;
126    }
127
128
129    /**
130     * @param propertyName The propertyName to set.
131     */
132    public void setPropertyName(String propertyName) {
133        this.propertyName = propertyName;
134    }
135
136
137    /**
138     * @return Returns the sortable.
139     */
140    public String getSortable() {
141        return sortable;
142    }
143
144
145    /**
146     * @param sortable The sortable to set.
147     */
148    public void setSortable(String sortable) {
149        this.sortable = sortable;
150    }
151
152
153    /**
154     * @return Returns the propertyURL.
155     */
156    public String getPropertyURL() {
157        return propertyURL;
158    }
159
160
161    /**
162     * @param propertyURL The propertyURL to set.
163     */
164    public void setPropertyURL(String propertyURL) {
165        this.propertyURL = propertyURL;
166    }
167
168        /**
169         * @return the columnAnchor
170         */
171        public HtmlData getColumnAnchor() {
172                return this.columnAnchor;
173        }
174
175        public boolean isMultipleAnchors(){
176                return this.columnAnchor instanceof MultipleAnchorHtmlData;
177        }
178
179        public List<AnchorHtmlData> getColumnAnchors(){
180                if(isMultipleAnchors())
181                        return ((MultipleAnchorHtmlData)this.columnAnchor).getAnchorHtmlData();
182                List<AnchorHtmlData> htmlData = new ArrayList<AnchorHtmlData>();
183                htmlData.add((AnchorHtmlData)columnAnchor);
184                return htmlData;
185        }
186
187        public int getNumberOfColumnAnchors(){
188                return getColumnAnchors().size();
189        }
190
191        /**
192         * @param columnAnchor the columnAnchor to set
193         */
194        public void setColumnAnchor(HtmlData columnAnchor) {
195                this.columnAnchor = columnAnchor;
196                if(columnAnchor!=null) 
197                        setPropertyURL(((AnchorHtmlData)columnAnchor).getHref());
198        }
199
200        /**
201     * @return Returns the propertyValue.
202     */
203    public String getPropertyValue() {
204        return propertyValue;
205    }
206
207
208    /**
209     * @param propertyValue The propertyValue to set.
210     */
211    public void setPropertyValue(String propertyValue) {
212        this.propertyValue = propertyValue;
213    }
214    
215    /**
216     * @return Returns the formatter.
217     */
218    public Formatter getFormatter() {
219        return formatter;
220    }
221
222
223    /**
224     * @param formatter The formatter to set.
225     */
226    public void setFormatter(Formatter formatter) {
227        this.formatter = formatter;
228    }
229
230    public Comparator getValueComparator() {
231        return valueComparator;
232    }
233
234    public void setValueComparator(Comparator valueComparator) {
235        this.valueComparator = valueComparator;
236    }
237
238    /**
239     * Returns the maximum column length.  If propertyValue's length exceeds this value, then 
240     * it will be truncated to this length when displayed
241     * @return
242     */
243    public int getMaxLength() {
244        return maxLength;
245    }
246
247    /**
248     * Sets the maximum column length.  If propertyValue's length exceeds this value, then 
249     * it will be truncated to this length when displayed
250     * @param maxColumnLength
251     */
252    public void setMaxLength(int maxColumnLength) {
253        this.maxLength = maxColumnLength;
254    }
255
256        /**
257         * @return the escapeXMLValue
258         */
259        public boolean isEscapeXMLValue() {
260                return this.escapeXMLValue;
261        }
262
263        /**
264         * @param escapeXMLValue the escapeXMLValue to set
265         */
266        public void setEscapeXMLValue(boolean escapeXMLValue) {
267                this.escapeXMLValue = escapeXMLValue;
268        }
269
270        public String getAlternateDisplayPropertyName() {
271                return this.alternateDisplayPropertyName;
272        }
273
274        public void setAlternateDisplayPropertyName(String alternateDisplayPropertyName) {
275                this.alternateDisplayPropertyName = alternateDisplayPropertyName;
276        }
277
278        public String getAdditionalDisplayPropertyName() {
279                return this.additionalDisplayPropertyName;
280        }
281
282        public void setAdditionalDisplayPropertyName(String additionalDisplayPropertyName) {
283                this.additionalDisplayPropertyName = additionalDisplayPropertyName;
284        }
285
286        public boolean isTotal() {
287                return this.total;
288        }
289
290        public void setTotal(boolean total) {
291                this.total = total;
292        }
293
294        public Object getUnformattedPropertyValue() {
295                return this.unformattedPropertyValue;
296        }
297
298        public void setUnformattedPropertyValue(Object unformattedPropertyValue) {
299                this.unformattedPropertyValue = unformattedPropertyValue;
300        }
301        
302}