本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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());
}
}
}
}
示例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;
}