1 package org.apache.poi.util; 2 3 import java.util.List ; 4 import java.util.ArrayList ; 5 6 15 public class List2d 16 { 17 List rows = new ArrayList (); 19 20 public Object get(int col, int row) 21 { 22 if (row >= rows.size()) 23 { 24 return null; 25 } 26 else 27 { 28 List cols = (List ) rows.get(row); 29 if (col >= cols.size()) 30 return null; 31 else 32 return cols.get( col ); 33 } 34 } 35 36 public void set(int col, int row, Object value) 37 { 38 resizeRows(row); 39 resizeCols(row,col); 40 List cols = (List ) rows.get( row ); 41 cols.set( col, value ); 42 } 43 44 private void resizeRows( int row ) 45 { 46 while (rows.size() <= row) 47 rows.add( new ArrayList () ); 48 } 49 50 private void resizeCols( int row, int col ) 51 { 52 List cols = (List ) rows.get( row ); 53 while (cols.size() <= col) 54 cols.add(null); 55 } 56 57 58 } 59 | Popular Tags |