KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.CoreField;
16
17 /**
18  * A list of fields
19  *
20  * @author Pierre van Rooden
21  * @version $Id: BasicFieldList.java,v 1.18 2006/07/11 09:30:26 michiel Exp $
22  */

23 public class BasicFieldList extends BasicList implements FieldList {
24
25     NodeManager nodemanager=null;
26
27     BasicFieldList() {
28         super();
29     }
30
31     public BasicFieldList(Collection JavaDoc c, NodeManager nodemanager) {
32         super(c);
33         this.nodemanager = nodemanager;
34     }
35
36     public Object JavaDoc convert(Object JavaDoc o, int index) {
37         if (o instanceof BasicField) {
38             return o;
39         } else if (o instanceof Field) {
40             // core-field does not have a node-manager, fix that.
41
Field f = new BasicField((Field)o, nodemanager);
42             set(index, f);
43             return f;
44         } else { // give it up
45
// perhaps we could anticipated DataType, String those kind of things too.
46
// but this is not used at the moment anyway.
47
return o;
48         }
49     }
50
51     protected Object JavaDoc validate(Object JavaDoc o) throws ClassCastException JavaDoc {
52         if (o instanceof CoreField) {
53             return o;
54         } else {
55             return (Field)o;
56         }
57     }
58
59     public Field getField(int index) {
60         return (Field)get(index);
61     }
62
63     public FieldIterator fieldIterator() {
64         return new BasicFieldIterator();
65     }
66
67     protected class BasicFieldIterator extends BasicIterator implements FieldIterator {
68
69         public Field nextField() {
70             return (Field) next();
71         }
72
73         public Field previousField() {
74             return (Field) previous();
75         }
76
77     }
78 }
79
Popular Tags