/*
 * Copyright Amherst College
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package edu.amherst.acdc.trellis.spi;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.stream.Stream;

import org.apache.commons.rdf.api.Graph;
import org.apache.commons.rdf.api.IRI;
import org.apache.commons.rdf.api.RDFSyntax;
import org.apache.commons.rdf.api.Triple;

/**
 * The SerializationService defines methods for reading and writing RDF streams
 * to/from a concrete RDF 1.1 syntax.
 *
 * @author acoburn
 */
public interface SerializationService {

    /**
     * A method for setting a namespace service
     * @param service the service
     */
    void bind(NamespaceService service);

    /**
     * A method for unbinding a namespace service
     * @param service the service
     */
    void unbind(NamespaceService service);

    /**
     * A method for setting the namespace service
     * @param service the service
     */
    default void setNamespaceService(NamespaceService service) {
        bind(service);
    }

    /**
     * Serialize the triple stream as RDF
     * @param triples the stream of triples
     * @param output the output stream
     * @param syntax the output format
     * @param profiles additional profile information used for output
     */
    void write(Stream<Triple> triples, OutputStream output, RDFSyntax syntax, IRI... profiles);

    /**
     * Read an input stream into a graph
     * @param graph the graph
     * @param input the input stream
     * @param syntax the RDF syntax
     */
    void read(Graph graph, InputStream input, RDFSyntax syntax);
}

@@ -720,49 +720,8 @@
 m;%0A%0A
-import org.apache.commons.rdf.api.Graph;%0A
 impo
@@ -1905,43 +1905,25 @@
 o a 
-graph%0A     * @param graph the graph
+stream of triples
 %0A   
@@ -1974,81 +1974,167 @@
 ram 
-syntax the RDF syntax%0A     */%0A    void read(Graph graph, InputStream inpu
+context the RDF context%0A     * @param syntax the RDF syntax%0A     * @return a stream of triples%0A     */%0A    Stream%3CTriple%3E read(InputStream input, String contex
 t, R

add support for a context in the SerializationService::read method