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

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


       
        Property p = this.jenaModel.createProperty(predicate.toString());
       
        String datatypeValue = ((DatatypeLiteral)object).getValue();
        String datatypeURI = ((DatatypeLiteral)object).getDatatype().toString();
        Literal o = this.jenaModel.createTypedLiteral(datatypeValue, datatypeURI);
       
        // Add the statement to the model
        this.jenaModel.add(s, p, o);
      }
    } catch(BadURIException e) {
View Full Code Here


    // f�r den dritten BaseDatatype nehmen wir eine neue Datentyp URI
    RDFDatatype DTtestB = TypeMapper.getInstance().getTypeByName(strTestB);
   
    com.hp.hpl.jena.rdf.model.Model model = ModelFactory.createDefaultModel();
   
    Literal litA11 = model.createTypedLiteral("teststring", DTtestA1);
    Literal litA12 = model.createTypedLiteral("teststring", DTtestA1);
    Literal litA2 = model.createTypedLiteral("teststring", DTtestA2);
    @SuppressWarnings("unused")
    Literal litB = model.createTypedLiteral("teststring", DTtestB);
   
    // alle Literals haben den gleichen Wert !
   
    // dann wollen wir mal schauen was passiert:
View Full Code Here

    // typed literals
    // semantisch so behandelt wie wir es wollen
    // Behold !!
    JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = true;
   
    Literal litA1 = model.createTypedLiteral("teststring", strTestA);
    Literal litA2 = model.createTypedLiteral("teststring", strTestA);
    Literal litB = model.createTypedLiteral("teststring", strTestB);
   
    // dann wollen wir mal schauen was passiert:
   
    // reflexivit�t: A == A , passt
    assertTrue(litA1.equals(litA1));
    // gleicher Inhalt, in zwei versch. Objekten, passt auch
    assertTrue(litA1.equals(litA2));
    // und zur sicherheit: 2 versch Datentyp URIs: nein
    assertFalse(litA1.equals(litB));
   
    // und nochmal der negativ Test:
    assertTrue(litB.equals(litB));
    assertFalse(litB.equals(litA1));
    assertFalse(litB.equals(litA2));
    assertEquals("Extract Datatype URI", litA1.getDatatypeURI(), strTestA);
    assertEquals("Extract value", "teststring", litA1.getLexicalForm());
   
    // im jena cvs geht auch folgendes, damit kann man das Object des Daten
    // Typs besser manipulieren
View Full Code Here

      log.debug("instanceof DatatypeLiteral");
     
      boolean originalFlag = JenaParameters.enableSilentAcceptanceOfUnknownDatatypes;
      JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = true;
     
      Literal l = model.createTypedLiteral(((DatatypeLiteral)o).getValue(),
              ((DatatypeLiteral)o).getDatatype().toString());
     
      JenaParameters.enableSilentAcceptanceOfUnknownDatatypes = originalFlag;
     
      return l.asNode();
     
    }
   
    if(o instanceof LanguageTagLiteral) {
      // langtag
View Full Code Here

                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x.isLiteral() )
                {
                    Literal titleStr = (Literal)x  ;
                    System.out.println("    "+titleStr) ;
                }
                else
                    System.out.println("Strange - not a literal: "+x) ;
                   
View Full Code Here

    @Test
    public void typedLiterals() {
        MGraph mGraph = new SimpleMGraph();
        com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
        Model model = ModelFactory.createModelForGraph(graph);
        Literal typedLiteral = model.createTypedLiteral("<elem>foo</elem>", XMLLiteralType.theXMLLiteralType);
        model.add(RDFS.Class, RDFS.label, typedLiteral);
        Assert.assertEquals(1, mGraph.size());
        StmtIterator iter = model.listStatements(RDFS.Class, RDFS.label, (Resource)null);
        Assert.assertTrue(iter.hasNext());
        RDFNode gotObject = iter.nextStatement().getObject();
View Full Code Here

                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
                    System.out.println("    "+titleStr) ;
                }
                else
                    System.out.println("Strange - not a literal: "+x) ;
                   
View Full Code Here

                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
                    System.out.println("    "+titleStr) ;
                }
                else
                    System.out.println("Strange - not a literal: "+x) ;
                   
View Full Code Here

                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
                if ( x.isLiteral() )
                {
                    Literal titleStr = (Literal)x  ;
                    System.out.println("    "+titleStr) ;
                }
                else
                    System.out.println("Strange - not a literal: "+x) ;
                   
View Full Code Here

    {
        Model m  = root.getModel() ;
        // Assume one result set per file.
        for ( int index = 1 ; ; index++ )
        {
            Literal ind = m.createTypedLiteral(index) ;
            StmtIterator sIter = m.listStatements(null, ResultSetGraphVocab.index, ind) ;
            if ( ! sIter.hasNext() )
                break ;
            Statement s = sIter.nextStatement() ;
            if ( sIter.hasNext() )
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.