Search in sources :

Example 36 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class TestConcurrentAccess method mrswGraph3.

@Test(expected = ConcurrentModificationException.class)
public void mrswGraph3() {
    Model m = create().getDefaultModel();
    Resource r = m.createResource("x");
    ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode) null);
    assertNotNull(iter1.next());
    Triple t = SSE.parseTriple("(<y> <p> 99)");
    m.getGraph().delete(t);
    // Bad
    iter1.hasNext();
}
Also used : Triple(org.apache.jena.graph.Triple) Statement(org.apache.jena.rdf.model.Statement) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 37 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class StandardAnalyzerAssembler method toList.

private List<String> toList(Resource list) {
    List<String> result = new ArrayList<>();
    Resource current = list;
    while (current != null && !current.equals(RDF.nil)) {
        Statement stmt = current.getProperty(RDF.first);
        if (stmt == null) {
            throw new TextIndexException("stop word list not well formed");
        }
        RDFNode node = stmt.getObject();
        if (!node.isLiteral()) {
            throw new TextIndexException("stop word is not a literal : " + node);
        }
        result.add(((Literal) node).getLexicalForm());
        stmt = current.getProperty(RDF.rest);
        if (stmt == null) {
            throw new TextIndexException("stop word list not terminated by rdf:nil");
        }
        node = stmt.getObject();
        if (!node.isResource()) {
            throw new TextIndexException("stop word list node is not a resource : " + node);
        }
        current = (Resource) node;
    }
    return result;
}
Also used : TextIndexException(org.apache.jena.query.text.TextIndexException) Statement(org.apache.jena.rdf.model.Statement) ArrayList(java.util.ArrayList) Resource(org.apache.jena.rdf.model.Resource) RDFNode(org.apache.jena.rdf.model.RDFNode)

Aggregations

Statement (org.apache.jena.rdf.model.Statement)37 Model (org.apache.jena.rdf.model.Model)17 Resource (org.apache.jena.rdf.model.Resource)14 Test (org.junit.Test)9 StmtIterator (org.apache.jena.rdf.model.StmtIterator)7 ArrayList (java.util.ArrayList)6 BaseTest (org.apache.jena.atlas.junit.BaseTest)6 Triple (org.apache.jena.graph.Triple)6 RDFNode (org.apache.jena.rdf.model.RDFNode)4 Property (org.apache.jena.rdf.model.Property)3 IOException (java.io.IOException)2 Dataset (org.apache.jena.query.Dataset)2 TextIndexException (org.apache.jena.query.text.TextIndexException)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 Files.createTempFile (java.nio.file.Files.createTempFile)1 Path (java.nio.file.Path)1