@Test public void html_serializer() throws Exception { final SchemaParser.Request request; final Schema result; try (InputStream inputStream = this.getClass().getResourceAsStream("sales-force.xls")) { request = getRequest(inputStream, "#2"); request.getMetadata().setEncoding("UTF-16"); result = htmlSchemaGuesser.parse(request); } try (InputStream inputStream = this.getClass().getResourceAsStream("sales-force.xls")) { request.getMetadata().getRowMetadata().setColumns(result.getSheetContents().get(0).getColumnMetadatas()); InputStream jsonStream = htmlSerializer.serialize(inputStream, request.getMetadata(), -1); String json = IOUtils.toString(jsonStream, UTF_8); logger.debug("json: {}", json); ObjectMapper mapper = new ObjectMapper(); CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, TreeMap.class); List<Map<String, String>> values = mapper.readValue(json, collectionType); logger.debug("values: {}", values); Map<String, String> row0 = values.get(0); Assertions.assertThat(row0).contains(MapEntry.entry("0000", "000001"), MapEntry.entry("0001", "aaa"), MapEntry.entry("0002", "France"), MapEntry.entry("0003", "x@talend.com")); } }
@Override public InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit) { try { PipedInputStream pipe = new PipedInputStream(); PipedOutputStream jsonOutput = new PipedOutputStream(pipe); Runnable r = () -> deserialize(rawContent, metadata, jsonOutput, limit); executor.execute(r); return pipe; } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON, e); } }
HtmlSerializer implements Serializer { @Override public InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit) { try { PipedInputStream pipe = new PipedInputStream(); PipedOutputStream jsonOutput = new PipedOutputStream(pipe); Runnable r = () -> deserialize(rawContent, metadata, jsonOutput, limit); executor.execute(r); return pipe; } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON, e); } } }
HtmlSerializer implements Serializer { @Override public InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit) { try { PipedInputStream pipe = new PipedInputStream(); PipedOutputStream jsonOutput = new PipedOutputStream(pipe); Runnable r = () -> deserialize(rawContent, metadata, jsonOutput, limit); executor.execute(r); return pipe; } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON, e); } }  }
HtmlSerializer implements Serializer { @Override public InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit) { try { PipedInputStream pipe = new PipedInputStream(); PipedOutputStream jsonOutput = new PipedOutputStream(pipe); Runnable r = () -> deserialize(rawContent, metadata, jsonOutput, limit); executor.execute(r); return pipe; } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON, e); } }  @Override InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit); }
HtmlSerializer implements Serializer { @Override public InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit) { try { PipedInputStream pipe = new PipedInputStream(); PipedOutputStream jsonOutput = new PipedOutputStream(pipe); Runnable r = () -> deserialize(rawContent, metadata, jsonOutput, limit); executor.execute(r); return pipe; } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNABLE_TO_SERIALIZE_TO_JSON, e); } }  @Override InputStream serialize(InputStream rawContent, DataSetMetadata metadata, long limit);  }