Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.TypedLiteral


  }

  @Test
  public void intToXsdIntAndBackToMany() {
    int value = 14;
    TypedLiteral tl = simpleLiteralFactory.createTypedLiteral(value);
    Assert.assertEquals(xsdInt, tl.getDataType());
    long longValue = simpleLiteralFactory.createObject(Long.class, tl);
    Assert.assertEquals(value, longValue);
    int intValue = simpleLiteralFactory.createObject(Integer.class, tl);
    Assert.assertEquals(value, intValue);
  }
View Full Code Here


   
 
  @Test public void typedLiteralEquality() {
    String stringValue = "some text";
    UriRef uriRef = new UriRef("http://example.org/datatypes/magic");
    TypedLiteral literal1 = new TypedLiteralImpl(stringValue, uriRef);
    TypedLiteral literal2 = new TypedLiteralImpl(stringValue, uriRef);   
    Assert.assertEquals(literal1, literal2);
    Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
    TypedLiteral literal3 = new TypedLiteralImpl("something else", uriRef);
    Assert.assertFalse(literal1.equals(literal3));
    UriRef uriRef2 = new UriRef("http://example.org/datatypes/other");
    TypedLiteral literal4 = new TypedLiteralImpl(stringValue, uriRef2);
    Assert.assertFalse(literal1.equals(literal4));
  }
View Full Code Here

   * The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp
   */
  @Test public void checkHashCode() {
    String stringValue = "some text";
    UriRef uriRef = new UriRef("http://example.org/datatypes/magic");
    TypedLiteral literal =  new TypedLiteralImpl(stringValue, uriRef);
    Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode());
  }
View Full Code Here

        defaultGraph = (UriRef) defaultGraphs.next().getObject();
      }
      Iterator<Triple> queryTemplates = contentGraph.filter(
          conceptProvider, CONCEPTS.queryTemplate, null);
      if (queryTemplates.hasNext()) {
        TypedLiteral queryTemplate =
            (TypedLiteral) queryTemplates.next().getObject();
        conceptProviderList.add(
            new RemoteConceptProvider(sparqlEndPoint,
            defaultGraph, queryTemplate.getLexicalForm()));
      }
    }
  }
View Full Code Here

        CONCEPTS.cacheEntry, conceptCacheEntryNode));
  }

  private NonLiteral getConceptCacheEntryNode(String searchTerm,
      NonLiteral conceptCacheNode, MGraph conceptCacheMGraph) {
    TypedLiteral searchLiteral = LiteralFactory.getInstance()
        .createTypedLiteral(searchTerm);
    Iterator<Triple> cacheEntries = conceptCacheMGraph.filter(
        conceptCacheNode, CONCEPTS.cacheEntry, null);
    while (cacheEntries.hasNext()) {
      NonLiteral conceptCacheEntryNode = (NonLiteral) cacheEntries.next()
View Full Code Here

  @Test
  public void dateStorage() {
    MGraph graph = getEmptyMGraph();
    Date date = new Date(0);
    LiteralFactory literalFactory = LiteralFactory.getInstance();
    TypedLiteral dateLiteral = literalFactory.createTypedLiteral(date);
    Triple triple = new TripleImpl(new BNode(), new UriRef("http://example.com/property"), dateLiteral);
    graph.add(triple);
    Assert.assertTrue(graph.contains(triple));
  }
View Full Code Here

  @Test
  public void dateStorage2() {
    MGraph graph = getEmptyMGraph();
    Date date = new Date(0);
    LiteralFactory literalFactory = LiteralFactory.getInstance();
    TypedLiteral dateLiteral = literalFactory.createTypedLiteral(date);
    System.out.println(dateLiteral);
    UriRef property = new UriRef("http://example.com/property");
    Triple triple = new TripleImpl(new BNode(), property, dateLiteral);
    graph.add(triple);
View Full Code Here

    StringBuffer sb = new StringBuffer("\"");
    escapeUtf8ToUsAscii(literal.getLexicalForm(), sb, false);
    sb = sb.append("\"");

    if(literal instanceof TypedLiteral) {
      TypedLiteral typedLiteral = (TypedLiteral) literal;
      sb.append("^^<");
      escapeUtf8ToUsAscii(
          typedLiteral.getDataType().getUnicodeString(), sb, false);
      sb.append(">");
    } else if(literal instanceof PlainLiteral) {
      PlainLiteral plainLiteral = (PlainLiteral) literal;
      if(plainLiteral.getLanguage() != null &&
          !plainLiteral.getLanguage().toString().equals("")) {
View Full Code Here

      jObject.put("type", "literal");
      if (plainLiteral.getLanguage() != null) {
        jObject.put("lang", plainLiteral.getLanguage().toString());
      }
    } else if (object instanceof TypedLiteral) {
      TypedLiteral literal = (TypedLiteral) object;
      jObject.put("value", literal.getLexicalForm());
      jObject.put("type", "literal");
      jObject.put("datatype", literal.getDataType().getUnicodeString());
    } else if (object instanceof UriRef) {
      UriRef uriRef = (UriRef) object;
      jObject.put("value", uriRef.getUnicodeString());
      jObject.put("type", "uri");
    } else if (object instanceof BNode) {
View Full Code Here

        graph.add(new TripleImpl(id, FOAF_PRIMARY_TOPIC_OF, metaId));
        graph.add(new TripleImpl(metaId, FOAF_PRIMARY_TOPIC, metaId));
        graph.add(new TripleImpl(metaId, RDF.type, FOAF_DOCUMENT));
        //add the site to the metadata
        //TODO: this should be the HTTP URI and not the id of the referenced site
        TypedLiteral siteName = literalFactory.createTypedLiteral(sign.getSite());
        graph.add(new TripleImpl(metaId, EntityToRDF.signSite, siteName));
       
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.TypedLiteral

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.