|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SimpleTableColumnModel.java | 0% | 0% | 0% | 0% |
|
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.simple;
|
|
16 |
|
|
17 |
import java.io.Serializable;
|
|
18 |
import java.util.HashMap;
|
|
19 |
import java.util.Iterator;
|
|
20 |
import java.util.List;
|
|
21 |
import java.util.Map;
|
|
22 |
|
|
23 |
import org.apache.tapestry.contrib.table.model.ITableColumn;
|
|
24 |
import org.apache.tapestry.contrib.table.model.ITableColumnModel;
|
|
25 |
import org.apache.tapestry.contrib.table.model.common.ArrayIterator;
|
|
26 |
|
|
27 |
/**
|
|
28 |
* A minimal implementation of the
|
|
29 |
* {@link org.apache.tapestry.contrib.table.model.ITableColumnModel} interface
|
|
30 |
* that stores columns as an array.
|
|
31 |
*
|
|
32 |
* @author mindbridge
|
|
33 |
*/
|
|
34 |
public class SimpleTableColumnModel implements ITableColumnModel, Serializable |
|
35 |
{ |
|
36 |
|
|
37 |
private ITableColumn[] m_arrColumns;
|
|
38 |
private Map m_mapColumns;
|
|
39 |
|
|
40 | 0 |
public SimpleTableColumnModel(ITableColumn[] arrColumns)
|
41 |
{ |
|
42 | 0 |
m_arrColumns = arrColumns; |
43 |
|
|
44 | 0 |
m_mapColumns = new HashMap();
|
45 | 0 |
for (int i = 0; i < m_arrColumns.length; i++) |
46 | 0 |
m_mapColumns.put(m_arrColumns[i].getColumnName(), m_arrColumns[i]); |
47 |
} |
|
48 |
|
|
49 | 0 |
public SimpleTableColumnModel(List arrColumns)
|
50 |
{ |
|
51 | 0 |
this((ITableColumn[]) arrColumns.toArray(new ITableColumn[arrColumns.size()])); |
52 |
} |
|
53 |
|
|
54 | 0 |
public int getColumnCount() |
55 |
{ |
|
56 | 0 |
return m_arrColumns.length;
|
57 |
} |
|
58 |
|
|
59 | 0 |
public ITableColumn getColumn(int nColumn) |
60 |
{ |
|
61 | 0 |
if (nColumn < 0 || nColumn >= m_arrColumns.length)
|
62 |
{ |
|
63 |
// error message
|
|
64 | 0 |
return null; |
65 |
} |
|
66 | 0 |
return m_arrColumns[nColumn];
|
67 |
} |
|
68 |
|
|
69 | 0 |
public ITableColumn getColumn(String strColumn)
|
70 |
{ |
|
71 | 0 |
return (ITableColumn) m_mapColumns.get(strColumn);
|
72 |
} |
|
73 |
|
|
74 | 0 |
public Iterator getColumns()
|
75 |
{ |
|
76 | 0 |
return new ArrayIterator(m_arrColumns); |
77 |
} |
|
78 |
|
|
79 |
} |
|
80 |
|
|