KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > corba > trader > TraderTypeCodeUtils


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.
23 Contributor(s): Sylvain Leblanc, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.corba.trader;
28
29 // Package dependencies
30
import org.omg.CORBA.TCKind JavaDoc;
31 import org.omg.DynamicAny.DynSequenceHelper JavaDoc;
32 import org.objectweb.openccm.corba.TypeCodeUtils;
33
34 /**
35  * This class provides trader specific CORBA::TypeCode util functions.
36  *
37  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
38  * @version 0.1
39  */

40 public abstract class TraderTypeCodeUtils {
41
42     private TraderTypeCodeUtils() {
43     }
44
45     /**
46      * Retrieve the TCKind object relative to a typeCodeId.
47      *
48      * @param typeCodeId The type code kind identifier as a string.
49      * This method provides all primitive type code from IDL keywords
50      * and also sequences of primitives type codes.
51      *
52      * @return The equivalent <code>org.omg.CORBA.TypeCode</code> or
53      * <code>null</code> if the <code>typeCodeId</code> doesn't exist.
54      */

55     public static org.omg.CORBA.TypeCode JavaDoc
56     getTypeCode(String JavaDoc typeCodeId) {
57         org.omg.CORBA.ORB JavaDoc orb = org.objectweb.openccm.corba.TheORB.getORB();
58         if (typeCodeId.equals("boolean"))
59             return orb.get_primitive_tc(TCKind.tk_boolean);
60         if (typeCodeId.equals("char"))
61             return orb.get_primitive_tc(TCKind.tk_char);
62         if (typeCodeId.equals("wchar"))
63             return orb.get_primitive_tc(TCKind.tk_wchar);
64         if (typeCodeId.equals("double"))
65             return orb.get_primitive_tc(TCKind.tk_double);
66         if (typeCodeId.equals("float"))
67             return orb.get_primitive_tc(TCKind.tk_float);
68         if (typeCodeId.equals("short"))
69             return orb.get_primitive_tc(TCKind.tk_short);
70         if (typeCodeId.equals("unsigned short"))
71             return orb.get_primitive_tc(TCKind.tk_ushort);
72         if (typeCodeId.equals("long"))
73             return orb.get_primitive_tc(TCKind.tk_long);
74         if (typeCodeId.equals("unsigned long"))
75             return orb.get_primitive_tc(TCKind.tk_ulong);
76         if (typeCodeId.equals("longlong"))
77             return orb.get_primitive_tc(TCKind.tk_longlong);
78         if (typeCodeId.equals("unsigned longlong"))
79             return orb.get_primitive_tc(TCKind.tk_ulonglong);
80         if (typeCodeId.equals("longdouble"))
81             return orb.get_primitive_tc(TCKind.tk_longdouble);
82         if (typeCodeId.equals("octet"))
83             return orb.get_primitive_tc(TCKind.tk_octet);
84         if (typeCodeId.equals("string"))
85             return orb.get_primitive_tc(TCKind.tk_string);
86         if (typeCodeId.equals("wstring"))
87             return orb.get_primitive_tc(TCKind.tk_wstring);
88         if (typeCodeId.startsWith("sequence")) {
89             int idx = typeCodeId.indexOf("<");
90             String JavaDoc content_type = typeCodeId.substring(idx+1, typeCodeId.length()-1);
91             org.omg.CORBA.TypeCode JavaDoc content_tc = getTypeCode(content_type);
92             switch (content_tc.kind().value()) {
93 // case org.omg.CORBA.TCKind._tk_boolean : { return org.omg.CORBA.BooleanSeqHelper.type(); }
94
// case org.omg.CORBA.TCKind._tk_char : { return org.omg.CORBA.CharSeqHelper.type(); }
95
// case org.omg.CORBA.TCKind._tk_wchar : { return org.omg.CORBA.WCharSeqHelper.type(); }
96
// case org.omg.CORBA.TCKind._tk_double : { return org.omg.CORBA.DoubleSeqHelper.type(); }
97
// case org.omg.CORBA.TCKind._tk_float : { return org.omg.CORBA.FloatSeqHelper.type(); }
98
// case org.omg.CORBA.TCKind._tk_short : { return org.omg.CORBA.ShortSeqHelper.type(); }
99
// case org.omg.CORBA.TCKind._tk_ushort : { return org.omg.CORBA.UShortSeqHelper.type(); }
100
// case org.omg.CORBA.TCKind._tk_long : { return org.omg.CORBA.LongSeqHelper.type(); }
101
// case org.omg.CORBA.TCKind._tk_ulong : { return org.omg.CORBA.ULongSeqHelper.type(); }
102
// case org.omg.CORBA.TCKind._tk_longlong : { return org.omg.CORBA.LongLongSeqHelper.type(); }
103
// case org.omg.CORBA.TCKind._tk_ulonglong : { return org.omg.CORBA.ULongLongSeqHelper.type(); }
104
// // case org.omg.CORBA.TCKind._tk_longdouble : { return org.omg.CORBA.LongDoubleSeqHelper.type(); }
105
// case org.omg.CORBA.TCKind._tk_octet : { return org.omg.CORBA.OctetSeqHelper.type(); }
106
// case org.omg.CORBA.TCKind._tk_string : { return org.omg.CORBA.StringSeqHelper.type(); }
107
// case org.omg.CORBA.TCKind._tk_wstring : { return org.omg.CORBA.WStringSeqHelper.type(); }
108
default : return orb.create_sequence_tc(0, content_tc);
109             }
110         }
111         
112         return null ; // unmanaged type code identifier
113
}
114
115     /**
116      * Insert a value in an <code>org.omg.CORBA.Any</code>.</br>
117      *
118      * Issue: How an array of values can be represented ??
119      * Are values separated by "," ???</br>
120      *
121      * Here we make the assumption of values inserted
122      * in "()" and separeted by "," e.g. (10, 5, 54,
123      * 67) is a sequence of long, ("test", "string") a
124      * sequence of strings and ('a', 'b', 'c') a
125      * sequence of characters.</br>
126      *
127      * @param tc The type code of the value.
128      * @param value The value image as a string.
129      *
130      * @return The filled CORBA::Any or <code>null</code> if
131      * a the TypeCode is not managed or if the value has an
132      * incorrect format.
133      */

134     public static org.omg.CORBA.Any JavaDoc
135     insertInAny(org.omg.CORBA.TypeCode JavaDoc orig_tc, String JavaDoc value)
136     {
137         org.omg.CORBA.Any JavaDoc the_any = org.objectweb.openccm.corba.TheORB.getORB().create_any();
138         org.omg.CORBA.TypeCode JavaDoc tc = orig_tc;
139         while (tc.kind() == TCKind.tk_alias) {
140             try {
141                 tc = tc.content_type();
142             } catch (org.omg.CORBA.TypeCodePackage.BadKind JavaDoc ex) {}
143         }
144         int kind = tc.kind().value();
145         try {
146             switch (kind) {
147                 case TCKind._tk_short : {
148                     short v = Short.parseShort(value);
149                     the_any.insert_short(v);
150                     break;
151                 }
152                 case TCKind._tk_ushort : {
153                     short v = Short.parseShort(value);
154                     the_any.insert_ushort(v);
155                     break;
156                 }
157                 case TCKind._tk_long : {
158                     int v = Integer.parseInt(value);
159                     the_any.insert_long(v);
160                     break;
161                 }
162                 case TCKind._tk_ulong : {
163                     int v = Integer.parseInt(value);
164                     the_any.insert_ulong(v);
165                     break;
166                 }
167                 case TCKind._tk_longlong : {
168                     long v = Long.parseLong(value);
169                     the_any.insert_longlong(v);
170                     break;
171                 }
172                 case TCKind._tk_ulonglong : {
173                     long v = Long.parseLong(value);
174                     the_any.insert_ulonglong(v);
175                     break;
176                 }
177                 case TCKind._tk_float : {
178                     float v = Float.parseFloat(value);
179                     the_any.insert_float(v);
180                     break;
181                 }
182                 case TCKind._tk_double : {
183                     double v = Double.parseDouble(value);
184                     the_any.insert_double(v);
185                     break;
186                 }
187                 case TCKind._tk_wchar : {
188                     char v = value.charAt(0);
189                     the_any.insert_wchar(v);
190                     break;
191                 }
192                 case TCKind._tk_char : {
193                     char v = value.charAt(0);
194                     the_any.insert_char(v);
195                     break;
196                 }
197                 case TCKind._tk_wstring : {
198                     the_any.insert_wstring(value);
199                     break;
200                 }
201                 case TCKind._tk_string : {
202                     the_any.insert_string(value);
203                     break;
204                 }
205                 case TCKind._tk_octet : {
206                     byte v = Byte.parseByte(value);
207                     the_any.insert_octet(v);
208                     break;
209                 }
210                 case TCKind._tk_boolean : {
211                     boolean v = new Boolean JavaDoc(value).booleanValue();
212                     the_any.insert_boolean(v);
213                     break;
214                 }
215                 case TCKind._tk_alias : {
216                     return insertInAny(TypeCodeUtils.getOrigType(tc), value);
217                 }
218                 case TCKind._tk_sequence : {
219                     // How an array of values can be represented ??
220
// Are values separated by "," ???
221

222                     // Here we make the assumption of values inserted
223
// in "()" and separeted by "," e.g. (10, 5, 54,
224
// 67) is a sequence of long, ("test", "string") a
225
// sequence of strings and ('a', 'b', 'c') a
226
// sequence of characters..
227

228                     // creates a tokenizer on the seq values
229
String JavaDoc content = value.substring(value.indexOf('(')+1, value.indexOf(')'));
230                     java.util.StringTokenizer JavaDoc st = new java.util.StringTokenizer JavaDoc(content, ",");
231                     
232                     try {
233                         
234                         // Creates a new dyn sequence
235
org.omg.DynamicAny.DynAny JavaDoc dyn_any = org.objectweb.openccm.corba.TheDynamicAnyFactory.getFactory().create_dyn_any_from_type_code(tc);
236                         org.omg.DynamicAny.DynSequence JavaDoc dyn_seq = DynSequenceHelper.narrow(dyn_any);
237
238                         // constructing the contained values sequence and
239
// init the dyn sequence size
240
org.omg.CORBA.Any JavaDoc[] values = new org.omg.CORBA.Any JavaDoc[st.countTokens()];
241                         dyn_seq.set_length(st.countTokens());
242
243                         // resolving the contained type
244
org.omg.CORBA.TypeCode JavaDoc content_tc = null;
245                         try {
246                             content_tc = tc.content_type();
247                         } catch (org.omg.CORBA.TypeCodePackage.BadKind JavaDoc ex) {
248                             System.err.println("in a content catch");
249                             // cannot happened here
250
}
251
252                         // feeding the contained values sequence
253
switch (content_tc.kind().value()) {
254                             case TCKind._tk_short : {
255                                 int i=0;
256                                 while (st.hasMoreTokens()) {
257                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
258                                     values[i].insert_short(Short.parseShort(st.nextToken().trim()));
259                                     i++;
260                                 }
261                                 break;
262                             }
263                             case TCKind._tk_ushort : {
264                                 int i=0;
265                                 while (st.hasMoreTokens()) {
266                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
267                                     values[i].insert_ushort(Short.parseShort(st.nextToken().trim()));
268                                     i++;
269                                 }
270                                 break;
271                             }
272                             case TCKind._tk_long : {
273                                 int i=0;
274                                 while (st.hasMoreTokens()) {
275                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
276                                     values[i].insert_long(Integer.parseInt(st.nextToken().trim()));
277                                     i++;
278                                 }
279                                 break;
280                             }
281                             case TCKind._tk_ulong : {
282                                 int i=0;
283                                 while (st.hasMoreTokens()) {
284                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
285                                     values[i].insert_ulong(Integer.parseInt(st.nextToken().trim()));
286                                     i++;
287                                 }
288                                 break;
289                             }
290                             case TCKind._tk_longlong : {
291                                 int i=0;
292                                 while (st.hasMoreTokens()) {
293                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
294                                     values[i].insert_longlong(Long.parseLong(st.nextToken().trim()));
295                                     i++;
296                                 }
297                                 break;
298                             }
299                             case TCKind._tk_ulonglong : {
300                                 int i=0;
301                                 while (st.hasMoreTokens()) {
302                                    values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
303                                     values[i].insert_ulonglong(Long.parseLong(st.nextToken().trim()));
304                                     i++;
305                                 }
306                                 break;
307                             }
308                             case TCKind._tk_float : {
309                                 int i=0;
310                                 while (st.hasMoreTokens()) {
311                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
312                                     values[i].insert_float(Float.parseFloat(st.nextToken().trim()));
313                                     i++;
314                                 }
315                                 break;
316                             }
317                             case TCKind._tk_double : {
318                                 int i=0;
319                                 while (st.hasMoreTokens()) {
320                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
321                                     values[i].insert_double(Double.parseDouble(st.nextToken().trim()));
322                                     i++;
323                                 }
324                                 break;
325                             }
326                             case TCKind._tk_wchar : {
327                                 int i=0;
328                                 while (st.hasMoreTokens()) {
329                                     String JavaDoc val = st.nextToken().trim();
330                                     // tests if packed as a char
331
if ( ! val.startsWith("'") ||
332                                          ! val.endsWith("'") ||
333                                          val.length() != 3 )
334                                         return null;
335                                     // gets the middle char
336
values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
337                                     values[i].insert_wchar(val.charAt(1));
338                                     i++;
339                                 }
340                                 break;
341                             }
342                             case TCKind._tk_char : {
343                                 int i=0;
344                                 while (st.hasMoreTokens()) {
345                                     String JavaDoc val = st.nextToken().trim();
346                                     // tests if packed as a char
347
if ( ! val.startsWith("'") ||
348                                          ! val.endsWith("'") ||
349                                          val.length() != 3 )
350                                         return null;
351                                     // gets the middle char
352
values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
353                                     values[i].insert_char(val.charAt(1));
354                                     i++;
355                                 }
356                                 break;
357                             }
358                             case TCKind._tk_wstring : {
359                                 int i=0;
360                                 while (st.hasMoreTokens()) {
361                                     String JavaDoc val = st.nextToken().trim();
362                                     // tests if packed as a string
363
if ( ! val.startsWith("\"") ||
364                                          ! val.endsWith("\"") )
365                                         return null;
366                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
367                                     values[i].insert_wstring(val.substring(1, val.length()-1));
368                                     i++;
369                                 }
370                                 break;
371                             }
372                             case TCKind._tk_string : {
373                                 int i=0;
374                                 while (st.hasMoreTokens()) {
375                                     String JavaDoc val = st.nextToken().trim();
376                                     // tests if packed as a string
377
if ( ! val.startsWith("\"") ||
378                                          ! val.endsWith("\"") )
379                                         return null;
380                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
381                                     values[i].insert_string(val.substring(1, val.length()-1));
382                                     i++;
383                                 }
384                                 break;
385                             }
386                             case TCKind._tk_octet : {
387                                 int i=0;
388                                 while (st.hasMoreTokens()) {
389                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
390                                     values[i].insert_octet(Byte.parseByte(st.nextToken().trim()));
391                                     i++;
392                                 }
393                                 break;
394                             }
395                             case TCKind._tk_boolean : {
396                                 int i=0;
397                                 while (st.hasMoreTokens()) {
398                                     values[i] = org.objectweb.openccm.corba.TheORB.getORB().create_any();
399                                     values[i].insert_boolean(Boolean.valueOf(st.nextToken().trim()).booleanValue());
400                                     i++;
401                                 }
402                                 break;
403                             }
404                         }
405                         dyn_seq.set_elements(values);
406                         return dyn_seq.to_any();
407                     } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode JavaDoc ex) {
408                     } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue JavaDoc ex) {
409                     } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch JavaDoc ex) {
410                     }
411                     return null;
412                 }
413                 default : return null;
414             }
415             return the_any;
416         } catch (NumberFormatException JavaDoc ex) {
417             throw new org.objectweb.util.misc.api.ExceptionWrapper(ex, "cannot insert in any");
418         }
419     }
420 // /**
421
// * Insert a value in an <code>org.omg.CORBA.Any</code>.</br>
422
// *
423
// * Issue: How an array of values can be represented ??
424
// * Are values separated by "," ???</br>
425
// *
426
// * Here we make the assumption of values inserted
427
// * in "()" and separeted by "," e.g. (10, 5, 54,
428
// * 67) is a sequence of long, ("test", "string") a
429
// * sequence of strings and ('a', 'b', 'c') a
430
// * sequence of characters.</br>
431
// *
432
// * @param tc The type code of the value.
433
// * @param value The value image as a string.
434
// *
435
// * @return The filled CORBA::Any or <code>null</code> if
436
// * a the TypeCode is not managed or if the value has an
437
// * incorrect format.
438
// */
439
// public static org.omg.CORBA.Any
440
// insertInAny(org.omg.CORBA.TypeCode tc, String value)
441
// {
442
// org.omg.CORBA.Any the_any = org.objectweb.openccm.corba.TheORB.getORB().create_any();
443
// int kind = tc.kind().value();
444
// try {
445
// switch (kind) {
446
// case TCKind._tk_short : {
447
// short v = Short.parseShort(value);
448
// the_any.insert_short(v);
449
// break;
450
// }
451
// case TCKind._tk_ushort : {
452
// short v = Short.parseShort(value);
453
// the_any.insert_ushort(v);
454
// break;
455
// }
456
// case TCKind._tk_long : {
457
// int v = Integer.parseInt(value);
458
// the_any.insert_long(v);
459
// break;
460
// }
461
// case TCKind._tk_ulong : {
462
// int v = Integer.parseInt(value);
463
// the_any.insert_ulong(v);
464
// break;
465
// }
466
// case TCKind._tk_longlong : {
467
// long v = Long.parseLong(value);
468
// the_any.insert_longlong(v);
469
// break;
470
// }
471
// case TCKind._tk_ulonglong : {
472
// long v = Long.parseLong(value);
473
// the_any.insert_ulonglong(v);
474
// break;
475
// }
476
// case TCKind._tk_float : {
477
// float v = Float.parseFloat(value);
478
// the_any.insert_float(v);
479
// break;
480
// }
481
// case TCKind._tk_double : {
482
// double v = Double.parseDouble(value);
483
// the_any.insert_double(v);
484
// break;
485
// }
486
// case TCKind._tk_wchar : {
487
// char v = value.charAt(0);
488
// the_any.insert_wchar(v);
489
// break;
490
// }
491
// case TCKind._tk_char : {
492
// char v = value.charAt(0);
493
// the_any.insert_char(v);
494
// break;
495
// }
496
// case TCKind._tk_wstring : {
497
// the_any.insert_wstring(value);
498
// break;
499
// }
500
// case TCKind._tk_string : {
501
// the_any.insert_string(value);
502
// break;
503
// }
504
// case TCKind._tk_octet : {
505
// byte v = Byte.parseByte(value);
506
// the_any.insert_octet(v);
507
// break;
508
// }
509
// case TCKind._tk_boolean : {
510
// boolean v = new Boolean(value).booleanValue();
511
// the_any.insert_boolean(v);
512
// break;
513
// }
514
// case TCKind._tk_alias : {
515
// return insertInAny(TypeCodeUtils.getOrigType(tc), value);
516
// }
517
// case TCKind._tk_sequence : {
518
// // How an array of values can be represented ??
519
// // Are values separated by "," ???
520

521 // // Here we make the assumption of values inserted
522
// // in "()" and separeted by "," e.g. (10, 5, 54,
523
// // 67) is a sequence of long, ("test", "string") a
524
// // sequence of strings and ('a', 'b', 'c') a
525
// // sequence of characters..
526
// String content = value.substring(value.indexOf('(')+1, value.indexOf(')'));
527
// java.util.StringTokenizer st = new java.util.StringTokenizer(content, ",");
528

529 // org.omg.CORBA.TypeCode content_tc = null;
530
// try {
531
// content_tc = tc.content_type();
532
// } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
533
// // cannot happened here
534
// }
535

536 // switch (content_tc.kind().value()) {
537
// case TCKind._tk_short : {
538
// short[] arr = new short[st.countTokens()];
539
// int i=0;
540
// while (st.hasMoreTokens()) {
541
// arr[i]= Short.parseShort(st.nextToken().trim());
542
// i++;
543
// }
544
// org.omg.CORBA.ShortSeqHelper.insert(the_any, arr);
545
// break;
546
// }
547
// case TCKind._tk_ushort : {
548
// short[] arr = new short[st.countTokens()];
549
// int i=0;
550
// while (st.hasMoreTokens()) {
551
// arr[i]= Short.parseShort(st.nextToken().trim());
552
// i++;
553
// }
554
// org.omg.CORBA.UShortSeqHelper.insert(the_any, arr);
555
// break;
556
// }
557
// case TCKind._tk_long : {
558
// int[] arr = new int[st.countTokens()];
559
// int i=0;
560
// while (st.hasMoreTokens()) {
561
// arr[i]= Integer.parseInt(st.nextToken().trim());
562
// i++;
563
// }
564
// org.omg.CORBA.LongSeqHelper.insert(the_any, arr);
565
// break;
566
// }
567
// case TCKind._tk_ulong : {
568
// int[] arr = new int[st.countTokens()];
569
// int i=0;
570
// while (st.hasMoreTokens()) {
571
// arr[i]= Integer.parseInt(st.nextToken().trim());
572
// i++;
573
// }
574
// org.omg.CORBA.ULongSeqHelper.insert(the_any, arr);
575
// break;
576
// }
577
// case TCKind._tk_longlong : {
578
// long[] arr = new long[st.countTokens()];
579
// int i=0;
580
// while (st.hasMoreTokens()) {
581
// arr[i]= Long.parseLong(st.nextToken().trim());
582
// i++;
583
// }
584
// org.omg.CORBA.LongLongSeqHelper.insert(the_any, arr);
585
// break;
586
// }
587
// case TCKind._tk_ulonglong : {
588
// long[] arr = new long[st.countTokens()];
589
// int i=0;
590
// while (st.hasMoreTokens()) {
591
// arr[i]= Long.parseLong(st.nextToken().trim());
592
// i++;
593
// }
594
// org.omg.CORBA.ULongLongSeqHelper.insert(the_any, arr);
595
// break;
596
// }
597
// case TCKind._tk_float : {
598
// float[] arr = new float[st.countTokens()];
599
// int i=0;
600
// while (st.hasMoreTokens()) {
601
// arr[i]= Float.parseFloat(st.nextToken().trim());
602
// i++;
603
// }
604
// org.omg.CORBA.FloatSeqHelper.insert(the_any, arr);
605
// break;
606
// }
607
// case TCKind._tk_double : {
608
// double[] arr = new double[st.countTokens()];
609
// int i=0;
610
// while (st.hasMoreTokens()) {
611
// arr[i]= Double.parseDouble(st.nextToken().trim());
612
// i++;
613
// }
614
// org.omg.CORBA.DoubleSeqHelper.insert(the_any, arr);
615
// break;
616
// }
617
// case TCKind._tk_wchar : {
618
// char[] arr = new char[st.countTokens()];
619
// int i=0;
620
// while (st.hasMoreTokens()) {
621
// String val = st.nextToken().trim();
622
// // tests if packed as a char
623
// if ( ! val.startsWith("'") ||
624
// ! val.endsWith("'") ||
625
// val.length() != 3 )
626
// return null;
627
// // gets the middle char
628
// arr[i]= val.charAt(1);
629
// i++;
630
// }
631
// org.omg.CORBA.WCharSeqHelper.insert(the_any, arr);
632
// break;
633
// }
634
// case TCKind._tk_char : {
635
// char[] arr = new char[st.countTokens()];
636
// int i=0;
637
// while (st.hasMoreTokens()) {
638
// String val = st.nextToken().trim();
639
// // tests if packed as a char
640
// if ( ! val.startsWith("'") ||
641
// ! val.endsWith("'") ||
642
// val.length() != 3 )
643
// return null;
644
// // gets the middle char
645
// arr[i]= val.charAt(1);
646
// i++;
647
// }
648
// org.omg.CORBA.CharSeqHelper.insert(the_any, arr);
649
// break;
650
// }
651
// case TCKind._tk_wstring : {
652
// String[] arr = new String[st.countTokens()];
653
// int i=0;
654
// while (st.hasMoreTokens()) {
655
// String val = st.nextToken().trim();
656
// // tests if packed as a string
657
// if ( ! val.startsWith("\"") ||
658
// ! val.endsWith("\"") )
659
// return null;
660
// arr[i]= val.substring(1, val.length()-1);
661
// i++;
662
// }
663
// org.omg.CORBA.WStringSeqHelper.insert(the_any, arr);
664
// break;
665
// }
666
// case TCKind._tk_string : {
667
// String[] arr = new String[st.countTokens()];
668
// int i=0;
669
// while (st.hasMoreTokens()) {
670
// String val = st.nextToken().trim();
671
// // tests if packed as a string
672
// if ( ! val.startsWith("\"") ||
673
// ! val.endsWith("\"") )
674
// return null;
675
// arr[i]= val.substring(1, val.length()-1);
676
// i++;
677
// }
678
// org.omg.CORBA.StringSeqHelper.insert(the_any, arr);
679
// break;
680
// }
681
// case TCKind._tk_octet : {
682
// byte[] arr = new byte[st.countTokens()];
683
// int i=0;
684
// while (st.hasMoreTokens()) {
685
// arr[i]= Byte.parseByte(st.nextToken().trim());
686
// i++;
687
// }
688
// org.omg.CORBA.OctetSeqHelper.insert(the_any, arr);
689
// break;
690
// }
691
// case TCKind._tk_boolean : {
692
// boolean[] arr = new boolean[st.countTokens()];
693
// int i=0;
694
// while (st.hasMoreTokens()) {
695
// arr[i]= Boolean.valueOf(st.nextToken().trim()).booleanValue();
696
// i++;
697
// }
698
// org.omg.CORBA.BooleanSeqHelper.insert(the_any, arr);
699
// break;
700
// }
701
// }
702
// return the_any;
703
// }
704
// default : return null;
705
// }
706
// return the_any;
707
// } catch (NumberFormatException ex) {
708
// throw new org.objectweb.util.api.ExceptionWrapper(ex, "cannot insert in any");
709
// }
710
// }
711
}
712
Popular Tags