1 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 34 public class SimpleTableColumnModel implements ITableColumnModel, Serializable 35 { 36 private static final long serialVersionUID = 1L; 37 38 private ITableColumn[] m_arrColumns; 39 private Map m_mapColumns; 40 41 public SimpleTableColumnModel(ITableColumn[] arrColumns) 42 { 43 m_arrColumns = arrColumns; 44 45 m_mapColumns = new HashMap (); 46 for (int i = 0; i < m_arrColumns.length; i++) 47 m_mapColumns.put(m_arrColumns[i].getColumnName(), m_arrColumns[i]); 48 } 49 50 public SimpleTableColumnModel(List arrColumns) 51 { 52 this((ITableColumn[]) arrColumns.toArray(new ITableColumn[arrColumns.size()])); 53 } 54 55 public int getColumnCount() 56 { 57 return m_arrColumns.length; 58 } 59 60 public ITableColumn getColumn(int nColumn) 61 { 62 if (nColumn < 0 || nColumn >= m_arrColumns.length) 63 { 64 return null; 66 } 67 return m_arrColumns[nColumn]; 68 } 69 70 public ITableColumn getColumn(String strColumn) 71 { 72 return (ITableColumn) m_mapColumns.get(strColumn); 73 } 74 75 public Iterator getColumns() 76 { 77 return new ArrayIterator(m_arrColumns); 78 } 79 80 } 81 | Popular Tags |