Examples of TypedLiteral


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

  @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

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

  @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

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

    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

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

      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

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

        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

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

                "Cannot build a UriRef resource on an anonymous public key!");
        log.debug("Searching for a meta graph entry for public key:");
        log.debug(" -- {}", publicKey);
        UriRef match = null;
        LiteralFactory lf = LiteralFactory.getInstance();
        TypedLiteral oiri = lf.createTypedLiteral(new UriRef(ontologyIri.toString()));
        TypedLiteral viri = versionIri == null ? null : lf.createTypedLiteral(new UriRef(versionIri
                .toString()));
        for (Iterator<Triple> it = graph.filter(null, HAS_ONTOLOGY_IRI_URIREF, oiri); it.hasNext();) {
            Resource subj = it.next().getSubject();
            log.debug(" -- Ontology IRI match found. Scanning");
            log.debug(" -- Resource : {}", subj);
View Full Code Here

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

        Iterator<Triple> startPosIterator = enhancements.filter(textAnnotation,
                ENHANCER_START, null);
        Iterator<Triple> endPosIterator = enhancements.filter(textAnnotation,
                ENHANCER_END, null);
        //start end is optional, but if start is present, that also end needs to be set
        TypedLiteral startPosLiteral;
        TypedLiteral endPosLiteral;
        if(startPosIterator.hasNext()){
            //NOTE: TextAnnotations might be use to select whole sections of a text
            //      (e.g. see STANBOL-617) in those cases adding the text of the
            //      whole section is not feasible.
            //assertNotNull("If fise:start is present the fise:selection-context MUST also be present (uri: "+textAnnotation+")!",
            //    selectionContextResource);
            Resource resource = startPosIterator.next().getObject();
            //only a single start position is supported
            assertFalse("fise:start MUST HAVE only a single value (uri: "+textAnnotation+")!",startPosIterator.hasNext());
            assertTrue("fise:start MUST be a typed Literal (uri: "+textAnnotation+")!",resource instanceof TypedLiteral);
            startPosLiteral = (TypedLiteral) resource;
            assertEquals("fise:start MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, startPosLiteral.getDataType());
            resource = null;
            Integer start = LiteralFactory.getInstance().createObject(Integer.class, startPosLiteral);
            assertNotNull("Unable to parse Integer from TypedLiteral "+startPosLiteral,start);
            //now get the end
            //end must be defined if start is present
            assertTrue("If fise:start is present also fise:end MUST BE defined (uri: "+textAnnotation+")!",endPosIterator.hasNext());
            resource = endPosIterator.next().getObject();
            //only a single end position is supported
            assertFalse("fise:end MUST HAVE only a single value (uri: "+textAnnotation+")!",endPosIterator.hasNext());
            assertTrue("fise:end values MUST BE TypedLiterals (uri: "+textAnnotation+")",resource instanceof TypedLiteral);
            endPosLiteral = (TypedLiteral) resource;
            assertEquals("fise:end MUST use xsd:int as data type (uri: "+textAnnotation+")",XSD.int_, endPosLiteral.getDataType());
            resource = null;
            Integer end = LiteralFactory.getInstance().createObject(Integer.class, endPosLiteral);
            assertNotNull("Unable to parse Integer from TypedLiteral "+endPosLiteral,end);
            //check for equality of the selected text and the text on the selected position in the content
            //System.out.println("TA ["+start+"|"+end+"]"+selectedText.getLexicalForm()+"<->"+content.substring(start,end));
View Full Code Here

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

                "Cannot build a UriRef resource on an anonymous public key!");
        log.debug("Searching for a meta graph entry for public key:");
        log.debug(" -- {}", publicKey);
        UriRef match = null;
        LiteralFactory lf = LiteralFactory.getInstance();
        TypedLiteral oiri = lf.createTypedLiteral(new UriRef(ontologyIri.toString()));
        TypedLiteral viri = versionIri == null ? null : lf.createTypedLiteral(new UriRef(versionIri
                .toString()));
        for (Iterator<Triple> it = meta.filter(null, HAS_ONTOLOGY_IRI_URIREF, oiri); it.hasNext();) {
            Resource subj = it.next().getSubject();
            log.debug(" -- Ontology IRI match found. Scanning");
            log.debug(" -- Resource : {}", subj);
View Full Code Here

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

        ContentItem contentItem = ciFactory.createContentItem(uri, new ByteArraySource(content,
                "text/plain; charset=UTF-8"));

        TripleCollection tc = new SimpleMGraph();
        TypedLiteral literal = LiteralFactory.getInstance().createTypedLiteral("Michael Jackson");
        UriRef subject = new UriRef("dummyUri");
        tc.add(new TripleImpl(subject, new UriRef("http://xmlns.com/foaf/0.1/givenName"), literal));
        contentItem.addPart(new UriRef(uri.getUnicodeString() + "_additionalMetadata"), tc);

        ContentItemBackend ciBackend = new ContentItemBackend(contentItem, true);
View Full Code Here

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

                            jldValue.setLanguage(plain.getLanguage().toString());
                        }
                        strValue = plain.getLexicalForm();
                    }
                    else if (currentTriple.getObject() instanceof TypedLiteral) {
                        TypedLiteral typedObject = (TypedLiteral) currentTriple.getObject();
                        String type = typedObject.getDataType().getUnicodeString();
                        jldValue.setType(type);
                        strValue = typedObject.getLexicalForm();
                    }
                    else if (currentTriple.getObject() instanceof UriRef) {
                        UriRef uriRef = (UriRef) currentTriple.getObject();
                        jldValue.setType(JsonLdCommon.ID);
                        strValue = uriRef.getUnicodeString();
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.