1 4 13 package org.jacorb.trading.client.dynprop; 14 15 import java.util.*; 16 import org.omg.CORBA.*; 17 import org.omg.CosTrading.*; 18 import org.omg.CosTradingDynamic.*; 19 20 24 25 public class DynamicPropEvalImpl 26 extends DynamicPropEvalPOA 27 { 28 private Random m_rand = new Random(); 29 30 36 public String _object_name() 37 { 38 return "DynPropDemo"; 39 } 40 41 42 47 public Any evalDP(String name, TypeCode returned_type, Any extra_info) 48 throws DPEvalFailure 49 { 50 Any result = ORB.init().create_any(); 51 52 System.out.println("evalDP(" + name + ")"); 53 54 TCKind kind = returned_type.kind(); 55 switch (kind.value()) { 56 case TCKind._tk_short: 57 result.insert_short((short)m_rand.nextInt()); 58 break; 59 case TCKind._tk_ushort: 60 result.insert_ushort((short)m_rand.nextInt()); 61 break; 62 case TCKind._tk_long: 63 result.insert_long(m_rand.nextInt()); 64 break; 65 case TCKind._tk_ulong: 66 result.insert_ulong(m_rand.nextInt()); 67 break; 68 case TCKind._tk_double: 69 result.insert_double(m_rand.nextDouble()); 70 break; 71 case TCKind._tk_float: 72 result.insert_float(m_rand.nextFloat()); 73 break; 74 case TCKind._tk_boolean: 75 result.insert_boolean((m_rand.nextInt() % 2 == 0)); 76 break; 77 case TCKind._tk_string: 78 result.insert_string("Next int = " + m_rand.nextInt()); 79 break; 80 default: 81 throw new DPEvalFailure(name, returned_type, extra_info); 82 } 83 84 return result; 85 } 86 } 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | Popular Tags |