1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.AbstractStorageHomeList; 31 32 import org.objectweb.openccm.ast.api.StorageHomeFactoryDecl; 33 34 import org.objectweb.openccm.ast.api.StorageHomeKeyDecl; 35 36 37 import org.objectweb.openccm.ast.api.AbstractStorageHomeDecl; 38 39 40 import org.objectweb.openccm.ast.api.ASTError; 41 42 43 import org.objectweb.openccm.ast.api.DeclarationKind; 44 45 46 import org.objectweb.openccm.ast.api.Declaration; 47 48 77 78 abstract public class StorageHomeBaseImpl 79 extends ForwardScopePsdlImpl 80 implements org.objectweb.openccm.ast.api.StorageHomeBase 81 { 82 88 89 protected AbstractStorageHomeListImpl abstract_storagehomes_; 90 91 97 102 protected 103 StorageHomeBaseImpl(Repository rep, 104 ScopeImpl parent) 105 { 106 super(rep, parent); 108 109 abstract_storagehomes_ = new AbstractStorageHomeListImpl(); 111 content_loaded_ = true; 112 } 113 114 120 126 129 public void 130 check(StorageTypeBaseImpl st) 131 { 132 Declaration[] decls = null; 133 134 decls = getKeys(); 136 if(decls != null) 137 { 138 for (int i=0; i<decls.length; i++) 139 { 140 ((StorageHomeKeyDeclImpl)decls[i]).check(st); 142 } 143 } 144 145 decls = getFactories(); 147 if(decls != null) 148 { 149 for (int i=0; i<decls.length; i++) 150 { 151 ((StorageHomeFactoryDeclImpl)decls[i]).check(st); 153 } 154 } 155 } 156 157 163 169 175 181 186 public Declaration[] 187 getKeys() 188 { 189 return getContents(true, DeclarationKind.dk_storage_home_key); 190 } 191 192 197 public Declaration[] 198 getFactories() 199 { 200 return getContents(true, DeclarationKind.dk_storage_home_factory); 201 } 202 203 209 215 218 public void 219 create() 220 { 221 super.create(); 223 224 int index = abstract_storagehomes_.checkSameItem(); 226 if( index != -1 ) 227 { 228 throw new ASTError(getName() + " implements twice " + ((AbstractStorageHomeDecl)abstract_storagehomes_.get(index)).getName() ); 229 } 230 } 231 232 238 244 250 255 public AbstractStorageHomeList 256 getAbstractStorageHomeList() 257 { 258 return abstract_storagehomes_; 259 } 260 261 266 public AbstractStorageHomeList 267 getAllImplementedAbstractStorageHomes() 268 { 269 AbstractStorageHomeDecl[] directly_impl = null; 270 AbstractStorageHomeListImpl implemented = new AbstractStorageHomeListImpl(); 271 272 directly_impl = getAbstractStorageHomeList().getAbstractStorageHomes(); 273 for(int i=0; i<directly_impl.length; i++) 274 { 275 AbstractStorageHomeDecl ash = (AbstractStorageHomeDecl)directly_impl[i]; 276 implemented.add(ash); 277 278 AbstractStorageHomeDecl[] tmp = 279 ash.getAllImplementedAbstractStorageHomes().getAbstractStorageHomes(); 280 for (int j=0; j<tmp.length; j++) 281 { 282 if (!implemented.contains(tmp[j])) 283 implemented.add(tmp[j]); 284 } 285 } 286 return implemented; 287 } 288 289 296 public StorageHomeKeyDecl 297 startStorageHomeKey(String name) 298 { 299 if ( findInScope(name) != null) 301 { 302 throw new ASTError(name + " is already defined." ); 303 } 304 305 StorageHomeKeyDecl decl = new StorageHomeKeyDeclImpl(getRepository(), this); 306 decl.setName(name); 307 return decl; 308 } 309 310 317 public StorageHomeFactoryDecl 318 startStorageHomeFactory(String name) 319 { 320 if ( findInScope(name) != null) 322 { 323 throw new ASTError(name + " is already defined." ); 324 } 325 326 StorageHomeFactoryDecl decl = new StorageHomeFactoryDeclImpl(getRepository(), this); 327 decl.setName(name); 328 return decl; 329 } 330 } 331 | Popular Tags |