本文整理汇总了Java中org.openrdf.model.Graph.match方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.match方法的具体用法?Java Graph.match怎么用?Java Graph.match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.Graph
的用法示例。
在下文中一共展示了Graph.match方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMetadataGraph
import org.openrdf.model.Graph; //导入方法依赖的package包/类
private void updateMetadataGraph(INamedGraphWithMetaData graph, File metaGraphFile) throws AnzoIoException {
INamedGraph metaGraph = null ;
try {
metaGraph = graph.getMetaDataGraph() ;
Graph metaFile = loadGraph(metaGraphFile) ;
URI newAcl = GraphUtil.getUniqueObjectURI(metaFile, graph.getNamedGraphUri(), uri(AnzoPredicates.USES_ACL)) ;
AnzoFactory.createACL(newAcl, metaGraph) ;
Iterator<Statement> acl = metaFile.match(newAcl, null, null) ;
while (acl.hasNext()) {
metaGraph.add(acl.next()) ;
}
metaGraph.add(graph.getNamedGraphUri(), uri(AnzoPredicates.USES_ACL), newAcl) ;
} catch (GraphUtilException e) {
throw new AnzoIoException("Unable to retrieve new ACL from meta graph file: " + metaGraphFile.getPath() + ".", e) ;
} finally {
if (metaGraph == null) {
metaGraph.close() ;
}
}
}
示例2: getObjectURI
import org.openrdf.model.Graph; //导入方法依赖的package包/类
/**
* Returns the object URI of the setting with the specified property.
*
* @param config the configuration settings.
* @param subject the subject (sub context) of the configuration setting.
* @param property the configuration property.
* @return the URI value of the desired property setting or null.
* @throws SailConfigException if there is no (single) URI to return.
*/
protected URI getObjectURI(Graph config, Resource subject, URI property) throws RepositoryConfigException {
Iterator<Statement> objects = config.match(subject, property, null);
if (!objects.hasNext())
return null;
// throw new RepositoryConfigException("found no settings for property " + property);
Statement st = objects.next();
if (objects.hasNext())
throw new RepositoryConfigException("found multiple settings for property " + property);
Value object = st.getObject();
if (object instanceof URI)
return (URI) object;
else
throw new RepositoryConfigException("property value is not a URI: " + property + " " + object);
}
示例3: getObjectLiteral
import org.openrdf.model.Graph; //导入方法依赖的package包/类
/**
* Returns the literal value of the triple's object matching the predicate.
*
* @param model the model of the configuration settings.
* @param implNode the model representing a configuration setting.
* @param predicate the predicate defining a configuration attribute.
* @return the literal value of the object or null.
* @throws SailConfigException if there is no literal to return.
*/
protected Literal getObjectLiteral(Graph model, Resource implNode, URI property) throws SailConfigException {
Iterator<Statement> objects = model.match(implNode, property, null);
if (!objects.hasNext())
return null;
Statement st = objects.next();
if (objects.hasNext())
throw new SailConfigException("found multiple object values for " + property);
Value object = st.getObject();
if (object instanceof Literal)
return (Literal) object;
else
throw new SailConfigException("object value is not a Literal: " + property + " " + object);
}
示例4: getObjectResource
import org.openrdf.model.Graph; //导入方法依赖的package包/类
/**
* Returns the object resource of the triple matching the supplied predicate.
*
* @param model the model of the configuration settings.
* @param implNode the model representing a configuration setting.
* @param predicate the predicate defining a configuration attribute.
* @return the resource representing the configuration attribute or null.
* @throws SailConfigException if there is no (single) resource to return.
*/
protected Resource getObjectResource(Graph model, Resource implNode, URI predicate) throws SailConfigException {
Iterator<Statement> objects = model.match(implNode, predicate, null);
if (!objects.hasNext())
return null;
// throw new SailConfigException("found no object value for " + predicate);
Statement st = objects.next();
if (objects.hasNext())
throw new SailConfigException("found multiple object values for " + predicate);
Value object = st.getObject();
if (object instanceof Resource)
return (Resource) object;
else
throw new SailConfigException("object value is not a Resource: " + predicate + " " + object);
}
示例5: filter
import org.openrdf.model.Graph; //导入方法依赖的package包/类
/**
* Helper method to extract a configuration's sub setting.
*
* @param model the configuration model
* @param implNode node representing a specific configuration context.
* @param option configuration option to look for
* @return set of found values for the configuration setting.
*/
// protected Set<Value> filter(Model model, Resource implNode, URI option) { // Sesame 3
protected Set<Value> filter(Graph model, Resource implNode, URI option) { // Sesame 2
// return model.filter(implNode, MEMBER, null).objects(); // Sesame 3
// Sesame 2:
Set<Value> values = new HashSet<Value>();
Iterator<Statement> objects = model.match(implNode, option, null);
while (objects.hasNext()) {
values.add(objects.next().getObject());
}
return values;
}