本文整理汇总了Java中org.apache.jena.util.iterator.Filter类的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Filter类属于org.apache.jena.util.iterator包,在下文中一共展示了Filter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showHierarchy
import org.apache.jena.util.iterator.Filter; //导入依赖的package包/类
/** Show the sub-class hierarchy encoded by the given model */
public void showHierarchy( PrintStream out, OntModel m ) {
// create an iterator over the root classes that are not anonymous class expressions
Iterator<OntClass> i = m.listHierarchyRootClasses()
.filterDrop( new Filter<OntClass>() {
@Override
public boolean accept( OntClass r ) {
return r.isAnon();
}} );
while (i.hasNext()) {
showClass( out, i.next(), new ArrayList<OntClass>(), 0 );
}
}
示例2: testTrie
import org.apache.jena.util.iterator.Filter; //导入依赖的package包/类
@Test
public void testTrie() {
Trie<String> trie = new Trie<String>();
trie.register("a/b/d", "1");
trie.register("a/c", "2");
trie.register("a/b/e", "3");
trie.register("f", "4");
assertEquals("1", trie.match("a/b/d/foo/bar").getMatch());
assertEquals("foo/bar", trie.match("a/b/d/foo/bar").getPathRemainder());
assertEquals("2", trie.match("a/c").getMatch());
assertEquals("3", trie.match("a/b/e/g").getMatch());
assertEquals("4", trie.match("f/g").getMatch());
assertNull(trie.match("g"));
assertNull(trie.match("a/b/g"));
assertNull(trie.match("a/d"));
TestUtil.testArray( trie.findAll("a/b", null), new String[] {"1", "3"});
TestUtil.testArray( trie.findAll("a", null), new String[] {"1", "2", "3"});
TestUtil.testArray( trie.findAll("a/b/d", null), new String[] {"1"});
TestUtil.testArray( trie.findAll("f", null), new String[] {"4"});
TestUtil.testArray( trie.findAll("g", null), new String[] {});
TestUtil.testArray( trie.findAll("", null), new String[] {"1", "2", "3", "4"});
TestUtil.testArray( trie.findAll("", new Filter<String>() {
@Override
public boolean accept(String o) {
return Integer.parseInt(o) >= 3;
}}), new String[] {"3", "4"});
trie.unregister("f");
trie.unregister("a/b/e");
assertEquals("1", trie.match("a/b/d/foo/bar").getMatch());
assertEquals("2", trie.match("a/c").getMatch());
assertNull( trie.match("a/b/e/g") );
assertNull( trie.match("f/g") );
trie.register("a/b/d", "1");
assertEquals("1", trie.match("a/b/d/foo/bar").getMatch());
}