View Javadoc

1   /*
2    * Copyright 2004 Jeff Johnston
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.extremecomponents.table.cell;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  import org.extremecomponents.table.model.TableModelUtils;
22  import org.extremecomponents.util.HtmlBuilder;
23  
24  
25  
26  /***
27   * Will generate a simple cell to display.
28   *
29   * @author Jeff Johnston
30   */
31  public class DisplayCell extends BaseCell
32  {
33  	private static Log logger = LogFactory.getLog(DisplayCell.class);
34  
35  	public String html()
36  	{
37  		HtmlBuilder html = new HtmlBuilder();
38  		
39  		html.append(startTD());
40  
41  		Object value = column.getValue();
42  		if (value != null && StringUtils.isNotEmpty(value.toString()))		
43  		{
44  			html.append(value);
45  		}
46  		else
47  		{
48  			html.append(" ");
49  		}
50  
51  		html.append(endTD());
52  
53  		return html.toString();
54  	}
55  	
56  	public String value()
57  	{
58  		Object obj = column.getValue();
59  		if (obj != null && StringUtils.isNotBlank(obj.toString()))		
60  		{
61  			return TableModelUtils.parseCell(obj.toString());
62  		}
63  
64  		return "";
65  	}
66  }