use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class RepositoryConfigUtil method getIDStatement.
private static Statement getIDStatement(Model model, String repositoryID) {
Literal idLiteral = SimpleValueFactory.getInstance().createLiteral(repositoryID);
Model idStatementList = model.filter(null, REPOSITORYID, idLiteral);
if (idStatementList.size() == 1) {
return idStatementList.iterator().next();
} else if (idStatementList.isEmpty()) {
return null;
} else {
throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID);
}
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class RepositoryConfigUtil method getRepositoryIDs.
public static Set<String> getRepositoryIDs(Model model) throws RepositoryException {
Set<String> idSet = new LinkedHashSet<String>();
model.filter(null, REPOSITORYID, null).forEach(idStatement -> {
if (idStatement.getObject() instanceof Literal) {
Literal idLiteral = (Literal) idStatement.getObject();
idSet.add(idLiteral.getLabel());
}
});
return idSet;
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class RepositoryConfigUtil method getIDStatement.
private static Statement getIDStatement(RepositoryConnection con, String repositoryID) throws RepositoryException, RepositoryConfigException {
Literal idLiteral = con.getRepository().getValueFactory().createLiteral(repositoryID);
List<Statement> idStatementList = Iterations.asList(con.getStatements(null, REPOSITORYID, idLiteral, true));
if (idStatementList.size() == 1) {
return idStatementList.get(0);
} else if (idStatementList.isEmpty()) {
return null;
} else {
throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID);
}
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class SimpleLiteralTest method testStringEmpty.
/**
* Test method for {@link org.eclipse.rdf4j.model.impl.SimpleLiteral#SimpleLiteral(java.lang.String)}.
*/
@Test
public final void testStringEmpty() throws Exception {
Literal test = new SimpleLiteral("");
assertEquals("", test.getLabel());
assertFalse(test.getLanguage().isPresent());
assertEquals(XMLSchema.STRING, test.getDatatype());
}
use of org.eclipse.rdf4j.model.Literal in project rdf4j by eclipse.
the class LiteralsTest method testCreateLiteralObjectLong.
/**
* Test method for
* {@link org.eclipse.rdf4j.model.util.Literals#createLiteral(org.eclipse.rdf4j.model.ValueFactory, java.lang.Object)}
* .
*/
@Test
public void testCreateLiteralObjectLong() throws Exception {
Object obj = new Long(42);
Literal l = Literals.createLiteral(SimpleValueFactory.getInstance(), obj);
assertNotNull(l);
assertEquals(l.getDatatype(), XMLSchema.LONG);
assertEquals(l.getLabel(), "42");
}
Aggregations