@Test public void readList2() throws Exception { String inputText = "A\n" + "B\n" + "C\n" + "D\n" + "E\n" + "F\n"; VType value = TextIO.readList(new StringReader(inputText)); assertThat(value, instanceOf(VStringArray.class)); VStringArray array = (VStringArray) value; assertThat(array.getData(), equalTo(Arrays.asList("A", "B", "C", "D", "E", "F"))); }
/** * Default toString implementation for VStringArray. * * @param vStringArray the object * @return the string representation */ public static String toString(VStringArray vStringArray) { StringBuilder builder = new StringBuilder(); Class type = ValueUtil.typeOf(vStringArray); builder.append(type.getSimpleName()).append("["); builder.append(format.format(vStringArray)); builder.append(", size ").append(vStringArray.getData().size()); appendAlarm(builder, vStringArray); appendTime(builder, vStringArray); builder.append(']'); return builder.toString(); }
@Override public Object calculate(List<Object> args) { VStringArray stringArray = (VStringArray) args.get(0); if (stringArray == null) { return null; } StringBuffer sb = new StringBuffer(); for (String str : stringArray.getData()) { sb.append(str); } return ValueFactory.newVString(sb.toString(), ValueFactory.alarmNone(), ValueFactory.timeNow()); }