UNPKG

rdf-data-factory

Version:

A TypeScript/JavaScript implementation of the RDF/JS data factory.

50 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Literal = void 0; const NamedNode_1 = require("./NamedNode"); /** * A term that represents an RDF literal, * containing a string with an optional language tag and optional direction * or datatype. */ class Literal { constructor(value, languageOrDatatype) { this.termType = 'Literal'; this.value = value; if (typeof languageOrDatatype === 'string') { this.language = languageOrDatatype; this.datatype = Literal.RDF_LANGUAGE_STRING; this.direction = ''; } else if (languageOrDatatype) { if ('termType' in languageOrDatatype) { this.language = ''; this.datatype = languageOrDatatype; this.direction = ''; } else { this.language = languageOrDatatype.language; this.datatype = languageOrDatatype.direction ? Literal.RDF_DIRECTIONAL_LANGUAGE_STRING : Literal.RDF_LANGUAGE_STRING; this.direction = languageOrDatatype.direction || ''; } } else { this.language = ''; this.datatype = Literal.XSD_STRING; this.direction = ''; } } equals(other) { return !!other && other.termType === 'Literal' && other.value === this.value && other.language === this.language && ((other.direction === this.direction) || (!other.direction && this.direction === '')) && this.datatype.equals(other.datatype); } } exports.Literal = Literal; Literal.RDF_LANGUAGE_STRING = new NamedNode_1.NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#langString'); Literal.RDF_DIRECTIONAL_LANGUAGE_STRING = new NamedNode_1.NamedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString'); Literal.XSD_STRING = new NamedNode_1.NamedNode('http://www.w3.org/2001/XMLSchema#string'); //# sourceMappingURL=Literal.js.map