Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-362

model.listStatements(s,p,o,lang) has problems when o or lang is null

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Jena 2.7.4
    • Fix Version/s: Jena 2.10.0
    • Component/s: Jena
    • Labels:
      None

      Description

      1) model.listStatements(s,p,null,lang) doesn't filter on lang param
      2) model.listStatements(s,p,o,null) only returns statements whose object has lang "" (when o != null)

      TEST 1
      import org.junit.Test;
      import com.hp.hpl.jena.rdf.model.*;
      public class LstStmt1 {
      @Test
      public final void test() {
      Model m = ModelFactory.createDefaultModel();
      Resource s = m.createResource("http://www.a.com/s");
      Property p = m.createProperty("http://www.a.com/p");

      m.add(s,p,m.createResource("http://www.a.com/o"));
      m.add(s,p,"texte","fr");
      m.add(s,p,"text","en");

      StmtIterator it = m.listStatements(s, p, null,"en");
      // list all the statements - not what one can expect
      for (;it.hasNext()

      { System.out.println(it.next()); }
      }
      }

      TEST2

      public class LstStmt2 {
      @Test
      public final void test() {
      Model m = ModelFactory.createDefaultModel();
      Resource s = m.createResource("http://www.a.com/s");
      Property p = m.createProperty("http://www.a.com/p");

      m.add(s,p,"text","en");
      m.add(s,p,"text");

      StmtIterator it = m.listStatements(s, p,"text",null);
      // should list the 2 statements, but doesn't: only the one without lang
      for (;it.hasNext() { System.out.println(it.next()); }

      }
      }

        Attachments

        1. ListStatementTest.java
          2 kB
          François-Paul Servant
        2. ModelCom.java
          52 kB
          François-Paul Servant

          Activity

            People

            • Assignee:
              andy Andy Seaborne
              Reporter:
              fps61 François-Paul Servant
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: