285.7. エントリーのフィルタリング

上記のデータ形式のセクションで示したように、XPath を使用してエントリーを除外できます。Camel の Bean Integration を利用して、独自の条件を実装することもできます。たとえば、上記の XPath の例と同等のフィルターは次のようになります。

from("rss:file:src/test/data/rss20.xml?splitEntries=true&consumer.delay=100"). filter().method("myFilterBean", "titleContainsCamel").to("mock:result");

このためのカスタム Bean は次のようになります。

public static class FilterBean {
       public boolean titleContainsCamel(@Body SyndFeed feed) {
           SyndEntry firstEntry = (SyndEntry) feed.getEntries().get(0);
return firstEntry.getTitle().contains("Camel");