1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.AnyValue; 31 32 33 import org.objectweb.openccm.ast.api.TypeKind; 34 35 36 import org.objectweb.openccm.ast.api.DeclarationKind; 37 38 39 import org.objectweb.openccm.ast.api.StringList; 40 41 42 import org.omg.CORBA.EnumDef ; 43 import org.omg.CORBA.EnumDefHelper; 44 45 70 71 public class EnumDeclImpl 72 extends DeclarationImpl 73 implements org.objectweb.openccm.ast.api.EnumDecl, 74 IDLTypeWrapper 75 { 76 82 83 private EnumDef enum_def_; 84 85 86 private StringListImpl members_; 87 88 94 100 protected 101 EnumDeclImpl(Repository rep, 102 ScopeImpl parent) 103 { 104 super(rep, parent); 106 107 enum_def_ = null; 109 members_ = new StringListImpl(); 110 } 111 112 118 124 129 protected void 130 load(org.omg.CORBA.Contained contained) 131 { 132 enum_def_ = EnumDefHelper.narrow(contained); 133 String [] members = enum_def_.members(); 134 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 135 for (int i=0; i<members.length; i++) 136 { 137 members_.add(members[i]); 138 DeclarationWithAnyValueImpl decl = new DeclarationWithAnyValueImpl(getRepository(), the_parent_); 139 decl.setName(members[i]); 140 AnyValue av = new AnyValueImpl(); 141 av.setAsEnum(enumTC, i, members[i]); 142 decl.setAnyValue(av); 143 decl.create(); 144 } 145 super.load(contained); 146 } 147 148 153 protected void 154 loadAsMapping(org.omg.CORBA.Contained contained) 155 { 156 enum_def_ = EnumDefHelper.narrow(contained); 157 String [] members = enum_def_.members(); 158 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 159 for (int i=0;i<members.length;i++) 160 { 161 members_.add(members[i]); 162 DeclarationWithAnyValueImpl decl = new DeclarationWithAnyValueImpl(getRepository(), the_parent_); 163 decl.setName(members[i]); 164 AnyValue av = new AnyValueImpl(); 165 av.setAsEnum(enumTC, i, members[i]); 166 decl.setAnyValue(av); 167 decl.create(); 168 } 169 170 super.loadAsMapping(contained); 171 } 172 173 178 protected org.omg.CORBA.Contained 179 getContained() 180 { 181 return enum_def_; 182 } 183 184 190 196 204 public String 205 declaratorAt(int index) 206 { 207 return (String )members_.get(index); 208 } 209 210 216 222 227 public long 228 getDeclKind() 229 { 230 return DeclarationKind.dk_enum; 231 } 232 233 236 public void 237 create() 238 { 239 String [] members = members_.getStrings(); 240 241 enum_def_ = the_parent_.getContainer(). 242 create_enum(getId(), getName(), getVersion(), members); 243 244 org.omg.CORBA.TypeCode enumTC = enum_def_.type(); 245 for(int i=0; i<members_.getSize(); i++) 246 { 247 String name = (String )members_.get(i); 248 DeclarationWithAnyValueImpl decl = new DeclarationWithAnyValueImpl(getRepository(), the_parent_); 249 decl.setName(name); 250 AnyValue av = new AnyValueImpl(); 251 av.setAsEnum(enumTC, i, name); 252 decl.setAnyValue(av); 253 decl.create(); 254 } 255 256 super.create(); 257 } 258 259 265 270 public TypeKind 271 getTypeKind() 272 { 273 return TypeKind.tk_enum; 274 } 275 276 282 287 public StringList 288 getMemberList() 289 { 290 return members_; 291 } 292 293 299 304 public org.omg.CORBA.IDLType 305 getIDLType() 306 { 307 return enum_def_; 308 } 309 } 310 | Popular Tags |