本文整理汇总了Java中org.apache.clerezza.rdf.core.TripleCollection.filter方法的典型用法代码示例。如果您正苦于以下问题:Java TripleCollection.filter方法的具体用法?Java TripleCollection.filter怎么用?Java TripleCollection.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.clerezza.rdf.core.TripleCollection
的用法示例。
在下文中一共展示了TripleCollection.filter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
/**
* Checks if the value is parsed of the parsed triple filter.
* IMPARTANT: This method expects that exactly one of subject, predicate and
* object is <code>null</code>
* @param source the triple collection
* @param sub subject filter (<code>null</code> for wildcard)
* @param pred predicate filter (<code>null</code> for wildcard)
* @param obj Object filter (<code>null</code> for wildcard)
* @param value the value
* @return <code>true</code> if the parsed value is part of the triples selected
* by the parsed triple pattern.
*/
public boolean hasValue(TripleCollection source, NonLiteral sub, UriRef pred, Resource obj, Resource value){
if(value == null){
return false;
}
Iterator<Triple> it = source.filter(sub, pred, obj);
while(it.hasNext()){
Triple t = it.next();
Resource act = sub == null ? t.getSubject() : pred == null
? t.getPredicate() : t.getObject();
if(act.equals(value)){
return true;
}
}
return false;
}
示例2: assertOptValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> Set<T> assertOptValues(TripleCollection graph,
NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
if(!it.hasNext()){
return Collections.emptySet();
}
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getObject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
示例3: getAddress
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private Address getAddress(TripleCollection inputGraph) {
Address addr = new Address();
Iterator<Triple> itriple = inputGraph.filter(null,schema_streetAddress,null);
while ( itriple.hasNext() ) {
Triple triple = itriple.next();
UriRef addressUri = (UriRef) triple.getSubject();
addr.setStreetAddress( ((PlainLiteralImpl) triple.getObject()).getLexicalForm() );
// get locality
Iterator<Triple> addresslocalityIter = inputGraph.filter(addressUri, schema_addressLocality, null) ;
if ( addresslocalityIter != null ) {
while ( addresslocalityIter.hasNext() ) {
String locality = ((PlainLiteralImpl) addresslocalityIter.next().getObject()).getLexicalForm();
if ( ! "".equals(locality) ) {
addr.setLocality( locality );
}
}
}
// get country code
Iterator<Triple> addressCountryIter = inputGraph.filter(addressUri, schema_addressCountry, null) ;
if ( addressCountryIter != null ) {
while ( addressCountryIter.hasNext() ) {
String countryCode = ((PlainLiteralImpl) addressCountryIter.next().getObject()).getLexicalForm();
if ( ! "".equals( countryCode ) ) {
addr.setCountryCode( countryCode );
}
}
}
}
return addr;
}
示例4: assertHasValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> Set<T> assertHasValues(TripleCollection graph,
NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
assertTrue("missing value for property "+property+ "on subject "+subject, it.hasNext());
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getObject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
示例5: assertHasInvValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> Set<T> assertHasInvValues(TripleCollection graph, NonLiteral object,
UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(null, property, object);
assertTrue("missing incoming value for property "+property+ "on object "+object, it.hasNext());
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getSubject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
示例6: assertSingleValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> T assertSingleValue(TripleCollection graph, NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
assertTrue("missing value for property "+property+ "on subject "+subject, it.hasNext());
Resource value = it.next().getObject();
assertFalse("multi values for property "+property+ "on subject "+subject, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
示例7: assertOptValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> T assertOptValue(TripleCollection graph, NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
if(!it.hasNext()){
return null;
}
Resource value = it.next().getObject();
assertFalse("multi values for property "+property+ "on subject "+subject, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
示例8: assertSingleInvValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private <T extends Resource> T assertSingleInvValue(TripleCollection graph, Resource object, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(null, property, object);
assertTrue("missing value for property "+property+ "on object "+object, it.hasNext());
Resource value = it.next().getSubject();
assertFalse("multi values for property "+property+ "on object "+object, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
示例9: assertNoValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private void assertNoValue(TripleCollection graph, NonLiteral subject,
UriRef property) {
Iterator<Triple> it = graph.filter(subject, property, null);
assertFalse(it.hasNext());
}
示例10: assertNoInvValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入方法依赖的package包/类
private void assertNoInvValue(TripleCollection graph, Resource object,
UriRef property) {
Iterator<Triple> it = graph.filter(null, property, object);
assertFalse(it.hasNext());
}