1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.AbstractStorageTypeDecl; 31 32 33 import org.objectweb.openccm.ast.api.StorageTypeStateMemberDecl; 34 35 36 import org.objectweb.openccm.ast.api.AbstractStorageTypeList; 37 38 39 import org.objectweb.openccm.ast.api.ASTError; 40 41 64 65 abstract public class StorageTypeBaseImpl 66 extends ForwardScopePsdlImpl 67 implements org.objectweb.openccm.ast.api.StorageTypeBase 68 { 69 75 76 protected AbstractStorageTypeListImpl abstract_storagetypes_; 77 78 84 89 protected 90 StorageTypeBaseImpl(Repository rep, 91 ScopeImpl parent) 92 { 93 super(rep, parent); 95 96 abstract_storagetypes_ = new AbstractStorageTypeListImpl(); 98 content_loaded_ = true; 99 } 100 101 107 114 protected boolean 115 isValidState(String state) 116 { 117 DeclarationImpl decl = null; 118 119 decl = (DeclarationImpl)findInScope(state); 121 if(decl == null) 122 { 123 boolean found = false; 125 int size = abstract_storagetypes_.getSize(); 126 if (size > 0) 127 { 128 int i = 0; 129 while( (i<size) && !found ) 130 { 131 found = ((AbstractStorageTypeDeclImpl)abstract_storagetypes_.get(i)).isValidState(state); 132 i++; 133 } 134 } 135 if(!found) return false; 136 } 137 return true; 138 } 139 140 146 152 158 164 170 176 182 185 public void 186 create() 187 { 188 super.create(); 190 191 int index = abstract_storagetypes_.checkSameItem(); 193 if( index != -1 ) 194 { 195 throw new ASTError(getName() + " implements twice " + ((AbstractStorageTypeDecl)abstract_storagetypes_.get(index)).getName() ); 196 } 197 } 198 199 205 211 217 222 public AbstractStorageTypeList 223 getAbstractStorageTypeList() 224 { 225 return abstract_storagetypes_; 226 } 227 228 233 public AbstractStorageTypeList 234 getAllImplementedAbstractStorageTypes() 235 { 236 AbstractStorageTypeDecl[] directly_impl = null; 237 AbstractStorageTypeListImpl implemented = new AbstractStorageTypeListImpl(); 238 239 directly_impl = getAbstractStorageTypeList().getAbstractStorageTypes(); 240 for(int i=0; i<directly_impl.length; i++) 241 { 242 AbstractStorageTypeDecl ast = (AbstractStorageTypeDecl)directly_impl[i]; 243 implemented.add(ast); 244 245 AbstractStorageTypeDecl[] tmp = 246 ast.getAllImplementedAbstractStorageTypes().getAbstractStorageTypes(); 247 for (int j=0; j<tmp.length; j++) 248 { 249 if (!implemented.contains(tmp[j])) 250 implemented.add(tmp[j]); 251 } 252 } 253 return implemented; 254 } 255 256 263 public StorageTypeStateMemberDecl 264 getState(String name) 265 { 266 StorageTypeStateMemberDecl decl = null; 267 268 decl = (StorageTypeStateMemberDecl)findInScope(name); 270 if(decl == null) 271 { 272 int size = abstract_storagetypes_.getSize(); 274 if (size > 0) 275 { 276 int i = 0; 277 while( (i<size) && (decl == null) ) 278 { 279 decl = ((AbstractStorageTypeDecl)abstract_storagetypes_.get(i)).getState(name); 280 i++; 281 } 282 } 283 } 284 return decl; 285 } 286 } 287 | Popular Tags |