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


Java Statement.getResource方法代码示例

本文整理汇总了Java中org.apache.jena.rdf.model.Statement.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.getResource方法的具体用法?Java Statement.getResource怎么用?Java Statement.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.rdf.model.Statement的用法示例。


在下文中一共展示了Statement.getResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFirstRange

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
private static Resource getFirstRange(Resource property, Set<Resource> reached) {
	Resource directRange = getFirstDirectRange(property);
	if(directRange != null) {
		return directRange;
	}
	StmtIterator it = property.listProperties(RDFS.subPropertyOf);
	while (it.hasNext()) {
		Statement ss = it.next();
		if (ss.getObject().isURIResource()) {
			Resource superProperty = ss.getResource();
			if (!reached.contains(superProperty)) {
				reached.add(superProperty);
				Resource r = getFirstRange(superProperty, reached);
				if (r != null) {
					it.close();
					return r;
				}
			}
		}
	}
	return null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:23,代码来源:JenaUtil.java

示例2: hasIndirectType

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * Checks whether a given Resource is an instance of a given type, or
 * a subclass thereof.  Make sure that the expectedType parameter is associated
 * with the right Model, because the system will try to walk up the superclasses
 * of expectedType.  The expectedType may have no Model, in which case
 * the method will use the instance's Model.
 * @param instance  the Resource to test
 * @param expectedType  the type that instance is expected to have
 * @return true if resource has rdf:type expectedType
 */
public static boolean hasIndirectType(Resource instance, Resource expectedType) {
	
	if(expectedType.getModel() == null) {
		expectedType = expectedType.inModel(instance.getModel());
	}
	
	StmtIterator it = instance.listProperties(RDF.type);
	while(it.hasNext()) {
		Statement s = it.next();
		if(s.getObject().isResource()) {
			Resource actualType = s.getResource();
			if(actualType.equals(expectedType) || JenaUtil.hasSuperClass(actualType, expectedType)) {
				it.close();
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:30,代码来源:JenaUtil.java

示例3: getResource

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
protected Resource getResource(Resource resource, String name)
   {
if (resource == null) throw new IllegalArgumentException("Resource cannot be null");

StmtIterator it = resource.listProperties();
try
{
    while (it.hasNext())
    {
	Statement stmt = it.next();
	if (stmt.getObject().isAnon() && stmt.getPredicate().getLocalName().equals(name))
	{
	    if (log.isTraceEnabled()) log.trace("Found Resource {} for property name: {} ", stmt.getResource(), name);
	    return stmt.getResource();
	}
    }
}
finally
{
    it.close();
}

return null;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:25,代码来源:Skolemizer.java

示例4: exportVersions

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * Initiates export of versions for the given resource if it is a versioned resourced
 * 
 * @param uri resource uri
 * @throws FcrepoOperationFailedException
 * @throws IOException
 */
private void exportVersions(final URI uri) throws FcrepoOperationFailedException, IOException {
    // Do not check for versions if disabled, already exporting a version, or the repo root
    if (!config.includeVersions() || uri.toString().contains(FCR_VERSIONS_PATH)
            || uri.equals(repositoryRoot)) {
        return;
    }

    // Create URI for location of the versions endpoint for this resource
    final URI versionsUri = addRelativePath(uri, FCR_VERSIONS_PATH);
    try (FcrepoResponse response = client().get(versionsUri).accept(config.getRdfLanguage()).perform()) {
        // Verify that fcr:versions can be accessed, which will fail if the resource is not versioned
        checkValidResponse(response, versionsUri, config.getUsername());

        // Persist versions response
        final File file = TransferProcess.fileForURI(versionsUri, null, null, config.getBaseDirectory(),
                config.getRdfExtension());
        writeResponse(uri, response.getBody(), null, file);

        // Extract uris of previous versions for export
        final Model model = createDefaultModel().read(new FileInputStream(file), null, config.getRdfLanguage());
        final Resource resc = model.getResource(uri.toString());

        final StmtIterator versionsIt = resc.listProperties(HAS_VERSION);
        while (versionsIt.hasNext()) {
            final Statement versionSt = versionsIt.next();
            final Resource versionResc = versionSt.getResource();
            exportLogger.info("Exporting version: {}", versionResc.getURI());
            logger.info("Exporting version {} for {}", versionResc.getURI(), uri);

            export(URI.create(versionResc.getURI()));
        }
    } catch (ResourceNotFoundRuntimeException e) {
        // Expected case for when the resource is not versioned
        logger.trace("Resource {} is not versioned", uri);
    }
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-import-export,代码行数:44,代码来源:Exporter.java

示例5: getResourceProperty

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public static Resource getResourceProperty(Resource subject, Property predicate) {
	Statement s = subject.getProperty(predicate);
	if(s != null && s.getObject().isResource()) {
		return s.getResource();
	}
	else {
		return null;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:10,代码来源:JenaUtil.java

示例6: getResourcePropertyWithType

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
public static Resource getResourcePropertyWithType(Resource subject, Property predicate, Resource type) {
	StmtIterator it = subject.listProperties(predicate);
	while(it.hasNext()) {
		Statement s = it.next();
		if(s.getObject().isResource() && JenaUtil.hasIndirectType(s.getResource(), type)) {
			it.close();
			return s.getResource();
		}
	}
	return null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:12,代码来源:JenaUtil.java

示例7: applyEntailments

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
/**
 * Ensures that the data graph includes any entailed triples inferred by the regime
 * specified using sh:entailment in the shapes graph.
 * Should be called prior to validation.
 * Throws an Exception if unsupported entailments are found.
 * If multiple sh:entailments are present then their order is undefined but they all get applied.
 */
public void applyEntailments() throws InterruptedException {
	Model shapesModel = dataset.getNamedModel(shapesGraphURI.toString());
	for(Statement s : shapesModel.listStatements(null, SH.entailment, (RDFNode)null).toList()) {
		if(s.getObject().isURIResource()) {
			if(SHACLEntailment.get().getEngine(s.getResource().getURI()) != null) {
				this.dataset = SHACLEntailment.get().withEntailment(dataset, shapesGraphURI, shapesGraph, s.getResource(), monitor);
			}
			else {
				throw new UnsupportedOperationException("Unsupported entailment regime " + s.getResource());
			}
		}
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:21,代码来源:ValidationEngine.java

示例8: getPredicate

import org.apache.jena.rdf.model.Statement; //导入方法依赖的package包/类
@Override
public Resource getPredicate() {
	Statement s = getProperty(SH.predicate);
	return s != null && s.getObject().isResource() ? s.getResource() : null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:6,代码来源:SHRuleImpl.java


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