T212Mapper { public Data readData(InputStream is) throws IOException, T212FormatException { return readValue(is,Data.class); } T212Mapper(); T212Mapper enableDefaultParserFeatures(); T212Mapper enableDefaultVerifyFeatures(); T212Mapper enable(SegmentParserFeature feature); T212Mapper enable(ParserFeature feature); T212Mapper enable(VerifyFeature feature); T212Mapper disable(SegmentParserFeature feature); T212Mapper disable(ParserFeature feature); T212Mapper disable(VerifyFeature feature); T212Mapper configurator(T212Configurator configurator); ObjectMapper objectMapper(); T readValue(InputStream is, Class<T> value); T readValue(byte[] bytes, Class<T> value); T readValue(Reader reader, Class<T> value); T readValue(String data, Class<T> value); void writeValueAsStream(T value, Class<T> type, OutputStream outputStream); void writeValueAsWriter(T value, Class<T> type, Writer writer); Map<String,String> readMap(InputStream is); Map<String,String> readMap(byte[] bytes); Map<String,String> readMap(Reader reader); Map<String,String> readMap(String data); Map<String,Object> readDeepMap(InputStream is); Map<String,Object> readDeepMap(byte[] bytes); Map<String,Object> readDeepMap(Reader reader); Map<String,Object> readDeepMap(String data); Data readData(InputStream is); Data readData(byte[] bytes); Data readData(Reader reader); Data readData(String data); String writeMapAsString(Map data); char[] writeMapAsCharArray(Map data); String writeDataAsString(Data data); char[] writeDataAsCharArray(Data data);  }
@Test public void readData() { String h212 = "##0136ST=32;CN=2011;PW=123456;MN=LD130133000015;CP=" + "&&DataTime=20160824003817;B01-Rtd=36.91;011-Rtd=231.0,011-Flag=N;060-Rtd=1.803,060-Flag=N&&" + "4980\r\n"; T212Mapper mapper = new T212Mapper() .enableDefaultParserFeatures() .enableDefaultVerifyFeatures(); try { Data data = mapper.readData(h212); assertEquals(data.getSt(),"32"); assertEquals(data.getCn(),"2011"); assertEquals(data.getPw(),"123456"); assertEquals(data.getMn(),"LD130133000015"); CpData cp = data.getCp(); assertEquals(cp.getDataTime(),"20160824003817"); Map<String,Pollution> pollutionMap = cp.getPollution(); Pollution pB01 = pollutionMap.get("B01"); assertEquals(pB01.getRtd(),new BigDecimal("36.91")); Pollution p011 = pollutionMap.get("011"); assertEquals(p011.getRtd(),new BigDecimal("231.0")); assertEquals(p011.getFlag(),"N"); Pollution p060 = pollutionMap.get("060"); assertEquals(p060.getRtd(),new BigDecimal("1.803")); assertEquals(p060.getFlag(),"N"); } catch (Exception e) { e.printStackTrace(); assert false; } }