org.openrdf.rio
Class RDFFormat

java.lang.Object
  extended by info.aduna.lang.FileFormat
      extended by org.openrdf.rio.RDFFormat

public class RDFFormat
extends FileFormat

Represents the concept of an RDF data serialization format. RDF formats are identified by a name and can have one or more associated MIME types, zero or more associated file extensions and can specify a (default) character encoding. Some formats are able to encode context information while other are not; this is indicated by the value of supportsContexts.

Author:
Arjohn Kampman

Field Summary
static RDFFormat BINARY
          A binary RDF format.
static RDFFormat N3
          The N3/Notation3 file format.
static RDFFormat NQUADS
          The N-Quads file format, an RDF serialization format that supports recording of named graphs.
static RDFFormat NTRIPLES
          The N-Triples file format.
static RDFFormat RDFXML
          The RDF/XML file format.
static RDFFormat TRIG
          The TriG file format, a Turtle-based RDF serialization format that supports recording of named graphs.
static RDFFormat TRIX
          The TriX file format, an XML-based RDF serialization format that supports recording of named graphs.
static RDFFormat TURTLE
          The Turtle file format.
 
Constructor Summary
RDFFormat(String name, Collection<String> mimeTypes, Charset charset, Collection<String> fileExtensions, boolean supportsNamespaces, boolean supportsContexts)
          Creates a new RDFFormat object.
RDFFormat(String name, String mimeType, Charset charset, Collection<String> fileExtensions, boolean supportsNamespaces, boolean supportsContexts)
          Creates a new RDFFormat object.
RDFFormat(String name, String mimeType, Charset charset, String fileExtension, boolean supportsNamespaces, boolean supportsContexts)
          Creates a new RDFFormat object.
 
Method Summary
static RDFFormat forFileName(String fileName)
          Tries to determine the appropriate RDF file format based on the extension of a file name.
static RDFFormat forFileName(String fileName, RDFFormat fallback)
          Tries to determine the appropriate RDF file format based on the extension of a file name.
static RDFFormat forMIMEType(String mimeType)
          Tries to determine the appropriate RDF file format based on the a MIME type that describes the content type.
static RDFFormat forMIMEType(String mimeType, RDFFormat fallback)
          Tries to determine the appropriate RDF file format based on the a MIME type that describes the content type.
static List<String> getAcceptParams(Iterable<RDFFormat> rdfFormats, boolean requireContext, RDFFormat preferredFormat)
           
static void register(RDFFormat rdfFormat)
          Registers the specified RDF file format.
static RDFFormat register(String name, String mimeType, String fileExt, Charset charset)
          Registers the specified RDF file format.
 boolean supportsContexts()
           
 boolean supportsNamespaces()
           
static RDFFormat valueOf(String formatName)
          Returns the RDF format whose name matches the specified name.
static Collection<RDFFormat> values()
          Returns all known/registered RDF formats.
 
Methods inherited from class info.aduna.lang.FileFormat
equals, getCharset, getDefaultFileExtension, getDefaultMIMEType, getFileExtensions, getMIMETypes, getName, hasCharset, hasDefaultFileExtension, hasDefaultMIMEType, hasFileExtension, hashCode, hasMIMEType, matchFileName, matchFileName, matchMIMEType, matchMIMEType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RDFXML

public static final RDFFormat RDFXML
The RDF/XML file format.

Several file extensions are accepted for RDF/XML documents, including .rdf, .rdfs (for RDF Schema files), .owl (for OWL ontologies), and .xml. The media type is application/rdf+xml, but application/xml is also accepted. The character encoding is UTF-8.

See Also:
http://www.w3.org/TR/rdf-syntax-grammar/

NTRIPLES

public static final RDFFormat NTRIPLES
The N-Triples file format.

The file extension .nt is recommend for N-Triples documents. The media type is text/plain and encoding is in 7-bit US-ASCII.

See Also:
http://www.w3.org/TR/rdf-testcases/#ntriples

TURTLE

public static final RDFFormat TURTLE
The Turtle file format.

The file extension .ttl is recommend for Turtle documents. The media type is text/turtle, but application/x-turtle is also accepted. Character encoding is UTF-8.

See Also:
http://www.w3.org/TeamSubmission/turtle/

N3

public static final RDFFormat N3
The N3/Notation3 file format.

The file extension .n3 is recommended for N3 documents. The media type is text/rdf+n3 and the encoding is UTF-8.

See Also:
http://www.w3.org/DesignIssues/Notation3.html

TRIX

public static final RDFFormat TRIX
The TriX file format, an XML-based RDF serialization format that supports recording of named graphs.

The file extension .trix is recommended for TriX documents, .xml is also accepted. The media type is application/trix and the encoding is UTF-8.

See Also:
http://swdev.nokia.com/trix/

TRIG

public static final RDFFormat TRIG
The TriG file format, a Turtle-based RDF serialization format that supports recording of named graphs.

The file extension .trig is recommend for TriG documents. The media type is application/x-trig and the encoding is UTF-8.

See Also:
http://www.wiwiss.fu-berlin.de/suhl/bizer/TriG/Spec/

BINARY

public static final RDFFormat BINARY
A binary RDF format.

The file extension .brf is recommend for binary RDF documents. The media type is application/x-binary-rdf.

See Also:
http://rivuli-development.com/2011/11/binary-rdf-in-sesame/

NQUADS

public static final RDFFormat NQUADS
The N-Quads file format, an RDF serialization format that supports recording of named graphs.

The file extension .nq is recommended for N-Quads documents. The media type is text/x-nquads and the encoding is 7-bit US-ASCII.

See Also:
http://sw.deri.org/2008/07/n-quads/
Constructor Detail

RDFFormat

public RDFFormat(String name,
                 String mimeType,
                 Charset charset,
                 String fileExtension,
                 boolean supportsNamespaces,
                 boolean supportsContexts)
Creates a new RDFFormat object.

Parameters:
name - The name of the RDF file format, e.g. "RDF/XML".
mimeType - The MIME type of the RDF file format, e.g. application/rdf+xml for the RDF/XML file format.
charset - The default character encoding of the RDF file format. Specify null if not applicable.
fileExtension - The (default) file extension for the RDF file format, e.g. rdf for RDF/XML files.

RDFFormat

public RDFFormat(String name,
                 String mimeType,
                 Charset charset,
                 Collection<String> fileExtensions,
                 boolean supportsNamespaces,
                 boolean supportsContexts)
Creates a new RDFFormat object.

Parameters:
name - The name of the RDF file format, e.g. "RDF/XML".
mimeType - The MIME type of the RDF file format, e.g. application/rdf+xml for the RDF/XML file format.
charset - The default character encoding of the RDF file format. Specify null if not applicable.
fileExtensions - The RDF format's file extensions, e.g. rdf for RDF/XML files. The first item in the list is interpreted as the default file extension for the format.

RDFFormat

public RDFFormat(String name,
                 Collection<String> mimeTypes,
                 Charset charset,
                 Collection<String> fileExtensions,
                 boolean supportsNamespaces,
                 boolean supportsContexts)
Creates a new RDFFormat object.

Parameters:
name - The name of the RDF file format, e.g. "RDF/XML".
mimeTypes - The MIME types of the RDF file format, e.g. application/rdf+xml for the RDF/XML file format. The first item in the list is interpreted as the default MIME type for the format.
charset - The default character encoding of the RDF file format. Specify null if not applicable.
fileExtensions - The RDF format's file extensions, e.g. rdf for RDF/XML files. The first item in the list is interpreted as the default file extension for the format.
Method Detail

values

public static Collection<RDFFormat> values()
Returns all known/registered RDF formats.


register

public static RDFFormat register(String name,
                                 String mimeType,
                                 String fileExt,
                                 Charset charset)
Registers the specified RDF file format.

Parameters:
name - The name of the RDF file format, e.g. "RDF/XML".
mimeType - The MIME type of the RDF file format, e.g. application/rdf+xml for the RDF/XML file format.
fileExt - The (default) file extension for the RDF file format, e.g. rdf for RDF/XML files.

register

public static void register(RDFFormat rdfFormat)
Registers the specified RDF file format.


forMIMEType

public static RDFFormat forMIMEType(String mimeType)
Tries to determine the appropriate RDF file format based on the a MIME type that describes the content type.

Parameters:
mimeType - A MIME type, e.g. "application/rdf+xml".
Returns:
An RDFFormat object if the MIME type was recognized, or null otherwise.
See Also:
forMIMEType(String,RDFFormat), FileFormat.getMIMETypes()

forMIMEType

public static RDFFormat forMIMEType(String mimeType,
                                    RDFFormat fallback)
Tries to determine the appropriate RDF file format based on the a MIME type that describes the content type. The supplied fallback format will be returned when the MIME type was not recognized.

Parameters:
mimeType - A file name.
Returns:
An RDFFormat that matches the MIME type, or the fallback format if the extension was not recognized.
See Also:
forMIMEType(String), FileFormat.getMIMETypes()

forFileName

public static RDFFormat forFileName(String fileName)
Tries to determine the appropriate RDF file format based on the extension of a file name.

Parameters:
fileName - A file name.
Returns:
An RDFFormat object if the file extension was recognized, or null otherwise.
See Also:
forFileName(String,RDFFormat), FileFormat.getFileExtensions()

forFileName

public static RDFFormat forFileName(String fileName,
                                    RDFFormat fallback)
Tries to determine the appropriate RDF file format based on the extension of a file name. The supplied fallback format will be returned when the file name extension was not recognized.

Parameters:
fileName - A file name.
Returns:
An RDFFormat that matches the file name extension, or the fallback format if the extension was not recognized.
See Also:
forFileName(String), FileFormat.getFileExtensions()

valueOf

public static RDFFormat valueOf(String formatName)
Returns the RDF format whose name matches the specified name.

Parameters:
formatName - A format name.
Returns:
The RDF format whose name matches the specified name, or null if there is no such format.

getAcceptParams

public static List<String> getAcceptParams(Iterable<RDFFormat> rdfFormats,
                                           boolean requireContext,
                                           RDFFormat preferredFormat)

supportsNamespaces

public boolean supportsNamespaces()

supportsContexts

public boolean supportsContexts()


Copyright © 2001-2012 Aduna. All Rights Reserved.