本文整理汇总了Java中com.hp.hpl.jena.util.iterator.ClosableIterator类的典型用法代码示例。如果您正苦于以下问题:Java ClosableIterator类的具体用法?Java ClosableIterator怎么用?Java ClosableIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClosableIterator类属于com.hp.hpl.jena.util.iterator包,在下文中一共展示了ClosableIterator类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: bodyCall
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @param length the length of the argument list, may be less than the length of the args array
* for some rule engines
* @param context an execution context giving access to other relevant data
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
if (length != 3) {
throw new BuiltinException(this, context, "builtin " + getName() + " requires 3 arguments but saw " + length);
}
Node subj = getArg(0, args, context);
Node op1 = getArg(1, args, context);
Node p2 = getArg(2, args, context);
if (_logger.isDebugEnabled()) {
_logger.debug("in Rule " + context.getRule().getName() + " called with args (" + subj.toString() + ", " + op1.toString() + ", " + p2.toString() + ")");
}
ClosableIterator<Triple> citr = context.find(subj, op1, (Node)null);
while (citr.hasNext()) {
Object o = citr.next();
Node objval = ((Triple) o).getObject();
boolean bContainsObj = context.contains(objval, p2, (Node)null);
if (!bContainsObj) {
citr.close();
if (_logger.isDebugEnabled()) {
_logger.debug("in Rule " + context.getRule().getName() + " returning false on value '" + objval.toString() + "'");
}
return false;
}
}
citr.close();
if (_logger.isDebugEnabled()) {
_logger.debug("in Rule " + context.getRule().getName() + " returning true");
}
return true;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:40,代码来源:NoUnknownValues.java
示例2: bodyCall
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @param length the length of the argument list, may be less than the length of the args array
* for some rule engines
* @param context an execution context giving access to other relevant data
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
if (length != 3) {
throw new BuiltinException(this, context, "builtin " + getName() + " requires 3 arguments but saw " + length);
}
Node obj = getArg(2, args, context);
Node subj = getArg(0, args, context);
// Allow variables in subject position to correspond to a wild card
if (subj.isVariable()) {
subj = null;
}
// Allow variables in the predicate position to correspond to a wild card
Node pred = getArg(1, args, context);
if (pred.isVariable()) {
pred = null;
}
boolean bContainsObj = context.contains(subj, pred, obj);
if (!bContainsObj) {
return false;
}
// does it contain anything else?
ClosableIterator<Triple> citr = context.find(subj, pred, (Node)null);
boolean otherValue = false;
while (citr.hasNext()) {
Object o = citr.next();
Node objval = ((Triple) o).getObject();
if (!objval.equals(obj)) {
otherValue = true;
break;
}
}
citr.close();
return !otherValue;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:45,代码来源:NoValuesOtherThan.java
示例3: bodyCall
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @param length the length of the argument list, may be less than the length of the args array
* for some rule engines
* @param context an execution context giving access to other relevant data
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
if (length != 3) {
throw new BuiltinException(this, context, "builtin " + getName() + " requires 3 arguments but saw " + length);
}
Node obj = getArg(2, args, context);
Node subj = getArg(0, args, context);
// Allow variables in subject position to correspond to a wild card
if (subj.isVariable()) {
subj = null;
}
// Allow variables in the predicate position to correspond to a wild card
Node pred = getArg(1, args, context);
if (pred.isVariable()) {
pred = null;
}
boolean bContainsObj = context.contains(subj, pred, obj);
if (!bContainsObj) {
return false;
}
// does it contain anything else?
ClosableIterator<Triple> citr = context.find(subj, pred, (Node)null);
boolean otherValue = false;
while (citr.hasNext()) {
Triple o = citr.next();
Node objval = o.getObject();
if (!objval.equals(obj)) {
otherValue = true;
break;
}
}
citr.close();
return otherValue;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:45,代码来源:NotOnlyValue.java
示例4: bodyCall
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* This method is invoked when the builtin is called in a rule body.
* @param args the array of argument values for the builtin, this is an array
* of Nodes, some of which may be Node_RuleVariables.
* @param length the length of the argument list, may be less than the length of the args array
* for some rule engines
* @param context an execution context giving access to other relevant data
* @return return true if the buildin predicate is deemed to have succeeded in
* the current environment
*/
public boolean bodyCall(Node[] args, int length, RuleContext context) {
if (length != 3) {
throw new BuiltinException(this, context, "builtin " + getName() + " requires 3 arguments but saw " + length);
}
Node obj = getArg(2, args, context);
Node subj = getArg(0, args, context);
// Allow variables in subject position to correspond to a wild card
if (subj.isVariable()) {
subj = null;
}
// Allow variables in the predicate position to correspond to a wild card
Node pred = getArg(1, args, context);
if (pred.isVariable()) {
pred = null;
}
boolean bContainsObj = context.contains(subj, pred, obj);
if (!bContainsObj) {
return false;
}
// does it contain anything else?
ClosableIterator<Triple> citr = context.find((Node)null, pred, obj);
boolean otherSubject = false;
while (citr.hasNext()) {
Object o = citr.next();
Node tmpSubj = ((Triple) o).getSubject();
if (!tmpSubj.equals(subj)) {
otherSubject = true;
break;
}
}
citr.close();
return !otherSubject;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:45,代码来源:NoSubjectsOtherThan.java
示例5: find
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* Call this method to find the subject, predicate, or object of a triple matching the input
* pattern in the context. One of subject, predicate, or object can be null on input.
* @param subj - subject Node or null
* @param prop - predicate Node or null
* @param obj - object value Node or null
* @param cls - if subject is null, optional specification of a class to which the matching subject must belong
* @param context
* @return
*/
public static synchronized Node find(Node subj, Node prop, Node obj, Node cls, RuleContext context) {
ClosableIterator<Triple> itr = context.find(subj, prop, obj);
if (itr.hasNext()) {
Triple t = itr.next();
itr.close();
if (subj == null) {
if (cls == null || verifyNodeType(((Triple)t).getMatchSubject(), cls, context)) {
itr.close();
return ((Triple)t).getMatchSubject();
}
}
else if (prop == null) {
if (cls == null || verifyNodeType(((Triple)t).getMatchPredicate(), cls, context)) {
itr.close();
return ((Triple)t).getMatchPredicate();
}
}
else if (obj == null) {
if (cls == null || verifyNodeType(((Triple)t).getMatchObject(), cls, context)) {
itr.close();
return ((Triple) t).getMatchObject();
}
}
}
return null;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:37,代码来源:Utils.java
示例6: verifyNodeType
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
public static synchronized boolean verifyNodeType(Node matching, Node cls, RuleContext context) {
ClosableIterator<Triple> itr = context.find(matching, RDF.Nodes.type, cls);
if (itr.hasNext()) {
itr.close();
return true;
}
itr.close();
if (_logger.isDebugEnabled()) {
itr = context.find(matching, RDF.Nodes.type, null);
while (itr.hasNext()) {
_logger.debug("Check for type '" + cls.toString() + "' failed, type is '" + itr.next().toString() + "'");
}
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:16,代码来源:Utils.java
示例7: doTransitiveClosure
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* Find superclasses of input cls and make inst a type of each
*
* @param inst
* @param cls
*/
public static synchronized void doTransitiveClosure(Node inst, Node cls, RuleContext context) {
ClosableIterator<Triple> citr = context.find(cls, RDFS.subClassOf.asNode(), null);
while (citr.hasNext()) {
Triple t = citr.next();
Node scls = t.getObject();
if (scls.isURI()) {
// only give types that are named? (this would fail for unnamed unions, intersections, etc.
Triple tct = new Triple(inst, RDF.type.asNode(), scls);
Utils.doAddTriple(tct, context, true);
}
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:19,代码来源:GetInstance.java
示例8: writeOneGraphNode
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
protected void writeOneGraphNode(Resource subject)
{
// New top level item.
// Does not take effect until newline.
out.incIndent(indentProperty) ;
writeSubject(subject);
ClosableIterator<Property> iter = preparePropertiesForSubject(subject);
writePropertiesForSubject(subject, iter) ;
out.decIndent(indentProperty) ;
out.println(" .");
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:12,代码来源:N3JenaWriterCommon.java
示例9: writePropertiesForSubject
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
protected void writePropertiesForSubject(Resource subj, ClosableIterator<Property> iter)
{
// For each property.
for (; iter.hasNext();)
{
Property property = iter.next();
// Object list
writeObjectList(subj, property);
if (iter.hasNext())
out.println(" ;");
}
iter.close();
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:16,代码来源:N3JenaWriterCommon.java
示例10: preparePropertiesForSubject
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
protected ClosableIterator<Property> preparePropertiesForSubject(Resource r)
{
// Properties to do.
Set<Property> properties = new HashSet<Property>() ;
StmtIterator sIter = r.listProperties();
for ( ; sIter.hasNext() ; )
properties.add(sIter.nextStatement().getPredicate()) ;
sIter.close() ;
return WrappedIterator.create(properties.iterator()) ;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:12,代码来源:N3JenaWriterCommon.java
示例11: doGetPropValue
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* Internall implementation of all the getPropValue variants.
*/
private static Node doGetPropValue(ClosableIterator<Triple> it) {
Node result = null;
if (it.hasNext()) {
result = it.next().getObject();
}
it.close();
return result;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:12,代码来源:Util.java
示例12: contains
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* Return true if the triple pattern is already in either the graph or the stack.
* I.e. it has already been deduced.
*/
public boolean contains(Node s, Node p, Node o) {
// Can't use stackCache.contains because that does not do semantic equality
ClosableIterator<Triple> it = find(s, p, o);
boolean result = it.hasNext();
it.close();
return result;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:12,代码来源:BFRuleContext.java
示例13: contains
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* Return true if the triple pattern is already in either the graph or the stack.
* I.e. it has already been deduced.
*/
public boolean contains(Node s, Node p, Node o) {
ClosableIterator<Triple> it = find(s, p, o);
boolean result = it.hasNext();
it.close();
return result;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:11,代码来源:RETERuleContext.java
示例14: contains
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* @see com.hp.hpl.jena.reasoner.rulesys.RuleContext#contains(com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node)
*/
public boolean contains(Node s, Node p, Node o) {
ClosableIterator<Triple> i = find(s, p, o);
boolean result = i.hasNext();
i.close();
return result;
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:10,代码来源:BBRuleContext.java
示例15: find
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* @see com.hp.hpl.jena.reasoner.rulesys.RuleContext#find(com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node)
*/
public ClosableIterator<Triple> find(Node s, Node p, Node o) {
return graph.findDataMatches(new TriplePattern(s, p, o));
// return searchpath.find(new TriplePattern(s, p, o));
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:8,代码来源:BBRuleContext.java
示例16: find
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* In some formulations the context includes deductions that are not yet
* visible to the underlying graph but need to be checked for.
*/
public ClosableIterator<Triple> find(Node s, Node p, Node o);
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:6,代码来源:RuleContext.java
示例17: find
import com.hp.hpl.jena.util.iterator.ClosableIterator; //导入依赖的package包/类
/**
* In some formulations the context includes deductions that are not yet
* visible to the underlying graph but need to be checked for.
* However, currently this calls the graph find directly.
*/
public ClosableIterator<Triple> find(Node s, Node p, Node o) {
//return graph.find(s, p, o).andThen(pendingCache.find(s, p, o));
return graph.findDataMatches(s, p, o);
}
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:10,代码来源:BFRuleContext.java
注:本文中的com.hp.hpl.jena.util.iterator.ClosableIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论