1 26 27 package org.objectweb.openccm.pss.generator.common.lib; 28 29 31 import org.objectweb.openccm.ast.api.AbstractStorageHomeDecl; 32 import org.objectweb.openccm.ast.api.AbstractStorageTypeDecl; 33 import org.objectweb.openccm.ast.api.StorageHomeKeyDecl; 34 import org.objectweb.openccm.ast.api.StorageHomeFactoryDecl; 35 import org.objectweb.openccm.ast.api.PsdlOperationDecl; 36 import org.objectweb.openccm.ast.api.Declaration; 37 import org.objectweb.openccm.ast.api.DeclarationKind; 38 39 import org.objectweb.openccm.generator.java.ast.api.*; 40 import org.objectweb.openccm.generator.java.ast.lib.*; 41 42 import java.util.List ; 43 import org.objectweb.openccm.generator.common.lib.GenerationException; 44 import org.objectweb.openccm.pss.generator.common.api.PSDL2JavaGenerator; 45 46 47 54 55 public class AbstractStorageHomeMapping 56 implements org.objectweb.openccm.pss.generator.common.api.AbstractStorageHomeMapping 57 { 58 59 65 66 private AbstractStorageHomeDecl ash_; 67 68 74 77 78 public AbstractStorageHomeMapping() 79 { 80 ash_ = null; 82 } 83 84 90 96 101 public void 102 setAbstractStorageHome(AbstractStorageHomeDecl ash) 103 { 104 ash_ = ash; 105 } 106 107 112 public void 113 toJava(PSDL2JavaGenerator generator) 114 throws GenerationException 115 { 116 InterfaceObject itf = null; 117 MethodObject method = null; 118 AbstractStorageHomeDecl[] inherited = null; 119 List vect = null; 120 PsdlOperationDecl[] operations = null; 121 AbstractStorageTypeDecl ast = null; 122 StorageHomeKeyDecl[] keys = null; 123 StorageHomeFactoryDecl[] factories = null; 124 Declaration decl = null; 125 126 itf = new InterfaceObjectImpl(ash_.getName()); 127 itf.addComment(" Abstract Storage Home "+ash_.getName()); 128 itf.addComment(""); 129 itf.addComment(" @author OpenCCM PSDL Compiler"); 130 itf.setModifier(ModifierKindImpl.mk_public); 131 itf.setPackage(generator.getTranslator().getPackage(ash_)); 132 133 inherited = ash_.getAbstractStorageHomeList().getAbstractStorageHomes(); 135 for (int i=0; i<inherited.length; i++) 136 itf.addInheritedObject(generator.getTranslator().getAbsoluteName(inherited[i])); 137 138 if (inherited.length < 1) 139 itf.addInheritedObject("org.omg.CosPersistentState.StorageHomeBase"); 140 141 generator.getJavaRepository().addObject(itf); 142 143 ast = ash_.getAbstractStorageType(); 145 146 vect = generator.getDeclarations(ash_, DeclarationKind.dk_storage_home_factory); 148 factories = (StorageHomeFactoryDecl[])vect.toArray(new StorageHomeFactoryDecl[0]); 149 for (int i=0; i<factories.length; i++) 150 { 151 org.objectweb.openccm.pss.generator.common.api.PSDLFactoryMapping factory = null; 152 153 factory = (org.objectweb.openccm.pss.generator.common.api.PSDLFactoryMapping) 154 MappingObjectFactory.getClass("PSDLFactoryMapping"); 155 factory.setFactory(factories[i]); 156 factory.toJava(generator, itf, ast, null); 157 } 158 159 vect = generator.getDeclarations(ash_, DeclarationKind.dk_storage_home_key); 161 keys = (StorageHomeKeyDecl[])vect.toArray(new StorageHomeKeyDecl[0]); 162 for (int i=0; i<keys.length; i++) 163 { 164 org.objectweb.openccm.pss.generator.common.api.PSDLKeyMapping key = null; 165 166 key = (org.objectweb.openccm.pss.generator.common.api.PSDLKeyMapping) 167 MappingObjectFactory.getClass("PSDLKeyMapping"); 168 key.setKey(keys[i]); 169 key.toJava(generator, itf, ast); 170 } 171 172 vect = generator.getDeclarations(ash_, DeclarationKind.dk_psdl_operation); 174 operations = (PsdlOperationDecl[])vect.toArray(new PsdlOperationDecl[0]); 175 for (int i=0; i<operations.length; i++) 176 { 177 org.objectweb.openccm.pss.generator.common.api.PSDLOperationMapping op = null; 178 179 op = (org.objectweb.openccm.pss.generator.common.api.PSDLOperationMapping) 180 MappingObjectFactory.getClass("PSDLOperationMapping"); 181 op.setOperation(operations[i]); 182 op.toJava(generator.getTranslator(), itf); 183 } 184 } 185 186 } 187 | Popular Tags |