KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > ExceptionListImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class manages exception lists.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class ExceptionListImpl
39        implements ExceptionList
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     /**
48      ** List of exceptions.
49      **/

50     protected org.objectweb.ccm.util.Vector list_;
51
52     // ==================================================================
53
//
54
// Constructor.
55
//
56
// ==================================================================
57

58     /**
59      ** The default constructor.
60      **/

61     public ExceptionListImpl()
62     {
63         // Init internal state.
64
list_ = new org.objectweb.ccm.util.Vector();
65     }
66
67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73     /**
74      **
75      **/

76     protected void
77     destroy()
78     {
79         for (int i=0;i<list_.size();i++)
80         {
81             ((ExceptionRef)list_.get(i)).removeRef();
82         }
83     }
84
85     // ==================================================================
86
//
87
// Methods for the ExceptionList interface.
88
//
89
// ==================================================================
90

91     /**
92      ** Add an exception.
93      **
94      ** @param exception The exception to add to the list.
95      **/

96     public void
97     add(ExceptionRef exception)
98     {
99         if (exception != null)
100         {
101             exception.addRef();
102             list_.add(exception);
103         }
104     }
105
106     /**
107      **
108      **/

109     public ExceptionDecl[]
110     getExceptions()
111     {
112         ExceptionDecl[] result = new ExceptionDecl[list_.size()];
113
114         for(int i=0; i<result.length; i++)
115             result[i] = (ExceptionDecl)(list_.get(i));
116
117         return result;
118     }
119
120     /**
121      **
122      **/

123     public org.omg.CORBA.ExceptionDef JavaDoc[]
124     getExceptionDefs()
125     {
126         org.omg.CORBA.ExceptionDef JavaDoc[] result = new org.omg.CORBA.ExceptionDef JavaDoc[list_.size()];
127
128         for(int i=0; i<result.length; i++)
129             result[i] = ((ExceptionRef)list_.get(i)).getExceptionDef();
130
131         return result;
132     }
133
134     /**
135      **
136      **/

137     public org.omg.CORBA.ExceptionDescription JavaDoc[]
138     getExceptionDescriptions()
139     {
140         org.omg.CORBA.ExceptionDescription JavaDoc[] result = new org.omg.CORBA.ExceptionDescription JavaDoc[list_.size()];
141
142         ExceptionDeclImpl exc = null;
143         for(int i=0; i<result.length; i++)
144         {
145             exc = (ExceptionDeclImpl)list_.get(i);
146             result[i] = new org.omg.CORBA.ExceptionDescription JavaDoc(exc.getName(),
147                                                                exc.getId(),
148                                                                exc.the_parent_.getId(),
149                                                                exc.getVersion(),
150                                                                exc.getExceptionDef().type());
151         }
152
153         return result;
154     }
155 }
156
Popular Tags