1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class EnumDeclImpl 39 extends DeclarationImpl 40 implements TypeRef, EnumDecl 41 { 42 48 51 private org.omg.CORBA.EnumDef enum_def_; 52 53 56 private org.objectweb.ccm.util.Vector members_; 57 58 64 69 protected 70 EnumDeclImpl(Repository rep, ScopeImpl parent) 71 { 72 super(rep, parent); 74 75 enum_def_ = null; 77 members_ = new org.objectweb.ccm.util.Vector(); 78 the_declaration_kind_ = DeclarationKind._dk_enum; 79 } 80 81 87 92 protected void 93 load(org.omg.CORBA.Contained contained) 94 { 95 enum_def_ = org.omg.CORBA.EnumDefHelper.narrow(contained); 96 String [] members = enum_def_.members(); 97 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 98 for (int i=0;i<members.length;i++) 99 { 100 addMember(members[i]); 101 AnyValueDeclImpl decl = new AnyValueDeclImpl(getRepository(), the_parent_); 102 decl.setName(members[i]); 103 AnyValue av = new AnyValue(); 104 av.setAsEnum(enumTC, i, members[i]); 105 decl.setAnyValue(av); 106 decl.create(); 107 } 108 super.load(contained); 109 } 110 111 116 protected void 117 loadAsMapping(org.omg.CORBA.Contained contained) 118 { 119 enum_def_ = org.omg.CORBA.EnumDefHelper.narrow(contained); 120 String [] members = enum_def_.members(); 121 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 122 for (int i=0;i<members.length;i++) 123 { 124 addMember(members[i]); 125 AnyValueDeclImpl decl = new AnyValueDeclImpl(getRepository(), the_parent_); 126 decl.setName(members[i]); 127 AnyValue av = new AnyValue(); 128 av.setAsEnum(enumTC, i, members[i]); 129 decl.setAnyValue(av); 130 decl.create(); 131 } 132 133 super.loadAsMapping(contained); 134 } 135 136 142 145 public void 146 create() 147 { 148 String [] members = new String [members_.size()]; 149 for(int i=0; i<members.length; i++) 150 members[i] = (String )(members_.get(i)); 151 152 enum_def_ = the_parent_.getContainer().create_enum(getId(), getName(), 153 getVersion(), members); 154 155 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 156 for(int i=0; i<members_.size(); i++) 157 { 158 String name = (String )members_.get(i); 159 AnyValueDeclImpl decl = new AnyValueDeclImpl(getRepository(), the_parent_); 160 decl.setName(name); 161 AnyValue av = new AnyValue(); 162 av.setAsEnum(enumTC, i, name); 163 decl.setAnyValue(av); 164 decl.create(); 165 } 166 167 super.create(); 168 } 169 170 178 public String 179 declaratorAt(int index) 180 { 181 return (String )members_.get(index); 182 } 183 184 190 195 public org.omg.CORBA.IDLType 196 getIDLType() 197 { 198 return enum_def_; 199 } 200 201 204 public int 205 getTypeKind() 206 { 207 return TypeKind._tk_enum; 208 } 209 210 216 221 public void 222 addMember(String name) 223 { 224 members_.add(name); 225 } 226 227 230 public String [] 231 getMembers() 232 { 233 String [] result = new String [members_.size()]; 234 for (int i=0;i<result.length;i++) 235 { 236 result[i] = (String )members_.get(i); 237 } 238 return result; 239 } 240 241 247 252 protected org.omg.CORBA.Contained 253 getContained() 254 { 255 return enum_def_; 256 } 257 } 258 | Popular Tags |