1 27 28 package org.objectweb.speedo.generation.lib; 29 30 import org.objectweb.speedo.metadata.SpeedoClass; 31 import org.objectweb.speedo.metadata.SpeedoField; 32 import org.objectweb.jorm.api.PMapper; 33 34 import java.util.StringTokenizer ; 35 36 41 public abstract class NamingRules { 42 43 46 public final static String proxy = "Proxy"; 47 48 51 public final static String fields = "Fields"; 52 53 56 public final static String home = "Home"; 57 58 61 public final static String objectId = "_Id"; 62 63 69 public final static String proxyName(String className) { 70 return className + proxy; 71 } 72 73 79 public final static String homeName(String className) { 80 return className + home; 81 } 82 83 public final static String generatedObjectIdName(String className) { 84 return className + objectId; 85 } 86 87 93 public final static String fieldsName(String className) { 94 return className + fields; 95 } 96 97 104 public final static String bindingName(String className) { 105 return className + "Binding"; 106 } 107 108 115 public final static String fqBindingName(String className, String mapperName) { 116 String p = packageName(className); 117 if (p == null || p.length() == 0) { 118 return mapperName + "." + className + "Binding"; 119 } else { 120 return p + "." + mapperName + "." + className(className) + "Binding"; 121 } 122 } 123 124 130 public final static String mappingName(String className) { 131 return className + "Mapping"; 132 } 133 134 140 public final static String binderName(String compositeNameName) { 141 return compositeNameName + "Binder"; 142 } 143 144 public final static String fpncName(String className) { 145 return className + "FPNC"; 146 } 147 148 public final static String kfpncName(String className) { 149 return className + "KFPNC"; 150 } 151 152 158 public final static String pnameName(String compositeNameName) { 159 return compositeNameName + "PName"; 160 } 161 162 168 public final static String pngName(String compositeNameName) { 169 return compositeNameName + "PNG"; 170 } 171 172 178 public final static String fqMappingName(String className) { 179 return className + PMapper.PCLASSMAPPINGAPPENDER; 180 } 181 182 188 public final static String accessorName(String className) { 189 return className + "Accessor"; 190 } 191 192 198 public final static String keyName(String className) { 199 return className + "Key"; 200 } 201 202 208 public final static String getterName(SpeedoClass sc, String fieldName) { 209 return "jdoGet" + fieldName; 210 } 211 public final static String getterName(SpeedoField sf) { 212 return "jdoGet" + sf.name; 213 } 214 215 221 public final static String setterName(SpeedoClass sc, String fieldName) { 222 return "jdoSet" + fieldName; 223 } 224 225 231 public final static String coherentSetterName(SpeedoClass sc, String fieldName) { 232 return "jdoCoherentSet" + fieldName; 233 } 234 235 241 public final static String setterName(SpeedoField field) { 242 if (field.relationType == SpeedoField.NO_RELATION) { 243 return setterName(field.jdoClass, field.name); 244 } else { 245 return coherentSetterName(field.jdoClass, field.name); 246 } 247 } 248 249 255 public static String className(String completeClassName) { 256 StringTokenizer tok = new StringTokenizer (completeClassName, "."); 257 String res = ""; 258 while (tok.hasMoreTokens()) res = tok.nextToken(); 259 return res; 260 } 261 262 268 public static String packageName(String completeClassName) { 269 StringTokenizer tok = new StringTokenizer (completeClassName, "."); 270 String res = ""; 271 String resold = ""; 272 while (tok.hasMoreTokens()) { 273 resold = (res == "") ? "" : ((resold == "") ? res : resold + "." + res); 274 res = tok.nextToken(); 275 } 276 return resold; 277 } 278 } 279 | Popular Tags |