use of org.apache.jena.rdf.model.Model in project jena by apache.
the class FileManager method loadModelWorker.
private Model loadModelWorker(String filenameOrURI, String baseURI, String rdfSyntax) {
if (hasCachedModel(filenameOrURI)) {
if (log.isDebugEnabled())
log.debug("Model cache hit: " + filenameOrURI);
return getFromCache(filenameOrURI);
}
Model m = ModelFactory.createDefaultModel();
readModelWorker(m, filenameOrURI, baseURI, rdfSyntax);
if (isCachingModels())
addCacheModel(filenameOrURI, m);
return m;
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class MoreTests method testLatin1.
public void testLatin1() throws IOException {
Model m = createMemModel();
RDFReader rdr = m.getReader();
InputStream r = new FileInputStream("testing/arp/i18n/latin1.rdf");
rdr.setErrorHandler(this);
expected = new int[] { WARN_NONCANONICAL_IANA_NAME };
rdr.read(m, r, "http://example.org/");
checkExpected();
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class MoreTests method testARPMacArabic.
public void testARPMacArabic() throws IOException {
Model m = createMemModel();
RDFReader rdr = m.getReader();
InputStream r = new FileInputStream("testing/arp/i18n/arabic-macarabic.rdf");
rdr.setErrorHandler(this);
expected = new int[] { WARN_UNSUPPORTED_ENCODING, WARN_NON_IANA_ENCODING };
expected[Charset.isSupported("MacArabic") ? 0 : 1] = 0;
// Only one of the warnings is expected, which depends on Java version
rdr.read(m, r, "http://example.org/");
checkExpected();
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class AbstractWholeFileQuadInputFormatTests method writeGoodTuples.
private void writeGoodTuples(OutputStream output, int num) {
Dataset ds = DatasetFactory.createGeneral();
Model m = ModelFactory.createDefaultModel();
Resource currSubj = m.createResource("http://example.org/subjects/0");
Property predicate = m.createProperty("http://example.org/predicate");
for (int i = 0; i < num; i++) {
if (i % 100 == 0) {
ds.addNamedModel("http://example.org/graphs/" + (i / 100), m);
m = ModelFactory.createDefaultModel();
}
if (i % 10 == 0) {
currSubj = m.createResource("http://example.org/subjects/" + (i / 10));
}
m.add(currSubj, predicate, m.createTypedLiteral(i));
}
if (!m.isEmpty()) {
ds.addNamedModel("http://example.org/graphs/extra", m);
}
this.writeTuples(ds, output);
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class AbstractCompressedWholeFileQuadInputFormatTests method writeGoodTuples.
private void writeGoodTuples(OutputStream output, int num) {
Dataset ds = DatasetFactory.createGeneral();
Model m = ModelFactory.createDefaultModel();
Resource currSubj = m.createResource("http://example.org/subjects/0");
Property predicate = m.createProperty("http://example.org/predicate");
for (int i = 0; i < num; i++) {
if (i % 100 == 0) {
ds.addNamedModel("http://example.org/graphs/" + (i / 100), m);
m = ModelFactory.createDefaultModel();
}
if (i % 10 == 0) {
currSubj = m.createResource("http://example.org/subjects/" + (i / 10));
}
m.add(currSubj, predicate, m.createTypedLiteral(i));
}
if (!m.isEmpty()) {
ds.addNamedModel("http://example.org/graphs/extra", m);
}
this.writeTuples(ds, output);
}
Aggregations