|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fuberlin.wiwiss.ng4j.impl.GraphReaderService
public class GraphReaderService
Reads RDF graphs from external sources (URLs, InputStreams,
Readers, Strings). Supports TriX, TriG and all serializations
supported by Jena. Supports reading of Named Graphs into
NamedGraphSet
s.
To read from a source, three steps must be performed:
setSourceURL(java.lang.String)
, setSourceReader(java.io.Reader, java.lang.String)
,
setSourceInputStream(java.io.InputStream, java.lang.String)
, setSourceString(java.lang.String, java.lang.String)
or
setSourceFile(java.io.File)
.setLanguage(java.lang.String)
. This step is optional. If no language is
given, the class will try to guess the language based on
MIME types and filename extensions of the URL or base URI.readInto(Model)
or readInto(NamedGraphSet)
.Design note: This class wraps the document reading functions of Jena and the Named Graph reading functions of NG4J into a single interface without adding more methods and logic to Model.
TODO: The baseURI argument to setXXX should be optional for languages that are able provide a base URI within the document (that is, RDF/XML). This is hard because Jena's RDF parser doesn't expose the base URI.
Constructor Summary | |
---|---|
GraphReaderService()
|
Method Summary | |
---|---|
void |
readInto(Model model)
Adds all statements from the source to a Jena Model. |
void |
readInto(NamedGraphSet set)
Adds one or more Named Graphs from the source to a NamedGraphSet. |
void |
setLanguage(String lang)
Sets the language of the source. |
String |
setReaderClassName(String lang,
String className)
Adds support for additional languages. |
void |
setSourceFile(File sourceFile)
Sets a File as the source. |
void |
setSourceInputStream(InputStream inputStream,
String baseURI)
Sets an InputStream as the source. |
void |
setSourceReader(Reader reader,
String baseURI)
Sets a Reader as the source. |
void |
setSourceString(String sourceString,
String baseURI)
Sets a String as the source. |
void |
setSourceURL(String url)
Sets an URL as the source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphReaderService()
Method Detail |
---|
public void setSourceURL(String url)
url
- An URL of a RDF documentpublic void setSourceReader(Reader reader, String baseURI)
reader
- A Reader of a RDF documentbaseURI
- The base URI of the documentpublic void setSourceInputStream(InputStream inputStream, String baseURI)
inputStream
- An InputStream of a RDF documentpublic void setSourceString(String sourceString, String baseURI)
sourceString
- A String containing an RDF documentpublic void setSourceFile(File sourceFile)
sourceFile
- A file containing an RDF documentpublic void setLanguage(String lang)
lang
- One of the above language IDspublic void readInto(NamedGraphSet set)
Existing graphs in the NamedGraphSet will be replaced by graphs with the same name from the source.
setSourceXXX and setLanguage must have been called before readInto.
set
- The NamedGraphSet to which statements will be addedpublic void readInto(Model model)
model
- The model to which statements will be addedpublic String setReaderClassName(String lang, String className)
lang
- A language nameclassName
- A class implementing RDFReader
RDFReaderF.setReaderClassName(java.lang.String, java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |