package test.order; import java.util.ArrayList; import java.util.List; import java.util.Random; public class TestTableData { public static final int TOTAL_ROWS = 1000; public static final int TOTAL_COLS = 10; private Random randomGenerator = new Random(); private List tableRows; private ArrayList colInfo; private enum DataSize { SHORT, MEDIUM, LONG } public TestTableData() { initializeData(); } private String getText(DataSize size) { switch (size) { case SHORT: return "Short short"; case MEDIUM: return "Medium medium medium medium medium medium medium "; case LONG: return "Long long long long long long long long long long long long long long long long long long "; default: return "Default default "; } } private double getNumber(DataSize size) { switch (size) { case SHORT: return randomGenerator.nextDouble() + 10; case MEDIUM: return randomGenerator.nextDouble() + 10000; case LONG: return randomGenerator.nextDouble() + 10000000; default: return randomGenerator.nextDouble(); } } private void initializeData() { tableRows = new ArrayList(); List colOrder = new ArrayList(); colInfo = new ArrayList(); for (int colIndex = 0; colIndex < TOTAL_COLS; colIndex++) { colOrder.add(colIndex); String format = null; String informat = null; int length = 0; int colType = 0; switch (colIndex % 2) { case 0: // gerade: Numerisch colType = 1; break; case 1: // ungerade: Text colType = 2; break; } ColumnDescriptor info = new ColumnDescriptor(colIndex, "Col" + colIndex, "Spalte " + colIndex, format, informat, length, colType); colInfo.add(info); } for (int i = 0; i < TOTAL_ROWS; i++) { TableRow row = new TableRow(i + 1, colInfo, colOrder, null); for (int j = 0; j < TOTAL_COLS; j++) { switch (j % 2) { case 0: // gerade: Numerisch switch (j % 3) { case 0: row.add(new Double(getNumber(DataSize.SHORT))); break; case 1: row.add(new Double(getNumber(DataSize.MEDIUM))); break; case 2: row.add(new Double(getNumber(DataSize.LONG))); break; default: row.add(new Double(getNumber(DataSize.MEDIUM))); break; } break; case 1: // ungerade: Text switch (j % 3) { case 0: row.add(new String(getText(DataSize.SHORT))); break; case 1: row.add(new String(getText(DataSize.MEDIUM))); break; case 2: row.add(new String(getText(DataSize.LONG))); break; default: row.add(new String(getText(DataSize.MEDIUM))); break; } break; } } tableRows.add(row); } } public List getTableRows() { return tableRows; } public ArrayList getColInfos() { return colInfo; } }