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

Examples of com.hp.hpl.jena.rdf.model.Model.createLiteral()


    public void testBasics() {
        Model base = ModelFactory.createDefaultModel();
        Resource r = base.createResource(egNS + "r");
        Property p = base.createProperty(egNS + "p");
        Property q = base.createProperty(egNS + "q");
        Literal l = base.createLiteral("foo");
        Statement asserted = base.createStatement(r, p, l);
        r.addProperty(p, l);
       
        List<Rule> rules = Rule.parseRules("(?r eg:p ?v) -> (?v eg:q ?r).");
        GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
View Full Code Here


   
    @Test public void test_ext_2()
    {
        IndexBuilderNode b = new IndexBuilderNode() ;
        Model model = ModelFactory.createDefaultModel() ;
        Literal lit = model.createLiteral("example") ;
        b.index(lit, "foo") ;
        b.closeWriter() ;
       
        IndexLARQ index = b.getIndex() ;
        NodeIterator nIter = index.searchModelByIndex("foo") ;
View Full Code Here

    @Test public void test_remove_5() throws Exception
    {
        IndexBuilderString indexBuilder = new IndexBuilderString();
      Model model = ModelFactory.createDefaultModel();
        model.register(indexBuilder) ;
        model.add(model.createResource("http://example/r1"), model.createProperty("http://example/p"), model.createLiteral("foo"));
        model.add(model.createResource("http://example/r2"), model.createProperty("http://example/p"), model.createLiteral("foo"));

        model.removeAll(model.getResource("http://example/r1"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        IndexLARQ index = indexBuilder.getIndex() ;
        assertTrue(index.searchModelByIndex("foo").hasNext()) ; // the Model is used as reference counting, still one literal "foo" is present in the Lucene index
View Full Code Here

    {
        IndexBuilderString indexBuilder = new IndexBuilderString();
      Model model = ModelFactory.createDefaultModel();
        model.register(indexBuilder) ;
        model.add(model.createResource("http://example/r1"), model.createProperty("http://example/p"), model.createLiteral("foo"));
        model.add(model.createResource("http://example/r2"), model.createProperty("http://example/p"), model.createLiteral("foo"));

        model.removeAll(model.getResource("http://example/r1"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        IndexLARQ index = indexBuilder.getIndex() ;
        assertTrue(index.searchModelByIndex("foo").hasNext()) ; // the Model is used as reference counting, still one literal "foo" is present in the Lucene index
View Full Code Here

      Model model = ModelFactory.createDefaultModel();
        model.register(indexBuilder) ;
        model.add(model.createResource("http://example/r1"), model.createProperty("http://example/p"), model.createLiteral("foo"));
        model.add(model.createResource("http://example/r2"), model.createProperty("http://example/p"), model.createLiteral("foo"));

        model.removeAll(model.getResource("http://example/r1"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        IndexLARQ index = indexBuilder.getIndex() ;
        assertTrue(index.searchModelByIndex("foo").hasNext()) ; // the Model is used as reference counting, still one literal "foo" is present in the Lucene index

        model.removeAll(model.getResource("http://example/r2"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        index = indexBuilder.getIndex() ;
View Full Code Here

        model.removeAll(model.getResource("http://example/r1"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        IndexLARQ index = indexBuilder.getIndex() ;
        assertTrue(index.searchModelByIndex("foo").hasNext()) ; // the Model is used as reference counting, still one literal "foo" is present in the Lucene index

        model.removeAll(model.getResource("http://example/r2"), model.getProperty("http://example/p"), model.createLiteral("foo"));       
        index = indexBuilder.getIndex() ;
        assertFalse(index.searchModelByIndex("foo").hasNext()) ;
    }
   
    @Test public void test_duplicates_1()
View Full Code Here

      Model model =getContextModel();
      Resource s = getResource(model, subject.trim());
        Property p = model.createProperty(predicate.trim());
        Literal o;
        if (lang == null && datatype == null) {
            o = model.createLiteral(lex.trim());
        } else if (lang != null) {
            o = model.createLiteral(lex.trim(), lang.trim());
        } else {
            o = model.createTypedLiteral(lex.trim(), datatype.trim());
        }
View Full Code Here

        Property p = model.createProperty(predicate.trim());
        Literal o;
        if (lang == null && datatype == null) {
            o = model.createLiteral(lex.trim());
        } else if (lang != null) {
            o = model.createLiteral(lex.trim(), lang.trim());
        } else {
            o = model.createTypedLiteral(lex.trim(), datatype.trim());
        }
        model.add(s, p, o);
    }
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());
  }

  public void testRDFNodeAsResource()
  {
View Full Code Here

  {
    final List<String> history = new ArrayList<String>();
    final Model m = ModelFactory.createDefaultModel();
    final RDFNode S = m.createResource();
    final RDFNode P = m.createProperty("eh:PP");
    final RDFNode O = m.createLiteral("LL");
    /* */
    final RDFVisitor rv = new RDFVisitor() {
      @Override
      public Object visitBlank( final Resource R, final AnonId id )
      {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.