Class 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 Detail

      • SUPPORTS_RDF_STAR

        public static final boolean SUPPORTS_RDF_STAR
        Indicates that RDF-star triples can be serialized natively for this format.
        See Also:
        Constant Field Values
      • NO_RDF_STAR

        public static final boolean NO_RDF_STAR
        Indicates that RDF-star triples will NOT be serialized natively for this format.
        See Also:
        Constant Field Values
      • 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 and text/xml are also accepted. The character encoding is UTF-8.

        See Also:
        RDF/XML Syntax Specification (Revised)
      • 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 application/n-triples and encoding is in UTF-8.

        See Also:
        N-Triples
      • 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:
        Turtle - Terse RDF Triple Language
      • 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 .xml is recommended for TriX documents, .trix is also accepted. The media type is application/trix and the encoding is UTF-8.

        See Also:
        TriX: RDF Triples in XML
      • 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/trig and the encoding is UTF-8.

        See Also:
        The TriG Syntax
      • 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:
        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 application/n-quads and the encoding is UTF-8.

        See Also:
        N-Quads: Extending N-Triples with Context
      • JSONLD

        public static final RDFFormat JSONLD
        The JSON-LD file format, an RDF serialization format that supports recording of named graphs.

        The file extension .jsonld is recommended for JSON-LD documents. The media type is application/ld+json and the encoding is UTF-8.

        See Also:
        JSON-LD 1.0
      • NDJSONLD

        public static final RDFFormat NDJSONLD
        The NDJSON-LD is a Newline Delimited JSON-LD format.

        The file extension .ndjsonld is recommended for NDJSON-LD documents. The media type is application/x-ld+ndjson and the encoding is UTF-8.

      • RDFJSON

        public static final RDFFormat RDFJSON
        The RDF/JSON file format, an RDF serialization format that supports recording of named graphs.

        The file extension .rj is recommended for RDF/JSON documents. The media type is application/rdf+json and the encoding is UTF-8.

        See Also:
        RDF 1.1 JSON Alternate Serialization (RDF/JSON)
      • RDFA

        public static final RDFFormat RDFA
        The RDFa file format, an RDF serialization format.

        The file extension .xhtml is recommended for RDFa documents. The preferred media type is application/xhtml+xml and the encoding is UTF-8.

        See Also:
        XHTML+RDFa 1.1
      • HDT

        public static final RDFFormat HDT
        The HDT file format, an RDF serialization format.

        The file extension .hdt is recommended for HDT documents.

        See Also:
        HDT v1.0
    • Constructor Detail

      • RDFFormat

        @Deprecated
        public RDFFormat​(String name,
                         String mimeType,
                         Charset charset,
                         String fileExtension,
                         boolean supportsNamespaces,
                         boolean supportsContexts)
        Deprecated.
        since 3.2.0
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
      • RDFFormat

        public RDFFormat​(String name,
                         String mimeType,
                         Charset charset,
                         String fileExtension,
                         boolean supportsNamespaces,
                         boolean supportsContexts,
                         boolean supportsRDFStar)
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
        supportsRDFStar - True if the RDFFormat supports the encoding of RDF-star triples natively and false otherwise.
      • RDFFormat

        @Deprecated
        public RDFFormat​(String name,
                         String mimeType,
                         Charset charset,
                         Collection<String> fileExtensions,
                         boolean supportsNamespaces,
                         boolean supportsContexts)
        Deprecated.
        since 3.2.0
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
      • RDFFormat

        public RDFFormat​(String name,
                         String mimeType,
                         Charset charset,
                         Collection<String> fileExtensions,
                         boolean supportsNamespaces,
                         boolean supportsContexts,
                         boolean supportsRDFStar)
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
        supportsRDFStar - True if the RDFFormat supports the encoding of RDF-star triples natively and false otherwise.
      • RDFFormat

        @Deprecated
        public RDFFormat​(String name,
                         Collection<String> mimeTypes,
                         Charset charset,
                         Collection<String> fileExtensions,
                         boolean supportsNamespaces,
                         boolean supportsContexts)
        Deprecated.
        since 3.2.0
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
      • RDFFormat

        public RDFFormat​(String name,
                         Collection<String> mimeTypes,
                         Charset charset,
                         Collection<String> fileExtensions,
                         boolean supportsNamespaces,
                         boolean supportsContexts,
                         boolean supportsRDFStar)
        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.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
        supportsRDFStar - True if the RDFFormat supports the encoding of RDF-star triples natively and false otherwise.
      • RDFFormat

        @Deprecated
        public RDFFormat​(String name,
                         Collection<String> mimeTypes,
                         Charset charset,
                         Collection<String> fileExtensions,
                         IRI standardURI,
                         boolean supportsNamespaces,
                         boolean supportsContexts)
        Deprecated.
        since 3.2.0
        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.
        standardURI - The standard URI that has been assigned to this format by a standards organisation or null if it does not currently have a standard URI.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
      • RDFFormat

        public RDFFormat​(String name,
                         Collection<String> mimeTypes,
                         Charset charset,
                         Collection<String> fileExtensions,
                         IRI standardURI,
                         boolean supportsNamespaces,
                         boolean supportsContexts,
                         boolean supportsRDFStar)
        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.
        standardURI - The standard URI that has been assigned to this format by a standards organisation or null if it does not currently have a standard URI.
        supportsNamespaces - True if the RDFFormat supports the encoding of namespace/prefix information and false otherwise.
        supportsContexts - True if the RDFFormat supports the encoding of contexts/named graphs and false otherwise.
        supportsRDFStar - True if the RDFFormat supports the encoding of RDF-star triples natively and false otherwise.
    • Method Detail

      • getAcceptParams

        public static List<String> getAcceptParams​(Iterable<RDFFormat> rdfFormats,
                                                   boolean requireContext,
                                                   RDFFormat preferredFormat)
        Processes the supplied collection of RDFFormats and assigns quality values to each based on whether context must be supported and whether the format is preferred.
        Parameters:
        rdfFormats - The RDFFormats to process.
        requireContext - True to decrease the quality value for formats where supportsContexts() returns false.
        preferredFormat - The preferred RDFFormat. If it is not in the list then the quality of all formats will be processed as if they are not preferred.
        Returns:
        A list of strings containing the content types and an attached q-value specifying the quality for the format for each type.
      • supportsNamespaces

        public boolean supportsNamespaces()
        Return true if the RDFFormat supports the encoding of namespace/prefix information.
      • supportsContexts

        public boolean supportsContexts()
        Return true if the RDFFormat supports the encoding of contexts/named graphs.
      • supportsRDFStar

        public boolean supportsRDFStar()
        Return true if the RDFFormat supports the encoding of RDF-star triples natively.
      • hasStandardURI

        public boolean hasStandardURI()
        Returns:
        True if a standard URI has been assigned to this format by a standards organisation.
      • getStandardURI

        public IRI getStandardURI()
        Returns:
        The standard URI that has been assigned to this format by a standards organisation or null if it does not currently have a standard URI.