@Test public void writeList1() throws Exception{ VType vType = ValueFactory.toVType(new ArrayDouble(10, 8, 6, 4, 2, 0)); StringWriter writer = new StringWriter(); TextIO.writeList(vType, writer); writer.flush(); assertThat(writer.toString(), equalTo("10.0" + System.lineSeparator() + "8.0" + System.lineSeparator() + "6.0" + System.lineSeparator() + "4.0" + System.lineSeparator() + "2.0" + System.lineSeparator() + "0.0" + System.lineSeparator())); }
public static void writeList(VType vType, Writer writer) throws IOException { PrintWriter out = new PrintWriter(writer); if (vType instanceof VNumberArray) { VNumberArray array = (VNumberArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().getDouble(i)); } } else if (vType instanceof VStringArray) { VStringArray array = (VStringArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().get(i)); } } else { throw new UnsupportedOperationException("Can't serialize " + ValueUtil.typeOf(vType).getSimpleName() + " to a list"); } out.flush(); }
TextIO { public static void writeList(VType vType, Writer writer) throws IOException { PrintWriter out = new PrintWriter(writer); if (vType instanceof VNumberArray) { VNumberArray array = (VNumberArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().getDouble(i)); } } else if (vType instanceof VStringArray) { VStringArray array = (VStringArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().get(i)); } } else { throw new UnsupportedOperationException("Can't serialize " + ValueUtil.typeOf(vType).getSimpleName() + " to a list"); } out.flush(); } }
TextIO { public static void writeList(VType vType, Writer writer) throws IOException { PrintWriter out = new PrintWriter(writer); if (vType instanceof VNumberArray) { VNumberArray array = (VNumberArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().getDouble(i)); } } else if (vType instanceof VStringArray) { VStringArray array = (VStringArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().get(i)); } } else { throw new UnsupportedOperationException("Can't serialize " + ValueUtil.typeOf(vType).getSimpleName() + " to a list"); } out.flush(); }  }
TextIO { public static void writeList(VType vType, Writer writer) throws IOException { PrintWriter out = new PrintWriter(writer); if (vType instanceof VNumberArray) { VNumberArray array = (VNumberArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().getDouble(i)); } } else if (vType instanceof VStringArray) { VStringArray array = (VStringArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().get(i)); } } else { throw new UnsupportedOperationException("Can't serialize " + ValueUtil.typeOf(vType).getSimpleName() + " to a list"); } out.flush(); }  static VType readList(Reader reader); static void writeList(VType vType, Writer writer); }
TextIO { public static void writeList(VType vType, Writer writer) throws IOException { PrintWriter out = new PrintWriter(writer); if (vType instanceof VNumberArray) { VNumberArray array = (VNumberArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().getDouble(i)); } } else if (vType instanceof VStringArray) { VStringArray array = (VStringArray) vType; for (int i = 0; i < array.getData().size(); i++) { out.println(array.getData().get(i)); } } else { throw new UnsupportedOperationException("Can't serialize " + ValueUtil.typeOf(vType).getSimpleName() + " to a list"); } out.flush(); }  static VType readList(Reader reader); static void writeList(VType vType, Writer writer);  }