直接上代碼:
1 /* 2 * 獲取LOV的值和描述/本地化值:key=val,val=描述/本地化值 如果描述沒有,則本地化值/值作為描述 3 */ 4 public static Map<String, String> GetLovValLocalVal(TCSession session,String lovId) { 5 try { 6 TcUtilsLovInfo lovinfo = GetLovInfo(session, lovId); 7 if (lovinfo != null) { 8 // 使用LinkedHashMap保證獲取的Lov順序 9 Map<String, String> lovs = new LinkedHashMap<String, String>();10 for (int i = 0; i < lovinfo.vals.length; i++) {11 String key = lovinfo.vals[i];12 String val = key;13 boolean hasDesc = false;14 if (lovinfo.descriptions.length > i) {15 // 描述不能為空16 if (!lovinfo.descriptions[i].trim().isEmpty()) {17 val = lovinfo.descriptions[i];18 hasDesc = true;19 }20 }21 if (!hasDesc) {22 // 本地化值不能為空23 if (!lovinfo.displayNames[i].trim().isEmpty()) {24 val = lovinfo.displayNames[i];25 hasDesc = true;26 }27 }28 lovs.put(key, val);29 }30 return lovs;31 }32 33 } catch (Exception ex) {34 ex.printStackTrace();35 }36 return null;37 }38 39 private static TcUtilsLovInfo GetLovInfo(TCSession session, String lovId) {40 TcUtilsLovInfo lovinfo = null;41 try {42 TCComponentListOfValuesType componentType = (TCComponentListOfValuesType) session43 .getTypeComponent("ListOfValues");44 TCComponentListOfValues componentValues[] = componentType45 .find(lovId);46 if (componentValues != null && componentValues.length > 0) {47 TCComponentListOfValues compLov = componentValues[0];48 ListOfValuesInfo info = compLov.getListOfValues();49 String[] values = info.getStringListOfValues();50 String[] des = info.getDescriptions();51 String[] display = info.getLOVDisplayValues();52 String[] fullNames = info.getValuesFullNames();53 String[] displayDes = info.getDispDescription();54 55 lovinfo = new TcUtilsLovInfo();56 lovinfo.descriptions = des;57 lovinfo.fullNames = fullNames;58 lovinfo.vals = values;59 lovinfo.displayNames = display;60 lovinfo.displayDescriptions = displayDes;61 }62 63 } catch (TCException ex) {64 ex.printStackTrace();65 }66 return lovinfo;67 }完畢.
轉載于:https://www.cnblogs.com/zhoulian/p/9429285.html