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

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


  /** map a list type to an RDF list, e.g. IDREFS (list of IDREF) */

  public static RDFList toRDFList(Node node, String values, String itemType, Set<restriction> restrictions, Context ctx)
  throws Exception {
    if (values==null) return null;
    RDFList l= ctx.getModel().createList();
    StringTokenizer t = new StringTokenizer(values);
    while (l!=null && t.hasMoreTokens())
      l = toRDFList(node,t.nextToken(),itemType,l,restrictions,ctx);
    return l;
  }
View Full Code Here


    if (s!=null) return s.toXML(element,rdf,pack,ctx);

    if (type!=null && type.equals(XSD_URI+"#IDREFS") && rdf instanceof Resource
        && ((Resource)rdf).hasProperty(RDF.first)
        && rdf.canAs(RDFList.class)) {
      RDFList l = (RDFList) rdf.as(RDFList.class);
      for (ExtendedIterator i=l.iterator(); i.hasNext();) {
        v = toXMLValue(element, (RDFNode) i.next(), XSD.IDREF.getURI(), ctx);
        if (v==null) return false; // failed for this type
        element.appendChild(doc.createTextNode(pack==null?v:pack+v));
        pack = " ";
      }
View Full Code Here

  }
 
  public String listToString(Resource r, Element elem, String type, Context ctx) {
    String v = null;
    if (r.canAs(RDFList.class)) {
      RDFList l = (RDFList) r.as(RDFList.class);
      for (ExtendedIterator i=l.iterator(); i.hasNext();) {
        String s1 = toXMLValue(elem,(RDFNode) i.next(),type,ctx);
        v = v==null?s1:v+ " "+s1;
      }
    }       
    return v;
View Full Code Here

      // isolate restrictions on each member
      Set<restriction> r = new HashSet<restriction>();
      r.addAll(restrictions);
      MemberType m = v.elementAt(i);
      simpleType s = m.getSimpleType();
      RDFList l;
      if (s!=null && (l=s.toRDFList(node,value,list,r,ctx))!=null) return l;
      else if (s==null && (l=schema.toRDFList(node,value,m.getType(),list,r,ctx))!=null) return l;
    }
    return null;
  }
View Full Code Here

 
  public boolean toRDF(Resource subject, Property prop, Seq seq, Node node, String value, Set<restriction> restrictions, Context ctx)
  throws Exception {
    Model m = ctx.getModel();
    schema xs = (schema) this.get_owner();
    RDFList l= m.createList();

    simpleType t = get_type(ctx);
    String type = expandQName(ctx.getDefaultNS(),itemType, m);
   
    StringTokenizer tok = new StringTokenizer(value);
View Full Code Here

      schema xsd = (schema) this.get_owner();
      simpleType t = get_type(ctx);
      String type = null;
      if (t==null) type = expandQName(ctx.getDefaultNS(),itemType, ctx.getModel());

      RDFList list = (RDFList) rdf.as(RDFList.class);
      String pack = null;
      for (ExtendedIterator i = list.iterator(); ok && i.hasNext(); ) {
        RDFNode n = (RDFNode) i.next()
        if (t!=null) ok=t.toXML(e,n,pack,ctx);
        else ok=xsd.toXMLText(e,n,type,pack,ctx);
        pack = " "; // whitespace separator
      }
View Full Code Here

      schema xsd = (schema) this.get_owner();
      simpleType simple = ctx.getSimpleType(xsd.expandQName(ctx.getDefaultNS(),itemType,m));
      String type = null;
      if (simple==null) type = expandQName(ctx.getDefaultNS(),itemType, m);

      RDFList list = (RDFList) rdf.as(RDFList.class);
      for (ExtendedIterator i = list.iterator(); ok && i.hasNext(); ) {
        RDFNode n = (RDFNode) i.next();
        if (simple!=null) ok=simple.toXML(attr,n,ctx);
        else ok=xsd.toXML(attr,n,type,ctx);
      }
    } catch (Exception e) { // non-fatal
View Full Code Here

    if (rest!=null || ctx.isGlobalElement(def)) {
      OntResource r = p.getRange();
      p.removeRange(r);
      Vector<Resource> v = new Vector<Resource>();
      v.add(RDF.nil);
      RDFList nil = ont.createList(v.iterator());
      OntClass c = ont.createEnumeratedClass(null,nil);
      if (rest!=null) rest.addRange(uri,c);
      Vector<Resource> u = new Vector<Resource>();
      u.add(r); u.add(c);
      p.addRange(ont.createUnionClass(null,ont.createList(u.iterator())));
View Full Code Here

        c.addEquivalentClass(e);
        return c;
      }
      // declare enumerated complex type
      else {
        RDFList e = enumeration.toOWL(xs.ont, _enumeration, _node, ctx);
        return xs.ont.createEnumeratedClass(uri,e);
      }
    }

    if (base!=null) {
View Full Code Here

   
    else if (rest!=null && c==null) {
      List<OntClass> restrictions = buildRestrictions(rest, ctx);
      if (ctx.get_class().equals("intersectionOf")) {
        if (restrictions.size()>=1) {
          RDFList l = xs.ont.createList(restrictions.iterator());
          if (cls!=null) cls.removeProperties();
          if (uri!=null) ctx.putOntClass(uri, cls = xs.ont.createIntersectionClass(uri,l));
          else if (createAnon) cls = xs.ont.createIntersectionClass(null,l);
        }
      }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.RDFList

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.