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

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


    ResIterator assertions = metaModel.listSubjectsWithProperty(
        METAMODEL.asserter, sourceRes);
    Set<NamedNode> result = new HashSet<NamedNode>();
    while (assertions.hasNext()) {
      Resource assertion = assertions.nextResource();
      Literal assertionTimeLit = assertion.getProperty(
          METAMODEL.assertionTime).getLiteral();
      Resource assertedComponent = assertion.getProperty(
          METAMODEL.assertedComponent).getResource();
      if (!assertedComponent.hasProperty(RDF.type, type)) {
        continue;
      }

      Date assertionTime;
      assertionTime = ((XSDDateTime) assertionTimeLit.getValue())
          .asCalendar().getTime();
      if (moment.equals(assertionTime)) {
        result.add(new NamedNodeImpl(assertedComponent.getURI()));
      }
View Full Code Here


        continue;
      }
      Statement revocationTimeStmt = assertion
          .getProperty(METAMODEL.revocationTime);
      if (revocationTimeStmt != null) {
        Literal revocationTimeLit = revocationTimeStmt.getLiteral();
        Date revocationTime = ((XSDDateTime) revocationTimeLit
            .getValue()).asCalendar().getTime();
        if (moment.equals(revocationTime)) {
          result.add(new NamedNodeImpl(assertedComponent.getURI()));
        }
      }
View Full Code Here

  /**
   * @param i
   * @return
   */
  private Iterator<ComponentDirectory> getComponentsByHash(int hashCode) {
    Literal hashLit = indexModel.createTypedLiteral(hashCode);
    final ResIterator resIterator = indexModel.listSubjectsWithProperty(
        METAMODEL.hashCode, hashLit);
    return new Iterator<ComponentDirectory>() {

      public boolean hasNext() {
View Full Code Here

        while (subjectIter.hasNext()) {
          Resource infoDiscoResource = subjectIter.nextResource();
          RDFNode infoBitNode = infoDiscoResource.getProperty(
              DISCOBITS.infoBit).getObject();
          if (infoBitNode instanceof Literal) {
            final Literal literaInfoBit = (Literal) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
                        return Channels
                            .newChannel(new ByteArrayInputStream(
                                literaInfoBit
                                    .getString()
                                    .getBytes(
                                        "utf-8")));
                      }

                    };
                  }

                  public String getMimeTypeString() {
                    return "application/xhtml+xml";
                  }

                });
          } else {
            final Resource literaInfoBit = (Resource) infoBitNode;
            infoDiscoBitURIs.put(infoDiscoResource.getURI(),
                new InfoBit() {

                  public MessageBody getContent() {
                    return new MessageBody2Read() {

                      public ReadableByteChannel read()
                          throws IOException {
                        // TODO Auto-generated method
                        // stub
                        return Channels
                            .newChannel(new ByteArrayInputStream(
                                (byte[]) literaInfoBit.getRequiredProperty(DISCOBITS.bytes).getLiteral().getValue()
                                    ));
                      }

                    };
                  }

                  public String getMimeTypeString() {
                    return literaInfoBit.getRequiredProperty(DISCOBITS.mediaType).getString();
                  }

                });
          }
        }
View Full Code Here

  public static void textToRDF(Resource subject, Seq seq, Node n, Context ctx) {
    String value = ((Text) n).getNodeValue();
    value = processWhitespace(n,value,null,ctx);
    if (!value.equals("")) {
      Model m = ctx.getModel();
      Literal lit = m.createLiteral(value);
      Statement stmt = m.createStatement(subject, RDF.value, lit);
      m.add(stmt);
      if (seq!=null) seq.add(stmt.createReifiedStatement());
    }
  }
View Full Code Here

 
  public boolean toRDF(Resource subject, Property prop, String value, String type, Element elem, Context ctx)
  throws Exception {
    if (elem.hasAttribute("xml:lang")) {
      // no datatype required for a lang qualified string
      Literal l = ctx.getModel().createLiteral(value,elem.getAttribute("xml:lang"));
      subject.addProperty(prop,l);
      return true;
    }
    return toRDF(elem, subject, prop, processWhitespace(elem,value,type,ctx), type, null, null, ctx);
  }
View Full Code Here

    else if (type.endsWith("#ENTITY")) {
      DocumentType doctype = elem.getOwnerDocument().getDoctype();
      Pattern entityPattern = Pattern.compile("<!ENTITY\\s+"+value+"\\s+'(.*)'>");
      Matcher match = entityPattern.matcher(doctype.getInternalSubset());
      if (match.find()) value = match.group(1);
      Literal l = m.createTypedLiteral(value,RDF.getURI()+"XMLLiteral");
      stmt = m.createStatement(subject,prop,l);
    }
    else { // schema datatype?
      RDFDatatype dt = getDatatype(type);
      if (dt != null) {
        Literal l = m.createTypedLiteral(processWhitespace(elem,value,type,ctx), dt);
        stmt = m.createStatement(subject,prop,l);
      }
    }
    return stmt;
  }
View Full Code Here

    if (restriction != null)
      return restriction.toRDF(subject, node, getValue(e), RDF.value, null, null, ctx);
    else if (extension != null)
      return extension.toRDF(subject, e, RDF.value, null, ctx);
    else {// otherwise just add plain literal
      Literal l = model.createLiteral(schema.processWhitespace(node,getValue(e),null,ctx));
      subject.addProperty(RDF.value, l);
      return true;
    }     
  }
View Full Code Here

      // add simple content encoded as rdf:value
      Statement s = r.getProperty(RDF.value);
      if (extension!=null) extension.toXML(e,r,pending,ctx);
      else if (restriction!=null) restriction.toXML(e,r,pending,ctx);
      else if (s!=null && s.getObject() instanceof Literal) {
        Literal l = (Literal) s.getObject();
        e.appendChild(e.getOwnerDocument().createTextNode(l.getString()));
      }
      return true;
    }
    return false;
  }
View Full Code Here

      int index = ((complexType) t).toRDF(o, elem, 0, subSeq, null,true,ctx);
      // mop up remaining values in sequence
      produceMixed(subSeq, index, elem);
    }
    else if (value!=null && stmt==null){ // untyped!
      Literal l = m.createLiteral(schema.processWhitespace(elem,value,null,ctx));
      stmt = m.createStatement(subject,prop,l);     
    }
    else if (type==null){ // empty
      if (is_nillable() && elem.hasAttributeNS(schema.XSI,"nil") && elem.getAttributeNS(schema.XSI,"nil").equals("true"))
        stmt = m.createStatement(subject,prop,RDF.nil);
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.