Interface RDFSyntax

All Known Implementing Classes:
W3CRDFSyntax

public interface RDFSyntax
An RDF syntax, e.g. as used for parsing and writing RDF.

An RDF syntax is uniquely identified by its mediaType(), and has a suggested fileExtension().

Some of the RDF syntaxes may supportsDataset(), meaning they can represent Quads.

An enumeration of the official RDF 1.1 syntaxes is available in W3CRDFSyntax - for convenience they are also accessible as constants here, e.g. RDFSyntax.JSONLD.

  • Field Details

  • Method Details

    • name

      String name()
      A short name of the RDF Syntax e.g. JSONLD.

      The name is specific to Commons RDF and carries no particular meaning.

      Returns:
      Short name for RDF syntax
    • title

      String title()
      The title of the RDF Syntax.

      This is generally the title of the corresponding standard, e.g. RDF 1.1 Turtle.

      Returns:
      Title of RDF Syntax
    • mediaType

      String mediaType()
      The IANA media type for the RDF syntax.

      The media type can be used as part of Content-Type and Accept for content negotiation in the HTTP protocol.

      Returns:
      The registered media type of the RDF Syntax
    • mediaTypes

      default Set<String> mediaTypes()
      Set of IANA media types that covers this RDF syntax, including any non-official media types.

      The media type can be used as part of Content-Type and Accept for content negotiation in the HTTP protocol.

      The returned Set MUST include the value mediaType(); this is the behaviour of the default implementation.

      Returns:
      The media types corresponding to the RDF Syntax
    • fileExtension

      String fileExtension()
      The IANA-registered file extension.

      The file extension includes the leading period, e.g. .jsonld

      Returns:
      The registered file extension of the RDF Syntax
    • fileExtensions

      default Set<String> fileExtensions()
      Set of file extensions for this RDF syntax, including any non-official extensions.

      The file extension includes the leading period, e.g. .jsonld

      The returned Set MUST include the value from fileExtension(); this is the behaviour of the default implementation.

      Returns:
      The file extensions corresponding to the RDF Syntax
    • supportsDataset

      boolean supportsDataset()
      Indicate if this RDF syntax supports RDF Datasets.
      Returns:
      true if this RDF Syntax supports datasets; false otherwise
    • iri

      IRI iri()
      Return the IRI that identifies the RDF syntax.

      Note that the identifying IRI is generally distinct from the IRI of the document that specifies the RDF syntax.

      Returns:
      Identifying IRI, e.g. http://www.w3.org/ns/formats/JSON-LD
    • equals

      boolean equals(Object obj)
      Compare this RDFSyntax with another object.

      Two RDFSyntaxes are considered equal if their mediaType()s are equal when compared as lower case strings according to String.toLowerCase(Locale) with the locale Locale.ROOT.

      Overrides:
      equals in class Object
      Parameters:
      obj - the object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise
    • hashCode

      int hashCode()
      The hash code of an RDFSyntax is equivalent to the hash code of the mediaType() in lower case according to String.toLowerCase(Locale) with the locale Locale.ROOT.
      Overrides:
      hashCode in class Object
      Returns:
      Hash code of RDFSyntax
    • w3cSyntaxes

      static Set<RDFSyntax> w3cSyntaxes()
      Return the RDF 1.1 serialization syntaxes.

      This lists the W3C standardized RDF 1.1 syntaxes like TURTLE and JSONLD. Note the existence of other RDF syntaxes that are not included here, e.g. N3 and TriX.

      The syntaxes returned only support the mediaType() and fileExtension() as defined in the corresponding W3C specification.

      Returns:
      A set of the official RDF 1.1 RDFSyntaxes.
      See Also:
    • byMediaType

      static Optional<RDFSyntax> byMediaType(String mediaType)
      Return the RDFSyntax with the specified media type.

      The mediaType is compared in lower case to all media types supported, therefore it might not be equal to the mediaType() of the returned RDFSyntax.

      If the media type specifies parameters, e.g. text/turtle; charset=ascii, only the part of the string to before ; is considered.

      This method support all syntaxes returned by w3cSyntaxes().

      Parameters:
      mediaType - The media type to match
      Returns:
      If Optional.isPresent(), the RDFSyntax which has a matching mediaType(), otherwise Optional.empty() indicating that no matching syntax was found.
    • byFileExtension

      static Optional<RDFSyntax> byFileExtension(String fileExtension)
      Return the RDFSyntax with the specified file extension.

      The fileExtension is compared in lower case to all extensions supported, therefore it might not be equal to the fileExtension() of the returned RDFSyntax.

      This method support all syntaxes returned by w3cSyntaxes().

      Parameters:
      fileExtension - The fileExtension to match, starting with .
      Returns:
      If Optional.isPresent(), the RDFSyntax which has a matching fileExtension(), otherwise Optional.empty() indicating that no matching file extension was found.
    • byName

      static Optional<RDFSyntax> byName(String name)
      Return the RDFSyntax with the specified name().

      This method support all syntaxes returned by w3cSyntaxes().

      Parameters:
      name - The name to match, , e.g. "JSONLD"
      Returns:
      If Optional.isPresent(), the RDFSyntax which has a matching name(), otherwise Optional.empty() indicating that no matching name was found.