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


Java StmtIterator.close方法代码示例

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


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

示例1: addTransitiveObjects

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private static void addTransitiveObjects(Set<Resource> resources, Set<Resource> reached,
		Resource subject, Property predicate) {
	resources.add(subject);
	reached.add(subject);
	StmtIterator it = subject.listProperties(predicate);
	try {
		while (it.hasNext()) {
			RDFNode object = it.next().getObject();
			if (object instanceof Resource) {
				if (!reached.contains(object)) {
					addTransitiveObjects(resources, reached, (Resource)object, predicate);
				}
			}
		}
	}
	finally {
		it.close();
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:20,代码来源:JenaUtil.java

示例2: addTransitiveSubjects

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private static void addTransitiveSubjects(Set<Resource> reached, Resource object,
		Property predicate, ProgressMonitor monitor) {
	if (object != null) {
		reached.add(object);
		StmtIterator it = object.getModel().listStatements(null, predicate, object);
		try {
			while (it.hasNext()) {
				if (monitor != null && monitor.isCanceled()) {
					it.close();
					return;
				}
				Resource subject = it.next().getSubject();
				if (!reached.contains(subject)) {
					addTransitiveSubjects(reached, subject, predicate, monitor);
				}
			}
		}
		finally {
			it.close();
		}
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:23,代码来源:JenaUtil.java

示例3: getFirstRange

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的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

示例4: hasIndirectType

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的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

示例5: hasSuperClass

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private static boolean hasSuperClass(Resource subClass, Resource superClass, Set<Resource> reached) {
	StmtIterator it = subClass.listProperties(RDFS.subClassOf);
	while(it.hasNext()) {
		Statement s = it.next();
		if(superClass.equals(s.getObject())) {
			it.close();
			return true;
		}
		else if(!reached.contains(s.getResource())) {
			reached.add(s.getResource());
			if(hasSuperClass(s.getResource(), superClass, reached)) {
				it.close();
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:19,代码来源:JenaUtil.java

示例6: getSPARQL

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
@Override
protected String getSPARQL(Constraint constraint) {
	SHSPARQLConstraint sc = SHFactory.asSPARQLConstraint(constraint.getParameterValue());
	String select = JenaUtil.getStringProperty(sc, SH.select);
	if(select == null) {
		String message = "Missing " + SH.PREFIX + ":" + SH.select.getLocalName() + " of " + RDFLabels.get().getLabel(sc);
		if(sc.isAnon()) {
			StmtIterator it = sc.getModel().listStatements(null, null, sc);
			if(it.hasNext()) {
				Statement s = it.next();
				it.close();
				message += " at " + RDFLabels.get().getLabel(s.getSubject());
				message += " via " + RDFLabels.get().getLabel(s.getPredicate());
			}
		}
		throw new SHACLException(message);
	}
	return SPARQLSubstitutions.withPrefixes(select, sc);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:20,代码来源:SPARQLConstraintExecutor.java

示例7: getParameters

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
@Override
public List<SHParameter> getParameters() {
	List<SHParameter> results = new LinkedList<SHParameter>();
	StmtIterator it = null;
	JenaUtil.setGraphReadOptimization(true);
	try {
		Set<Resource> classes = JenaUtil.getAllSuperClasses(this);
		classes.add(this);
		for(Resource cls : classes) {
			it = cls.listProperties(SH.parameter);
			while(it.hasNext()) {
				Resource param = it.next().getResource();
				results.add(param.as(SHParameter.class));
			}
		}
	}
	finally {
		if (it != null) {
			it.close();
		}
		JenaUtil.setGraphReadOptimization(false);
	}
	return results;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:25,代码来源:SHParameterizableImpl.java

示例8: getResourceDefaultType

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public static Resource getResourceDefaultType(Resource resource) {
	StmtIterator it = resource.getModel().listStatements(null, null, resource);
	try {
		while(it.hasNext()) {
			Statement s = it.next();
			Resource defaultValueType = JenaUtil.getResourceProperty(s.getPredicate(), DASH.defaultValueType);
			if(defaultValueType != null) {
				return defaultValueType;
			}
		}
	}
	finally {
		it.close();
	}
	return null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:17,代码来源:SHACLUtil.java

示例9: getResource

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的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

示例10: getResourcePropertyWithType

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的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

示例11: getDirectDriver

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
private DeclarativeFunctionDriver getDirectDriver(Resource spinFunction) {
	if(!spinFunction.hasProperty(SPIN_ABSTRACT, JenaDatatypes.TRUE) &&
		!spinFunction.hasProperty(DASH.abstract_, JenaDatatypes.TRUE)) {
		StmtIterator it = spinFunction.listProperties();
		while(it.hasNext()) {
			Statement s = it.next();
			final DeclarativeFunctionDriver driver = drivers.get(s.getPredicate());
			if(driver != null) {
				it.close();
				return driver;
			}
		}
	}
	return null;
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:16,代码来源:DeclarativeFunctionDrivers.java

示例12: updateConforms

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
public void updateConforms() {
	boolean conforms = true;
	StmtIterator it = report.listProperties(SH.result);
	while(it.hasNext()) {
		Statement s = it.next();
		if(s.getResource().hasProperty(RDF.type, SH.ValidationResult)) {
			conforms = false;
			it.close();
			break;
		}
	}
	report.removeAll(SH.conforms);
	report.addProperty(SH.conforms, conforms ? JenaDatatypes.TRUE : JenaDatatypes.FALSE);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:15,代码来源:ValidationEngine.java

示例13: getLocalParameters

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
@Override
public Map<Property, Parameter> getLocalParameters()
{
    Map<Property, Parameter> args = new HashMap<>();
    
    StmtIterator it = listProperties(LDT.param);
    try
    {
        while(it.hasNext())
        {
            Statement stmt = it.next();
            if (!stmt.getObject().canAs(Parameter.class))
            {
                if (log.isErrorEnabled()) log.error("Unsupported Argument '{}' for Template '{}' (rdf:type ldt:Parameter missing)", stmt.getObject(), getURI());
                throw new OntologyException("Unsupported Argument '" + stmt.getObject() + "' for Template '" + getURI() + "' (rdf:type ldt:Parameter missing)");
            }

            Parameter arg = stmt.getObject().as(Parameter.class);
            if (args.containsKey(arg.getPredicate()))
            {
                if (log.isErrorEnabled()) log.error("Multiple Arguments with the same predicate '{}' for Template '{}' ", arg.getPredicate(), getURI());
                throw new OntologyException("Multiple Arguments with the same predicate '" + arg.getPredicate() + "' for Template '" + getURI() + "'");
            }
            
            args.put(arg.getPredicate(), arg);
        }
    }
    finally
    {
        it.close();
    }
    
    return args;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:35,代码来源:TemplateImpl.java

示例14: getLiteral

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

if (namePath.contains("."))
{
    String name = namePath.substring(0, namePath.indexOf("."));
    String nameSubPath = namePath.substring(namePath.indexOf(".") + 1);
    Resource subResource = getResource(resource, name);
    if (subResource != null) return getLiteral(subResource, nameSubPath);
}

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

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

示例15: parse

import org.apache.jena.rdf.model.StmtIterator; //导入方法依赖的package包/类
@Override
public void parse() throws DMPGraphException {

	final StmtIterator iter = model.listStatements();

	while (iter.hasNext()) {

		rdfHandler.handleStatement(iter.next());
	}

	iter.close();
}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:13,代码来源:JenaModelParser.java


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