org.openrdf.query.resultio
Class TupleQueryResultFormat

java.lang.Object
  extended by info.aduna.lang.FileFormat
      extended by org.openrdf.query.resultio.TupleQueryResultFormat

public class TupleQueryResultFormat
extends FileFormat

Represents the concept of an tuple query result serialization format. Tuple query result 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.

Author:
Arjohn Kampman

Field Summary
static TupleQueryResultFormat BINARY
          Binary RDF results table format.
static TupleQueryResultFormat JSON
          SPARQL Query Results JSON Format.
static TupleQueryResultFormat SPARQL
          SPARQL Query Results XML Format.
 
Constructor Summary
TupleQueryResultFormat(String name, Collection<String> mimeTypes, Charset charset, Collection<String> fileExtensions)
          Creates a new TupleQueryResultFormat object.
TupleQueryResultFormat(String name, String mimeType, Charset charset, String fileExt)
          Creates a new TupleQueryResultFormat object.
TupleQueryResultFormat(String name, String mimeType, String fileExt)
          Creates a new TupleQueryResultFormat object.
 
Method Summary
static TupleQueryResultFormat forFileName(String fileName)
          Tries to determine the appropriate tuple file format for a file, based on the extension specified in a file name.
static TupleQueryResultFormat forFileName(String fileName, TupleQueryResultFormat fallback)
          Tries to determine the appropriate tuple file format for a file, based on the extension specified in a file name.
static TupleQueryResultFormat forMIMEType(String mimeType)
          Tries to determine the appropriate tuple file format based on the a MIME type that describes the content type.
static TupleQueryResultFormat forMIMEType(String mimeType, TupleQueryResultFormat fallback)
          Tries to determine the appropriate tuple file format based on the a MIME type that describes the content type.
static TupleQueryResultFormat register(String name, String mimeType, String fileExt)
          Registers the specified tuple query result format.
static void register(TupleQueryResultFormat format)
          Registers the specified tuple query result format.
static Collection<TupleQueryResultFormat> values()
          Returns all known/registered tuple query result 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

SPARQL

public static final TupleQueryResultFormat SPARQL
SPARQL Query Results XML Format.


BINARY

public static final TupleQueryResultFormat BINARY
Binary RDF results table format.


JSON

public static final TupleQueryResultFormat JSON
SPARQL Query Results JSON Format.

Constructor Detail

TupleQueryResultFormat

public TupleQueryResultFormat(String name,
                              String mimeType,
                              String fileExt)
Creates a new TupleQueryResultFormat object.

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

TupleQueryResultFormat

public TupleQueryResultFormat(String name,
                              String mimeType,
                              Charset charset,
                              String fileExt)
Creates a new TupleQueryResultFormat object.

Parameters:
name - The name of the format, e.g. "SPARQL/XML".
mimeType - The MIME type of the format, e.g. application/sparql-results+xml for the SPARQL/XML format.
charset - The default character encoding of the format. Specify null if not applicable.
fileExt - The (default) file extension for the format, e.g. srx for SPARQL/XML.

TupleQueryResultFormat

public TupleQueryResultFormat(String name,
                              Collection<String> mimeTypes,
                              Charset charset,
                              Collection<String> fileExtensions)
Creates a new TupleQueryResultFormat object.

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

values

public static Collection<TupleQueryResultFormat> values()
Returns all known/registered tuple query result formats.


register

public static TupleQueryResultFormat register(String name,
                                              String mimeType,
                                              String fileExt)
Registers the specified tuple query result format.

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

register

public static void register(TupleQueryResultFormat format)
Registers the specified tuple query result format.


forMIMEType

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

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

forMIMEType

public static TupleQueryResultFormat forMIMEType(String mimeType,
                                                 TupleQueryResultFormat fallback)
Tries to determine the appropriate tuple 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 MIME type, e.g. "application/sparql-results+xml"
fallback - a fallback TupleQueryResultFormat that will be returned by the method if no match for the supplied MIME type can be found.
Returns:
A TupleQueryResultFormat that matches the MIME type, or the fallback format if the extension was not recognized.
See Also:
forMIMEType(String), FileFormat.getMIMETypes()

forFileName

public static TupleQueryResultFormat forFileName(String fileName)
Tries to determine the appropriate tuple file format for a file, based on the extension specified in a file name.

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

forFileName

public static TupleQueryResultFormat forFileName(String fileName,
                                                 TupleQueryResultFormat fallback)
Tries to determine the appropriate tuple file format for a file, based on the extension specified in a file name. The supplied fallback format will be returned when the file name extension was not recognized.

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


Copyright © 2001-2009 Aduna. All Rights Reserved.