1 18 package org.objectweb.speedo.generation.mivisitor; 19 20 import org.objectweb.speedo.metadata.SpeedoField; 21 import org.objectweb.speedo.metadata.SpeedoExtension; 22 import org.objectweb.speedo.api.SpeedoException; 23 import org.objectweb.speedo.api.SpeedoProperties; 24 import org.objectweb.util.monolog.api.BasicLevel; 25 26 33 public class FieldConverterVisitor extends AbstractMetaInfoVisitor { 34 35 protected String getLoggerName() { 36 return super.getLoggerName() + ".fieldconverter"; 37 } 38 39 public void visitField(SpeedoField sf) throws SpeedoException { 40 super.visitField(sf); 41 if (sf.desc.startsWith("Ljava/sql/")) { 42 SpeedoExtension se = new SpeedoExtension(); 43 se.vendorName = SpeedoProperties.VENDOR_NAME; 44 se.key = SpeedoProperties.FIELD_CONVERTER; 45 se.value = "org.objectweb.speedo.lib.Sql"; 46 se.value += sf.desc.substring(10, sf.desc.length()-1); 47 se.value += "FieldMapping"; 48 logger.log(BasicLevel.DEBUG, "Use the converter '" + se.value 49 + "' for the field '" + sf.name + "'"); 50 sf.addExtension(se); 51 } else if (sf.desc.startsWith("Ljava/util/Locale")) { 52 SpeedoExtension se = new SpeedoExtension(); 53 se.vendorName = SpeedoProperties.VENDOR_NAME; 54 se.key = SpeedoProperties.FIELD_CONVERTER; 55 se.value = "org.objectweb.speedo.lib.LocaleFieldMapping"; 56 logger.log(BasicLevel.DEBUG, "Use the converter '" + se.value 57 + "' for the field '" + sf.name + "'"); 58 sf.addExtension(se); 59 } 60 } 61 } 62 | Popular Tags |