01: //$Id: MckoiCaseFragment.java 3890 2004-06-03 16:31:32Z steveebersole $
02: package org.hibernate.sql;
03:
04: import java.util.Iterator;
05: import java.util.Map;
06:
07: /**
08: * A Mckoi IF function.
09: * <br>
10: * <code>if(..., ..., ...) as ...</code>
11: * <br>
12: * @author Gavin King
13: */
14: public class MckoiCaseFragment extends CaseFragment {
15:
16: public String toFragmentString() {
17: StringBuffer buf = new StringBuffer(cases.size() * 15 + 10);
18: StringBuffer buf2 = new StringBuffer(cases.size());
19:
20: Iterator iter = cases.entrySet().iterator();
21: while (iter.hasNext()) {
22: Map.Entry me = (Map.Entry) iter.next();
23: buf.append(" if(").append(me.getKey()).append(
24: " is not null").append(", ").append(me.getValue())
25: .append(", ");
26: buf2.append(")");
27: }
28:
29: buf.append("null");
30: buf.append(buf2);
31: if (returnColumnName != null) {
32: buf.append(" as ").append(returnColumnName);
33: }
34:
35: return buf.toString();
36: }
37: }
|