@Test public void testTokensAreCorrect() throws IOException { try (ObjectStream<Parse> samples = new ConstitParseSampleStream(ObjectStreamUtils.createObjectStream(getSample1()))) { Parse p = samples.read(); Parse[] tagNodes = p.getTagNodes(); String[] tokens = new String[tagNodes.length]; for (int ti = 0; ti < tagNodes.length; ti++) { tokens[ti] = tagNodes[ti].getCoveredText(); } Assert.assertArrayEquals(sample1Tokens, tokens); } }
public Parse read() throws IOException { if (parses.isEmpty()) { byte[] xmlbytes = samples.read(); if (xmlbytes != null) { List<Parse> producedParses = new ArrayList<>(); try { saxParser.parse(new ByteArrayInputStream(xmlbytes), new ConstitDocumentHandler(producedParses)); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } parses.addAll(producedParses); } } if (parses.size() > 0) { return parses.remove(0); } return null; }
ConstitParseSampleStream extends FilterObjectStream<byte[], Parse> { public Parse read() throws IOException { if (parses.isEmpty()) { byte[] xmlbytes = samples.read(); if (xmlbytes != null) { List<Parse> producedParses = new ArrayList<>(); try { saxParser.parse(new ByteArrayInputStream(xmlbytes), new ConstitDocumentHandler(producedParses)); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } parses.addAll(producedParses); } } if (parses.size() > 0) { return parses.remove(0); } return null; } }
ConstitParseSampleStream extends FilterObjectStream<byte[], Parse> { public Parse read() throws IOException { if (parses.isEmpty()) { byte[] xmlbytes = samples.read(); if (xmlbytes != null) { List<Parse> producedParses = new ArrayList<>(); try { saxParser.parse(new ByteArrayInputStream(xmlbytes), new ConstitDocumentHandler(producedParses)); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } parses.addAll(producedParses); } } if (parses.size() > 0) { return parses.remove(0); } return null; } protected  ConstitParseSampleStream(ObjectStream<byte[]> samples); }
ConstitParseSampleStream extends FilterObjectStream<byte[], Parse> { public Parse read() throws IOException { if (parses.isEmpty()) { byte[] xmlbytes = samples.read(); if (xmlbytes != null) { List<Parse> producedParses = new ArrayList<>(); try { saxParser.parse(new ByteArrayInputStream(xmlbytes), new ConstitDocumentHandler(producedParses)); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } parses.addAll(producedParses); } } if (parses.size() > 0) { return parses.remove(0); } return null; } protected  ConstitParseSampleStream(ObjectStream<byte[]> samples); Parse read(); }
ConstitParseSampleStream extends FilterObjectStream<byte[], Parse> { public Parse read() throws IOException { if (parses.isEmpty()) { byte[] xmlbytes = samples.read(); if (xmlbytes != null) { List<Parse> producedParses = new ArrayList<>(); try { saxParser.parse(new ByteArrayInputStream(xmlbytes), new ConstitDocumentHandler(producedParses)); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } parses.addAll(producedParses); } } if (parses.size() > 0) { return parses.remove(0); } return null; } protected  ConstitParseSampleStream(ObjectStream<byte[]> samples); Parse read();  }