1 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 31 public class SimpleSetTableDataModel extends AbstractTableDataModel implements Serializable 32 { 33 private static final long serialVersionUID = 1L; 34 35 private Set m_setRows; 36 37 public SimpleSetTableDataModel(Set setRows) 38 { 39 m_setRows = setRows; 40 } 41 42 45 public int getRowCount() 46 { 47 return m_setRows.size(); 48 } 49 50 53 public Iterator getRows() 54 { 55 return m_setRows.iterator(); 56 } 57 58 63 public void addRow(Object objRow) 64 { 65 if (m_setRows.contains(objRow)) return; 66 m_setRows.add(objRow); 67 68 CTableDataModelEvent objEvent = new CTableDataModelEvent(); 69 fireTableDataModelEvent(objEvent); 70 } 71 72 public void addRows(Collection arrRows) 73 { 74 m_setRows.addAll(arrRows); 75 76 CTableDataModelEvent objEvent = new CTableDataModelEvent(); 77 fireTableDataModelEvent(objEvent); 78 } 79 80 85 public void removeRow(Object objRow) 86 { 87 if (!m_setRows.contains(objRow)) return; 88 m_setRows.remove(objRow); 89 90 CTableDataModelEvent objEvent = new CTableDataModelEvent(); 91 fireTableDataModelEvent(objEvent); 92 } 93 94 public void removeRows(Collection arrRows) 95 { 96 m_setRows.removeAll(arrRows); 97 98 CTableDataModelEvent objEvent = new CTableDataModelEvent(); 99 fireTableDataModelEvent(objEvent); 100 } 101 102 } 103 | Popular Tags |