svn commit: r585658 - in /ofbiz/trunk/framework/base/src/base/org/ofbiz/base: config/ util/ util/collections/ util/string/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r585658 - in /ofbiz/trunk/framework/base/src/base/org/ofbiz/base: config/ util/ util/collections/ util/string/

doogie-3
Author: doogie
Date: Wed Oct 17 13:07:09 2007
New Revision: 585658

URL: http://svn.apache.org/viewvc?rev=585658&view=rev
Log:
Switch all internal uses of StringBuffer over to StringBuilder; the
latter is unsynchronized, so is faster when there are no multi-
threaded concerns.  Closes
https://issues.apache.org/jira/browse/OFBIZ-1329

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/config/ResourceLoader.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilXml.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapStack.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/config/ResourceLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/config/ResourceLoader.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/config/ResourceLoader.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/config/ResourceLoader.java Wed Oct 17 13:07:09 2007
@@ -177,7 +177,7 @@
      * @return
      */
     public String fullLocation(String location) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
 
         if (envName != null && envName.length() > 0) {
             String propValue = System.getProperty(envName);

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java Wed Oct 17 13:07:09 2007
@@ -163,7 +163,7 @@
                 }
                 logger.log(callingClass, levelObjs[level], msg, t);
             } else {
-                StringBuffer prefixBuf = new StringBuffer();
+                StringBuilder prefixBuf = new StringBuilder();
 
                 prefixBuf.append(dateFormat.format(new java.util.Date()));
                 prefixBuf.append(" [OFBiz");

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java Wed Oct 17 13:07:09 2007
@@ -240,7 +240,7 @@
                     i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength);
                     requestLength -= i;
                     newLine = new String(line, 0, i);
-                    StringBuffer fieldValue = new StringBuffer(BUFFER_SIZE);
+                    StringBuilder fieldValue = new StringBuilder(BUFFER_SIZE);
 
                     while (requestLength > 0/* i != -1*/ && !newLine.startsWith(boundary)) {
                         // The last line of the field

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java Wed Oct 17 13:07:09 2007
@@ -154,7 +154,7 @@
 
     public static String certToString(Certificate cert) throws CertificateEncodingException {
         byte[] certBuf = cert.getEncoded();
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append("-----BEGIN CERTIFICATE-----\n");
         buf.append(new String(Base64.encodeBase64Chunked(certBuf)));
         buf.append("\n-----END CERTIFICATE-----\n");

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java Wed Oct 17 13:07:09 2007
@@ -67,7 +67,7 @@
 
         if (i < 0) return mainString;
 
-        StringBuffer mainSb = new StringBuffer(mainString);
+        StringBuilder mainSb = new StringBuilder(mainString);
 
         while (i >= 0) {
             mainSb.replace(i, i + oldString.length(), newString);
@@ -85,7 +85,7 @@
     public static String join(List list, String delim) {
         if (list == null || list.size() < 1)
             return null;
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         Iterator i = list.iterator();
 
         while (i.hasNext()) {
@@ -197,7 +197,7 @@
      */
     public static String mapToStr(Map map) {
         if (map == null) return null;
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         Set keySet = map.keySet();
         Iterator i = keySet.iterator();
         boolean first = true;
@@ -319,7 +319,7 @@
     public static String cleanUpPathPrefix(String prefix) {
         if (prefix == null || prefix.length() == 0) return "";
 
-        StringBuffer cppBuff = new StringBuffer(prefix.replace('\\', '/'));
+        StringBuilder cppBuff = new StringBuilder(prefix.replace('\\', '/'));
 
         if (cppBuff.charAt(0) != '/') {
             cppBuff.insert(0, '/');
@@ -336,7 +336,7 @@
     }
 
     public static String toHexString(byte[] bytes) {
-        StringBuffer buf = new StringBuffer(bytes.length * 2);
+        StringBuilder buf = new StringBuilder(bytes.length * 2);
         for (int i = 0; i < bytes.length; i++) {
             buf.append(hexChar[(bytes[i] & 0xf0) >>> 4]);
             buf.append(hexChar[bytes[i] & 0x0f]);
@@ -346,7 +346,7 @@
     }
 
     public static String cleanHexString(String str) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for (int i = 0; i < str.length(); i++) {
             if (str.charAt(i) != 32 && str.charAt(i) != ':') {
                 buf.append(str.charAt(i));
@@ -431,7 +431,7 @@
     }
     
     public static String padNumberString(String numberString, int targetMinLength) {
-        StringBuffer outStrBfr = new StringBuffer(numberString);
+        StringBuilder outStrBfr = new StringBuilder(numberString);
         while (targetMinLength > outStrBfr.length()) {
             outStrBfr.insert(0, '0');
         }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java Wed Oct 17 13:07:09 2007
@@ -118,7 +118,7 @@
 
         Map uiDateTimeMap = UtilProperties.getResourceBundleMap("DateTimeLabels", locale);
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         for (int i = parts.size() - 1; i >= 0 && count > 0; i--) {
             if (sb.length() > 0) sb.append(", ");
             Double D = (Double) parts.get(i);

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java Wed Oct 17 13:07:09 2007
@@ -635,7 +635,7 @@
 
     /** URL Encodes a Map of arguements */
     public static String urlEncodeArgs(Map args, boolean useExpandedEntites) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         if (args != null) {
             Iterator i = args.entrySet().iterator();
             while (i.hasNext()) {
@@ -677,7 +677,7 @@
     }
 
     public static String encodeAmpersands(String htmlString) {
-        StringBuffer htmlBuffer = new StringBuffer(htmlString);
+        StringBuilder htmlBuffer = new StringBuilder(htmlString);
         int ampLoc = -1;
         while ((ampLoc = htmlBuffer.indexOf("&", ampLoc + 1)) != -1) {
             //NOTE: this should work fine, but if it doesn't could try making sure all characters between & and ; are letters, that would qualify as an entity
@@ -878,7 +878,7 @@
         String retStr = null;
         if (UtilValidate.isNotEmpty(queryString)) {
             StringTokenizer queryTokens = new StringTokenizer(queryString, "&");
-            StringBuffer cleanQuery = new StringBuffer();
+            StringBuilder cleanQuery = new StringBuilder();
             while (queryTokens.hasMoreTokens()) {
                 String token = queryTokens.nextToken();
                 if (token.startsWith("amp;")) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java Wed Oct 17 13:07:09 2007
@@ -164,7 +164,7 @@
     }
 
     public static String printMap(Map theMap) {
-        StringBuffer theBuf = new StringBuffer();
+        StringBuilder theBuf = new StringBuilder();
         Iterator entryIter = theMap.entrySet().iterator();
         while (entryIter.hasNext()) {
             Map.Entry entry = (Map.Entry) entryIter.next();
@@ -744,7 +744,7 @@
             if (realMapIfNeeded != null) {
                 return realMapIfNeeded.toString();
             } else {
-                StringBuffer outString = new StringBuffer("{");
+                StringBuilder outString = new StringBuilder("{");
                 for (int i = 0; i < names.length; i++) {
                     if (i > 0) outString.append(',');
                     outString.append('{');

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java Wed Oct 17 13:07:09 2007
@@ -102,7 +102,7 @@
             if (index.length == 1) {
                 return name[index[0]];
             } else {
-                StringBuffer nameBuf = new StringBuffer();
+                StringBuilder nameBuf = new StringBuilder();
                 for (int i = 0; i < index.length; i++) {
                     if (nameBuf.length() > 0) {
                         nameBuf.append(" ");

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java Wed Oct 17 13:07:09 2007
@@ -175,7 +175,7 @@
     public String timerString(int level, String message) {
         // String retString =  "[[" + message + ": seconds since start: " + secondsSinceStart() + ",since last(" + lastMessage + "):" + secondsSinceLast() + "]]";
 
-        StringBuffer retStringBuf = new StringBuffer();
+        StringBuilder retStringBuf = new StringBuilder();
 
         for (int i = 0; i < level; i++) {
             retStringBuf.append("| ");

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilXml.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilXml.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilXml.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilXml.java Wed Oct 17 13:07:09 2007
@@ -492,7 +492,7 @@
 
         if (textNode == null) return null;
 
-        StringBuffer valueBuffer = new StringBuffer();
+        StringBuilder valueBuffer = new StringBuilder();
         do {
             if (textNode.getNodeType() == Node.CDATA_SECTION_NODE || textNode.getNodeType() == Node.TEXT_NODE) {
                 valueBuffer.append(textNode.getNodeValue());

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java Wed Oct 17 13:07:09 2007
@@ -296,7 +296,7 @@
     }
 
     public String toString() {
-        StringBuffer retVal = new StringBuffer();
+        StringBuilder retVal = new StringBuilder();
         Set keySet = keySet();
         Iterator keys = keySet.iterator();
 

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapStack.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapStack.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapStack.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapStack.java Wed Oct 17 13:07:09 2007
@@ -348,7 +348,7 @@
     }
     
     public String toString() {
-        StringBuffer fullMapString = new StringBuffer();
+        StringBuilder fullMapString = new StringBuilder();
         int curLevel = 0;
         Iterator stackIter = this.stackList.iterator();
         while (stackIter.hasNext()) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=585658&r1=585657&r2=585658&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java Wed Oct 17 13:07:09 2007
@@ -98,7 +98,7 @@
      * @return The original String expanded by replacing varaible place holders.
      */    
     public String expandString(Map context, Locale locale) {
-        StringBuffer expanded = new StringBuffer();
+        StringBuilder expanded = new StringBuilder();
         
         Iterator stringElementIter = stringElements.iterator();
         while (stringElementIter.hasNext()) {
@@ -196,7 +196,7 @@
             }
         }
 
-        StringBuffer expanded = new StringBuffer();
+        StringBuilder expanded = new StringBuilder();
         // TODO: for performance to save object build up and tear down times we should use Javolution to make OnTheFlyHandler reusable and use a factory methods instead of constructor
         ParseElementHandler handler = new OnTheFlyHandler(expanded, context, timeZone, locale);
         parseString(original, handler);
@@ -256,7 +256,7 @@
     }
 
     public static interface StringElement extends Serializable {
-        public void appendElement(StringBuffer buffer, Map context, Locale locale);
+        public void appendElement(StringBuilder buffer, Map context, Locale locale);
     }
     
     public static class ConstantElement implements StringElement {
@@ -266,7 +266,7 @@
             this.value = value;
         }
         
-        public void appendElement(StringBuffer buffer, Map context, Locale locale) {
+        public void appendElement(StringBuilder buffer, Map context, Locale locale) {
             buffer.append(this.value);
         }
     }
@@ -278,7 +278,7 @@
             this.scriptlet = scriptlet;
         }
         
-        public void appendElement(StringBuffer buffer, Map context, Locale locale) {
+        public void appendElement(StringBuilder buffer, Map context, Locale locale) {
             try {
                 Object scriptResult = BshUtil.eval(scriptlet, context);
                 if (scriptResult != null) {
@@ -298,7 +298,7 @@
             this.fma = new FlexibleMapAccessor(valueName);
         }
         
-        public void appendElement(StringBuffer buffer, Map context, Locale locale) {
+        public void appendElement(StringBuilder buffer, Map context, Locale locale) {
             Object retVal = fma.get(context, locale);
             if (retVal != null) {
                 buffer.append(retVal.toString());
@@ -340,12 +340,12 @@
     }
     
     public static class OnTheFlyHandler implements ParseElementHandler {
-        protected StringBuffer targetBuffer;
+        protected StringBuilder targetBuffer;
         protected Map context;
         protected Locale locale;
         protected TimeZone timeZone;
         
-        public OnTheFlyHandler(StringBuffer targetBuffer, Map context, TimeZone timeZone, Locale locale) {
+        public OnTheFlyHandler(StringBuilder targetBuffer, Map context, TimeZone timeZone, Locale locale) {
             this.targetBuffer = targetBuffer;
             this.context = context;
             this.timeZone = timeZone;