Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
SqlTableColumn |
|
| 2.0;2 |
1 | // Copyright 2004, 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.contrib.table.model.sql; |
|
16 | ||
17 | import java.sql.ResultSet; |
|
18 | import java.sql.SQLException; |
|
19 | ||
20 | import org.apache.commons.logging.Log; |
|
21 | import org.apache.commons.logging.LogFactory; |
|
22 | import org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn; |
|
23 | ||
24 | /** |
|
25 | * @author mindbridge |
|
26 | */ |
|
27 | public class SqlTableColumn extends SimpleTableColumn |
|
28 | { |
|
29 | ||
30 | private static final long serialVersionUID = 1L; |
|
31 | 0 | private static final Log LOG = LogFactory.getLog(SqlTableColumn.class); |
32 | ||
33 | /** |
|
34 | * Creates an SqlTableColumn. |
|
35 | * |
|
36 | * @param strSqlField |
|
37 | * the identifying name of the column and the SQL field it refers |
|
38 | * to |
|
39 | * @param strDisplayName |
|
40 | * the display name of the column |
|
41 | */ |
|
42 | public SqlTableColumn(String strSqlField, String strDisplayName) |
|
43 | { |
|
44 | 0 | super(strSqlField, strDisplayName); |
45 | 0 | } |
46 | ||
47 | /** |
|
48 | * Creates an SqlTableColumn. |
|
49 | * |
|
50 | * @param strSqlField |
|
51 | * the identifying name of the column and the SQL field it refers |
|
52 | * to |
|
53 | * @param strDisplayName |
|
54 | * the display name of the column |
|
55 | * @param bSortable |
|
56 | * whether the column is sortable |
|
57 | */ |
|
58 | public SqlTableColumn(String strSqlField, String strDisplayName, |
|
59 | boolean bSortable) |
|
60 | { |
|
61 | 0 | super(strSqlField, strDisplayName, bSortable); |
62 | 0 | } |
63 | ||
64 | /** |
|
65 | * @see org.apache.tapestry.contrib.table.model.simple.SimpleTableColumn#getColumnValue(Object) |
|
66 | */ |
|
67 | public Object getColumnValue(Object objRow) |
|
68 | { |
|
69 | try |
|
70 | { |
|
71 | 0 | ResultSet objRS = (ResultSet) objRow; |
72 | 0 | String strColumnName = getColumnName(); |
73 | 0 | Object objValue = objRS.getObject(strColumnName); |
74 | 0 | if (objValue == null) objValue = ""; |
75 | 0 | return objValue; |
76 | } |
|
77 | 0 | catch (SQLException e) |
78 | { |
|
79 | 0 | LOG.error("Cannot get the value for column: " + getColumnName(), e); |
80 | 0 | return ""; |
81 | } |
|
82 | } |
|
83 | ||
84 | } |