de.fuberlin.wiwiss.ng4j.trix
Class TriXReader

java.lang.Object
  extended by de.fuberlin.wiwiss.ng4j.trix.TriXReader
All Implemented Interfaces:
NamedGraphSetReader, ParserCallback

public class TriXReader
extends Object
implements ParserCallback, NamedGraphSetReader

Reads TriX files (see TriX specification) into NamedGraphSets.

Ignores additional graph names if there are more than one name per graph. Doesn't allow the same name for multiple graphs. Graphs without name get assigned a default name given by the caller.

TODO: Discuss if above cases are really wanted for TriX and move them up into the SAXHandler

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
TriXReader()
           
 
Method Summary
 void endGraph()
          Called at the end of each trix:graph element
 void objectBNode(String id)
          Called for each trix:triple element whose object is a trix:id.
 void objectPlainLiteral(String value, String lang)
          Called for each trix:triple element whose object is a trix:plainLiteral.
 void objectTypedLiteral(String value, String datatypeURI)
          Called for each trix:triple element whose object is a trix:typedLiteral.
 void objectURI(String uri)
          Called for each trix:triple element whose object is a trix:uri.
 void predicate(String uri)
          Called for the predicate of each trix:triple.
 void read(NamedGraphSet namedGraphSet, InputStream source, String baseURI, String defaultGraphName)
          Reads Named Graphs from an InputStream into a NamedGraphSet.
 void read(NamedGraphSet namedGraphSet, Reader source, String baseURI, String defaultGraphName)
          Reads Named Graphs from a Reader into a NamedGraphSet.
 void startGraph(List uris)
          Called at the beginning of each trix:graph element.
 void subjectBNode(String id)
          Called for each trix:triple element whose subject is a trix:id.
 void subjectPlainLiteral(String value, String lang)
          Called for each trix:triple element whose subject is a trix:plainLiteral.
 void subjectTypedLiteral(String value, String datatypeURI)
          Called for each trix:triple element whose subject is a trix:typedLiteral.
 void subjectURI(String uri)
          Called for each trix:triple element whose subject is a trix:uri.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriXReader

public TriXReader()
Method Detail

read

public void read(NamedGraphSet namedGraphSet,
                 Reader source,
                 String baseURI,
                 String defaultGraphName)
Description copied from interface: NamedGraphSetReader
Reads Named Graphs from a Reader into a NamedGraphSet. 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 NamedGraphSetReader
Parameters:
namedGraphSet - Graphs read from the source will be stored into this NamedGraphSet
source - The source of the input serialization
baseURI - The URI from where the input was read
defaultGraphName - If a graph in the input has no name attached, then this will be used. When in doubt, use the baseURI.

read

public void read(NamedGraphSet namedGraphSet,
                 InputStream source,
                 String baseURI,
                 String defaultGraphName)
Description copied from interface: NamedGraphSetReader
Reads Named Graphs from an InputStream into a NamedGraphSet. 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 NamedGraphSetReader
Parameters:
namedGraphSet - Graphs read from the source will be stored into this NamedGraphSet
source - The source of the input serialization
baseURI - The URI from where the input was read
defaultGraphName - If a graph in the input has no name attached, then this will be used. When in doubt, use the baseURI.

startGraph

public void startGraph(List uris)
Description copied from interface: ParserCallback
Called at the beginning of each trix:graph element.

Specified by:
startGraph in interface ParserCallback
Parameters:
uris - zero or more names of the graph, as strings

endGraph

public void endGraph()
Description copied from interface: ParserCallback
Called at the end of each trix:graph element

Specified by:
endGraph in interface ParserCallback

subjectURI

public void subjectURI(String uri)
Description copied from interface: ParserCallback
Called for each trix:triple element whose subject is a trix:uri.

Specified by:
subjectURI in interface ParserCallback
Parameters:
uri - the subject URI of the triple

subjectBNode

public void subjectBNode(String id)
Description copied from interface: ParserCallback
Called for each trix:triple element whose subject is a trix:id.

Specified by:
subjectBNode in interface ParserCallback
Parameters:
id - the subject blank node ID of the triple

subjectPlainLiteral

public void subjectPlainLiteral(String value,
                                String lang)
Description copied from interface: ParserCallback
Called for each trix:triple element whose subject is a trix:plainLiteral. Note that RDF doesn't allow literals as subjects, but TriX does.

Specified by:
subjectPlainLiteral in interface ParserCallback
Parameters:
value - the subject literal value of the triple
lang - the language tag of the subject literal, or null if none was given

subjectTypedLiteral

public void subjectTypedLiteral(String value,
                                String datatypeURI)
Description copied from interface: ParserCallback
Called for each trix:triple element whose subject is a trix:typedLiteral. Note that RDF doesn't allow literals as subjects, but TriX does.

Specified by:
subjectTypedLiteral in interface ParserCallback
Parameters:
value - the subject literal value of the triple
datatypeURI - the datatype URI of the subject literal

predicate

public void predicate(String uri)
Description copied from interface: ParserCallback
Called for the predicate of each trix:triple.

Specified by:
predicate in interface ParserCallback
Parameters:
uri - the predicate URI of the triple.

objectURI

public void objectURI(String uri)
Description copied from interface: ParserCallback
Called for each trix:triple element whose object is a trix:uri.

Specified by:
objectURI in interface ParserCallback
Parameters:
uri - the object URI of the triple

objectBNode

public void objectBNode(String id)
Description copied from interface: ParserCallback
Called for each trix:triple element whose object is a trix:id.

Specified by:
objectBNode in interface ParserCallback
Parameters:
id - the object blank node ID of the triple

objectPlainLiteral

public void objectPlainLiteral(String value,
                               String lang)
Description copied from interface: ParserCallback
Called for each trix:triple element whose object is a trix:plainLiteral.

Specified by:
objectPlainLiteral in interface ParserCallback
Parameters:
value - the object literal value of the triple
lang - the language tag of the object literal, or null if none was given

objectTypedLiteral

public void objectTypedLiteral(String value,
                               String datatypeURI)
Description copied from interface: ParserCallback
Called for each trix:triple element whose object is a trix:typedLiteral.

Specified by:
objectTypedLiteral in interface ParserCallback
Parameters:
value - the object literal value of the triple
datatypeURI - the datatype URI of the object literal