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

Seq "set" and "add" methods yield different results.

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 3.17.0
    • Jena 4.0.0
    • Core
    • None

    Description

      I think the issue is in the Seq.set() method but the if the example below is executed the results are variously boolean values or strings representing boolean values.

      Code:

      import org.apache.jena.rdf.model.Model;
      import org.apache.jena.rdf.model.ModelFactory;
      import org.apache.jena.rdf.model.Seq;
      
      public class SeqTest {    
          public static void main(String[] args) {
              Model m = ModelFactory.createDefaultModel();
              Seq seq = m.createSeq();
              seq.add( 1L );
              seq.add(2, 2L );
              m.write(System.out, "TURTLE");
              seq.set(1, 1L);
              m.write(System.out, "TURTLE");
          }
      }
      
      

      Result:

      [ a       <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
                "1" ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
                "2"
      ] .
      [ a       <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1>
                "1"^^<http://www.w3.org/2001/XMLSchema#long> ;
        <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2>
                "2"
      ] .
      

      The Collection.add() code and the Seq.add() methods both insert string representations for the long values.  The Seq.set() method on the other hand places a typed literal in the graph.

      Personally I would rather see the typed literal but I don't know that the standard says.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            claude Claude Warren
            claude Claude Warren
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment