use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectInteger.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectInteger() throws Exception {
Object obj = new Integer(4);
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.INT);
assertEquals(l.getLabel(), "4");
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectString.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectString() throws Exception {
Object obj = "random unique string";
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.STRING);
assertEquals(l.getLabel(), "random unique string");
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectBoolean.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectBoolean() throws Exception {
Object obj = Boolean.TRUE;
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.BOOLEAN);
assertTrue(l.booleanValue());
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralOrFailObjectByte.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteralOrFail(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralOrFailObjectByte() throws Exception {
Object obj = new Integer(42).byteValue();
Literal l = Literals.createLiteralOrFail(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.BYTE);
assertEquals(l.getLabel(), "42");
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class DAWGTestResultSetParser method getBindingNames.
private List<String> getBindingNames(Resource resultSetNode) throws RDFHandlerException {
List<String> bindingNames = new ArrayList<String>(16);
Iterator<Value> varIter = GraphUtil.getObjectIterator(graph, resultSetNode, RESULTVARIABLE);
while (varIter.hasNext()) {
Value varName = varIter.next();
if (varName instanceof Literal) {
bindingNames.add(((Literal) varName).getLabel());
} else {
throw new RDFHandlerException("Value for " + RESULTVARIABLE + " is not a literal: " + varName);
}
}
return bindingNames;
}
Aggregations