1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class UnionMembersImpl 39 implements UnionMembers 40 { 41 47 50 private org.objectweb.ccm.util.Vector member_names_; 51 52 55 private org.objectweb.ccm.util.Vector member_types_; 56 57 60 private org.objectweb.ccm.util.Vector member_values_; 61 62 65 private TypeRef discriminator_; 66 67 73 76 public 77 UnionMembersImpl() 78 { 79 member_names_ = new org.objectweb.ccm.util.Vector(); 81 member_types_ = new org.objectweb.ccm.util.Vector(); 82 member_values_ = new org.objectweb.ccm.util.Vector(); 83 discriminator_ = null; 84 } 85 86 92 97 protected org.omg.CORBA.UnionMember [] 98 getMemberDefs() 99 { 100 org.omg.CORBA.UnionMember [] result = 101 new org.omg.CORBA.UnionMember [member_names_.size()]; 102 103 for(int i=0; i<result.length; i++) 104 { 105 result[i] = new org.omg.CORBA.UnionMember ( 106 (String )member_names_.get(i), 107 ((AnyValue)member_values_.get(i)).computeAny(discriminator_.getIDLType().type()), 108 org.objectweb.openccm.corba.TypeCodeUtils.getTC_void(), 109 ((TypeRef)member_types_.get(i)).getIDLType()); 110 } 111 112 return result; 113 } 114 115 118 protected void 119 destroy() 120 { 121 if (discriminator_!=null) 122 discriminator_.removeRef(); 123 124 for (int i=0;i<member_types_.size();i++) 125 { 126 ((TypeRef)member_types_.get(i)).removeRef(); 127 } 128 } 129 130 136 142 public void 143 addMember(String name, 144 TypeRef type, 145 AnyValue value) 146 { 147 if ((type != null) && (name!=null) && (value!=null)) 148 { 149 member_names_.add(name); 150 type.addRef(); 151 member_types_.add(type); 152 member_values_.add(value); 153 } 154 } 155 156 159 public void 160 setDiscriminator(TypeRef type) 161 { 162 if (type!=null) 163 { 164 discriminator_ = type; 165 discriminator_.addRef(); 166 } 167 } 168 169 172 public TypeRef 173 getDiscriminator() 174 { 175 return discriminator_; 176 } 177 178 181 public String [] 182 getMemberNames() 183 { 184 String [] result = new String [member_names_.size()]; 185 for (int i=0;i<result.length;i++) 186 { 187 result[i] = (String )member_names_.get(i); 188 } 189 return result; 190 } 191 192 195 public TypeRef[] 196 getMemberTypes() 197 { 198 TypeRef[] result = new TypeRef[member_types_.size()]; 199 for (int i=0;i<result.length;i++) 200 { 201 result[i] = (TypeRef)member_types_.get(i); 202 } 203 return result; 204 } 205 206 209 public AnyValue[] 210 getMemberValues() 211 { 212 AnyValue[] result = new AnyValue[member_values_.size()]; 213 for (int i=0;i<result.length;i++) 214 { 215 result[i] = (AnyValue)member_values_.get(i); 216 } 217 return result; 218 } 219 } 220 | Popular Tags |