Search in sources :

Example 1 with NamespaceAware

use of org.eclipse.rdf4j.model.NamespaceAware in project rdf4j by eclipse.

the class Rio method write.

/**
 * Writes the given statements to the given {@link RDFHandler}.
 * <p>
 * If the collection is a {@link Model}, its namespaces will also be written.
 *
 * @param model
 *        A collection of statements, such as a {@link Model}, to be written.
 * @throws RDFHandlerException
 *         Thrown if there is an error writing the statements.
 */
public static void write(Iterable<Statement> model, RDFHandler writer) throws RDFHandlerException {
    writer.startRDF();
    if (model instanceof NamespaceAware) {
        for (Namespace nextNamespace : ((NamespaceAware) model).getNamespaces()) {
            writer.handleNamespace(nextNamespace.getPrefix(), nextNamespace.getName());
        }
    }
    for (final Statement st : model) {
        writer.handleStatement(st);
    }
    writer.endRDF();
}
Also used : NamespaceAware(org.eclipse.rdf4j.model.NamespaceAware) Statement(org.eclipse.rdf4j.model.Statement) Namespace(org.eclipse.rdf4j.model.Namespace)

Aggregations

Namespace (org.eclipse.rdf4j.model.Namespace)1 NamespaceAware (org.eclipse.rdf4j.model.NamespaceAware)1 Statement (org.eclipse.rdf4j.model.Statement)1