SegmentGenerator implements Closeable, Configured<SegmentGenerator> { public void writeObjectValue(String value) throws IOException { writeValue(true,value); } SegmentGenerator(Writer writer); void writeKey(String key); void writePathKey(String key); void writeValue(String value); void writeObjectValue(String value); SegmentGenerator writeObjectStart(); void writeObjectEnd(); SegmentToken nextToken(); void initToken(); void setGeneratorFeature(int generatorFeature); @Override void close(); @Override void configured(Configurator<SegmentGenerator> by);  }
@Test public void testWriteObjectValue(){ String data = "ST=32;CN=2011;PW=123456;MN=LD130133000015;CP=&&DataTime=20160824003817000;B01-Rtd=36.91;011-Rtd=231.0,011-Flag=N;060-Rtd=1.803,060-Flag=N&&"; StringWriter writer = new StringWriter(); SegmentGenerator generator = new SegmentGenerator(writer); try { generator.initToken(); generator.writeKey("ST"); generator.writeValue("32"); generator.writeKey("CN"); generator.writeValue("2011"); generator.writeKey("PW"); generator.writeValue("123456"); generator.writeKey("MN"); generator.writeValue("LD130133000015"); generator.writeKey("CP"); generator.writeObjectValue("DataTime=20160824003817000;B01-Rtd=36.91;011-Rtd=231.0,011-Flag=N;060-Rtd=1.803,060-Flag=N"); assertEquals(writer.toString(),data); } catch (IOException e) { e.printStackTrace(); } }