IDEMPIERE-308 Performance: Replace with StringBuilder / some classes revisited to make them safer against NPE

This commit is contained in:
Richard Morales 2012-10-12 18:10:46 -05:00
parent 655dec54b0
commit ff9384f32e
6 changed files with 12 additions and 12 deletions

View File

@ -249,7 +249,7 @@ public class ImmediateBankTransfer extends SvrProcess
MCash cash = createCash(); MCash cash = createCash();
MCashLine cashLines[]= createCashLines(cash); MCashLine cashLines[]= createCashLines(cash);
StringBuilder processMsg = new StringBuilder(cash.getDocumentNo()); StringBuilder processMsg = new StringBuilder().append(cash.getDocumentNo());
cash.setDocAction(p_docAction); cash.setDocAction(p_docAction);
if (!cash.processIt(p_docAction)) if (!cash.processIt(p_docAction))

View File

@ -90,7 +90,7 @@ public class ImportOrder extends SvrProcess
{ {
StringBuilder sql = null; StringBuilder sql = null;
int no = 0; int no = 0;
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID; StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
// **** Prepare **** // **** Prepare ****

View File

@ -77,7 +77,7 @@ public class ProjectPhaseGenOrder extends SvrProcess
{ {
MOrderLine ol = new MOrderLine(order); MOrderLine ol = new MOrderLine(order);
ol.setLine(fromPhase.getSeqNo()); ol.setLine(fromPhase.getSeqNo());
StringBuilder sb = new StringBuilder (fromPhase.getName()); StringBuilder sb = new StringBuilder ().append(fromPhase.getName());
if (fromPhase.getDescription() != null && fromPhase.getDescription().length() > 0) if (fromPhase.getDescription() != null && fromPhase.getDescription().length() > 0)
sb.append(" - ").append(fromPhase.getDescription()); sb.append(" - ").append(fromPhase.getDescription());
ol.setDescription(sb.toString()); ol.setDescription(sb.toString());
@ -122,7 +122,7 @@ public class ProjectPhaseGenOrder extends SvrProcess
{ {
MOrderLine ol = new MOrderLine(order); MOrderLine ol = new MOrderLine(order);
ol.setLine(tasks[i].getSeqNo()); ol.setLine(tasks[i].getSeqNo());
StringBuilder sb = new StringBuilder (tasks[i].getName()); StringBuilder sb = new StringBuilder ().append(tasks[i].getName());
if (tasks[i].getDescription() != null && tasks[i].getDescription().length() > 0) if (tasks[i].getDescription() != null && tasks[i].getDescription().length() > 0)
sb.append(" - ").append(tasks[i].getDescription()); sb.append(" - ").append(tasks[i].getDescription());
ol.setDescription(sb.toString()); ol.setDescription(sb.toString());

View File

@ -746,7 +746,7 @@ public class RequestEMailProcessor extends SvrProcess
String deliveryMessage = null; String deliveryMessage = null;
if (content instanceof InputStream) if (content instanceof InputStream)
{ {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
InputStream is = (InputStream)content; InputStream is = (InputStream)content;
int c; int c;
while ((c = is.read()) != -1) while ((c = is.read()) != -1)

View File

@ -337,7 +337,7 @@ public class PromotionRule {
//optional promotion code filter //optional promotion code filter
String promotionCode = (String)order.get_Value("PromotionCode"); String promotionCode = (String)order.get_Value("PromotionCode");
StringBuffer sql = new StringBuffer(); StringBuilder sql = new StringBuilder();
sql.append(select) sql.append(select)
.append(" WHERE") .append(" WHERE")
.append(" (" + bpFilter + ")") .append(" (" + bpFilter + ")")

View File

@ -270,12 +270,12 @@ public class MDistribution extends X_GL_Distribution
*/ */
public String validate() public String validate()
{ {
StringBuilder retValue = null; String retValue = null;
getLines(true); getLines(true);
if (m_lines.length == 0) if (m_lines.length == 0)
retValue = new StringBuilder("@NoLines@"); retValue = "@NoLines@";
else if (getPercentTotal().compareTo(Env.ONEHUNDRED) != 0) else if (getPercentTotal().compareTo(Env.ONEHUNDRED) != 0)
retValue = new StringBuilder("@PercentTotal@ <> 100"); retValue = "@PercentTotal@ <> 100";
else else
{ {
// More then one line with 0 // More then one line with 0
@ -286,8 +286,8 @@ public class MDistribution extends X_GL_Distribution
{ {
if (lineFound >= 0 && m_lines[i].getPercent().compareTo(Env.ZERO) == 0) if (lineFound >= 0 && m_lines[i].getPercent().compareTo(Env.ZERO) == 0)
{ {
retValue = new StringBuilder("@Line@ ").append(lineFound) retValue = "@Line@ " + lineFound
.append(" + ").append(m_lines[i].getLine()).append(": == 0"); + " + " + m_lines[i].getLine() + ": == 0";
break; break;
} }
lineFound = m_lines[i].getLine(); lineFound = m_lines[i].getLine();
@ -296,7 +296,7 @@ public class MDistribution extends X_GL_Distribution
} }
setIsValid (retValue == null); setIsValid (retValue == null);
return retValue.toString(); return retValue;
} // validate } // validate