KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > ScopeListImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** To use AST Declaration. */
30 import org.objectweb.openccm.ast.api.Declaration;
31
32 /** To use AST Scope. */
33 import org.objectweb.openccm.ast.api.Scope;
34
35 /**
36  * ScopeListImpl is a wrapper class for AST Scope lists.
37  *
38  *
39  * Inherits from:
40  *
41  * - ListBaseImpl: The base class for all lists.
42  *
43  *
44  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
45  *
46  * @version 0.1
47  */

48
49 public class ScopeListImpl
50        extends ListBaseImpl
51 {
52     // ==================================================================
53
//
54
// Internal state.
55
//
56
// ==================================================================
57

58     // ==================================================================
59
//
60
// Constructor.
61
//
62
// ==================================================================
63

64     /**
65      * The default constructor.
66      */

67     public
68     ScopeListImpl()
69     {
70         // Call the ListBaseImpl constructor.
71
super();
72     }
73
74     // ==================================================================
75
//
76
// Internal methods.
77
//
78
// ==================================================================
79

80     // ==================================================================
81
//
82
// Public methods.
83
//
84
// ==================================================================
85

86     /**
87      * Find a declaration into the list.
88      *
89      * @param name The name of the searched declaration.
90      * @return The declaration that was searched
91      * or null if it does not exist.
92      */

93     public Declaration
94     find(String JavaDoc name)
95     {
96         // Iterate on all elements of the list.
97
for(java.util.Iterator JavaDoc it = iterator(); it.hasNext(); )
98         {
99             // Obtain the current element.
100
Scope scope = (Scope)it.next();
101
102             // Find the named declaration.
103
Declaration decl = scope.find(name);
104
105             // If found then returns it.
106
if (decl != null) return decl;
107         }
108
109         // Else not found.
110
return null;
111     }
112
113     /**
114      * Add a Scope to this list.
115      *
116      * @param scope The Scope to add to the list.
117      */

118     public void
119     addScope(Scope scope)
120     {
121         super.addObject(scope);
122     }
123
124     /**
125      * Obtain all the AST scopes added to this list.
126      *
127      * @return All the AST scopes added to this list.
128      */

129     public Scope[]
130     getScopes()
131     {
132        return (Scope[])super.toArray(new Scope[0]);
133     }
134 }
135
Popular Tags