Java Code Examples for org.eclipse.rdf4j.model.Model#isEmpty()

The following examples show how to use org.eclipse.rdf4j.model.Model#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrangedWriter.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private synchronized Set<Statement> queueBlankStatements(SubjectInContext key) {
	Model firstMatch = blanks.filter(key.getSubject(), null, null, key.getContext());
	Model matches = firstMatch.isEmpty() ? blankReferences.filter(key.getSubject(), null, null, key.getContext())
			: firstMatch;
	if (matches.isEmpty()) {
		return null;
	}
	Set<Statement> set = stmtBySubject.get(key);
	if (set == null) {
		stmtBySubject.put(key, set = new TreeSet<>(comparator));
	}
	set.addAll(matches);
	if (firstMatch.isEmpty()) {
		// repeat blank node values
		queueSize += matches.size();
	} else {
		if (repeatBlankNodes && key.getSubject() instanceof BNode && isStillReferenced(key)) {
			blankReferences.addAll(matches);
		}
		blanks.remove(key.getSubject(), null, null, key.getContext());
	}
	return set;
}
 
Example 2
Source File: RepositoryConfigUtil.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Statement getIDStatement(Model model, String repositoryID) {
	Literal idLiteral = SimpleValueFactory.getInstance().createLiteral(repositoryID);
	Model idStatementList = model.filter(null, REPOSITORYID, idLiteral);

	if (idStatementList.size() == 1) {
		return idStatementList.iterator().next();
	} else if (idStatementList.isEmpty()) {
		return null;
	} else {
		throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID);
	}
}
 
Example 3
Source File: SourceGenerator.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Gets the range of a given property IRI.
 *
 * @param propertyIri The property to fetch the range of
 * @return The IRI representing the range of the property
 */
private IRI getRangeOfProperty(final IRI propertyIri) {
    final Model submodel = this.metaModel.filter(propertyIri, RDFS.RANGE, null);
    if (!submodel.isEmpty()) {
        return (IRI) submodel.iterator().next().getObject();
    } else {
        return null;
    }
}