1 package org.hibernate.sql; 3 4 import java.util.Iterator ; 5 import java.util.Map ; 6 7 15 public class DecodeCaseFragment extends CaseFragment { 16 17 public String toFragmentString() { 18 19 StringBuffer buf = new StringBuffer ( cases.size() * 15 + 10 ) 20 .append("decode("); 21 22 Iterator iter = cases.entrySet().iterator(); 23 while ( iter.hasNext() ) { 24 Map.Entry me = (Map.Entry ) iter.next(); 25 26 if ( iter.hasNext() ) { 27 buf.append(", ") 28 .append( me.getKey() ) 29 .append(", ") 30 .append( me.getValue() ); 31 } 32 else { 33 buf.insert( 7, me.getKey() ) 34 .append(", ") 35 .append( me.getValue() ); 36 } 37 } 38 39 buf.append(')'); 40 41 if (returnColumnName!=null) { 42 buf.append(" as ") 43 .append(returnColumnName); 44 } 45 46 return buf.toString(); 47 } 48 } | Popular Tags |