IDEMPIERE-738 Reduce duplicate string reported by Eclipse Memory Analyzer
This commit is contained in:
parent
cd1ee182ed
commit
cda5dd6e20
|
@ -70,6 +70,9 @@ public final class Msg
|
||||||
private CCache<String,CCache<String,String>> m_languages
|
private CCache<String,CCache<String,String>> m_languages
|
||||||
= new CCache<String,CCache<String,String>>(null, "msg_lang", 2, 0, false);
|
= new CCache<String,CCache<String,String>>(null, "msg_lang", 2, 0, false);
|
||||||
|
|
||||||
|
private CCache<String,CCache<String,String>> m_elementCache
|
||||||
|
= new CCache<String,CCache<String,String>>(null, "msg_element", 2, 0, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Language specific Message Map
|
* Get Language specific Message Map
|
||||||
* @param ad_language Language Key
|
* @param ad_language Language Key
|
||||||
|
@ -95,6 +98,21 @@ public final class Msg
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getMsgMap
|
} // getMsgMap
|
||||||
|
|
||||||
|
private CCache<String,String> getElementMap (String ad_language)
|
||||||
|
{
|
||||||
|
String AD_Language = ad_language;
|
||||||
|
if (AD_Language == null || AD_Language.length() == 0)
|
||||||
|
AD_Language = Language.getBaseAD_Language();
|
||||||
|
// Do we have the language ?
|
||||||
|
CCache<String,String> retValue = (CCache<String,String>)m_elementCache.get(AD_Language);
|
||||||
|
if (retValue != null && retValue.size() > 0)
|
||||||
|
return retValue;
|
||||||
|
|
||||||
|
retValue = new CCache<String, String>("element", 100);
|
||||||
|
m_elementCache.put(AD_Language, retValue);
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init message HashMap.
|
* Init message HashMap.
|
||||||
|
@ -466,32 +484,28 @@ public final class Msg
|
||||||
if (AD_Language == null || AD_Language.length() == 0)
|
if (AD_Language == null || AD_Language.length() == 0)
|
||||||
AD_Language = Language.getBaseAD_Language();
|
AD_Language = Language.getBaseAD_Language();
|
||||||
|
|
||||||
|
Msg msg = get();
|
||||||
|
CCache<String, String> cache = msg.getElementMap(AD_Language);
|
||||||
|
String key = ColumnName+"|"+isSOTrx;
|
||||||
|
String retStr = cache.get(key);
|
||||||
|
if (retStr != null)
|
||||||
|
return retStr;
|
||||||
|
|
||||||
// Check AD_Element
|
// Check AD_Element
|
||||||
String retStr = "";
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try
|
if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Element"))
|
||||||
|
pstmt = DB.prepareStatement("SELECT Name, PO_Name FROM AD_Element WHERE UPPER(ColumnName)=?", null);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Element"))
|
pstmt = DB.prepareStatement("SELECT t.Name, t.PO_Name FROM AD_Element_Trl t, AD_Element e "
|
||||||
pstmt = DB.prepareStatement("SELECT Name, PO_Name FROM AD_Element WHERE UPPER(ColumnName)=?", null);
|
+ "WHERE t.AD_Element_ID=e.AD_Element_ID AND UPPER(e.ColumnName)=? "
|
||||||
else
|
+ "AND t.AD_Language=?", null);
|
||||||
{
|
pstmt.setString(2, AD_Language);
|
||||||
pstmt = DB.prepareStatement("SELECT t.Name, t.PO_Name FROM AD_Element_Trl t, AD_Element e "
|
|
||||||
+ "WHERE t.AD_Element_ID=e.AD_Element_ID AND UPPER(e.ColumnName)=? "
|
|
||||||
+ "AND t.AD_Language=?", null);
|
|
||||||
pstmt.setString(2, AD_Language);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return ColumnName;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
DB.close(rs);
|
|
||||||
rs = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pstmt.setString(1, ColumnName.toUpperCase());
|
pstmt.setString(1, ColumnName.toUpperCase());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -515,8 +529,11 @@ public final class Msg
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null; pstmt = null;
|
rs = null; pstmt = null;
|
||||||
}
|
}
|
||||||
if (retStr != null)
|
if (retStr != null) {
|
||||||
return retStr.trim();
|
retStr = retStr.trim();
|
||||||
|
cache.put(key, retStr);
|
||||||
|
return retStr;
|
||||||
|
}
|
||||||
return retStr;
|
return retStr;
|
||||||
} // getElement
|
} // getElement
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,8 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
MTreeNode mNode = (MTreeNode) sNode.getData();
|
MTreeNode mNode = (MTreeNode) sNode.getData();
|
||||||
treeValues[i] = mNode.getName();
|
treeValues[i] = mNode.getName();
|
||||||
treeDescription[i] = mNode.getDescription();
|
treeDescription[i] = mNode.getDescription();
|
||||||
treeImages[i] = mNode.getImagePath();
|
String imagePath = mNode.getImagePath();
|
||||||
|
treeImages[i] = imagePath != null ? imagePath.intern() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
image = element.getImage();
|
image = element.getImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return image;
|
return image != null ? image.intern() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue