KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > implementation > BasicRelationManagerList


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.implementation;
12
13 import java.util.*;
14 import org.mmbase.bridge.*;
15 import org.mmbase.module.core.*;
16
17 /**
18  * A list of relation managers
19  *
20  * @author Pierre van Rooden
21  * @version $Id: BasicRelationManagerList.java,v 1.15 2005/10/12 00:37:05 michiel Exp $
22  */

23 public class BasicRelationManagerList extends BasicNodeManagerList implements RelationManagerList {
24
25     BasicRelationManagerList() {
26         super();
27     }
28
29     BasicRelationManagerList(Collection c, Cloud cloud) {
30         super(c, cloud);
31     }
32
33     protected Object JavaDoc validate(Object JavaDoc o) throws ClassCastException JavaDoc,IllegalArgumentException JavaDoc {
34         if (o instanceof MMObjectNode) {
35             MMObjectBuilder bul=((MMObjectNode) o).getBuilder();
36             if ((bul instanceof org.mmbase.module.corebuilders.TypeRel) ||
37                 (bul instanceof org.mmbase.module.corebuilders.RelDef)) {
38                 return o;
39             } else {
40                 throw new IllegalArgumentException JavaDoc("requires a relationmanager (typerel or reldef) node");
41             }
42         } else {
43             return (RelationManager)o;
44         }
45     }
46
47     /**
48     *
49     */

50     public RelationManager getRelationManager(int index) {
51         return (RelationManager) get(index);
52     }
53
54     /**
55     *
56     */

57     public RelationManagerIterator relationManagerIterator() {
58         return new BasicRelationManagerIterator();
59     };
60
61     /**
62      *
63      */

64     public RelationManagerList subRelationManagerList(int fromIndex, int toIndex) {
65         return new BasicRelationManagerList(subList(fromIndex, toIndex), cloud);
66     }
67
68     protected class BasicRelationManagerIterator extends BasicNodeManagerIterator implements RelationManagerIterator {
69
70         public RelationManager nextRelationManager() {
71             return (RelationManager)next();
72         }
73         public RelationManager previousRelationManager() {
74             return (RelationManager)previous();
75         }
76     }
77
78 }
79
Popular Tags