当前位置: 首页>>代码示例>>Java>>正文


Java TripleCollection.filter方法代码示例

本文整理汇总了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;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:28,代码来源:Fise2FamEngine.java

示例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;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:17,代码来源:Fise2FamEngineTest.java

示例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;
}
 
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:33,代码来源:OsmRdfTransformer.java

示例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;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:15,代码来源:Fise2FamEngineTest.java

示例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;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:15,代码来源:Fise2FamEngineTest.java

示例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);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Fise2FamEngineTest.java

示例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);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:12,代码来源:Fise2FamEngineTest.java

示例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);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Fise2FamEngineTest.java

示例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());
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:6,代码来源:Fise2FamEngineTest.java

示例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());
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:6,代码来源:Fise2FamEngineTest.java


注:本文中的org.apache.clerezza.rdf.core.TripleCollection.filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。