1 56 57 package org.objectstyle.cayenne.access.trans; 58 59 import java.sql.Types ; 60 61 import org.objectstyle.cayenne.map.DbAttribute; 62 import org.objectstyle.cayenne.map.DbRelationship; 63 64 71 public class TrimmingQualifierTranslator extends QualifierTranslator { 72 73 protected String trimFunction; 74 75 78 protected TrimmingQualifierTranslator() { 79 super(); 80 } 81 82 85 public TrimmingQualifierTranslator( 86 QueryAssembler queryAssembler, 87 String trimFunction) { 88 super(queryAssembler); 89 this.trimFunction = trimFunction; 90 } 91 92 95 protected void processColumn(StringBuffer buf, DbAttribute dbAttr) { 96 if (dbAttr.getType() == Types.CHAR) { 97 buf.append(trimFunction).append("("); 98 super.processColumn(buf, dbAttr); 99 buf.append(')'); 100 } else { 101 super.processColumn(buf, dbAttr); 102 } 103 } 104 105 108 protected void processColumn( 109 StringBuffer buf, 110 DbAttribute dbAttr, 111 DbRelationship rel) { 112 if (dbAttr.getType() == Types.CHAR) { 113 buf.append(trimFunction).append("("); 114 super.processColumn(buf, dbAttr, rel); 115 buf.append(')'); 116 } else { 117 super.processColumn(buf, dbAttr, rel); 118 } 119 } 120 121 125 public String getTrimFunction() { 126 return trimFunction; 127 } 128 129 133 public void setTrimFunction(String trimFunction) { 134 this.trimFunction = trimFunction; 135 } 136 } | Popular Tags |