1 23 24 package org.objectweb.jorm.genclass.lib; 25 26 import org.objectweb.jorm.api.PAccessor; 27 import org.objectweb.jorm.api.PBinding; 28 import org.objectweb.jorm.api.PClassMapping; 29 import org.objectweb.jorm.api.PMapper; 30 import org.objectweb.jorm.api.PMappingCallback; 31 import org.objectweb.jorm.api.PException; 32 import org.objectweb.jorm.api.PClassMappingCtrl; 33 import org.objectweb.jorm.api.PNameIterator; 34 import org.objectweb.jorm.metainfo.api.GenClass; 35 import org.objectweb.jorm.metainfo.api.MetaObject; 36 import org.objectweb.jorm.naming.api.PBinder; 37 import org.objectweb.jorm.naming.api.PNameCoder; 38 import org.objectweb.jorm.genclass.api.FieldDesc; 39 import org.objectweb.jorm.genclass.api.GenClassProp; 40 import org.objectweb.jorm.type.api.PExceptionTyping; 41 import org.objectweb.jorm.type.api.PType; 42 import org.objectweb.jorm.util.api.Loggable; 43 import org.objectweb.util.monolog.api.Logger; 44 import org.objectweb.util.monolog.api.LoggerFactory; 45 46 import java.util.Iterator ; 47 import java.util.Collections ; 48 49 55 public abstract class GenClassMapping 56 implements PClassMapping, PClassMappingCtrl, GenClassProp, Loggable { 57 61 protected PMappingCallback mapper = null; 62 63 66 protected GenClass genClassMetaInfo = null; 67 68 71 protected PType genClassPType = null; 72 73 74 protected String jormClassName = ""; 75 76 80 protected FieldDesc[] indexFields = null; 81 82 86 protected FieldDesc[] identifierFields = null; 87 88 96 protected FieldDesc[] elemFields = null; 97 98 101 protected PBinder binder = null; 102 103 protected PNameCoder classPNC; 104 105 110 protected PClassMapping elemClassMapping = null; 111 112 116 protected PNameCoder elemNameCoder = null; 117 118 protected String projectName = null; 119 120 123 protected Logger logger = null; 124 125 128 protected LoggerFactory loggerFactory = null; 129 130 131 public FieldDesc[] getElemFields() { 132 return elemFields; 133 } 134 135 public FieldDesc[] getIdentifierFields() { 136 return identifierFields; 137 } 138 139 public FieldDesc[] getIndexFields() { 140 return indexFields; 141 } 142 143 144 public String getProjectName() { 145 return projectName; 146 } 147 148 public void setProjectName(String projectName) { 149 this.projectName = projectName; 150 } 151 152 157 public String getClassName() { 158 return jormClassName; 159 } 160 161 166 public PClassMapping getGenClassMapping() { 167 return elemClassMapping; 168 } 169 170 177 public PClassMapping getGenClassMapping(String fn) { 178 return null; 179 } 180 181 188 public MetaObject getMetaInfo() { 189 return genClassMetaInfo; 190 } 191 192 197 public PBinder getPBinder() { 198 return binder; 199 } 200 201 public PNameCoder getClassPNameCoder() { 202 return classPNC; 203 } 204 205 210 public PMapper getPMapper() { 211 return mapper; 212 } 213 214 227 public PNameCoder getPNameCoder() 228 throws UnsupportedOperationException { 229 return elemNameCoder; 230 } 231 232 241 public PNameCoder getPNameCoder(String fn) 242 throws UnsupportedOperationException { 243 throw new UnsupportedOperationException (); 244 } 245 246 253 public void init(PMappingCallback mapper, MetaObject metaclass) throws PException { 254 this.mapper = mapper; 255 genClassMetaInfo = (GenClass) metaclass; 256 } 257 258 public Iterator getPNameIterator(Object conn) throws PException { 259 return getPNameIterator(conn, false, false, null); 260 } 261 262 272 public void setPBinder(PBinder pb) throws PExceptionTyping { 273 binder = pb; 274 } 275 276 public void setClassPNameCoder(PNameCoder pnc) throws PException { 277 this.classPNC = pnc; 278 } 279 280 public void configureRefFields(PClassMapping.ReferenceConfigurator rc) 281 throws PException, UnsupportedOperationException { 282 throw new UnsupportedOperationException (); 283 } 284 285 303 public void setPNameCoder(PNameCoder pnc) 304 throws PException, UnsupportedOperationException { 305 elemNameCoder = pnc; 306 } 307 308 324 public void setPNameCoder(String fn, PNameCoder pnc) 325 throws PException, UnsupportedOperationException { 326 throw new UnsupportedOperationException (); 327 } 328 329 333 public void setGenClassMapping(PClassMapping pcm) 334 throws UnsupportedOperationException { 335 elemClassMapping = pcm; 338 } 339 340 344 public void setGenClassMapping(String fn, PClassMapping pcm) 345 throws UnsupportedOperationException { 346 throw new UnsupportedOperationException (); 347 } 348 349 354 public PType getPType() { 355 return genClassPType; 356 } 357 358 364 public void setPType(PType pt) { 365 if (genClassPType == null) { 366 genClassPType = pt; 367 jormClassName += pt.getJormName(); 368 binder.setPType(pt); 369 if (pt.getNestedPType() != null) { 370 if (elemClassMapping != null) { 371 elemClassMapping.getPBinder().setPType(pt.getNestedPType()); 373 } 374 if (pt.getNestedPType().getTypeCode() == PType.TYPECODE_REFERENCE) { 375 elemNameCoder.setPType(pt.getNestedPType()); 376 } 377 } 378 } 379 } 380 public void read(PBinding pb, Object conn, PAccessor pa, Object txctx) throws PException { 381 read(pb, conn, pa); 382 } 383 384 386 391 public void setIdentifierDesc(FieldDesc[] fds) { 392 identifierFields = fds; 393 } 394 395 400 public void setIndexDesc(FieldDesc[] fds) { 401 indexFields = fds; 402 } 403 404 409 public void setElemDesc(FieldDesc[] fds) { 410 elemFields = fds; 411 } 412 413 417 public void setLoggerFactory(LoggerFactory lf) { 418 loggerFactory = lf; 419 } 420 421 425 public void setLogger(Logger logger) { 426 this.logger = logger; 427 } 428 429 public Logger getLogger() { 430 return logger; 431 } 432 433 public LoggerFactory getLoggerFactory() { 434 return loggerFactory; 435 } 436 } 437 | Popular Tags |