|
|||||||||||||||||||
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 | |||||||||||||||
SimpleSetTableDataModel.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.Collection;
|
|
19 |
import java.util.Iterator;
|
|
20 |
import java.util.Set;
|
|
21 |
|
|
22 |
import org.apache.tapestry.contrib.table.model.CTableDataModelEvent;
|
|
23 |
import org.apache.tapestry.contrib.table.model.common.AbstractTableDataModel;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* A minimal set implementation of the
|
|
27 |
* {@link org.apache.tapestry.contrib.table.model.ITableDataModel} interface
|
|
28 |
*
|
|
29 |
* @author mindbridge
|
|
30 |
*/
|
|
31 |
public class SimpleSetTableDataModel extends AbstractTableDataModel implements Serializable |
|
32 |
{ |
|
33 |
private Set m_setRows;
|
|
34 |
|
|
35 | 0 |
public SimpleSetTableDataModel(Set setRows)
|
36 |
{ |
|
37 | 0 |
m_setRows = setRows; |
38 |
} |
|
39 |
|
|
40 |
/**
|
|
41 |
* @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRowCount()
|
|
42 |
*/
|
|
43 | 0 |
public int getRowCount() |
44 |
{ |
|
45 | 0 |
return m_setRows.size();
|
46 |
} |
|
47 |
|
|
48 |
/**
|
|
49 |
* @see org.apache.tapestry.contrib.table.model.ITableDataModel#getRows()
|
|
50 |
*/
|
|
51 | 0 |
public Iterator getRows()
|
52 |
{ |
|
53 | 0 |
return m_setRows.iterator();
|
54 |
} |
|
55 |
|
|
56 |
/**
|
|
57 |
* Method addRow.
|
|
58 |
* Adds a row object to the model at its end
|
|
59 |
* @param objRow the row object to add
|
|
60 |
*/
|
|
61 | 0 |
public void addRow(Object objRow) |
62 |
{ |
|
63 | 0 |
if (m_setRows.contains(objRow)) return; |
64 | 0 |
m_setRows.add(objRow); |
65 |
|
|
66 | 0 |
CTableDataModelEvent objEvent = new CTableDataModelEvent();
|
67 | 0 |
fireTableDataModelEvent(objEvent); |
68 |
} |
|
69 |
|
|
70 | 0 |
public void addRows(Collection arrRows) |
71 |
{ |
|
72 | 0 |
m_setRows.addAll(arrRows); |
73 |
|
|
74 | 0 |
CTableDataModelEvent objEvent = new CTableDataModelEvent();
|
75 | 0 |
fireTableDataModelEvent(objEvent); |
76 |
} |
|
77 |
|
|
78 |
/**
|
|
79 |
* Method removeRow.
|
|
80 |
* Removes a row object from the model
|
|
81 |
* @param objRow the row object to remove
|
|
82 |
*/
|
|
83 | 0 |
public void removeRow(Object objRow) |
84 |
{ |
|
85 | 0 |
if (!m_setRows.contains(objRow)) return; |
86 | 0 |
m_setRows.remove(objRow); |
87 |
|
|
88 | 0 |
CTableDataModelEvent objEvent = new CTableDataModelEvent();
|
89 | 0 |
fireTableDataModelEvent(objEvent); |
90 |
} |
|
91 |
|
|
92 | 0 |
public void removeRows(Collection arrRows) |
93 |
{ |
|
94 | 0 |
m_setRows.removeAll(arrRows); |
95 |
|
|
96 | 0 |
CTableDataModelEvent objEvent = new CTableDataModelEvent();
|
97 | 0 |
fireTableDataModelEvent(objEvent); |
98 |
} |
|
99 |
|
|
100 |
} |
|
101 |
|
|