use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class ModelsTest method testObjectLiteral.
public void testObjectLiteral() {
Literal lit = VF.createLiteral(1.0);
model1.add(foo, bar, lit);
model1.add(foo, bar, foo);
Value result = Models.objectLiteral(model1).orElse(null);
assertNotNull(result);
assertEquals(lit, result);
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class DAWGTestResultSetWriter method startQueryResult.
/*---------*
* Methods *
*---------*/
@Override
public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
try {
rdfHandler.startRDF();
resultSetNode = vf.createBNode();
bnodeMap.clear();
reportStatement(resultSetNode, RDF.TYPE, RESULTSET);
for (String bindingName : bindingNames) {
Literal bindingNameLit = vf.createLiteral(bindingName);
reportStatement(resultSetNode, RESULTVARIABLE, bindingNameLit);
}
} catch (RDFHandlerException e) {
throw new TupleQueryResultHandlerException(e);
}
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class DAWGTestBooleanParser method endRDF.
@Override
public void endRDF() throws RDFHandlerException {
try {
Resource resultSetNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RESULTSET);
Literal booleanLit = GraphUtil.getUniqueObjectLiteral(graph, resultSetNode, BOOLEAN);
if (booleanLit.equals(DAWGTestResultSetSchema.TRUE)) {
value = true;
} else if (booleanLit.equals(DAWGTestResultSetSchema.FALSE)) {
value = false;
} else {
throw new RDFHandlerException("Invalid boolean value: " + booleanLit);
}
} catch (GraphUtilException e) {
throw new RDFHandlerException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralOrFailObjectLong.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralOrFailObjectLong() throws Exception {
Object obj = new Long(42);
Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.LONG);
assertEquals(l.getLabel(), "42");
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectObject.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectObject() throws Exception {
Object obj = new Object();
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.STRING);
}
Aggregations