Search in sources :

Example 31 with Model

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;
}
Also used : Model(org.apache.jena.rdf.model.Model)

Example 32 with Model

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();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 33 with Model

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();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 34 with Model

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);
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Example 35 with Model

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);
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Aggregations

Model (org.apache.jena.rdf.model.Model)920 Test (org.junit.Test)338 Dataset (org.apache.jena.query.Dataset)196 Resource (org.apache.jena.rdf.model.Resource)178 StringReader (java.io.StringReader)66 Statement (org.apache.jena.rdf.model.Statement)54 Property (org.apache.jena.rdf.model.Property)45 InfModel (org.apache.jena.rdf.model.InfModel)41 Ignore (org.junit.Ignore)38 RDFNode (org.apache.jena.rdf.model.RDFNode)35 Node (org.apache.jena.graph.Node)34 URI (java.net.URI)33 Graph (org.apache.jena.graph.Graph)33 QueryExecution (org.apache.jena.query.QueryExecution)31 Reader (java.io.Reader)30 StmtIterator (org.apache.jena.rdf.model.StmtIterator)27 RDFReaderI (org.apache.jena.rdf.model.RDFReaderI)25 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)24 RdfUtils (won.protocol.util.RdfUtils)24 InputStream (java.io.InputStream)22