1 10 11 package org.mmbase.bridge.implementation; 12 13 import java.util.Collection ; 14 import org.mmbase.bridge.*; 15 import org.mmbase.module.core.*; 16 17 23 public class BasicRelationList extends BasicNodeList implements RelationList { 24 25 BasicRelationList() { 26 super(); 27 } 28 29 BasicRelationList(Collection c, Cloud cloud) { 30 super(c, cloud); 31 } 32 33 BasicRelationList(Collection c, NodeManager nodemanager) { 34 super(c, nodemanager); 35 } 36 37 protected Object validate(Object o) throws ClassCastException ,IllegalArgumentException { 38 if (o instanceof MMObjectNode) { 39 if (((MMObjectNode) o).getBuilder() instanceof org.mmbase.module.corebuilders.InsRel) { 40 return o; 41 } else { 42 throw new IllegalArgumentException ("Requires a relation node, but builder of " + o + " is " + ((MMObjectNode) o).getBuilder()); 43 } 44 } else { 45 if (! (o instanceof Relation)) throw new ClassCastException ("" + o + " is not a Relation, but a " + o.getClass()); 46 return o; 47 } 48 } 49 50 53 public Relation getRelation(int index) { 54 return (Relation)get(index); 55 } 56 57 60 public RelationList subRelationList(int fromIndex, int toIndex) { 61 if (nodeManager != null) { 62 return new BasicRelationList(subList(fromIndex, toIndex), nodeManager); 63 } else { 64 return new BasicRelationList(subList(fromIndex, toIndex), cloud); 65 } 66 } 67 68 71 public RelationIterator relationIterator() { 72 return new BasicRelationIterator(); 73 } 74 75 protected class BasicRelationIterator extends BasicNodeIterator implements RelationIterator { 76 77 public Relation nextRelation() { 78 return (Relation)next(); 79 } 80 81 public Relation previousRelation() { 82 return (Relation)previous(); 83 } 84 } 85 } 86 | Popular Tags |