1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class AttributeDeclImpl 39 extends DeclarationImpl 40 implements AttributeDecl 41 { 42 48 51 private org.omg.CORBA.ExtAttributeDef ext_attribute_def_; 52 53 56 private int mode_; 57 58 61 private TypeRef type_; 62 63 66 private ExceptionListImpl get_exceptions_; 67 68 71 private ExceptionListImpl set_exceptions_; 72 73 79 84 protected 85 AttributeDeclImpl(Repository rep, ScopeImpl parent) 86 { 87 super(rep, parent); 89 90 ext_attribute_def_ = null; 92 mode_ = AttributeDecl.ATTR_NORMAL; 93 type_ = null; 94 get_exceptions_ = new ExceptionListImpl(); 95 set_exceptions_ = new ExceptionListImpl(); 96 the_declaration_kind_ = DeclarationKind._dk_attribute; 97 } 98 99 105 110 protected void 111 load(org.omg.CORBA.Contained contained) 112 { 113 ext_attribute_def_ = org.omg.CORBA.ExtAttributeDefHelper.narrow(contained); 114 mode_ = ext_attribute_def_.mode().value(); 115 setType(getRepository().getAsTypeRef(ext_attribute_def_.type_def())); 116 117 org.omg.CORBA.ExceptionDef [] exc = ext_attribute_def_.get_exceptions(); 118 for (int i=0;i<exc.length;i++) 119 get_exceptions_.add((ExceptionRef)getRepository().lookupId(exc[i].id())); 120 121 exc = ext_attribute_def_.set_exceptions(); 122 for (int i=0;i<exc.length;i++) 123 set_exceptions_.add((ExceptionRef)getRepository().lookupId(exc[i].id())); 124 125 super.load(contained); 126 } 127 128 133 protected void 134 loadAsMapping(org.omg.CORBA.Contained contained) 135 { 136 ext_attribute_def_ = org.omg.CORBA.ExtAttributeDefHelper.narrow(contained); 137 mode_ = ext_attribute_def_.mode().value(); 138 setType(getRepository().getAsMappedTypeRef(ext_attribute_def_.type_def())); 139 140 org.omg.CORBA.ExceptionDef [] exc = ext_attribute_def_.get_exceptions(); 141 for (int i=0;i<exc.length;i++) 142 get_exceptions_.add((ExceptionRef)getRepository().lookupMappedId(exc[i].id())); 143 144 exc = ext_attribute_def_.set_exceptions(); 145 for (int i=0;i<exc.length;i++) 146 set_exceptions_.add((ExceptionRef)getRepository().lookupMappedId(exc[i].id())); 147 148 super.loadAsMapping(contained); 149 } 150 151 157 160 public void 161 create() 162 { 163 ext_attribute_def_ = the_parent_.createExtAttribute(this, type_.getIDLType(), 164 org.omg.CORBA.AttributeMode.from_int(mode_), 165 get_exceptions_.getExceptionDefs(), 166 set_exceptions_.getExceptionDefs()); 167 168 super.create(); 169 } 170 171 178 public Declaration[] 179 getDependencies() 180 { 181 if (dependencies_!=null) 182 return dependencies_; 183 184 org.objectweb.ccm.util.Vector attr_depend = new org.objectweb.ccm.util.Vector(); 185 Declaration[] depend = null; 186 187 if (getType().isDeclaration()) 189 attr_depend.add(getType()); 190 191 depend = getType().getDependencies(); 192 for (int i=0;i<depend.length;i++) 193 attr_depend.add(depend[i]); 194 195 if (isReadonly()) 197 addDependencies(attr_depend, getExceptions()); 198 else 199 { 200 addDependencies(attr_depend, getGetExceptions()); 201 addDependencies(attr_depend, getSetExceptions()); 202 } 203 204 dependencies_ = (Declaration[])attr_depend.toArray(new Declaration[0]); 205 return dependencies_; 206 } 207 208 211 protected void 212 addDependencies(org.objectweb.ccm.util.Vector attr_depend, 213 ExceptionDecl[] excs) 214 { 215 Declaration[] depend = null; 216 for (int i=0;i<excs.length;i++) 217 { 218 attr_depend.add(excs[i]); 219 depend = excs[i].getDependencies(); 220 for (int j=0;j<depend.length;j++) 221 { 222 if (attr_depend.indexOf(depend[j])==-1) 223 attr_depend.add(depend[j]); 224 } 225 } 226 } 227 228 229 235 238 public void 239 setNormal() 240 { 241 mode_ = AttributeDecl.ATTR_NORMAL; 242 } 243 244 247 public void 248 setReadonly() 249 { 250 mode_ = AttributeDecl.ATTR_READONLY; 251 } 252 253 258 public void 259 setType(TypeRef type) 260 { 261 if(type != null) 262 { 263 type_ = type; 264 type_.addRef(); 265 } 266 } 267 268 274 public ExceptionList 275 getGetExceptionList() 276 { 277 return get_exceptions_; 278 } 279 280 287 public ExceptionList 288 getSetExceptionList() 289 { 290 return set_exceptions_; 291 } 292 293 299 public ExceptionDecl[] 300 getGetExceptions() 301 { 302 if (mode_==AttributeDecl.ATTR_NORMAL) 303 return get_exceptions_.getExceptions(); 304 return new ExceptionDecl[0]; 305 } 306 307 314 public ExceptionDecl[] 315 getSetExceptions() 316 { 317 if (mode_==AttributeDecl.ATTR_NORMAL) 318 return set_exceptions_.getExceptions(); 319 return new ExceptionDecl[0]; 320 } 321 322 325 public ExceptionDecl[] 326 getExceptions() 327 { 328 if (mode_==AttributeDecl.ATTR_READONLY) 329 return get_exceptions_.getExceptions(); 330 return new ExceptionDecl[0]; 331 } 332 333 336 public boolean 337 isReadonly() 338 { 339 return mode_==AttributeDecl.ATTR_READONLY; 340 } 341 342 345 public TypeRef 346 getType() 347 { 348 return type_; 349 } 350 351 357 360 public void 361 destroy() 362 { 363 if (type_!=null) 364 type_.removeRef(); 365 366 get_exceptions_.destroy(); 367 set_exceptions_.destroy(); 368 super.destroy(); 369 } 370 371 377 protected org.omg.CORBA.Contained 378 getContained() 379 { 380 return ext_attribute_def_; 381 } 382 } 383 | Popular Tags |