KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > util > CollectionRelationList


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.bridge.util;
12
13 import org.mmbase.bridge.*;
14 import java.util.*;
15 import org.mmbase.util.logging.*;
16
17 /**
18  * A list of nodes, based on a Collection of Nodes
19  *
20  * @author Michiel Meeuwissen
21  * @version $Id: CollectionRelationList.java,v 1.1 2005/12/29 19:08:01 michiel Exp $
22  * @since MMBase-1.8
23  */

24 public class CollectionRelationList extends CollectionNodeList implements RelationList {
25
26     private static final Logger log = Logging.getLoggerInstance(CollectionRelationList.class);
27
28
29     public CollectionRelationList(Collection c, NodeManager nodeManager) {
30         super(c, nodeManager);
31     }
32
33
34     public CollectionRelationList(Collection c, Cloud cloud) {
35         super(c, cloud);
36     }
37
38     protected Object JavaDoc validate(Object JavaDoc o) throws ClassCastException JavaDoc,IllegalArgumentException JavaDoc {
39         return (Relation)o;
40     }
41     /**
42      *
43      */

44     public Relation getRelation(int index) {
45         return (Relation)get(index);
46     }
47
48     /**
49      *
50      */

51     public RelationList subRelationList(int fromIndex, int toIndex) {
52         if (nodeManager != null) {
53             return new CollectionRelationList(subList(fromIndex, toIndex), nodeManager);
54         } else {
55             return new CollectionRelationList(subList(fromIndex, toIndex), cloud);
56         }
57     }
58
59     /**
60      *
61      */

62     public RelationIterator relationIterator() {
63         return new BasicRelationIterator();
64     }
65
66     protected class BasicRelationIterator extends BasicNodeIterator implements RelationIterator {
67
68         public Relation nextRelation() {
69             return (Relation)next();
70         }
71
72         public Relation previousRelation() {
73             return (Relation)previous();
74         }
75     }
76 }
77
Popular Tags