KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > components > table > renderer > BooleanCellRenderer


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.components.table.renderer;
6
7 import com.opensymphony.webwork.components.table.WebTable;
8
9
10 /**
11  * @author $author$
12  * @version $Revision: 1.1 $
13  */

14 public class BooleanCellRenderer extends AbstractCellRenderer {
15     //~ Instance fields ////////////////////////////////////////////////////////
16

17     /**
18      * value used if the boolean object is false
19      */

20     protected String JavaDoc _falseValue = "false";
21
22     /**
23      * value used if the boolean object is true
24      */

25     protected String JavaDoc _trueValue = "true";
26
27     //~ Constructors ///////////////////////////////////////////////////////////
28

29     public BooleanCellRenderer() {
30         super();
31     }
32
33     //~ Methods ////////////////////////////////////////////////////////////////
34

35     public String JavaDoc getCellValue(WebTable table, Object JavaDoc data, int row, int col) {
36         if (data == null) {
37             return "";
38         }
39
40         if (data instanceof Boolean JavaDoc) {
41             return ((Boolean JavaDoc) data).booleanValue() ? _trueValue : _falseValue;
42         }
43
44         return data.toString(); //if here then not a boolean
45
}
46
47     public void setFalseValue(String JavaDoc falseValue) {
48         _falseValue = falseValue;
49     }
50
51     public void setTrueValue(String JavaDoc trueValue) {
52         _trueValue = trueValue;
53     }
54 }
55
Popular Tags