1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.TypeRef; 31 32 33 import org.objectweb.openccm.ast.api.DeclarationKind; 34 35 36 import org.objectweb.openccm.ast.api.Declaration; 37 38 39 import org.objectweb.openccm.ast.api.StructMember; 40 41 42 import org.objectweb.openccm.ast.api.StructMemberList; 43 44 45 import org.omg.CORBA.ExceptionDef ; 46 import org.omg.CORBA.ExceptionDefHelper; 47 48 60 61 public class ExceptionDeclImpl 62 extends ScopeImpl 63 implements org.objectweb.openccm.ast.api.ExceptionDecl 64 { 65 71 72 private ExceptionDef exception_def_; 73 74 75 private StructMemberListImpl members_; 76 77 83 89 public 90 ExceptionDeclImpl(Repository rep, 91 ScopeImpl parent) 92 { 93 super(rep, parent); 95 96 exception_def_ = null; 98 members_ = new StructMemberListImpl(); 99 } 100 101 107 110 protected void 111 doCreation() 112 { 113 exception_def_ = the_parent_.getContainer(). 114 create_exception(getId(), getName(), getVersion(), 115 members_.getStructMemberSeq()); 116 super.create(); 117 } 118 119 125 130 protected void 131 load(org.omg.CORBA.Contained contained) 132 { 133 exception_def_ = ExceptionDefHelper.narrow(contained); 134 org.omg.CORBA.StructMember [] members = exception_def_.members(); 135 136 super.load(contained); 138 139 for (int i=0; i<members.length; i++) 140 { 141 members_.addMember(members[i].name, 142 getRepository(). 143 getAsTypeRef((members[i].type_def))); 144 } 145 } 146 147 152 protected void 153 loadAsMapping(org.omg.CORBA.Contained contained) 154 { 155 exception_def_ = ExceptionDefHelper.narrow(contained); 156 org.omg.CORBA.StructMember [] members = exception_def_.members(); 157 158 super.loadAsMapping(contained); 160 161 for (int i=0; i<members.length; i++) 162 members_.addMember(members[i].name, 163 getRepository(). 164 getAsMappedTypeRef((members[i].type_def))); 165 } 166 167 173 protected org.omg.CORBA.Contained 174 getContained() 175 { 176 if(exception_def_ == null) 177 doCreation(); 178 179 return exception_def_; 180 } 181 182 188 194 protected org.omg.CORBA.Container 195 getContainer() 196 { 197 if(exception_def_ == null) 198 doCreation(); 199 200 return exception_def_; 201 } 202 203 209 214 public ExceptionDef 215 getExceptionDef() 216 { 217 return exception_def_; 218 } 219 220 225 public org.omg.CORBA.ExceptionDescription 226 getExceptionDescription() 227 { 228 return new org.omg.CORBA.ExceptionDescription (getName(), 229 getId(), 230 the_parent_.getId(), 231 getVersion(), 232 getExceptionDef().type()); 233 } 234 235 241 249 public Declaration[] 250 getDependencies() 251 { 252 if (dependencies_!=null) 253 return dependencies_; 254 255 java.util.List exc_depend = new java.util.ArrayList (); 257 Declaration[] depend = null; 258 259 StructMember[] members = members_.getStructMembers(); 260 for (int i=0; i<members.length; i++) 261 { 262 TypeRef member_type = members[i].getType(); 263 if (member_type.isDeclaration()) 264 { 265 if ((!containsDecl((Declaration)member_type)) && 266 (exc_depend.indexOf(member_type)==-1)) 267 exc_depend.add(member_type); 268 } 269 270 depend = member_type.getDependencies(); 271 for (int j=0; j<depend.length; j++) 272 { 273 if ((exc_depend.indexOf(depend[j])==-1) && 274 (!containsDecl(depend[j]))) 275 exc_depend.add(depend[j]); 276 } 277 } 278 dependencies_ = (Declaration[])exc_depend.toArray(new Declaration[0]); 279 return dependencies_; 280 } 281 282 288 293 public long 294 getDeclKind() 295 { 296 return DeclarationKind.dk_exception; 297 } 298 299 302 public void 303 create() 304 { 305 if(exception_def_ == null) 306 doCreation(); 307 else 308 exception_def_.members(members_.getStructMemberSeq()); 309 } 310 311 317 323 330 public String 331 declaratorAt(int index) 332 { 333 return members_.nameAt(index); 334 } 335 336 342 347 public StructMemberList 348 getMemberList() 349 { 350 return members_; 351 } 352 } 353 | Popular Tags |