KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

51     public NodeManager getNodeManager(int index) {
52         return (NodeManager) get(index);
53     }
54
55     /**
56      *
57      */

58     public NodeManagerIterator nodeManagerIterator() {
59         return new BasicNodeManagerIterator();
60     };
61
62     /**
63      *
64      */

65     public NodeManagerList subNodeManagerList(int fromIndex, int toIndex) {
66         return new BasicNodeManagerList(subList(fromIndex, toIndex), cloud);
67     }
68
69     protected class BasicNodeManagerIterator extends BasicNodeIterator implements NodeManagerIterator {
70
71         public NodeManager nextNodeManager() {
72             return (NodeManager)next();
73         }
74
75         public NodeManager previousNodeManager() {
76             return (NodeManager)previous();
77         }
78     }
79
80 }
81
Popular Tags