本文整理了Java中org.openrdf.model.Model.iterator()
方法的一些代码示例,展示了Model.iterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.iterator()
方法的具体详情如下:
包路径:org.openrdf.model.Model
类名称:Model
方法名:iterator
暂无
代码示例来源:origin: org.openrdf.alibaba/alibaba-model
public boolean hasNext() {
if (iter == null) {
iter = models[++idx].iterator();
}
while (!iter.hasNext() && idx < models.length - 1) {
iter = models[++idx].iterator();
}
return iter.hasNext();
}
代码示例来源:origin: org.openrdf.sesame/sesame-model
@Deprecated
@Override
public Iterator<Statement> match(Resource subj, IRI pred, Value obj, Resource... contexts) {
return this.filter(subj, pred, obj, contexts).iterator();
}
代码示例来源:origin: org.openrdf.alibaba/alibaba-model
public Iterator<Statement> iterator() {
return getDelegate().iterator();
}
代码示例来源:origin: org.openrdf.alibaba/alibaba-model
@Override
public Iterator<Statement> iterator() {
return getDelegate().filter(subj, pred, obj, contexts)
.iterator();
}
};
代码示例来源:origin: apache/stanbol
@Override
public void removeAllNaturalText(String field, String... languages) throws IllegalArgumentException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
ValueTypeFilter<Literal> vtf = new ValueTypeFilter<Literal>(languages);
Iterator<Statement> statements = model.filter(
subject, sesameFactory.createURI(field), null).iterator();
while(statements.hasNext()){
Statement statement = statements.next();
if(vtf.evaluate(statement.getObject())){
statements.remove();
}
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
public void removeAllNaturalText(String field, String... languages) throws IllegalArgumentException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
ValueTypeFilter<Literal> vtf = new ValueTypeFilter<Literal>(languages);
Iterator<Statement> statements = model.filter(
subject, sesameFactory.createURI(field), null).iterator();
while(statements.hasNext()){
Statement statement = statements.next();
if(vtf.evaluate(statement.getObject())){
statements.remove();
}
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-sail-base
private CloseableIteration<? extends Statement, SailException> union(
CloseableIteration<? extends Statement, SailException> result, Model included)
{
if (included.isEmpty()) {
return result;
}
final Iterator<Statement> iter = included.iterator();
CloseableIteration<Statement, SailException> incl;
incl = new CloseableIteratorIteration<Statement, SailException>(iter);
return new UnionIteration<Statement, SailException>(incl, result);
}
代码示例来源:origin: apache/stanbol
@Override
@SuppressWarnings("unchecked")
public Iterator<Reference> getReferences(String field) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Reference>(Reference.class)), //filter references
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
@SuppressWarnings("unchecked")
public Iterator<Reference> getReferences(String field) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Reference>(Reference.class)), //filter references
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: net.fortytwo.sesametools/common
/**
* Fetches a collection of generalized lists based on the given subject and
* predicate, where lists are allowed to branch from head to tail.
*
* @param subject the subject of a statement pointing to the list
* @param predicate the predicate of a statement pointing to the list
* @param graphToSearch the Model from which the list is to be fetched
* @param contexts the Model contexts from which the list is to be fetched
* @return all matching lists. If no matching lists are found, an empty
* collection is returned.
*/
public Collection<List<Value>> getListsAtNode(
final Resource subject, final IRI predicate,
final Model graphToSearch, final Resource... contexts) {
OpenRDFUtil.verifyContextNotNull(contexts);
Collection<List<Value>> results;
final Iterator<Statement> headStatementMatches = graphToSearch.filter(
subject, predicate, null, contexts).iterator();
final Set<Resource> heads = new HashSet<>();
while (headStatementMatches.hasNext()) {
final Statement nextHeadStatement = headStatementMatches.next();
if (nextHeadStatement.getObject() instanceof Resource) {
heads.add((Resource) nextHeadStatement.getObject());
}
}
results = this.getLists(heads, graphToSearch, contexts);
return results;
}
代码示例来源:origin: apache/stanbol
@Override
@SuppressWarnings("unchecked")
public <T> Iterator<T> get(String field, final Class<T> type) throws UnsupportedTypeException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
//filter for values that are compatible with the parsed type
Iterator<?> iterator = IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<T>(type));
if(!Value.class.isAssignableFrom(type)){
//if the requested type is not a Sesame value, we need also to
//transform results
iterator = IteratorUtils.transformedIterator(
iterator, // the already filtered values
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); // need to be transformed
}
return (Iterator<T>)iterator;
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
@SuppressWarnings("unchecked")
public <T> Iterator<T> get(String field, final Class<T> type) throws UnsupportedTypeException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
//filter for values that are compatible with the parsed type
Iterator<?> iterator = IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<T>(type));
if(!Value.class.isAssignableFrom(type)){
//if the requested type is not a Sesame value, we need also to
//transform results
iterator = IteratorUtils.transformedIterator(
iterator, // the already filtered values
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); // need to be transformed
}
return (Iterator<T>)iterator;
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
@SuppressWarnings("unchecked")
public Iterator<Object> get(String field) throws IllegalArgumentException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
notPredicate(instanceofPredicate(BNode.class))),
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); // transform the values
}
代码示例来源:origin: apache/stanbol
@Override
@SuppressWarnings("unchecked")
public Iterator<Object> get(String field) throws IllegalArgumentException {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
notPredicate(instanceofPredicate(BNode.class))),
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); // transform the values
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
@SuppressWarnings("unchecked")
public Iterator<Text> get(String field, String...languages) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Text>(languages)), //filter languages
org.apache.stanbol.entityhub.model.sesame.ModelUtils.STRING_LITERAL_TO_TEXT_TRANSFORMER), //transform strings to Text
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.model.sesame
@Override
@SuppressWarnings("unchecked")
public Iterator<Text> getText(String field) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Text>(Text.class)), //filter plain literals
org.apache.stanbol.entityhub.model.sesame.ModelUtils.STRING_LITERAL_TO_TEXT_TRANSFORMER),
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: apache/stanbol
@Override
@SuppressWarnings("unchecked")
public Iterator<Text> get(String field, String...languages) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Text>(languages)), //filter languages
org.apache.stanbol.entityhub.model.sesame.ModelUtils.STRING_LITERAL_TO_TEXT_TRANSFORMER), //transform strings to Text
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: apache/stanbol
@Override
@SuppressWarnings("unchecked")
public Iterator<Text> getText(String field) {
if(field == null){
throw new IllegalArgumentException("The parsed field MUST NOT be NULL");
} else if(field.isEmpty()){
throw new IllegalArgumentException("The parsed field MUST NOT be Empty");
}
URI property = sesameFactory.createURI(field);
return IteratorUtils.transformedIterator(
IteratorUtils.transformedIterator(
IteratorUtils.filteredIterator(
IteratorUtils.transformedIterator(
model.filter(subject, property, null).iterator(),
objectTransFormer), // get the object from the statement
new ValueTypeFilter<Text>(Text.class)), //filter plain literals
org.apache.stanbol.entityhub.model.sesame.ModelUtils.STRING_LITERAL_TO_TEXT_TRANSFORMER),
org.apache.stanbol.entityhub.model.sesame.ModelUtils.VALUE_TRANSFORMER); //transform to Text instances
}
代码示例来源:origin: apache/marmotta
/**
* Get the statements for the query pattern passed as arguments. In case the subject resource is acceptable for caching,
* refreshes the cache for this resource and returns a merged query result together with the wrapped connection.
* Otherwise, simply delegates to the wrapped connection.
*
* @param subj
* @param pred
* @param obj
* @param includeInferred
* @param contexts
* @return
* @throws SailException
*/
@Override
public CloseableIteration<? extends Statement, SailException> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException {
if (accept(subj)) {
log.debug("Refreshing resource: {}", subj.stringValue());
final Model cached = ldcache.get((URI)subj);
// join the results of the cache connection and the wrapped connection in a single result
return new UnionIteration<>(
new CloseableIteratorIteration<Statement, SailException>(cached.iterator()),
super.getStatements(subj, pred, obj, includeInferred, contexts)
);
} else {
return super.getStatements(subj, pred, obj, includeInferred, contexts);
}
}
代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-optimistic
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(
BindingSet bindings) throws QueryEvaluationException {
if (this.bindings != null) {
QueryBindingSet b = new QueryBindingSet(bindings);
b.addAll(this.bindings);
bindings = b;
}
CloseableIteration<? extends Statement, QueryEvaluationException> stIter = null;
try {
Resource[] contexts = contexts(sp, dataset, bindings);
if (contexts == null)
return new EmptyIteration<BindingSet, QueryEvaluationException>();
Iterator<Statement> iter = filter(model, bindings).iterator();
stIter = new CloseableIteratorIteration<Statement, QueryEvaluationException>(iter);
if (contexts.length == 0 && sp.getScope() == Scope.NAMED_CONTEXTS) {
stIter = new NamedContextCursor(stIter);
}
} catch (ClassCastException e) {
// Invalid value type for subject, predicate and/or context
return new EmptyIteration<BindingSet, QueryEvaluationException>();
}
// The same variable might have been used multiple times in this
// StatementPattern, verify value equality in those cases.
stIter = new StatementPatternCursor(stIter, sp);
// Return an iterator that converts the statements to var bindings
return new StatementBindingSetCursor(stIter, sp, bindings);
}
内容来源于网络,如有侵权,请联系作者删除!