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

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


  {
    // Resource r = model.createResource( "eh:/rhubarb" );
    final UniqueValueClass2 r = new UniqueValueClass2("rhubarb");
    Assert.assertNull("not expecting registered RDF Datatype", TypeMapper
        .getInstance().getTypeByValue(r));
    final Literal typed = model.createTypedLiteral(r); // Sets the type
    // mapper -
    // contaminates it
    // with
    // UniqueValueClass2
    final Literal string = model.createLiteral(r.value);
    Assert.assertEquals(string.getLexicalForm(), typed.getLexicalForm());
    Assert.assertEquals(string.getLanguage(), typed.getLanguage());
    JenaTestBase.assertDiffer(string.getDatatypeURI(),
        typed.getDatatypeURI());
    Assert.assertNotNull(
        "a datatype should have been invented for Resource[Impl]",
        typed.getDatatype());
    JenaTestBase.assertDiffer(typed, string);
    JenaTestBase.assertDiffer(typed.getValue(), string.getValue());
    Assert.assertEquals(r, typed.getValue());
    JenaTestBase.assertDiffer(typed.hashCode(), string.hashCode());
  }
View Full Code Here


  }

  public void testRDFNodeAsLiteral()
  {
    final Model m = ModelHelper.modelWithStatements(this, "");
    final Literal l = m.createLiteral("hello, world");
    Assert.assertSame(l, ((RDFNode) l).asLiteral());
  }
View Full Code Here

  }

  public void testResourceAsLiteralThrows()
  {
    final Model m = ModelHelper.modelWithStatements(this, "");
    final Literal l = m.createLiteral("hello, world");
    try
    {
      l.asResource();
      Assert.fail("should not be able to do Literal.asResource()");
    }
    catch (final ResourceRequiredException e)
    {
    }
View Full Code Here

  private static String _getValueAsString(RDFNode node) {
    if ( node == null ) {
      return null;
    }
    else if ( node instanceof Literal ) {
      Literal lit = (Literal) node;
      return lit.getLexicalForm();
    }
    else {
      return ((Resource) node).getURI();
    }
  }
View Full Code Here

  }

  public void testAddLiteralPassesLiteralUnmodified()
  {
    final Resource r = model.createResource();
    final Literal lit = model.createLiteral("spoo");
    r.addLiteral(RDF.value, lit);
    Assert.assertTrue("model should contain unmodified literal",
        model.contains(null, RDF.value, lit));
  }
View Full Code Here

  public void testFillingContainer()
  {
    final Container c = createContainer();
    final String lang = "fr";
    final Literal tvLiteral = model.createLiteral("test 12 string 2");
    // Resource tvResObj = model.createResource( new ResTestObjF() );
    c.add(AbstractModelTestBase.tvBoolean);
    Assert.assertTrue(c.contains(AbstractModelTestBase.tvBoolean));
    c.add(AbstractModelTestBase.tvByte);
    Assert.assertTrue(c.contains(AbstractModelTestBase.tvByte));
View Full Code Here

  @Override
  public void setUp() throws Exception
  {
    super.setUp();
    final Literal tvLitObjs[] = {
        model.createTypedLiteral(new LitTestObj(1)),
        model.createTypedLiteral(new LitTestObj(2)) };

    for (int i = 0; i < num; i += 1)
    {
View Full Code Here

     * the _null_ argument to LiteralImpl was preserved only for backward
     * compatability. It was be logged and has now become an exception.
     */
    try
    {
      final Literal lit = model.createLiteral(null, "");
      model.query(new SimpleSelector(null, null, lit));
      Assert.fail("SHould have thrown a null pointer exception");
    }
    catch (final NullPointerException expected)
    { // expected}
    }

    try
    {
      final Literal lit = model.createLiteral(null, "en");
      model.query(new SimpleSelector(null, null, lit));
      Assert.fail("SHould have thrown a null pointer exception");
    }
    catch (final NullPointerException expected)
    { // expected}
View Full Code Here

  }

  public void testSeqAccessByIndexing()
  {
    // LitTestObj tvObject = new LitTestObj(12345);
    final Literal tvLiteral = model.createLiteral("test 12 string 2");
    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();
View Full Code Here

  }

  public void testSeqInsertByIndexing()
  {
    // LitTestObj tvObject = new LitTestObj(12345);
    final Literal tvLiteral = model.createLiteral("test 12 string 2");
    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();
View Full Code Here

TOP

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

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.