use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class CustomTurtleParserTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vf = ValueFactoryImpl.getInstance();
settingsNoVerifyLangTag = new ParserConfig();
settingsNoVerifyLangTag.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, false);
errors = new ParseErrorCollector();
parser = Rio.createParser(RDFFormat.TURTLE);
statementCollector = new StatementCollector(new LinkedHashModel());
parser.setRDFHandler(statementCollector);
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class CustomTurtleParserTest method testLiteralWithNewlines.
@Test
public void testLiteralWithNewlines() throws Exception {
String namespace = "http://www.foo.com/bar#";
String okLiteralString = "Literal \n without \n new line at the beginning. \n ";
String errLiteralString = "\n Literal \n with \n new line at the beginning. \n ";
IRI mySubject = vf.createIRI(namespace, "Subject");
IRI myPredicate = vf.createIRI(namespace, "Predicate");
Literal myOkObject = vf.createLiteral(okLiteralString);
Literal myErrObject = vf.createLiteral(errLiteralString);
StringWriter out = new StringWriter();
Model model = new LinkedHashModel();
model.add(mySubject, myPredicate, myOkObject);
model.add(mySubject, myPredicate, myErrObject);
Rio.write(model, out, RDFFormat.TURTLE);
String str = out.toString();
System.err.println(str);
assertTrue("okLiteralString not found", str.contains(okLiteralString));
assertTrue("errLiteralString not found", str.contains(errLiteralString));
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class HTTPRepositoryConnection method add.
@Override
public void add(Statement st, Resource... contexts) throws RepositoryException {
if (!isActive()) {
// operation is not part of a transaction - just send directly
OpenRDFUtil.verifyContextNotNull(contexts);
final Model m = new LinkedHashModel();
if (contexts.length == 0) {
// if no context is specified in the method call, statement's own
// context (if any) is used.
m.add(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext());
} else {
m.add(st.getSubject(), st.getPredicate(), st.getObject(), contexts);
}
addModel(m);
} else {
super.add(st, contexts);
}
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class ModelBuilderTest method setUp.
@Before
public void setUp() throws Exception {
model = new LinkedHashModel();
testBuilder = new ModelBuilder(model);
}
use of org.eclipse.rdf4j.model.impl.LinkedHashModel in project rdf4j by eclipse.
the class QueryResults method asModel.
/**
* Get a {@link Model} containing all elements obtained from the specified query result.
*
* @param iteration
* the source iteration to get the statements from. This can be a {@link GraphQueryResult}, a
* {@link RepositoryResult<Statement>}, or any other instance of {@link CloseableIteration
* <Statement>}
* @return a {@link Model} containing all statements obtained from the specified source iteration.
*/
public static Model asModel(CloseableIteration<? extends Statement, ? extends RDF4JException> iteration) throws QueryEvaluationException {
Model model = new LinkedHashModel();
addAll(iteration, model);
return model;
}
Aggregations