Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Seq


    }
  }

  public void testSeqAdd()
  {
    final Seq seq = model.createSeq();
    Assert.assertEquals(0, seq.size());
    Assert.assertTrue(model.contains(seq, RDF.type, RDF.Seq));
    //
    seq.add(AbstractModelTestBase.tvBoolean);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvBoolean));
    Assert.assertFalse(seq.contains(!AbstractModelTestBase.tvBoolean));
    //
    seq.add(AbstractModelTestBase.tvByte);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvByte));
    Assert.assertFalse(seq.contains((byte) 101));
    //
    seq.add(AbstractModelTestBase.tvShort);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvShort));
    Assert.assertFalse(seq.contains((short) 102));
    //
    seq.add(AbstractModelTestBase.tvInt);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvInt));
    Assert.assertFalse(seq.contains(-101));
    //
    seq.add(AbstractModelTestBase.tvLong);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvLong));
    Assert.assertFalse(seq.contains(-102));
    //
    seq.add(AbstractModelTestBase.tvChar);
    Assert.assertTrue(seq.contains(AbstractModelTestBase.tvChar));
    Assert.assertFalse(seq.contains('?'));
    //
    seq.add(123.456f);
    Assert.assertTrue(seq.contains(123.456f));
    Assert.assertFalse(seq.contains(456.123f));
    //
    seq.add(-123.456d);
    Assert.assertTrue(seq.contains(-123.456d));
    Assert.assertFalse(seq.contains(-456.123d));
    //
    seq.add("a string");
    Assert.assertTrue(seq.contains("a string"));
    Assert.assertFalse(seq.contains("a necklace"));
    //
    seq.add(model.createLiteral("another string"));
    Assert.assertTrue(seq.contains("another string"));
    Assert.assertFalse(seq.contains("another necklace"));
    //
    seq.add(new LitTestObj(12345));
    Assert.assertTrue(seq.contains(new LitTestObj(12345)));
    Assert.assertFalse(seq.contains(new LitTestObj(54321)));
    //
    // Resource present = model.createResource( new ResTestObjF() );
    // Resource absent = model.createResource( new ResTestObjF() );
    // seq.add( present );
    // assertTrue( seq.contains( present ) );
    // assertFalse( seq.contains( absent ) );
    //
    Assert.assertEquals(11, seq.size());
  }
View Full Code Here


  }

  public void testSeqAddInts()
  {
    final int num = 10;
    final Seq seq = model.createSeq();
    for (int i = 0; i < num; i += 1)
    {
      seq.add(i);
    }
    Assert.assertEquals(num, seq.size());
    final List<RDFNode> L = seq.iterator().toList();
    Assert.assertEquals(num, L.size());
    for (int i = 0; i < num; i += 1)
    {
      Assert.assertEquals(i, ((Literal) L.get(i)).getInt());
    }
View Full Code Here

    final Resource tvResource = model.createResource();
    // Resource tvResObj = model.createResource(new ResTestObjF());
    final Object tvLitObj = new LitTestObj(1234);
    final Bag tvBag = model.createBag();
    final Alt tvAlt = model.createAlt();
    final Seq tvSeq = model.createSeq();

    final Seq seq = model.createSeq();
    seq.add(model.createResource());
    seq.add(1, true);
    Assert.assertEquals(true, seq.getBoolean(1));
    seq.add(1, (byte) 1);
    Assert.assertEquals((byte) 1, seq.getByte(1));
    seq.add(1, (short) 2);
    Assert.assertEquals((short) 2, seq.getShort(1));
    seq.add(1, -1);
    Assert.assertEquals(-1, seq.getInt(1));
    seq.add(1, -2);
    Assert.assertEquals(-2, seq.getLong(1));
    seq.add(1, '!');
    Assert.assertEquals('!', seq.getChar(1));
    seq.add(1, 123.456f);
    Assert.assertEquals(123.456f, seq.getFloat(1), 0.00005);
    seq.add(1, 12345.67890);
    Assert.assertEquals(12345.67890, seq.getDouble(1), 0.00000005);
    seq.add(1, "some string");
    Assert.assertEquals("some string", seq.getString(1));
    seq.add(1, tvLitObj);
    // assertEquals( tvLitObj, seq.getObject( 1, new LitTestObjF() ) );
    seq.add(1, tvResource);
    Assert.assertEquals(tvResource, seq.getResource(1));
    // seq.add( 1, tvResObj );
    // assertEquals( tvResObj, seq.getResource( 1, new ResTestObjF() ) );
    seq.add(1, tvLiteral);
    Assert.assertEquals(tvLiteral, seq.getLiteral(1));
    seq.add(1, tvBag);
    Assert.assertEquals(tvBag, seq.getBag(1));
    seq.add(1, tvAlt);
    Assert.assertEquals(tvAlt, seq.getAlt(1));
    seq.add(1, tvSeq);
    Assert.assertEquals(tvSeq, seq.getSeq(1));
    //
    Assert.assertEquals(0, seq.indexOf(1234543));
    Assert.assertEquals(1, seq.indexOf(tvSeq));
    Assert.assertEquals(2, seq.indexOf(tvAlt));
    Assert.assertEquals(3, seq.indexOf(tvBag));
    Assert.assertEquals(4, seq.indexOf(tvLiteral));
    Assert.assertEquals(5, seq.indexOf(tvResource));
    Assert.assertEquals(6, seq.indexOf(tvLitObj));
    Assert.assertEquals(7, seq.indexOf("some string"));
    Assert.assertEquals(8, seq.indexOf(12345.67890));
    Assert.assertEquals(9, seq.indexOf(123.456f));
    Assert.assertEquals(10, seq.indexOf('!'));
    Assert.assertEquals(11, seq.indexOf(-2));
    Assert.assertEquals(12, seq.indexOf(-1));
    Assert.assertEquals(13, seq.indexOf((short) 2));
    Assert.assertEquals(14, seq.indexOf((byte) 1));
    Assert.assertEquals(15, seq.indexOf(true));
  }
View Full Code Here

    // Resource tvResObj = model.createResource(new ResTestObjF());
    // Bag tvBag = model.createBag();
    // Alt tvAlt = model.createAlt();
    // Seq tvSeq = model.createSeq();
    final int num = 10;
    final Seq seq = model.createSeq();

    for (int i = 0; i < num; i++)
    {
      seq.add(i);
    }

    seq.set(5, AbstractModelTestBase.tvBoolean);
    Assert.assertEquals(AbstractModelTestBase.tvBoolean, seq.getBoolean(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvByte);
    Assert.assertEquals(AbstractModelTestBase.tvByte, seq.getByte(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvShort);
    Assert.assertEquals(AbstractModelTestBase.tvShort, seq.getShort(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvInt);
    Assert.assertEquals(AbstractModelTestBase.tvInt, seq.getInt(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvLong);
    Assert.assertEquals(AbstractModelTestBase.tvLong, seq.getLong(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvString);
    Assert.assertEquals(AbstractModelTestBase.tvString, seq.getString(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvBoolean);
    Assert.assertEquals(AbstractModelTestBase.tvBoolean, seq.getBoolean(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvFloat);
    Assert.assertEquals(AbstractModelTestBase.tvFloat, seq.getFloat(5),
        0.00005);
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvDouble);
    Assert.assertEquals(AbstractModelTestBase.tvDouble, seq.getDouble(5),
        0.000000005);
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, tvLiteral);
    Assert.assertEquals(tvLiteral, seq.getLiteral(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, tvResource);
    Assert.assertEquals(tvResource, seq.getResource(5));
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    seq.set(5, AbstractModelTestBase.tvLitObj);
    // assertEquals( tvLitObj, seq.getObject( 5, new LitTestObjF() ) );
    Assert.assertEquals(3, seq.getInt(4));
    Assert.assertEquals(5, seq.getInt(6));
    Assert.assertEquals(num, seq.size());

    // seq.set( 5, tvResObj );
    // assertEquals( tvResObj, seq.getResource( 5, new ResTestObjF() ) );
    // assertEquals( 3, seq.getInt( 4 ) );
    // assertEquals( 5, seq.getInt( 6 ) );
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Seq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.