1 26 27 package org.objectweb.openccm.pss.generator.jdo.lib; 28 29 31 import org.objectweb.openccm.generator.java.ast.api.*; 32 import org.objectweb.openccm.generator.java.ast.lib.*; 33 34 import org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator; 35 import org.objectweb.openccm.pss.generator.common.lib.PSDLTools; 36 37 38 45 public class StateMemberMapping 46 extends org.objectweb.openccm.pss.generator.common.lib.StateMemberMapping 47 { 48 49 55 61 64 public StateMemberMapping() 65 { 66 super(); 67 } 68 69 75 81 88 public void 89 toJavaAccessors( PSDL_JavaTranslator translator, 90 InterfaceObject obj, 91 boolean finalAccessor ) 92 { 93 MethodObject method = null; 94 ParameterObject param = null; 95 96 if (PSDLTools.isAbstractStorageTypeReference(state_.getType())) 97 { 98 method = new MethodObjectImpl(); 100 method.addComment("Get the "+state_.getName()+" value."); 101 method.addComment(" "); 102 method.addComment("@return The "+state_.getName()+" value."); 103 method.setName( state_.getName() ); 104 method.setReturnType( translator.RefToJava(state_.getType()) ); 105 method.setFinal( finalAccessor ); 106 method.getImpl().setMacro("REF_GET_METHOD"); 107 method.getImpl().addContextValue("st_type", translator.RefToJava(state_.getType()) ); 108 method.getImpl().addContextValue("state", state_.getName()); 109 obj.addMethod(method); 110 111 method = new MethodObjectImpl(); 113 method.addComment("Get the "+state_.getName()+" value."); 114 method.addComment(" "); 115 method.addComment("@param yr - Use to have a different signature."); 116 method.addComment(" "); 117 method.addComment("@return The "+state_.getName()+" value."); 118 method.setName( state_.getName() ); 119 method.setReturnType( translator.toJava(state_.getType()) ); 120 method.setFinal( finalAccessor ); 121 param = new ParameterObjectImpl(); 122 param.setName("yr"); 123 param.setType("org.omg.CosPersistentState.YieldRef"); 124 method.addParameter(param); 125 method.getImpl().setMacro("GET_METHOD"); 126 method.getImpl().addContextValue("var", mapStateName()); 127 obj.addMethod(method); 128 129 if (!state_.isReadonly()) 130 { 131 method = new MethodObjectImpl(); 133 method.addComment("Set the "+state_.getName()+" value."); 134 method.addComment(" "); 135 method.addComment("@param new_one - The value to set."); 136 method.setName( state_.getName() ); 137 method.setReturnType("void"); 138 method.setFinal( finalAccessor ); 139 param = new ParameterObjectImpl(); 140 param.setName("new_one"); 141 param.setType( translator.RefToJava(state_.getType()) ); 142 method.addParameter(param); 143 method.getImpl().setMacro("REF_SET_METHOD"); 144 method.getImpl().addContextValue("var", mapStateName()); 145 method.getImpl().addContextValue("value", "new_one"); 146 obj.addMethod(method); 147 148 method = new MethodObjectImpl(); 150 method.addComment("Set the "+state_.getName()+" value."); 151 method.addComment(" "); 152 method.addComment("@param new_one_ref - The value reference to set."); 153 method.setName( state_.getName() ); 154 method.setReturnType("void"); 155 method.setFinal( finalAccessor ); 156 param = new ParameterObjectImpl(); 157 param.setName("new_one_ref"); 158 param.setType( translator.toJava(state_.getType()) ); 159 method.addParameter(param); 160 method.getImpl().setMacro("SET_METHOD"); 161 method.getImpl().addContextValue("var", mapStateName()); 162 method.getImpl().addContextValue("value", "new_one_ref"); 163 obj.addMethod(method); 164 } 165 } 166 else 167 { 168 method = new MethodObjectImpl(); 170 method.addComment("Get the "+state_.getName()+" value."); 171 method.addComment(" "); 172 method.addComment("@return The "+state_.getName()+" value."); 173 method.setName( state_.getName() ); 174 method.setReturnType( translator.toJava(state_.getType()) ); 175 method.setFinal( finalAccessor ); 176 method.getImpl().setMacro("GET_METHOD"); 177 method.getImpl().addContextValue("var", mapStateName()); 178 obj.addMethod(method); 179 180 if (!state_.isReadonly()) 181 { 182 method = new MethodObjectImpl(); 184 method.addComment("Set the "+state_.getName()+" value."); 185 method.addComment(" "); 186 method.addComment("@param new_one - The value to set."); 187 method.setName( state_.getName() ); 188 method.setReturnType("void"); 189 method.setFinal( finalAccessor ); 190 param = new ParameterObjectImpl(); 191 param.setName("new_one"); 192 param.setType( translator.toJava(state_.getType()) ); 193 method.addParameter(param); 194 method.getImpl().setMacro("SET_METHOD"); 195 method.getImpl().addContextValue("var", mapStateName()); 196 method.getImpl().addContextValue("value", "new_one"); 197 obj.addMethod(method); 198 199 if ( !PSDLTools.isImmutable(state_.getType()) 200 && !PSDLTools.isAbstractStorageType(state_.getType()) ) 201 { 202 method = new MethodObjectImpl(); 204 method.addComment("Update the "+state_.getName()+" value."); 205 method.addComment(" "); 206 method.addComment("@param fu - ForUpdate."); 207 method.setName( state_.getName() ); 208 method.setReturnType( translator.toJava(state_.getType()) ); 209 method.setFinal( finalAccessor ); 210 param = new ParameterObjectImpl(); 211 param.setName("fu"); 212 param.setType("org.omg.CosPersistentState.ForUpdate"); 213 method.addParameter(param); 214 method.getImpl().setMacro("GET_UPDATE_METHOD"); 215 method.getImpl().addContextValue("var", mapStateName()); 216 obj.addMethod(method); 217 } 218 } 219 } 220 } 221 222 } 223 | Popular Tags |