KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > sql > CaseFragment


1 //$Id: CaseFragment.java,v 1.2 2004/07/23 05:30:26 steveebersole Exp $
2
package org.hibernate.sql;
3
4 import java.util.Map JavaDoc;
5
6 import org.hibernate.util.StringHelper;
7
8 import org.apache.commons.collections.SequencedHashMap;
9
10 /**
11  * Abstract SQL case fragment renderer
12  *
13  * @author Gavin King, Simon Harris
14  */

15 public abstract class CaseFragment {
16     public abstract String JavaDoc toFragmentString();
17
18     protected String JavaDoc returnColumnName;
19
20     protected Map JavaDoc cases = new SequencedHashMap();
21
22     public CaseFragment setReturnColumnName(String JavaDoc returnColumnName) {
23         this.returnColumnName = returnColumnName;
24         return this;
25     }
26
27     public CaseFragment setReturnColumnName(String JavaDoc returnColumnName, String JavaDoc suffix) {
28         return setReturnColumnName( new Alias(suffix).toAliasString(returnColumnName) );
29     }
30
31     public CaseFragment addWhenColumnNotNull(String JavaDoc alias, String JavaDoc columnName, String JavaDoc value) {
32         cases.put( StringHelper.qualify(alias, columnName), value );
33         return this;
34     }
35 }
36
Popular Tags