Class RDFFormats


  • public final class RDFFormats
    extends java.lang.Object

    Utilities for RDFFormat

    Since:
    1.0
    Version:
    1.0
    Author:
    Michael Grove
    See Also:
    SupportedFileFormats
    • Field Detail

      • UNKNOWN_BASE_FORMAT

        public static RDFFormat UNKNOWN_BASE_FORMAT
      • TURTLE

        public static final RDFFormat TURTLE
        Format denoting [Turtle](https://www.w3.org/TR/turtle/)
      • PRETTY_TURTLE

        public static final RDFFormat PRETTY_TURTLE
      • NTRIPLES

        public static final RDFFormat NTRIPLES
        [N-triples](http://www.w3.org/TR/n-triples/)
      • NQUADS

        public static final RDFFormat NQUADS
        [NQuads](http://www.w3.org/TR/n-quads/)
      • RDFXML

        public static final RDFFormat RDFXML
        [RDF/XML](http://www.w3.org/TR/rdf-syntax-grammar/)
      • N3

        public static final RDFFormat N3
        [Notation 3](http://www.w3.org/TeamSubmission/n3/)
      • TRIG

        public static final RDFFormat TRIG
        [TriG](http://www.w3.org/TR/trig)
      • RDFJSON

        public static final RDFFormat RDFJSON
        [RDF/JSON](http://www.w3.org/TR/rdf-json/)
      • BINARY

        public static final RDFFormat BINARY
        Binary RDF
      • JSONLD

        public static final RDFFormat JSONLD
        [JSON-LD](ttp://www.w3.org/TR/json-ld/)
    • Method Detail

      • forFile

        @Nonnull
        public static java.util.Optional<RDFFormat> forFile​(@Nonnull
                                                            java.nio.file.Path thePath)
        Return the format for the file denoted by the given Path. If none can be determined
        Parameters:
        thePath - the file to be parsed
        Returns:
        the RDF format
      • forName

        @Nonnull
        public static java.util.Optional<RDFFormat> forName​(@Nonnull
                                                            java.lang.String theName)
        Return the format with the provided name
        Parameters:
        theName - the name of the format
        Returns:
        the format
      • forMime

        @Nonnull
        public static java.util.Optional<RDFFormat> forMime​(@Nonnull
                                                            java.lang.String theMime)
        Return the format which supports the given mimetype
        Parameters:
        theMime - the mimetype
        Returns:
        the format that supports the mimetype
        Implementation Notes:
        The default mimetypes are checked for _all_ formats before the full set of mimetypes for each format are considered.
      • compressedForName

        @Nonnull
        public static RDFFormat compressedForName​(RDFFormat theFormat,
                                                  java.lang.String theName)
        Return the compressed RDFFormat for the given name, with the provided base format.
        Parameters:
        theFormat -
        theName -
        Returns:
      • forFile

        public static RDFFormat forFile​(java.io.File theFile,
                                        RDFFormat theBaseFormat)
      • forFile

        public static java.util.Optional<RDFFormat> forFile​(java.lang.String theFileName)
      • forFile

        public static RDFFormat forFile​(java.lang.String theFileName,
                                        RDFFormat theBaseFormat)
      • supportsContexts

        public static boolean supportsContexts​(@Nonnull
                                               RDFFormat theFormat)
        Return whether or not the format is capable of serializing the context information for a Statement.
        Parameters:
        theFormat - the format
        Returns:
        `true` if the format can serialize quads, `false` otherwise
      • register

        public static RDFFormat register​(@Nonnull
                                         java.lang.String theName,
                                         @Nonnull
                                         IRI theId,
                                         @Nonnull
                                         java.util.List<java.lang.String> theMimetypes,
                                         @Nonnull
                                         java.util.List<java.lang.String> theFileExtensions)
        Create a new RDFFormats.RDFFormatImpl
        Parameters:
        theName - the human-friendly name of the format
        theId - the IRI of the format
        theMimetypes - the list of supported mimetypes. There must be *at least* `1`, and the first element in the list is taken to be the default mimetype
        theFileExtensions - the list of supported extensions. There must be *at least* `1`, and the first element in the list is taken to be the default extension
      • registerBinary

        public static RDFFormat.BinaryRDFFormat registerBinary​(@Nonnull
                                                               java.lang.String theName,
                                                               @Nonnull
                                                               IRI theId,
                                                               @Nonnull
                                                               java.util.List<java.lang.String> theMimetypes,
                                                               @Nonnull
                                                               java.util.List<java.lang.String> theFileExtensions)
        Parameters:
        theName - the human-friendly name of the format
        theId - the IRI of the format
        theMimetypes - the list of supported mimetypes. There must be *at least* `1`, and the first element in the list is taken to be the default mimetype
        theFileExtensions - the list of supported extensions. There must be *at least* `1`, and the first element in the list is taken to be the default extension