1 /*
2 * File: DataTableColumn.java
3 * Created: 12.4.2007 7:31:24
4 *
5 * Copyright 2007 Michal Burda.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 package net.sf.webmancer.widget;
23
24 import java.util.Map;
25
26 import net.sf.webmancer.db.IAttribute;
27 import net.sf.webmancer.db.ICell;
28 import net.sf.webmancer.model.IModelBuilder;
29 import net.sf.webmancer.model.IModeler;
30 import net.sf.webmancer.util.ContractChecker;
31
32 /**
33 * @author Michal Burda
34 *
35 */
36 public class DefaultDataTableColumn implements IDataTableColumn {
37 /**
38 *
39 */
40 private IAttribute attribute;
41
42 /**
43 * Constructs the DataTableColumn.
44 *
45 * @param attribute
46 * @param renderingStrategy
47 */
48 public DefaultDataTableColumn(IAttribute attribute) {
49 ContractChecker.mustNotBeNull(attribute, "attribute");
50 this.attribute = attribute;
51 }
52
53 /**
54 * @see net.sf.webmancer.widget.IDataTableColumn#getAttribute()
55 */
56 public IAttribute getAttribute() {
57 assert this.attribute != null;
58 return this.attribute;
59 }
60
61 /**
62 * @see net.sf.webmancer.widget.IDataTableColumn#renderCell(net.sf.webmancer.out.IRenderingOutput, net.sf.webmancer.db.IRow)
63 */
64 public void renderCell(IModelBuilder output, Map<IAttribute, ICell> row) {
65 String value = row.get(this.attribute).getValueForOutput();
66 output.element(IModeler.WEBMANCER_NAMESPACE, "Cell", value);
67 }
68
69
70 }