package com.yc.utils; /** * @author 沈奕洲 * 2011-11-16 * */ import java.text.DecimalFormat; import java.util.Map; public class MapSet { public static String ck_select(String sValue,String sDefault) { //下拉 String str=""; if (sValue.equalsIgnoreCase(sDefault)){ str=" Selected "; } ////System.out.println(sValue+"="+sDefault+"?"); return str; } public static String cb_Check(String sA,String sB){ String sChecked=""; if(sA.equalsIgnoreCase(sB)){ sChecked=" Checked "; } return sChecked; } /** * 显示网页结果 * @param o Map * @return 如果非null,则显示相应字符串,否则,"" */ public static String ShowMap(Object o){ String sDef=""; if(o!=null){ sDef=o.toString(); } return sDef; } public static String ShowMap(Map rowMap, String sKey){ String sDef=""; if((rowMap!=null)&&(sKey!=null)&&(!sKey.equals(""))){ if(rowMap.get(sKey)!=null){ sDef=rowMap.get(sKey).toString().trim(); //System.out.println("value:"+sDef); } } return sDef; } //格式化显示日期格式 bDate 为true:只显式年月日 else 显示全部 public static String ShowMap(Map rowMap, String sKey,int bDate){ String sDef=""; if((rowMap!=null)&&(sKey!=null)&&(!sKey.equals(""))){ if(rowMap.get(sKey)!=null){ if(bDate==0){ sDef=DateChange.formatDate(rowMap.get(sKey).toString()); } else if(bDate==1) { sDef=DateChange.parseFormatDateTime_str(rowMap.get(sKey).toString()); } else{ sDef=rowMap.get(sKey).toString(); } } } return sDef; } //格式化显示数量格式 sType==Money显示货币格式 sType==SL 显示数量 // if sType==sValue 不显示 public static String ShowMap(Map rowMap, String sKey,String sType){ String sDef=""; if((rowMap!=null)&&(sKey!=null)&&(!sKey.equals(""))){ if(rowMap.get(sKey)!=null){ if(sType=="Money" || sType.equals("Money")){ DecimalFormat format= new DecimalFormat("####.00"); //DecimalFormat format=new DecimalFormat(); //format.setMinimumFractionDigits(0); sDef=format.format(rowMap.get(sKey)); // System.out.println(sDef); }else{ DecimalFormat format= new DecimalFormat("####.00"); //DecimalFormat format=new DecimalFormat(); //format.setMinimumFractionDigits(0); sDef=format.format(rowMap.get(sKey).toString()); // sDef=format.format(rowMap.get(sKey)); // System.out.println(sDef); } } } return sDef; } }