@Test public void defaultPrecision() { ValueFormat f = new SimpleValueFormat(3); assertThat(f.format(newVDouble(1234.5678, display)), equalTo("1234.568")); assertThat(f.format(newVIntArray(new ArrayInt(1, 2, 3), alarmNone(), timeNow(), displayInt)), equalTo("[1, 2, 3]")); assertThat(f.format(newVIntArray(new ArrayInt(1), alarmNone(), timeNow(), displayInt)), equalTo("[1]")); assertThat(f.format(newVIntArray(new ArrayInt(1, 2, 3, 4, 5), alarmNone(), timeNow(), displayInt)), equalTo("[1, 2, 3, ...]")); assertThat(f.format(newVFloatArray(new ArrayFloat(new float[] {1, 2, 3}), alarmNone(), timeNow(), display)), equalTo("[1.000, 2.000, 3.000]")); assertThat(f.format(newVFloatArray(new ArrayFloat(new float[] {1}), alarmNone(), timeNow(), display)), equalTo("[1.000]")); assertThat(f.format(newVFloatArray(new ArrayFloat(new float[] {1, 2, 3, 4, 5}), alarmNone(), timeNow(), display)), equalTo("[1.000, 2.000, 3.000, ...]")); assertThat(f.format(newVDoubleArray(new ArrayDouble(1, 2, 3), alarmNone(), timeNow(), display)), equalTo("[1.000, 2.000, 3.000]")); assertThat(f.format(newVDoubleArray(new ArrayDouble(1), alarmNone(), timeNow(), display)), equalTo("[1.000]")); assertThat(f.format(newVDoubleArray(new ArrayDouble(1, 2, 3, 4, 5), alarmNone(), timeNow(), display)), equalTo("[1.000, 2.000, 3.000, ...]")); assertThat(f.format(newVStringArray(Arrays.asList("A", "B", "C"), alarmNone(), timeNow())), equalTo("[A, B, C]")); assertThat(f.format(newVStringArray(Arrays.asList("A"), alarmNone(), timeNow())), equalTo("[A]")); assertThat(f.format(newVStringArray(Arrays.asList("A", "B", "C", "D", "E"), alarmNone(), timeNow())), equalTo("[A, B, C, ...]")); assertThat(f.format(newVEnumArray(new ArrayInt(2, 0, 0), Arrays.asList("A", "B", "C"), alarmNone(), timeNow())), equalTo("[C, A, A]")); assertThat(f.format(newVEnumArray(new ArrayInt(2), Arrays.asList("A", "B", "C"), alarmNone(), timeNow())), equalTo("[C]")); assertThat(f.format(newVEnumArray(new ArrayInt(2, 0, 0, 1, 0), Arrays.asList("A", "B", "C"), alarmNone(), timeNow())), equalTo("[C, A, A, ...]")); }
@Override protected StringBuffer format(Scalar scalar, StringBuffer toAppendTo, FieldPosition pos) { if (scalar == null || scalar.getValue() == null) { return toAppendTo; } if (scalar instanceof Display && nf(scalar) != null) { NumberFormat f = nf(scalar); return f.format(scalar.getValue(), toAppendTo, pos); } toAppendTo.append(scalar.getValue()); return toAppendTo; }
SimpleValueFormat extends ValueFormat { @Override protected StringBuffer format(Scalar scalar, StringBuffer toAppendTo, FieldPosition pos) { if (scalar == null || scalar.getValue() == null) { return toAppendTo; } if (scalar instanceof Display && nf(scalar) != null) { NumberFormat f = nf(scalar); return f.format(scalar.getValue(), toAppendTo, pos); } toAppendTo.append(scalar.getValue()); return toAppendTo; } }
SimpleValueFormat extends ValueFormat { @Override protected StringBuffer format(Scalar scalar, StringBuffer toAppendTo, FieldPosition pos) { if (scalar == null || scalar.getValue() == null) { return toAppendTo; } if (scalar instanceof Display && nf(scalar) != null) { NumberFormat f = nf(scalar); return f.format(scalar.getValue(), toAppendTo, pos); } toAppendTo.append(scalar.getValue()); return toAppendTo; } SimpleValueFormat(int maxElements); }
SimpleValueFormat extends ValueFormat { @Override protected StringBuffer format(Scalar scalar, StringBuffer toAppendTo, FieldPosition pos) { if (scalar == null || scalar.getValue() == null) { return toAppendTo; } if (scalar instanceof Display && nf(scalar) != null) { NumberFormat f = nf(scalar); return f.format(scalar.getValue(), toAppendTo, pos); } toAppendTo.append(scalar.getValue()); return toAppendTo; } SimpleValueFormat(int maxElements);  }
SimpleValueFormat extends ValueFormat { @Override protected StringBuffer format(Scalar scalar, StringBuffer toAppendTo, FieldPosition pos) { if (scalar == null || scalar.getValue() == null) { return toAppendTo; } if (scalar instanceof Display && nf(scalar) != null) { NumberFormat f = nf(scalar); return f.format(scalar.getValue(), toAppendTo, pos); } toAppendTo.append(scalar.getValue()); return toAppendTo; } SimpleValueFormat(int maxElements);   }