@Test public void filterRowNumber() { VTable table1 = newVTable(column("Rack", newVStringArray(Arrays.asList("A", "A", "B"), alarmNone(), timeNow())), column("Slot", newVDoubleArray(new ArrayDouble(1,2,3), alarmNone(), timeNow(), displayNone())), column("CPU", newVStringArray(Arrays.asList("286", "286", "386"), alarmNone(), timeNow()))); RangeFilter valueFilter = new RangeFilter(table1, "Slot", ValueFactory.toVType(0), ValueFactory.toVType(1.5)); assertThat(valueFilter.filterRow(0), equalTo(true)); assertThat(valueFilter.filterRow(1), equalTo(false)); assertThat(valueFilter.filterRow(2), equalTo(false)); }
public boolean filterRow(int rowIndex) { if (min instanceof VNumber) { double columnValue = ((ListNumber) table.getColumnData(columnIndex)).getDouble(rowIndex); double minValue = ((VNumber) min).getValue().doubleValue(); double maxValue = ((VNumber) max).getValue().doubleValue(); return columnValue >= minValue && columnValue < maxValue; } else if (min instanceof VString) { @SuppressWarnings("unchecked") List<String> columnData = (List<String>) table.getColumnData(columnIndex); String columnValue = columnData.get(rowIndex); String minValue = ((VString) min).getValue(); String maxValue = ((VString) max).getValue(); return minValue.compareTo(columnValue) <= 0 && maxValue.compareTo(columnValue) > 0; } throw new IllegalStateException("Unexpected error"); }
RangeFilter { public boolean filterRow(int rowIndex) { if (min instanceof VNumber) { double columnValue = ((ListNumber) table.getColumnData(columnIndex)).getDouble(rowIndex); double minValue = ((VNumber) min).getValue().doubleValue(); double maxValue = ((VNumber) max).getValue().doubleValue(); return columnValue >= minValue && columnValue < maxValue; } else if (min instanceof VString) { @SuppressWarnings("unchecked") List<String> columnData = (List<String>) table.getColumnData(columnIndex); String columnValue = columnData.get(rowIndex); String minValue = ((VString) min).getValue(); String maxValue = ((VString) max).getValue(); return minValue.compareTo(columnValue) <= 0 && maxValue.compareTo(columnValue) > 0; } throw new IllegalStateException("Unexpected error"); } }
RangeFilter { public boolean filterRow(int rowIndex) { if (min instanceof VNumber) { double columnValue = ((ListNumber) table.getColumnData(columnIndex)).getDouble(rowIndex); double minValue = ((VNumber) min).getValue().doubleValue(); double maxValue = ((VNumber) max).getValue().doubleValue(); return columnValue >= minValue && columnValue < maxValue; } else if (min instanceof VString) { @SuppressWarnings("unchecked") List<String> columnData = (List<String>) table.getColumnData(columnIndex); String columnValue = columnData.get(rowIndex); String minValue = ((VString) min).getValue(); String maxValue = ((VString) max).getValue(); return minValue.compareTo(columnValue) <= 0 && maxValue.compareTo(columnValue) > 0; } throw new IllegalStateException("Unexpected error"); } RangeFilter(VTable table, String columnName, Object min, Object max); }
RangeFilter { public boolean filterRow(int rowIndex) { if (min instanceof VNumber) { double columnValue = ((ListNumber) table.getColumnData(columnIndex)).getDouble(rowIndex); double minValue = ((VNumber) min).getValue().doubleValue(); double maxValue = ((VNumber) max).getValue().doubleValue(); return columnValue >= minValue && columnValue < maxValue; } else if (min instanceof VString) { @SuppressWarnings("unchecked") List<String> columnData = (List<String>) table.getColumnData(columnIndex); String columnValue = columnData.get(rowIndex); String minValue = ((VString) min).getValue(); String maxValue = ((VString) max).getValue(); return minValue.compareTo(columnValue) <= 0 && maxValue.compareTo(columnValue) > 0; } throw new IllegalStateException("Unexpected error"); } RangeFilter(VTable table, String columnName, Object min, Object max); boolean filterRow(int rowIndex); }
RangeFilter { public boolean filterRow(int rowIndex) { if (min instanceof VNumber) { double columnValue = ((ListNumber) table.getColumnData(columnIndex)).getDouble(rowIndex); double minValue = ((VNumber) min).getValue().doubleValue(); double maxValue = ((VNumber) max).getValue().doubleValue(); return columnValue >= minValue && columnValue < maxValue; } else if (min instanceof VString) { @SuppressWarnings("unchecked") List<String> columnData = (List<String>) table.getColumnData(columnIndex); String columnValue = columnData.get(rowIndex); String minValue = ((VString) min).getValue(); String maxValue = ((VString) max).getValue(); return minValue.compareTo(columnValue) <= 0 && maxValue.compareTo(columnValue) > 0; } throw new IllegalStateException("Unexpected error"); } RangeFilter(VTable table, String columnName, Object min, Object max); boolean filterRow(int rowIndex);  }