Package org.ontoware.rdf2go.model.node

Examples of org.ontoware.rdf2go.model.node.DatatypeLiteral


    // SPARQL SELECT with typed literal
    System.out.println("Query 3:");
    // select name of all resources with integer age of 19:
    queryString = "SELECT ?name WHERE { ?resource <"+hasAge+"> \"19\"^^<"+XSD._integer+"> . ?resource <"+hasName+"> ?name }";
    //works also:
    DatatypeLiteral nineteen = model.createDatatypeLiteral("19",XSD._integer);
    String queryString2 = "SELECT ?name WHERE { ?resource <"+hasAge+"> "+nineteen.toSPARQL()+" . ?resource <"+hasName+"> ?name }";
    assert queryString.equals(queryString2);
   
    results = model.sparqlSelect(queryString);
    for(QueryRow row : results) {
      System.out.println(row);
View Full Code Here


    URI name = model.createURI(foafURI+"#term_name");
    URI icqId = model.createURI(foafURI+"#term_icqChatID");
    URI typeInteger = XSD._integer;
    BlankNode konrad = model.createBlankNode();
    PlainLiteral maxNameAsPlainLiteral = model.createPlainLiteral("Max Völkel");
    DatatypeLiteral number = model.createDatatypeLiteral("123", typeInteger);
    LanguageTagLiteral konradNameEnglish = model.createLanguageTagLiteral("Konrad Voelkel", "en");
    LanguageTagLiteral konradNameGerman = model.createLanguageTagLiteral("Konrad Völkel", "de");

    // adding statements to the model
   
View Full Code Here

  /* subclasses should overwrite this method for better performance */
  @Override
    public DatatypeLiteral createDatatypeLiteral(String literal, URI datatypeURI)
      throws ModelRuntimeException {
    Model defaultModel = this.getDefaultModel();
    DatatypeLiteral result = defaultModel.createDatatypeLiteral(literal,
        datatypeURI);
    defaultModel.close();
    return result;

  }
View Full Code Here

   
    if (node == null)
      return false;

    if (node instanceof DatatypeLiteral) {
      DatatypeLiteral dnode = (DatatypeLiteral) node;
      if (dnode.getDatatype().equals(XSD._boolean)) {
        return new Boolean(Boolean.parseBoolean(dnode.getValue()));
      } else
        throw new RDFDataException("Datatype is " + dnode.getDatatype()
            + " which is not known");
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
View Full Code Here

      assertEquals(predicate, s.getPredicate());
      Object literalObject = s.getObject();
      assertNotNull(literalObject);
      assertTrue("literalObject is if type: " + literalObject.getClass(),
              literalObject instanceof DatatypeLiteral);
      DatatypeLiteral rdflit = (DatatypeLiteral)s.getObject();
      assertEquals("Test", rdflit.getValue());
      assertEquals(dt, rdflit.getDatatype());
    }
    sit.close();
  }
View Full Code Here

    BlankNode node = this.model.createBlankNode();
    assertEquals(node, node.asBlankNode());
  }
 
  public void testCreateDatatypeLiteral() {
    DatatypeLiteral datatypeLiteral = this.model.createDatatypeLiteral("literal", dt);
    assertEquals("literal^^" + dt, datatypeLiteral.asLiteral().toString());
  }
View Full Code Here

  }
 
  @Override
    public int compareTo(Node other) {
    if(other instanceof DatatypeLiteral) {
      DatatypeLiteral oLit = (DatatypeLiteral)other;
     
      int diff = this.getValue().compareTo(oLit.getValue());
      if(diff != 0)
        return diff;
      // else
      return this.getDatatype().compareTo(oLit.getDatatype());
    }
    // else sort by type
    return NodeUtils.compareByType(this, other);
  }
View Full Code Here

    assertEquals("internalID", this.modelset.createBlankNode("internalID").getInternalID());
  }
 
  @Test
  public void testCreateDatatypeLiteral() {
    DatatypeLiteral datatypeLiteral = this.modelset.createDatatypeLiteral("literal", dt);
    assertEquals("literal^^" + dt, datatypeLiteral.asLiteral().toString());
  }
View Full Code Here

                bNode = new BNode();
                blankNodeMap.put(node.asBlankNode(), bNode);
            }
            return bNode;
        } else if (node instanceof DatatypeLiteral) {
            DatatypeLiteral dtl = node.asDatatypeLiteral();
            return new TypedLiteralImpl(dtl.getValue(), new UriRef(dtl.getDatatype().asURI().toString()));
        } else if (node instanceof PlainLiteral) {
            return new PlainLiteralImpl(node.asLiteral().getValue());
        }

        return null;
View Full Code Here

    else if (object instanceof org.ontoware.rdf2go.model.node.URI||
        object instanceof URIImpl)
      return new URINode(object.toString());
    else if (object instanceof DatatypeLiteral)
    {
      DatatypeLiteral dl = (DatatypeLiteral)object;
      return new LiteralNode(JavaXSD.xsd2java(dl.getValue(),dl.getDatatype().toString()));
    }
    else if (object instanceof String || object instanceof LanguageTagLiteral || object instanceof Literal)
    {
      return new LiteralNode(object.toString());
    }
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.node.DatatypeLiteral

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.