Exemplo n.º 1
0
 public List getValues() {
   List result = new ArrayList();
   RDFList l = this;
   while (l != null && l.getFirst() != null) {
     result.add(l.getFirst());
     l = l.getRest();
   }
   return result;
 }
Exemplo n.º 2
0
  public void append(Object value) {

    boolean done = false;
    RDFList current = this;

    while (!done) {
      if (current.getFirst() == null) {
        current.setFirst(value);
        current.setRest(getOWLModel().getRDFNil());
        done = true;
      } else if (current.getRest() == null || getOWLModel().getRDFNil().equals(current.getRest())) {
        RDFSNamedClass listClass = (RDFSNamedClass) getDirectType();
        RDFList newRest = (RDFList) listClass.createAnonymousInstance();
        newRest.setFirst(value);
        newRest.setRest(getOWLModel().getRDFNil());
        current.setRest(newRest);
        done = true;
      } else {
        current = current.getRest(); // Recursion into tail
      }
    }
  }
Exemplo n.º 3
0
 public static void removeListValue(
     RDFResource resource, RDFProperty property, RDFList li, int index) {
   if (index == 0) {
     RDFList rest = li.getRest();
     if (li.getOWLModel().getRDFNil().equals(rest)) {
       rest = null;
     }
     li.setRest(null);
     resource.setPropertyValue(property, rest);
     li.delete();
   } else {
     RDFList pred = null;
     while (index > 0) {
       index--;
       pred = li;
       li = li.getRest();
     }
     RDFList rest = li.getRest();
     li.setRest(null);
     pred.setRest(rest);
     li.delete();
   }
 }