本文整理匯總了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());
}