@Test public void test() { XpathSelector selector = new XpathSelector(); byte[] data = "<a href='/test'>épatant</a>".getBytes(); Instance<XElement> instance = selector.init(new BlobMetadata().setUri(Uri.create("http: List<String> results = instance.select(" Assertions.assertThat(results).containsExactly("/test"); results = instance.select(" Assertions.assertThat(results).containsExactly("épatant"); }
@Override public Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment) { Element element; try { if (!isSegment) { element = Jsoup.parse(payload.openStream(), Charsets.UTF_8.name(), data.getUri().toString()); } else { element = Jsoup.parseBodyFragment(IOUtils.toString(payload.openStream()), data.getUri().toString()).body(); } } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new XpathSelectorInstance(element); }
XpathSelector extends BodySelector<XElement> { @Override public Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment) { Element element; try { if (!isSegment) { element = Jsoup.parse(payload.openStream(), Charsets.UTF_8.name(), data.getUri().toString()); } else { element = Jsoup.parseBodyFragment(IOUtils.toString(payload.openStream()), data.getUri().toString()).body(); } } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new XpathSelectorInstance(element); } }
XpathSelector extends BodySelector<XElement> { @Override public Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment) { Element element; try { if (!isSegment) { element = Jsoup.parse(payload.openStream(), Charsets.UTF_8.name(), data.getUri().toString()); } else { element = Jsoup.parseBodyFragment(IOUtils.toString(payload.openStream()), data.getUri().toString()).body(); } } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new XpathSelectorInstance(element); }  }
XpathSelector extends BodySelector<XElement> { @Override public Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment) { Element element; try { if (!isSegment) { element = Jsoup.parse(payload.openStream(), Charsets.UTF_8.name(), data.getUri().toString()); } else { element = Jsoup.parseBodyFragment(IOUtils.toString(payload.openStream()), data.getUri().toString()).body(); } } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new XpathSelectorInstance(element); }  @Override String name(); @Override Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment); }
XpathSelector extends BodySelector<XElement> { @Override public Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment) { Element element; try { if (!isSegment) { element = Jsoup.parse(payload.openStream(), Charsets.UTF_8.name(), data.getUri().toString()); } else { element = Jsoup.parseBodyFragment(IOUtils.toString(payload.openStream()), data.getUri().toString()).body(); } } catch (IOException e) { payload.release(); throw Throwables.propagate(e); } return new XpathSelectorInstance(element); }  @Override String name(); @Override Instance<XElement> init(BlobMetadata data, Payload payload, boolean isSegment);  }