1 21 package org.jacorb.collection; 22 23 24 25 import org.omg.CosCollection.*; 26 27 import org.omg.CORBA.*; 28 29 30 31 public class NVPairManager { 32 33 private NVPair param[]; 34 35 public NVPairManager( NVPair[] parameters ){ 36 37 param = new NVPair[ parameters.length ]; 38 39 for( int i=0; i<parameters.length; i++ ) { 40 41 param[i] = parameters[i]; 42 43 } 44 45 }; 46 47 public int find_param_idx( String key ){ 48 49 for( int i = 0; i<param.length; i++ ){ 50 51 if ( key.equals(param[i].name) ) { 52 53 return i; 54 55 } 56 57 }; 58 59 return -1; 60 61 }; 62 63 public String find_string_param( String key ) throws ParameterInvalid { 64 65 int i = find_param_idx( key ); 66 67 if ( i == -1 ) { 68 69 return null; 70 71 } 72 73 if( param[i].value.type().kind().value() != TCKind._tk_string ){ 74 75 throw new ParameterInvalid( i, "Invalid parameter type" ); 76 77 } 78 79 return param[i].value.extract_string(); 80 81 }; 82 83 public Integer find_ulong_param( String key ) throws ParameterInvalid { 84 85 int i = find_param_idx( key ); 86 87 if ( i == -1 ) { 88 89 return null; 90 91 } 92 93 if( param[i].value.type().kind().value() != TCKind._tk_ulong ){ 94 95 throw new ParameterInvalid( i, "Invalid parameter type" ); 96 97 } 98 99 return new Integer (param[i].value.extract_ulong()); 100 101 }; 102 103 public Operations find_operations_param( String key ) throws ParameterInvalid { 104 105 int i = find_param_idx( key ); 106 107 if ( i == -1 ) { 108 109 return null; 110 111 } 112 113 122 123 org.omg.CORBA.Object obj = param[i].value.extract_Object(); 124 125 return OperationsHelper.narrow( obj ); 126 127 129 }; 130 131 }; 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | Popular Tags |