KickJava   Java API By Example, From Geeks To Geeks.

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


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 ExceptionDecl. */
30 import org.objectweb.openccm.ast.api.ExceptionDecl;
31
32 /** To use CORBA::ExceptionDef */
33 import org.omg.CORBA.ExceptionDef JavaDoc;
34
35 /** To use CORBA::ExceptionDescription */
36 import org.omg.CORBA.ExceptionDescription JavaDoc;
37
38 /**
39  * ExceptionListImpl is a wrapper class for IDL exception lists.
40  *
41  *
42  * Inherits from:
43  *
44  * - ListBaseImpl: The base class for all lists.
45  *
46  * - ExceptionList: OMG IDL for exception lists.
47  *
48  *
49  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
50  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
51  *
52  * @version 0.3
53  */

54
55 public class ExceptionListImpl
56        extends ListBaseImpl
57        implements org.objectweb.openccm.ast.api.ExceptionList
58 {
59     // ==================================================================
60
//
61
// Internal state.
62
//
63
// ==================================================================
64

65     // ==================================================================
66
//
67
// Constructor.
68
//
69
// ==================================================================
70

71     /**
72      * The default constructor.
73      */

74     public ExceptionListImpl()
75     {
76         // Call the ListBaseImpl constructor.
77
super();
78     }
79
80     // ==================================================================
81
//
82
// Internal methods.
83
//
84
// ==================================================================
85

86     // ==================================================================
87
//
88
// Public methods.
89
//
90
// ==================================================================
91

92     /**
93      * Obtain its associated CORBA::ExceptionDefSeq.
94      *
95      * @return Its associated CORBA::ExceptionDefSeq.
96      */

97     public ExceptionDef JavaDoc[]
98     getExceptionDefSeq()
99     {
100         // Create an array with the same length as the list.
101
ExceptionDef JavaDoc[] result = new ExceptionDef JavaDoc[getSize()];
102
103         // Iterate on all elements of the list.
104
java.util.Iterator JavaDoc it = iterator();
105         for(int i=0; it.hasNext(); i++)
106         {
107             // Obtain the current element.
108
ExceptionDeclImpl exc = (ExceptionDeclImpl)it.next();
109
110             // Obtain its associated CORBA::ExceptionDef.
111
result[i] = exc.getExceptionDef();
112         }
113
114         // Return the array.
115
return result;
116     }
117
118     /**
119      * Obtain its associated CORBA::ExceptionDescriptionSeq.
120      *
121      * @return Its associated CORBA::ExceptionDescriptionSeq.
122      */

123     public ExceptionDescription JavaDoc[]
124     getExceptionDescriptionSeq()
125     {
126         // Create an array with the same length as the list.
127
ExceptionDescription JavaDoc[] result = new ExceptionDescription JavaDoc[getSize()];
128
129         // Iterate on all elements of the list.
130
java.util.Iterator JavaDoc it = iterator();
131         for(int i=0; it.hasNext(); i++)
132         {
133             // Obtain the current element.
134
ExceptionDeclImpl exc = (ExceptionDeclImpl)it.next();
135
136             // Obtain its associated CORBA::ExceptionDescription.
137
result[i] = exc.getExceptionDescription();
138         }
139
140         // Return the array.
141
return result;
142     }
143
144     // ==================================================================
145
//
146
// Methods for OMG IDL org.objectweb.openccm.ast.api.ExceptionList
147
//
148
// ==================================================================
149

150     /**
151      * Add an ExceptionDecl to the list.
152      *
153      * @param exc The ExceptionDecl to add to the list.
154      */

155     public void
156     add(ExceptionDecl exception)
157     {
158         super.addObject(exception);
159     }
160
161     /**
162      * Obtain all the ExceptionDecl declarations added to this list.
163      *
164      * @return All the ExceptionDecl declarations added to this list.
165      */

166     public ExceptionDecl[]
167     getExceptions()
168     {
169        return (ExceptionDecl[])super.toArray(new ExceptionDecl[0]);
170     }
171 }
172
Popular Tags