KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_q816Components > ContainmentServiceProviderComposition > querySegImpl


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

28
29 package ist.coach.itut_q816Components.ContainmentServiceProviderComposition;
30
31 import ist.coach.coachEmfCommon.Utils;
32 import ist.coach.coachEmfCommon.ExceptionMessages;
33
34 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
35
36 import intt.itu.itut_x780.UIDType;
37 import intt.itu.itut_x780.ApplicationError;
38 /**
39  * This is the CIDL-based implementation of the
40  * OMG IDL3 CIDL:coach.ist/itut_q816Components/ContainmentServiceProviderComposition/ContainmentServiceProviderHome_impl/ContainmentServiceProvider_impl/querySeg:1.0 segment type.
41  *
42  * @author OpenCCM CIF_Jimpl Compiler.
43  */

44 public class querySegImpl
45      extends ist.coach.itut_q816Components.ContainmentServiceProviderComposition.querySeg
46 {
47     // ==================================================================
48
//
49
// Internal states.
50
//
51
// ==================================================================
52

53     // ==================================================================
54
//
55
// Constructors.
56
//
57
// ==================================================================
58

59     public querySegImpl()
60     {
61     }
62
63     // ==================================================================
64
//
65
// Methods.
66
//
67
// ==================================================================
68

69     /**
70      * Implementation of the ::itut_q816::Containment::exists operation.
71      */

72     public boolean
73     exists(org.omg.CosNaming.NameComponent JavaDoc[] name)
74     throws intt.itu.itut_x780.ApplicationError
75     {
76         //
77
// DONE : implement
78
//
79

80         if (ContainmentServiceProviderImpl.tree.containsKey(Utils.name2string(name)))
81             return true;
82         else
83             return false;
84
85     }
86
87     /**
88      * Implementation of the ::itut_q816::Containment::getContained operation.
89      */

90     public org.omg.CosNaming.NameComponent JavaDoc[][]
91     getContained(org.omg.CosNaming.NameComponent JavaDoc[] name)
92     throws intt.itu.itut_x780.ApplicationError
93     {
94         //
95
// DONE : Implement
96
//
97
org.omg.CosNaming.NameComponent JavaDoc[][] contained_objects =
98         new org.omg.CosNaming.NameComponent JavaDoc[0][0];
99
100         String JavaDoc name_str = Utils.name2string(name);
101
102         if (ContainmentServiceProviderImpl.tree.containsKey(name_str)) {
103             java.util.Vector JavaDoc contained_vector =
104                 (java.util.Vector JavaDoc) ContainmentServiceProviderImpl.tree.get(name_str);
105
106             contained_objects =
107                 new org.omg.CosNaming.NameComponent JavaDoc[contained_vector.size()][0];
108
109             for(int i = 0; i < contained_vector.size(); i++) {
110
111                 String JavaDoc child_name = (String JavaDoc) contained_vector.elementAt(i);
112
113                 if (child_name == null || child_name.length() == 0)
114                      System.err.println("Note that a NULL child found!");
115                 else {
116                     contained_objects[i] = Utils.string2name(child_name);
117                 }
118             }
119         }
120         //System.err.println("getContained returns " +
121
// contained_objects.length + " children");
122
return contained_objects;
123     }
124
125     /**
126      * Implementation of the ::itut_q816::Containment::getContainedByKind operation.
127      */

128     public org.omg.CosNaming.NameComponent JavaDoc[][]
129     getContainedByKind(org.omg.CosNaming.NameComponent JavaDoc[] name, String JavaDoc kind)
130     throws intt.itu.itut_x780.ApplicationError
131     {
132         //
133
// DONE : Implement
134
//
135
org.omg.CosNaming.NameComponent JavaDoc[][] contained_objects =
136                 new org.omg.CosNaming.NameComponent JavaDoc[0][0];
137         String JavaDoc name_str = Utils.name2string(name);
138
139         if (! ContainmentServiceProviderImpl.tree.containsKey(name_str)) {
140             ApplicationErrorInfoTypeImpl error_code =
141                     new ApplicationErrorInfoTypeImpl();
142             error_code.error = new UIDType(
143                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
144                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
145             error_code.details = ExceptionMessages.root_delete_error;
146
147             throw new ApplicationError(error_code);
148         }
149         java.util.Vector JavaDoc contained_vector =
150           (java.util.Vector JavaDoc) ContainmentServiceProviderImpl.tree.get(name_str);
151
152         java.util.Vector JavaDoc contained_by_kind_vector = new java.util.Vector JavaDoc();
153         String JavaDoc child_str;
154         for (int i = 0; i < contained_vector.size(); i++) {
155             child_str = (String JavaDoc) contained_vector.elementAt(i);
156
157             if (kind.equals(Utils.name2kind(child_str))) {
158                 contained_by_kind_vector.add(child_str);
159             }
160
161         }
162         contained_objects = new org.omg.CosNaming.NameComponent JavaDoc[
163                     contained_by_kind_vector.size()][0];
164
165         for(int j = 0; j < contained_by_kind_vector.size(); j++) {
166
167             child_str = (String JavaDoc) contained_by_kind_vector.elementAt(j);
168
169             if (child_str == null || child_str.length() == 0)
170                 System.err.println("NULL child found!");
171             else
172                 contained_objects[j] = Utils.string2name(child_str);
173         }
174
175         return contained_objects;
176
177     }
178
179 }
180
Popular Tags