View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kns.web.ui;
17  
18  import org.kuali.rice.core.web.format.Formatter;
19  import org.kuali.rice.kns.lookup.HtmlData;
20  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
21  import org.kuali.rice.kns.lookup.HtmlData.MultipleAnchorHtmlData;
22  
23  import java.util.ArrayList;
24  import java.util.Comparator;
25  import java.util.List;
26  
27  /**
28   * Represents a Column in a result table
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   *
32   * @deprecated KNS Struts deprecated, use KRAD and the Spring MVC framework.
33   */
34  @Deprecated
35  public class Column implements java.io.Serializable, PropertyRenderingConfigElement {
36      private static final long serialVersionUID = -5916942413570667803L;
37      private String columnTitle;
38      private String sortable = "true";
39      private String propertyName;
40      private String propertyValue;
41      private Object unformattedPropertyValue;
42      private String propertyURL;
43      private HtmlData columnAnchor;
44      private Formatter formatter;
45      private Comparator comparator;
46      private boolean escapeXMLValue=true;
47      
48      private String alternateDisplayPropertyName;
49      private String additionalDisplayPropertyName;
50      
51      private boolean total;
52      
53      /**
54       * A comparator used to compare the propertyValue values
55       */
56      private Comparator valueComparator;
57      
58      /**
59       * Represents the maximum column length.  If propertyValue's length exceeds this value, then 
60       * it will be truncated to this length when displayed
61       */
62      private int maxLength;
63      
64      public Column() {
65      }
66      
67      public Column(String columnTitle, String propertyName) {
68          this.columnTitle = columnTitle;
69          this.propertyName = propertyName;
70      }
71      
72      public Column(String columnTitle, String sortable, String propertyName) {
73          this.columnTitle = columnTitle;
74          this.sortable = sortable;
75          this.propertyName = propertyName;
76      }
77  
78      public Column(String columnTitle, String sortable, String propertyName, Comparator comparator) {
79          this(columnTitle, sortable, propertyName);
80          this.comparator = comparator;
81      }
82  
83      public Column(String columnTitle, String propertyName, Formatter formatter) {
84          this.columnTitle = columnTitle;
85          this.propertyName = propertyName;
86          this.formatter = formatter;
87      }
88  
89      /**
90       * @return Returns the comparator.
91       */
92      public Comparator getComparator() {
93          return comparator;
94      }
95  
96  
97      /**
98       * @param comparator The comparator to set.
99       */
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 }