Search in sources :

Example 1 with BigdataResource

use of com.bigdata.rdf.model.BigdataResource in project wikidata-query-rdf by wikimedia.

the class BigdataStatementToJenaStatementMapper method convertToJenaRDFNode.

/**
 * Convert Bigdata value to Jena RDF Node.
 *
 * @return Jena RDF node.
 */
public RDFNode convertToJenaRDFNode(final BigdataValue v) {
    if (v instanceof BigdataResource)
        return convertToJenaResource((BigdataResource) v);
    if (!(v instanceof BigdataLiteral))
        throw new IllegalArgumentException(v.getClass().getName());
    final BigdataLiteral l = (BigdataLiteral) v;
    final String lex = l.getLabel();
    final URI datatypeURI = l.getDatatype();
    final String languageTag = l.getLanguage();
    if (datatypeURI != null) {
        final RDFDatatype dt = JENA_TYPE_MAPPER.getSafeTypeByName(datatypeURI.stringValue());
        return ResourceFactory.createTypedLiteral(lex, dt);
    } else if (languageTag != null) {
        return ResourceFactory.createLangLiteral(lex, languageTag);
    } else {
        return ResourceFactory.createPlainLiteral(lex);
    }
}
Also used : BigdataResource(com.bigdata.rdf.model.BigdataResource) URI(org.openrdf.model.URI) RDFDatatype(org.apache.jena.datatypes.RDFDatatype) BigdataLiteral(com.bigdata.rdf.model.BigdataLiteral)

Aggregations

BigdataLiteral (com.bigdata.rdf.model.BigdataLiteral)1 BigdataResource (com.bigdata.rdf.model.BigdataResource)1 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)1 URI (org.openrdf.model.URI)1