Author: adrianc
Date: Sat Apr 25 03:41:31 2009 New Revision: 768459 URL: http://svn.apache.org/viewvc?rev=768459&view=rev Log: Eliminated unnecessary method by using Apache Commons. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=768459&r1=768458&r2=768459&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Sat Apr 25 03:41:31 2009 @@ -585,23 +585,6 @@ return htmlSpecialChars(html, true, true, true); } - public static String fromHtmlToSpecialChars(String html, boolean doubleQuotes, boolean singleQuotes, boolean insertBR) { - html = StringUtil.replaceString(html, "&", "&"); - html = StringUtil.replaceString(html, "<", "<"); - html = StringUtil.replaceString(html, ">", ">"); - if (doubleQuotes) { - html = StringUtil.replaceString(html, """, "\""); - } - if (singleQuotes) { - html = StringUtil.replaceString(html, "'", "'"); - } - if (insertBR) { - html = StringUtil.replaceString(html, "<br>", "\n"); - } - html = html.replace(" ", " "); - return html; - } - /** * Remove/collapse multiple newline characters * Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=768459&r1=768458&r2=768459&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java Sat Apr 25 03:41:31 2009 @@ -25,10 +25,10 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.xml.serialize.OutputFormat; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.FileUtil; -import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -76,10 +76,10 @@ } Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument); - propertyElem.setAttribute("key", StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKey(), true, true, false)); + propertyElem.setAttribute("key", StringEscapeUtils.unescapeHtml(labelInfo.getLabelKey())); if (UtilValidate.isNotEmpty(labelInfo.getLabelKeyComment())) { - Comment labelKeyComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelInfo.getLabelKeyComment(), true, true, false)); + Comment labelKeyComment = resourceDocument.createComment(StringEscapeUtils.unescapeHtml(labelInfo.getLabelKeyComment())); Node parent = propertyElem.getParentNode(); parent.insertBefore(labelKeyComment, propertyElem); } @@ -91,14 +91,14 @@ valueString = labelValue.getLabelValue(); } if (UtilValidate.isNotEmpty(valueString)) { - valueString = StringUtil.fromHtmlToSpecialChars(valueString, true, true, true); + valueString = StringEscapeUtils.unescapeHtml(valueString); Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", valueString, resourceDocument);; valueElem.setAttribute("xml:lang", localeFound); if (valueString.trim().length() == 0) { valueElem.setAttribute("xml:space", "preserve"); } if (UtilValidate.isNotEmpty(labelValue.getLabelComment())) { - Comment labelComment = resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelValue.getLabelComment(), true, true, false)); + Comment labelComment = resourceDocument.createComment(StringEscapeUtils.unescapeHtml(labelValue.getLabelComment())); Node parent = valueElem.getParentNode(); parent.insertBefore(labelComment, valueElem); } |
Free forum by Nabble | Edit this page |