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 suggestedfileExtension()
.Some of the RDF syntaxes may
supportsDataset()
, meaning they can representQuad
s.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 Summary
Fields Modifier and Type Field Description static RDFSyntax
JSONLD
JSON-LD 1.0static RDFSyntax
NQUADS
RDF 1.1 N-Quadsstatic RDFSyntax
NTRIPLES
RDF 1.1 N-Triplesstatic RDFSyntax
RDFA
HTML+RDFa 1.1 and XHTML+RDFa 1.1static RDFSyntax
RDFXML
RDF 1.1 XML Syntaxstatic RDFSyntax
TRIG
RDF 1.1 TriGstatic RDFSyntax
TURTLE
RDF 1.1 Turtle
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static java.util.Optional<RDFSyntax>
byFileExtension(java.lang.String fileExtension)
Return the RDFSyntax with the specified file extension.static java.util.Optional<RDFSyntax>
byMediaType(java.lang.String mediaType)
Return the RDFSyntax with the specified media type.static java.util.Optional<RDFSyntax>
byName(java.lang.String name)
Return the RDFSyntax with the specifiedname()
.boolean
equals(java.lang.Object obj)
Compare this RDFSyntax with another object.java.lang.String
fileExtension()
The IANA-registered file extension.default java.util.Set<java.lang.String>
fileExtensions()
Set of file extensions for this RDF syntax, including any non-official extensions.int
hashCode()
The hash code of an RDFSyntax is equivalent to the hash code of themediaType()
in lower case according toString.toLowerCase(Locale)
with the localeLocale.ROOT
.IRI
iri()
Return theIRI
that identifies the RDF syntax.java.lang.String
mediaType()
The IANA media type for the RDF syntax.default java.util.Set<java.lang.String>
mediaTypes()
Set of IANA media types that covers this RDF syntax, including any non-official media types.java.lang.String
name()
A short name of the RDF Syntax e.g.boolean
supportsDataset()
Indicate if this RDF syntax supports RDF Datasets.java.lang.String
title()
The title of the RDF Syntax.static java.util.Set<RDFSyntax>
w3cSyntaxes()
Return the RDF 1.1 serialization syntaxes.
-
-
-
Field Detail
-
JSONLD
static final RDFSyntax JSONLD
JSON-LD 1.0- See Also:
- https://www.w3.org/TR/json-ld/
-
TURTLE
static final RDFSyntax TURTLE
RDF 1.1 Turtle- See Also:
- https://www.w3.org/TR/turtle/
-
NQUADS
static final RDFSyntax NQUADS
RDF 1.1 N-Quads- See Also:
- https://www.w3.org/TR/n-quads/
-
NTRIPLES
static final RDFSyntax NTRIPLES
RDF 1.1 N-Triples- See Also:
- https://www.w3.org/TR/n-triples/
-
RDFA
static final RDFSyntax RDFA
HTML+RDFa 1.1 and XHTML+RDFa 1.1
-
RDFXML
static final RDFSyntax RDFXML
RDF 1.1 XML Syntax
-
TRIG
static final RDFSyntax TRIG
RDF 1.1 TriG- See Also:
- https://www.w3.org/TR/trig/
-
-
Method Detail
-
name
java.lang.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
java.lang.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
java.lang.String mediaType()
The IANA media type for the RDF syntax.The media type can be used as part of
Content-Type
andAccept
for content negotiation in the HTTP protocol.- Returns:
- The registered media type of the RDF Syntax
-
mediaTypes
default java.util.Set<java.lang.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
andAccept
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
java.lang.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 java.util.Set<java.lang.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 theIRI
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(java.lang.Object obj)
Compare this RDFSyntax with another object.Two
RDFSyntax
es are considered equal if theirmediaType()
s are equal when compared as lower case strings according toString.toLowerCase(Locale)
with the localeLocale.ROOT
.- Overrides:
equals
in classjava.lang.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 themediaType()
in lower case according toString.toLowerCase(Locale)
with the localeLocale.ROOT
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- Hash code of RDFSyntax
-
w3cSyntaxes
static java.util.Set<RDFSyntax> w3cSyntaxes()
Return the RDF 1.1 serialization syntaxes.This lists the W3C standardized RDF 1.1 syntaxes like
TURTLE
andJSONLD
. Note the existence of other RDF syntaxes that are not included here, e.g. N3 and TriX.The syntaxes returned only support the
mediaType()
andfileExtension()
as defined in the corresponding W3C specification.- Returns:
- A set of the official RDF 1.1
RDFSyntax
es. - See Also:
- RDF
1.1 Primer,
RDFParser
-
byMediaType
static java.util.Optional<RDFSyntax> byMediaType(java.lang.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 themediaType()
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()
, theRDFSyntax
which has a matchingmediaType()
, otherwiseOptional.empty()
indicating that no matching syntax was found.
-
byFileExtension
static java.util.Optional<RDFSyntax> byFileExtension(java.lang.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 thefileExtension()
of the returned RDFSyntax.This method support all syntaxes returned by
w3cSyntaxes()
.- Parameters:
fileExtension
- The fileExtension to match, starting with.
- Returns:
- If
Optional.isPresent()
, theRDFSyntax
which has a matchingfileExtension()
, otherwiseOptional.empty()
indicating that no matching file extension was found.
-
byName
static java.util.Optional<RDFSyntax> byName(java.lang.String name)
Return the RDFSyntax with the specifiedname()
.This method support all syntaxes returned by
w3cSyntaxes()
.
-
-