       (throw (ex-info (str "Unsupported format: " (pr-str format)) {:type :unsupported-format})))
     (let [^RDFParserFactory factory (.newInstance parser-class)]
       (.getParser factory))))
-
-(defn filename->rdf-format
-  "Given a filename we attempt to return an appropriate RDFFormat
-  object based on the files extension."
-  [fname]
-  (Rio/getParserFormatForFileName fname))
-
-(defn mimetype->rdf-format
-  "Given a mimetype string we attempt to return an appropriate
-  RDFFormat object based on the files extension."
-  [mime-type]
-  (let [base-type (str (mime/base-type mime-type))]
-    (condp = base-type
-      "application/n-triples" RDFFormat/NTRIPLES ;; Sesame doesn't yet support application/n-triples
-      (Rio/getParserFormatForMIMEType mime-type))))
 
 ;; http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/
 (defn- pipe


  ([destination & {:keys [append format encoding] :or {append false
                                                       encoding "UTF-8"}}]
     (let [^RDFFormat format (or format
                      (condp = (class destination)
                        String (Rio/getWriterFormatForFileName destination)
                        File   (Rio/getWriterFormatForFileName (str destination))
                        (throw (ex-info "Could not infer file format, please supply a :format parameter" {:error :could-not-infer-file-format :object destination}))))]
       (Rio/createWriter format
                         (io/writer destination
                                    :append append
                                    :encoding encoding)))))

(extend-protocol pr/ITripleWriteable
  RDFWriter

         (when-let [graph (.getContext st)]
           (sesame-rdf-type->type graph))))

(defn filename->rdf-format
  "Given a filename we attempt to return an appropriate RDFFormat
  object based on the files extension."
  [fname]
  (Rio/getParserFormatForFileName fname))

(defn mimetype->rdf-format
  "Given a mimetype string we attempt to return an appropriate
  RDFFormat object based on the files extension."
  [mime-type]
  (let [base-type (str (mime/base-type mime-type))]
    (condp = base-type
      "application/n-triples" RDFFormat/NTRIPLES ;; Sesame doesn't yet support application/n-triples
      (Rio/getParserFormatForMIMEType mime-type))))

(defn rdf-serializer
  "Coerces destination into an java.io.Writer using
  clojure.java.io/writer and returns an RDFSerializer.
