KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > decl > ChildrenType


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.tax.decl;
20
21 import java.util.*;
22
23 import org.netbeans.tax.*;
24
25 public abstract class ChildrenType extends TreeElementDecl.ContentType implements TypeCollection {
26
27     /** */
28     protected List context; // children collection
29

30
31     //
32
// init
33
//
34

35     public ChildrenType (Collection col) {
36         super ();
37
38         context = new LinkedList ();
39         context.addAll (col);
40     }
41
42     public ChildrenType () {
43         this (new ArrayList ());
44     }
45
46     public ChildrenType (ChildrenType childrenType) {
47         super (childrenType);
48         
49         context = new LinkedList ();
50         Iterator it = childrenType.context.iterator ();
51         while ( it.hasNext () ) {
52             context.add (((TreeElementDecl.ContentType)it.next ()).clone ());
53         }
54     }
55     
56     
57     //
58
// from TreeElementDecl.ContentType
59
//
60

61     /**
62      */

63     protected void setNodeDecl (TreeNodeDecl nodeDecl) {
64         super.setNodeDecl (nodeDecl);
65         
66         initNodeDecl ();
67     }
68     
69     protected final void initNodeDecl () {
70         // Iterator it = context.iterator();
71
// while ( it.hasNext() ) {
72
// TreeElementDecl.ContentType ct = (TreeElementDecl.ContentType)it.next();
73
// ct.setNodeDecl (getNodeDecl());
74
// }
75
}
76     
77     
78     //
79
// itself
80
//
81

82     /**
83      */

84     public void addTypes (Collection types) {
85         // remove null members
86
Iterator it = types.iterator ();
87         while (it.hasNext ()) {
88             if (it.next () == null) it.remove ();
89         }
90         context.addAll (types);
91         
92         initNodeDecl ();
93     }
94     
95     /** Add new type to collection. */
96     public void addType (TreeElementDecl.ContentType type) {
97         if (type == null)
98             return;
99         context.add (type);
100         
101         initNodeDecl ();
102     }
103     
104     /**
105      */

106     public Collection getTypes () {
107         return context;
108     }
109     
110     /**
111      */

112     public boolean allowElements () {
113         return true;
114     }
115     
116     /**
117      */

118     public boolean allowText () {
119         return false;
120     }
121     
122     /**
123      */

124     public boolean hasChildren () {
125         return context.size () > 0;
126     }
127     
128     /**
129      */

130     public abstract String JavaDoc getSeparator ();
131     
132 }
133
Popular Tags