}
@Override
public void addSQL(StringBuilder sql, long context)
{
DBDatabaseDriver driver = getDatabase().getDriver();
StringBuilder inner = new StringBuilder();
// Generate parts
for (Iterator<?> i = valueMap.keySet().iterator(); i.hasNext();)
{
Object key = i.next();
Object val = valueMap.get(key);
String part = driver.getSQLPhrase(DBDatabaseDriver.SQL_FUNC_DECODE_PART);
part = StringUtils.replaceAll(part, "{0}", getObjectValue(expr.getDataType(), key, DBExpr.CTX_DEFAULT, ""));
part = StringUtils.replaceAll(part, "{1}", getObjectValue(this.getDataType(), val, DBExpr.CTX_DEFAULT, ""));
inner.append(driver.getSQLPhrase(DBDatabaseDriver.SQL_FUNC_DECODE_SEP));
inner.append(part);
}
// Generate other
if (elseExpr != null)
{ // Else
String other = driver.getSQLPhrase(DBDatabaseDriver.SQL_FUNC_DECODE_ELSE);
other = StringUtils.replaceAll(other, "{0}", getObjectValue(getDataType(), elseExpr, DBExpr.CTX_DEFAULT, ""));
inner.append(driver.getSQLPhrase(DBDatabaseDriver.SQL_FUNC_DECODE_SEP));
inner.append(other);
}
DBValueExpr param = new DBValueExpr(getDatabase(), inner, DataType.UNKNOWN);
// Set Params
String template = driver.getSQLPhrase(DBDatabaseDriver.SQL_FUNC_DECODE);
super.addSQL(sql, template, new Object[] { param }, context);
}