1 5 package net.sourceforge.jwebunit; 6 7 8 13 public class ExpectedRow { 14 15 private ExpectedCell[] expectedCells; 16 17 26 public ExpectedRow(Object [] rowCells) { 27 this.expectedCells = new ExpectedCell[rowCells.length]; 28 for (int i = 0; i < rowCells.length; i++) { 29 Object column = rowCells[i]; 30 if (column instanceof ExpectedCell) { 31 this.expectedCells[i] = (ExpectedCell)column; 32 } else { 33 this.expectedCells[i] = new ExpectedCell(column.toString(), 1); 34 } 35 } 36 } 37 38 String [] getExpandedColumns() { 39 String [] expandedColumns = new String [getNumberOfColumns()]; 40 int targetColumn = 0; 41 for (int i = 0; i < expectedCells.length; i++) { 42 targetColumn = expandIntoColumns(expectedCells[i], expandedColumns, targetColumn); 43 } 44 return expandedColumns; 45 } 46 47 private int getNumberOfColumns() { 48 int numCols = 0; 49 for (int i = 0; i < expectedCells.length; i++) { 50 ExpectedCell column = expectedCells[i]; 51 numCols += (column).getColspan(); 52 } 53 return numCols; 54 } 55 56 private int expandIntoColumns(ExpectedCell cell, String [] targetArray, int offset) { 57 for (int columnsSpanned = 0; columnsSpanned < cell.getColspan(); columnsSpanned++) { 58 targetArray[offset] = cell.getExpectedValue(); 59 offset++; 60 } 61 return offset; 62 } 63 64 } 65 | Popular Tags |