Class: TermConverter

TermConverter()

Utility class for converting strings to terms, terms to quads and quads to string according to the https://rdf.js.org specification.

Constructor

new TermConverter()

Author:
  • Mihail Radkov
  • Svilen Velikov
  • Teodossi Dossev
Source:

Methods

(static) fromBase64RdfStarTriple(encodedTriple) → {string}

Decodes from Base64 encoded RDFStar triple.

Parameters:
Name Type Description
encodedTriple string

to be decoded from base64 url string

Source:
Returns:

decoded RDFStar triple, returns unchanged if the provided triple is not in the expected format

Type
string

(static) getLiteralQuads(subject, predicate, object, contextsopt, type, language) → {Array.<Quad>}

Convert the supplied params to a collection of quads.

The quads object term will be a literal with a data type or a language.

The produced quads size depends on the supplied amount of context.

Parameters:
Name Type Attributes Description
subject string

the quad's subject

predicate string

the quad's predicate

object string

the quad's object

contexts string | Array.<string> <optional>

the quad's context

type string

the quad's data type

language string

the quad's literal language

Source:
Returns:

a collection of quads constructed from the provided params

Type
Array.<Quad>

(static) getQuads(subject, predicate, object, contextsopt) → {Array.<Quad>}

Convert the supplied params to a collection of quads.

The produced quads size depends on the supplied amount of context.

Parameters:
Name Type Attributes Description
subject string

the quad's subject

predicate string

the quad's predicate

object string

the quad's object

contexts string | Array.<string> <optional>

the quad's context

Source:
Returns:

a collection of quads constructed from the provided params

Type
Array.<Quad>

(static) toBase64RdfStarTriple(triple) → {string}

Encodes RDFStarTriple to Base64 string.

Parameters:
Name Type Description
triple string

to be encoded as base64 url string

Source:
Returns:

encoded RDFStart triple, returns unchanged if the provided triple is not in the expected format

Type
string

(static) toNTripleValue(value) → {string}

Converts the provided value to N-Triple encoded value in case it is not already one or a literal value.

For example:

  • http://resource encodes to
  • "Literal title"@en will not be encoded
  • encodes to the same value

Empty or null values are ignored.

Parameters:
Name Type Description
value string

the value for converting

Source:
Returns:

the converted value to N-Triple

Type
string

(static) toNTripleValues(values) → {string|Array.<string>}

Converts the provided values to N-Triple encoded values in case they are not already one or literal values.

Empty or null values are ignored.

Parameters:
Name Type Description
values string | Array.<string>

the values for converting

Source:
See:
  • #toNTripleValue
Returns:

the converted value or values to N-Triple

Type
string | Array.<string>

(static) toString(quads) → {string}

Serializes the provided collection of quads to Turtle format or Trig in case any of the quads have context.

Parameters:
Name Type Description
quads Array.<Quad>

the collection of quads to serialize to Turtle

Source:
Returns:

a promise that will be resolved to Turtle or Trig text or rejected if the quads cannot be serialized

Type
string