1 22 23 package caramel.util; 24 25 import java.util.*; 26 import houston.*; 27 28 public class ColumnList 29 { 30 static Logger T = Logger.getLogger( ColumnList.class ); 31 32 private List _list; 33 34 public ColumnList( List list ) 35 { 36 _list = list; 37 } 38 39 public List getList() 40 { 41 return _list; 42 } 44 45 public List[] getTableRows( int columns ) 46 { 47 T.debug( "enter getList( " + columns + " )" ); 48 49 67 Object data[] = _list.toArray(); 68 69 int size = data.length; 70 int columnSize = size / columns; 71 if( ( size % columns ) != 0 ) 72 columnSize += 1; 74 75 T.debug( "size=" + size ); 76 T.debug( "columnSize=" + columnSize ); 77 78 80 List list[] = new List[columnSize]; 81 82 for( int row = 0; row < columnSize; row++ ) 83 { 84 list[row] = new ArrayList(); 85 86 for( int col = 0; col < columns; col++ ) 87 { 88 int index = ( col * columnSize ) + row; 89 90 if( index >= size ) 91 continue; 92 93 96 list[row].add( data[index] ); 97 } 98 } 99 100 T.debug( "leave getList()" ); 101 102 return list; 103 } 104 105 } 106 | Popular Tags |