01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.components.table.renderer;
06:
07: import com.opensymphony.webwork.components.table.WebTable;
08:
09: /**
10: * @author $author$
11: * @version $Revision: 1282 $
12: */
13: public class BooleanCellRenderer extends AbstractCellRenderer {
14:
15: /**
16: * value used if the boolean object is false
17: */
18: protected String _falseValue = "false";
19:
20: /**
21: * value used if the boolean object is true
22: */
23: protected String _trueValue = "true";
24:
25: public BooleanCellRenderer() {
26: super ();
27: }
28:
29: public String getCellValue(WebTable table, Object data, int row,
30: int col) {
31: if (data == null) {
32: return "";
33: }
34:
35: if (data instanceof Boolean) {
36: return ((Boolean) data).booleanValue() ? _trueValue
37: : _falseValue;
38: }
39:
40: return data.toString(); //if here then not a boolean
41: }
42:
43: public void setFalseValue(String falseValue) {
44: _falseValue = falseValue;
45: }
46:
47: public void setTrueValue(String trueValue) {
48: _trueValue = trueValue;
49: }
50: }
|