← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20626: Using StringBuilder instead of StringBuffer

 

------------------------------------------------------------
revno: 20626
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-10-12 11:40:12 +0200
message:
  Using StringBuilder instead of StringBuffer
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2015-09-22 07:35:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2015-10-12 09:40:12 +0000
@@ -408,14 +408,14 @@
      */
     public static String getPrettyColumnName( List<NameableObject> objects )
     {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder builder = new StringBuilder();
 
         for ( NameableObject object : objects )
         {
-            buffer.append( object != null ? (object.getShortName() + SPACE) : EMPTY );
+            builder.append( object != null ? (object.getShortName() + SPACE) : EMPTY );
         }
 
-        return buffer.length() > 0 ? buffer.substring( 0, buffer.lastIndexOf( SPACE ) ) : TOTAL_COLUMN_PRETTY_NAME;
+        return builder.length() > 0 ? builder.substring( 0, builder.lastIndexOf( SPACE ) ) : TOTAL_COLUMN_PRETTY_NAME;
     }
 
     /**

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java	2015-09-23 14:00:30 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/HsqlStatementBuilder.java	2015-10-12 09:40:12 +0000
@@ -166,7 +166,7 @@
     @Override
     public String queryDataElementStructureForOrgUnit()
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
         
         sqlsb.append( "(SELECT DISTINCT de.dataelementid, (de.name || ' ' || cc.name) AS DataElement " );
         sqlsb.append( "FROM dataelement AS de " );
@@ -180,7 +180,7 @@
     @Override
     public String queryRawDataElementsForOrgUnitBetweenPeriods(Integer orgUnitId, List<Integer> betweenPeriodIds)
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
 
         int i = 0;
         

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2015-09-23 14:00:30 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java	2015-10-12 09:40:12 +0000
@@ -172,7 +172,7 @@
     @Override
     public String queryDataElementStructureForOrgUnit()
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
         
         sqlsb.append( "(SELECT DISTINCT de.dataelementid, concat(de.name, \" \", cc.name) AS DataElement " );
         sqlsb.append( "FROM dataelement AS de " );
@@ -186,7 +186,7 @@
     @Override
     public String queryRawDataElementsForOrgUnitBetweenPeriods(Integer orgUnitId, List<Integer> betweenPeriodIds)
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
 
         int i = 0;
         

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2015-09-23 14:00:30 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java	2015-10-12 09:40:12 +0000
@@ -190,7 +190,7 @@
     @Override
     public String queryDataElementStructureForOrgUnit()
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
         
         sqlsb.append( "(SELECT DISTINCT de.dataelementid, (de.name || ' ' || cc.name) AS DataElement " );
         sqlsb.append( "FROM dataelement AS de " );
@@ -204,7 +204,7 @@
     @Override
     public String queryRawDataElementsForOrgUnitBetweenPeriods(Integer orgUnitId, List<Integer> betweenPeriodIds)
     {
-        StringBuffer sqlsb = new StringBuffer();
+        StringBuilder sqlsb = new StringBuilder();
 
         int i = 0;
         

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2015-09-14 18:06:48 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2015-10-12 09:40:12 +0000
@@ -919,7 +919,7 @@
     @Override
     public String toString()
     {
-        StringBuffer buffer = new StringBuffer( "[\n" );
+        StringBuilder builder = new StringBuilder( "[\n" );
 
         if ( headers != null && headers.size() > 0 )
         {
@@ -930,15 +930,15 @@
                 headerNames.add( header.getName() );
             }
 
-            buffer.append( headerNames ).append( "\n" );
+            builder.append( headerNames ).append( "\n" );
         }
 
         for ( List<Object> row : grid )
         {
-            buffer.append( row ).append( "\n" );
+            builder.append( row ).append( "\n" );
         }
 
-        return buffer.append( "]" ).toString();
+        return builder.append( "]" ).toString();
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	2015-02-23 11:48:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	2015-10-12 09:40:12 +0000
@@ -95,7 +95,7 @@
     {
         File cacheManifest = null;
         File i18nFolder = null;
-        StringBuffer stringBuffer = null;
+        StringBuilder builder = null;
         
         String locale = localeManager.getCurrentLocale().toString();
         
@@ -140,15 +140,15 @@
         {
             try ( BufferedReader bufferedReader = new BufferedReader( new FileReader( cacheManifest ) ) )
             {
-                stringBuffer = new StringBuffer();
+                builder = new StringBuilder();
                 String line;
                 while ( (line = bufferedReader.readLine()) != null )
                 {
-                    stringBuffer.append( line );
-                    stringBuffer.append( "\n" );
+                    builder.append( line );
+                    builder.append( "\n" );
                 }
-                stringBuffer.append( revisionTag );
-                stringBuffer.append( "\n" );
+                builder.append( revisionTag );
+                builder.append( "\n" );
 
                 if ( i18nFolder != null )
                 {
@@ -159,21 +159,21 @@
                         if ( i18nfiles[i].isFile() && i18nfiles[i].getName().equalsIgnoreCase( translationFile ) )
                         {
                             fileExists = true;
-                            stringBuffer.append( i18nPath + "/" + translationFile );
-                            stringBuffer.append( "\n" );
+                            builder.append( i18nPath + "/" + translationFile );
+                            builder.append( "\n" );
                             break;
                         }
                     }
 
                     if ( !fileExists )
                     {
-                        stringBuffer.append( i18nPath + "/" + defaultTranslationFile );
-                        stringBuffer.append( "\n" );
+                        builder.append( i18nPath + "/" + defaultTranslationFile );
+                        builder.append( "\n" );
 
                     }
                 }
 
-                inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
+                inputStream = new ByteArrayInputStream( builder.toString().getBytes() );
 
                 return SUCCESS;
 
@@ -184,15 +184,15 @@
             }
         }
 
-        stringBuffer = new StringBuffer();
-        stringBuffer.append( "CACHE MANIFEST" );
-        stringBuffer.append( revisionTag );
-        stringBuffer.append( "\n" );
-        stringBuffer.append( "NETWORK:" );
-        stringBuffer.append( "\n" );
-        stringBuffer.append( "*" );
+        builder = new StringBuilder();
+        builder.append( "CACHE MANIFEST" );
+        builder.append( revisionTag );
+        builder.append( "\n" );
+        builder.append( "NETWORK:" );
+        builder.append( "\n" );
+        builder.append( "*" );
 
-        inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
+        inputStream = new ByteArrayInputStream( builder.toString().getBytes() );
 
         return SUCCESS;
     }