Literal constructor

Literal(
  1. String value, {
  2. URIRef? datatype,
  3. String? lang,
})

Implementation

Literal(this.value, {this.datatype, this.lang}) {
  if (datatype != null && lang != null) {
    throw Exception('A Literal can only have one of lang or datatype,\n'
        'per http://www.w3.org/TR/rdf-concepts/#section-Graph-Literal');
  } else if (datatype == null && lang == null) {
    /// Check for default data types including numeric and datetime
    if (_isInteger(value)) {
      datatype = XSD.int;
    } else if (_isDouble(value)) {
      // Default to float instead of double for now.
      // TODO: differentiate between float and double.
      datatype = XSD.float;
    } else if (_isDateTime(value)) {
      datatype = XSD.dateTime;
    } else if (_isDateTimeStamp(value)) {
      datatype = XSD.dateTimeStamp;
    } else {
      datatype = XSD.string;
    }
  }
}