1 14 package org.compiere.model; 15 16 import java.util.*; 17 18 import org.compiere.util.*; 19 20 26 public class MCurrency extends X_C_Currency 27 { 28 33 public MCurrency (Properties ctx, int C_Currency_ID) 34 { 35 super (ctx, C_Currency_ID); 36 if (C_Currency_ID == 0) 37 { 38 setIsEMUMember (false); 39 setIsEuro (false); 40 setStdPrecision (0); 41 setCostingPrecision (0); 42 } 43 } 45 54 public MCurrency (Properties ctx, String ISO_Code, 55 String Description, String CurSymbol, int StdPrecision, int CostingPrecision) 56 { 57 super (ctx, 0); 58 setISO_Code(ISO_Code); 59 setDescription(Description); 60 setCurSymbol(CurSymbol); 61 setStdPrecision (StdPrecision); 62 setCostingPrecision (CostingPrecision); 63 setIsEMUMember (false); 64 setIsEuro (false); 65 } 67 68 69 private static CCache s_currencies = new CCache("currencies", 50); 70 71 77 public static MCurrency get (Properties ctx, int C_Currency_ID) 78 { 79 Integer key = new Integer (C_Currency_ID); 81 MCurrency retValue = (MCurrency)s_currencies.get(key); 82 if (retValue != null) 83 return retValue; 84 85 retValue = new MCurrency(ctx, C_Currency_ID); 87 if (retValue.getAD_Client_ID() == 0) 89 s_currencies.put(key, retValue); 90 return retValue; 91 } 93 99 public static String getISO_Code (Properties ctx, int C_Currency_ID) 100 { 101 String contextKey = "C_Currency_" + C_Currency_ID; 102 String retValue = ctx.getProperty(contextKey); 103 if (retValue != null) 104 return retValue; 105 106 MCurrency c = get(ctx, C_Currency_ID); 108 retValue = c.getISO_Code(); 109 ctx.setProperty(contextKey, retValue); 110 return retValue; 111 } 113 117 public String toString() 118 { 119 return "MCurrency[" + getC_Currency_ID() 120 + "-" + getISO_Code() + "-" + getCurSymbol() 121 + "," + getDescription() 122 + ",Precision=" + getStdPrecision() + "/" + getCostingPrecision(); 123 } 125 126 127 128 398 399 } | Popular Tags |