de.fuberlin.wiwiss.ng4j.impl
Class NamedGraphSetIO

java.lang.Object
  extended by de.fuberlin.wiwiss.ng4j.impl.NamedGraphSetIO
All Implemented Interfaces:
NamedGraphSet
Direct Known Subclasses:
NamedGraphSetBase, NamedGraphSetDB, NamedGraphSetImpl

public abstract class NamedGraphSetIO
extends Object
implements NamedGraphSet

Abstract NamedGraphSet implementation providing implementations for NamedGraphSet's various read and write methods.

TODO: Factor out graph writing into a GraphWriterService, use that also in NamedGraphModel

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
NamedGraphSetIO()
           
 
Method Summary
 void read(InputStream source, String lang, String baseURI)
          Read Named Graphs from an InputStream into the NamedGraphSet.
 void read(Reader source, String lang, String baseURI)
          Read Named Graphs from a Reader into the NamedGraphSet.
 void read(String url, String lang)
          Read Named Graphs from an URL into the NamedGraphSet.
 void write(OutputStream out, String lang, String baseURI)
          Writes a serialized represention of the NamedGraphSet to an OutputStream.
 void write(Writer out, String lang, String baseURI)
          Writes a serialized represention of the NamedGraphSet to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.fuberlin.wiwiss.ng4j.NamedGraphSet
addGraph, addQuad, asJenaGraph, asJenaModel, clear, close, containsGraph, containsGraph, containsQuad, countGraphs, countQuads, createGraph, createGraph, findQuads, findQuads, getGraph, getGraph, isEmpty, listGraphs, removeGraph, removeGraph, removeQuad
 

Constructor Detail

NamedGraphSetIO

public NamedGraphSetIO()
Method Detail

read

public void read(InputStream source,
                 String lang,
                 String baseURI)
Description copied from interface: NamedGraphSet
Read Named Graphs from an InputStream into the NamedGraphSet. Supported RDF serialization languages are "TRIX", "TRIX-EXT", "TRIG", "RDF/XML", "N-TRIPLE" and "N3".

Serialization languages that support named graphs (like TriX) will take the graph name(s) from the serialization. Other languages will take the base URI as the name of the graph.

If some of the graph names from the source are already used in the NamedGraphSet, then the statements from the old graphs will be replaced by those from the source.

Specified by:
read in interface NamedGraphSet
Parameters:
source - The source of the input serialization
lang - The RDF serialization language of the input
baseURI - The URI from where the input was read

read

public void read(Reader source,
                 String lang,
                 String baseURI)
Description copied from interface: NamedGraphSet
Read Named Graphs from a Reader into the NamedGraphSet. Supported RDF serialization languages are "TRIX", "TRIX-EXT", "TRIG", "RDF/XML", "N-TRIPLE" and "N3".

Serialization languages that support named graphs (like TriX) will take the graph name(s) from the serialization. Other languages will take the base URI as the name of the graph.

If some of the graph names from the source are already used in the NamedGraphSet, then the statements from the old graphs will be replaced by those from the source.

Specified by:
read in interface NamedGraphSet
Parameters:
source - The source of the input serialization
lang - The RDF serialization language of the input
baseURI - The URI from where the input was read

read

public void read(String url,
                 String lang)
Description copied from interface: NamedGraphSet
Read Named Graphs from an URL into the NamedGraphSet. Supported RDF serialization languages are "TRIX", "TRIX-EXT", "TRIG", "RDF/XML", "N-TRIPLE" and "N3".

Serialization languages that support named graphs (like TriX) will take the graph name(s) from the serialization. Other languages will take the URL as the name of the graph.

If some of the graph names from the source are already used in the NamedGraphSet, then the statements from the old graphs will be replaced by those from the source.

Specified by:
read in interface NamedGraphSet
Parameters:
url - The source of the input serialization
lang - The RDF serialization language of the input

write

public void write(OutputStream out,
                  String lang,
                  String baseURI)
Description copied from interface: NamedGraphSet
Writes a serialized represention of the NamedGraphSet to an OutputStream. Supported RDF serialization languages are "TRIX", "TRIG", "RDF/XML", "N-TRIPLE" and "N3".

If the specified serialization language doesn't support named graphs, then the union graph will be serialized, and knowledge about the graph name of each statement is lost. Only TriX supports named graphs.

The serialization will be UTF-8 encoded. There is currently no way to select a different encoding.

Specified by:
write in interface NamedGraphSet
Parameters:
out - The stream into which the serialization will be written
lang - The RDF serialization language to be used
baseURI - The base URI of the output file, or null if don't care

write

public void write(Writer out,
                  String lang,
                  String baseURI)
Description copied from interface: NamedGraphSet
Writes a serialized represention of the NamedGraphSet to a Writer. Supported RDF serialization languages are "TRIX", "TRIG", "RDF/XML", "N-TRIPLE" and "N3".

If the specified serialization language doesn't support named graphs, then the union graph will be serialized, and knowledge about the graph name of each statement is lost. Only TriX supports named graphs.

Note that this method might generate wrong results if the Writer is translated to bytes using anything but the system's default encoding. For this reason, NamedGraphSet.write(OutputStream, String, String) should be used if possible.

Specified by:
write in interface NamedGraphSet
Parameters:
out - The stream into which the serialization will be written
lang - The RDF serialization language to be used
baseURI - The base URI of the output file, or null if don't care