org.openrdf.rio
Class Rio

java.lang.Object
  extended by org.openrdf.rio.Rio

public class Rio
extends Object

Factory class providing static methods for creating RDF parsers and -writers for various RDF file formats.

Author:
Arjohn Kampman

Constructor Summary
Rio()
           
 
Method Summary
static RDFParser createParser(RDFFormat format)
          Convenience methods for creating RDFParser objects.
static RDFParser createParser(RDFFormat format, ValueFactory valueFactory)
          Convenience methods for creating RDFParser objects that use the specified ValueFactory to create RDF model objects.
static RDFWriter createWriter(RDFFormat format, OutputStream out)
          Convenience methods for creating RDFWriter objects.
static RDFWriter createWriter(RDFFormat format, Writer writer)
          Convenience methods for creating RDFWriter objects.
static RDFFormat getParserFormatForFileName(String fileName)
          Tries to match the extension of a file name against the list of RDF formats that can be parsed.
static RDFFormat getParserFormatForFileName(String fileName, RDFFormat fallback)
          Tries to match the extension of a file name against the list of RDF formats that can be parsed.
static RDFFormat getParserFormatForMIMEType(String mimeType)
          Tries to match a MIME type against the list of RDF formats that can be parsed.
static RDFFormat getParserFormatForMIMEType(String mimeType, RDFFormat fallback)
          Tries to match a MIME type against the list of RDF formats that can be parsed.
static RDFFormat getWriterFormatForFileName(String fileName)
          Tries to match the extension of a file name against the list of RDF formats that can be written.
static RDFFormat getWriterFormatForFileName(String fileName, RDFFormat fallback)
          Tries to match the extension of a file name against the list of RDF formats that can be written.
static RDFFormat getWriterFormatForMIMEType(String mimeType)
          Tries to match a MIME type against the list of RDF formats that can be written.
static RDFFormat getWriterFormatForMIMEType(String mimeType, RDFFormat fallback)
          Tries to match a MIME type against the list of RDF formats that can be written.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rio

public Rio()
Method Detail

getParserFormatForMIMEType

public static RDFFormat getParserFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of RDF formats that can be parsed.

Parameters:
mimeType - A MIME type, e.g. "application/rdf+xml".
Returns:
An RDFFormat object if a match was found, or null otherwise.
See Also:
getParserFormatForMIMEType(String, RDFFormat)

getParserFormatForMIMEType

public static RDFFormat getParserFormatForMIMEType(String mimeType,
                                                   RDFFormat fallback)
Tries to match a MIME type against the list of RDF formats that can be parsed. This method calls FileFormat.matchMIMEType(String, Iterable) with the specified MIME type, the keys of RDFParserRegistry.getInstance() and the fallback format as parameters.

Parameters:
mimeType - A MIME type, e.g. "application/rdf+xml".
fallback - The format that will be returned if no match was found.
Returns:
The matching RDFFormat, or fallback if no match was found.

getParserFormatForFileName

public static RDFFormat getParserFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be parsed.

Parameters:
fileName - A file name.
Returns:
An RDFFormat object if a match was found, or null otherwise.
See Also:
getParserFormatForFileName(String, RDFFormat)

getParserFormatForFileName

public static RDFFormat getParserFormatForFileName(String fileName,
                                                   RDFFormat fallback)
Tries to match the extension of a file name against the list of RDF formats that can be parsed. This method calls FileFormat.matchFileName(String, Iterable, info.aduna.lang.FileFormat) with the specified MIME type, the keys of RDFParserRegistry.getInstance() and the fallback format as parameters.

Parameters:
fileName - A file name.
fallback - The format that will be returned if no match was found.
Returns:
The matching RDFFormat, or fallback if no match was found.

getWriterFormatForMIMEType

public static RDFFormat getWriterFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of RDF formats that can be written.

Parameters:
mimeType - A MIME type, e.g. "application/rdf+xml".
Returns:
An RDFFormat object if a match was found, or null otherwise.
See Also:
getWriterFormatForMIMEType(String, RDFFormat)

getWriterFormatForMIMEType

public static RDFFormat getWriterFormatForMIMEType(String mimeType,
                                                   RDFFormat fallback)
Tries to match a MIME type against the list of RDF formats that can be written. This method calls FileFormat.matchMIMEType(String, Iterable, info.aduna.lang.FileFormat) with the specified MIME type, the keys of RDFWriterRegistry.getInstance() and the fallback format as parameters.

Parameters:
mimeType - A MIME type, e.g. "application/rdf+xml".
fallback - The format that will be returned if no match was found.
Returns:
The matching RDFFormat, or fallback if no match was found.

getWriterFormatForFileName

public static RDFFormat getWriterFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be written.

Parameters:
fileName - A file name.
Returns:
An RDFFormat object if a match was found, or null otherwise.
See Also:
getWriterFormatForFileName(String, RDFFormat)

getWriterFormatForFileName

public static RDFFormat getWriterFormatForFileName(String fileName,
                                                   RDFFormat fallback)
Tries to match the extension of a file name against the list of RDF formats that can be written. This method calls FileFormat.matchFileName(String, Iterable, info.aduna.lang.FileFormat) with the specified MIME type, the keys of RDFWriterRegistry.getInstance() and the fallback format as parameters.

Parameters:
fileName - A file name.
fallback - The format that will be returned if no match was found.
Returns:
The matching RDFFormat, or fallback if no match was found.

createParser

public static RDFParser createParser(RDFFormat format)
                              throws UnsupportedRDFormatException
Convenience methods for creating RDFParser objects. This method uses the registry returned by RDFParserRegistry.getInstance() to get a factory for the specified format and uses this factory to create the appropriate parser.

Throws:
UnsupportedRDFormatException - If no parser is available for the specified RDF format.

createParser

public static RDFParser createParser(RDFFormat format,
                                     ValueFactory valueFactory)
                              throws UnsupportedRDFormatException
Convenience methods for creating RDFParser objects that use the specified ValueFactory to create RDF model objects.

Throws:
UnsupportedRDFormatException - If no parser is available for the specified RDF format.
See Also:
createParser(RDFFormat), RDFParser.setValueFactory(ValueFactory)

createWriter

public static RDFWriter createWriter(RDFFormat format,
                                     OutputStream out)
                              throws UnsupportedRDFormatException
Convenience methods for creating RDFWriter objects. This method uses the registry returned by RDFWriterRegistry.getInstance() to get a factory for the specified format and uses this factory to create the appropriate writer.

Throws:
UnsupportedRDFormatException - If no writer is available for the specified RDF format.

createWriter

public static RDFWriter createWriter(RDFFormat format,
                                     Writer writer)
                              throws UnsupportedRDFormatException
Convenience methods for creating RDFWriter objects. This method uses the registry returned by RDFWriterRegistry.getInstance() to get a factory for the specified format and uses this factory to create the appropriate writer.

Throws:
UnsupportedRDFormatException - If no writer is available for the specified RDF format.

main

public static void main(String[] args)
                 throws IOException,
                        RDFParseException,
                        RDFHandlerException,
                        UnsupportedRDFormatException
Throws:
IOException
RDFParseException
RDFHandlerException
UnsupportedRDFormatException


Copyright © 2001-2012 Aduna. All Rights Reserved.