1 19 20 21 package org.apache.cayenne.access.trans; 22 23 import java.sql.Types ; 24 25 import org.apache.cayenne.map.DbAttribute; 26 import org.apache.cayenne.map.DbRelationship; 27 28 35 public class TrimmingQualifierTranslator extends QualifierTranslator { 36 37 protected String trimFunction; 38 39 42 protected TrimmingQualifierTranslator() { 43 super(); 44 } 45 46 49 public TrimmingQualifierTranslator( 50 QueryAssembler queryAssembler, 51 String trimFunction) { 52 super(queryAssembler); 53 this.trimFunction = trimFunction; 54 } 55 56 59 protected void processColumn(StringBuffer buf, DbAttribute dbAttr) { 60 if (dbAttr.getType() == Types.CHAR) { 61 buf.append(trimFunction).append("("); 62 super.processColumn(buf, dbAttr); 63 buf.append(')'); 64 } else { 65 super.processColumn(buf, dbAttr); 66 } 67 } 68 69 72 protected void processColumn( 73 StringBuffer buf, 74 DbAttribute dbAttr, 75 DbRelationship rel) { 76 if (dbAttr.getType() == Types.CHAR) { 77 buf.append(trimFunction).append("("); 78 super.processColumn(buf, dbAttr, rel); 79 buf.append(')'); 80 } else { 81 super.processColumn(buf, dbAttr, rel); 82 } 83 } 84 85 89 public String getTrimFunction() { 90 return trimFunction; 91 } 92 93 97 public void setTrimFunction(String trimFunction) { 98 this.trimFunction = trimFunction; 99 } 100 } 101 | Popular Tags |