1 25 package org.objectweb.jonas_ejb.genic; 26 27 import org.objectweb.jonas_ejb.deployment.api.EjbRelationshipRoleDesc; 28 import org.objectweb.jonas_ejb.deployment.api.EntityCmp2Desc; 29 import org.objectweb.jonas_ejb.lib.BeanNaming; 30 31 32 39 public class VcCMRField { 40 41 44 private String name; 45 48 private String uFLName; 49 52 private String typeName; 53 56 private EjbRelationshipRoleDesc rsr; 57 60 private EjbRelationshipRoleDesc rsr2; 61 64 private byte relationType = -1; 65 69 private String genClassName = null; 70 73 private EntityCmp2Desc element = null; 74 75 80 public VcCMRField(EjbRelationshipRoleDesc rsr) throws GenICException { 81 this.rsr = rsr; 82 name = rsr.getCmrFieldName(); 83 uFLName = upperFL(name); 84 element = rsr.getTargetBean(); 85 typeName = rsr.getCmrFieldType().getName(); 86 if (rsr.isTargetMultiple()) { 87 if (java.util.Collection .class.equals(rsr.getCmrFieldType())) { 88 genClassName = "org.objectweb.jonas_ejb.container.jorm.Set"; 90 } else if (java.util.Set .class.equals(rsr.getCmrFieldType())) { 91 genClassName = "org.objectweb.jonas_ejb.container.jorm.Set"; 92 } else { 93 throw new GenICException("Unauthorized multivalued relation type:" + rsr.getCmrFieldType()); 94 } 95 } 96 rsr2 = rsr.getOppositeRelationshipRole(); 97 relationType = rsr.getRelationType(); 98 } 99 100 103 public String getName() { 104 return name; 105 } 106 107 112 public String getTypeName() { 113 return typeName; 114 } 115 116 120 public String getUFLName() { 121 return uFLName; 122 } 123 124 127 public EjbRelationshipRoleDesc getRsr() { 128 return rsr; 129 } 130 131 134 public String getOppositeUFLCMRName() { 135 return upperFL(rsr2.getCmrFieldName()); 136 } 137 138 142 public String getHelperClassName() { 143 return "JOnAS" + rsr.getSourceBeanName() + "CoherenceHelper"; 144 } 145 146 150 public String getHelperFQClassName() { 151 String pn = BeanNaming.getPackageName(rsr2.getTargetBean().getFullDerivedBeanName()); 152 if (pn != null && pn.length() > 0) { 153 return pn + "." + getHelperClassName(); 154 } else { 155 return getHelperClassName(); 156 } 157 } 158 159 163 public String getOppositeHelperClassName() { 164 return "JOnAS" + rsr2.getSourceBeanName() + "CoherenceHelper"; 165 } 166 167 171 public String getOppositeHelperFQClassName() { 172 String pn = BeanNaming.getPackageName(rsr.getTargetBean().getFullDerivedBeanName()); 173 if (pn != null && pn.length() > 0) { 174 return pn + "." + getOppositeHelperClassName(); 175 } else { 176 return getOppositeHelperClassName(); 177 } 178 } 179 180 185 public String getGenClassName() { 186 return genClassName; 187 } 188 189 192 public EntityCmp2Desc getElement() { 193 return element; 194 } 195 196 201 public String upperFL(String word) { 202 return Character.toUpperCase(word.charAt(0)) + word.substring(1); 203 } 204 205 208 public boolean isOOu() { 209 return relationType == EjbRelationshipRoleDesc.OOU; 210 } 211 212 215 public boolean isOOb() { 216 return relationType == EjbRelationshipRoleDesc.OOB; 217 } 218 219 222 public boolean isOMu() { 223 return relationType == EjbRelationshipRoleDesc.OMU; 224 } 225 226 229 public boolean isMOu() { 230 return relationType == EjbRelationshipRoleDesc.MOU; 231 } 232 233 236 public boolean isMOb() { 237 return relationType == EjbRelationshipRoleDesc.MOB; 238 } 239 240 243 public boolean isOMb() { 244 return relationType == EjbRelationshipRoleDesc.OMB; 245 } 246 247 250 public boolean isMMu() { 251 return relationType == EjbRelationshipRoleDesc.MMU; 252 } 253 254 257 public boolean isMMb() { 258 return relationType == EjbRelationshipRoleDesc.MMB; 259 } 260 261 264 public String toString() { 265 StringBuffer ret = new StringBuffer (); 266 ret.append("\n Name = " + getName()); 267 ret.append("\n TypeName = " + getTypeName()); 268 ret.append("\n UFLName = " + getUFLName()); 269 ret.append("\n OppositeUFLCMRName = " + getOppositeUFLCMRName()); 270 ret.append("\n HelperClassName = " + getHelperClassName()); 271 ret.append("\n HelperFQClassName = " + getHelperFQClassName()); 272 ret.append("\n OppositeHelperClassName = " + getOppositeHelperClassName()); 273 ret.append("\n OppositeHelperFQClassName = " + getOppositeHelperFQClassName()); 274 ret.append("\n GenClassName = " + getGenClassName()); 275 ret.append("\n isOOu = " + isOOu()); 276 ret.append("\n isOOb = " + isOOb()); 277 ret.append("\n isOMu = " + isOMu()); 278 ret.append("\n isOMb = " + isOMb()); 279 ret.append("\n isMOb = " + isMOb()); 280 ret.append("\n isMNu = " + isMMu()); 281 ret.append("\n isMNb = " + isMMb()); 282 return (ret.toString()); 283 } 284 } 285 | Popular Tags |