View Javadoc

1   /**
2    * Copyright 2005-2013 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.kew.web;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.util.ConcreteKeyValue;
20  import org.kuali.rice.core.api.util.KeyValue;
21  import org.kuali.rice.kew.docsearch.SearchableAttributeValue;
22  
23  
24  /**
25   * A simple bean for storing key/value pairs that can be used for a number of
26   * tasks. Right now it is used to hold information that will be display on a jsp
27   * for drop down boxes.
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class KeyValueSort implements KeyValue {
32  
33  	private static final long serialVersionUID = 3575440091286391804L;
34  
35  	private String userDisplayValue;
36  	private Object sortValue;
37      private Class sortClass;
38      private SearchableAttributeValue searchableAttributeValue;
39      private final ConcreteKeyValue keyValue;
40      
41      
42  	public KeyValueSort() {
43  		keyValue = new ConcreteKeyValue();
44  	}
45  
46  	public KeyValueSort(String key, String value) {
47  		keyValue = new ConcreteKeyValue(key, value);
48  	}
49  
50      public KeyValueSort(String key, String value, Object sortValue, SearchableAttributeValue searchableAttributeValue) {
51          this(key,value);
52          this.sortValue = sortValue;
53          this.searchableAttributeValue = searchableAttributeValue;
54      }
55  
56      public KeyValueSort(String key, String value, String userDisplayValue, Object sortValue, SearchableAttributeValue searchableAttributeValue) {
57      	this(key,value,sortValue,searchableAttributeValue);
58          this.userDisplayValue = userDisplayValue;
59      }
60  
61      public KeyValueSort(KeyValueSort kvs) {
62          this(kvs.getKey(),kvs.getValue(),kvs.getUserDisplayValue(),kvs.getSortValue(),kvs.getSearchableAttributeValue());
63      }
64  
65  	public Object getSortValue() {
66  		return sortValue;
67  	}
68  
69  	public void setSortValue(Object sortValue) {
70  		this.sortValue = sortValue;
71          this.sortClass = sortValue.getClass();
72  	}
73  
74      public Class getSortClass() {
75          return sortClass;
76      }
77  
78      public SearchableAttributeValue getSearchableAttributeValue() {
79          return searchableAttributeValue;
80      }
81      
82      public String getUserDisplayValue() {
83      	if (StringUtils.isNotBlank(userDisplayValue)) {
84      		return userDisplayValue;
85      	}
86      	return getValue();
87      }
88  
89  	@Override
90  	public String getKey() {
91  		return keyValue.getKey();
92  	}
93  
94  	@Override
95  	public String getValue() {
96  		return keyValue.getValue();
97  	}
98  
99  	public void setKey(String k) {
100 		keyValue.setKey(k);
101 	}
102 
103 	public void setValue(String v) {
104 		keyValue.setValue(v);
105 	}
106 
107 }