1 29 30 package com.caucho.amber.query; 31 32 import java.sql.ResultSet; 33 import java.sql.SQLException; 34 35 import com.caucho.util.CharBuffer; 36 import com.caucho.util.L10N; 37 38 import com.caucho.amber.type.Type; 39 import com.caucho.amber.type.StringType; 40 41 import com.caucho.amber.entity.EntityItem; 42 43 import com.caucho.amber.connection.AmberConnectionImpl; 44 45 48 abstract public class AbstractAmberExpr implements AmberExpr { 49 private static final L10N L = new L10N(AbstractAmberExpr.class); 50 51 54 public boolean isBoolean() 55 { 56 return false; 57 } 58 59 62 public Type getType() 63 { 64 return StringType.create(); 65 } 66 67 70 public AmberExpr createBoolean() 71 throws QueryParseException 72 { 73 if (isBoolean()) 74 return this; 75 else 76 throw new QueryParseException(L.l("'{0}' can't be used as a boolean", 77 this)); 78 } 79 80 83 abstract public AmberExpr bindSelect(QueryParser parser); 84 85 88 public boolean usesFrom(FromItem from, int type) 89 { 90 return usesFrom(from, type, false); 91 } 92 93 96 public boolean usesFrom(FromItem from, int type, boolean isNot) 97 { 98 return false; 99 } 100 101 104 public AmberExpr replaceJoin(JoinExpr join) 105 { 106 return this; 107 } 108 109 112 public int getColumnCount() 113 { 114 return 1; 115 } 116 117 120 public void generateWhere(CharBuffer cb) 121 { 122 throw new UnsupportedOperationException(getClass().getName()); 123 } 124 125 128 public void generateJoin(CharBuffer cb) 129 { 130 generateWhere(cb); 131 } 132 133 136 public void generateSelect(CharBuffer cb) 137 { 138 generateWhere(cb); 139 } 140 141 144 public Object getObject(AmberConnectionImpl aConn, ResultSet rs, int index) 145 throws SQLException 146 { 147 return getType().getObject(aConn, rs, index); 148 } 149 150 153 public Object getCacheObject(AmberConnectionImpl aConn, 154 ResultSet rs, int index) 155 throws SQLException 156 { 157 return getObject(aConn, rs, index); 158 } 159 160 163 public EntityItem findItem(AmberConnectionImpl aConn, ResultSet rs, int index) 164 throws SQLException 165 { 166 return getType().findItem(aConn, rs, index); 167 } 168 } 169 | Popular Tags |