← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17434: replcae for() with for-each where applicable

 

------------------------------------------------------------
revno: 17434
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-11 18:43:17 +0545
message:
  replcae for() with for-each where applicable
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.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-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2014-10-14 05:46:33 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2014-11-11 12:58:17 +0000
@@ -245,8 +245,8 @@
         List<Object> valueList = new ArrayList<>( operands.size() + 2 );
         valueList.add( 1 );
         valueList.add( 1 );
-        
-        for ( int i = 0; i < operands.size(); i++ )
+
+        for ( DataElementOperand operand1 : operands )
         {
             valueList.add( 10.0 );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ActivityPlan.java	2014-11-11 12:58:17 +0000
@@ -110,9 +110,8 @@
         else
         {
             dout.writeInt( activitiesList.size() );
-            for ( int i = 0; i < activitiesList.size(); i++ )
+            for ( Activity activity : activitiesList )
             {
-                Activity activity = activitiesList.get( i );
                 activity.setClientVersion( TWO_POINT_EIGHT );
                 activity.serialize( dout );
             }
@@ -130,9 +129,8 @@
         else
         {
             dout.writeInt( activitiesList.size() );
-            for ( int i = 0; i < activitiesList.size(); i++ )
+            for ( Activity activity : activitiesList )
             {
-                Activity activity = activitiesList.get( i );
                 activity.setClientVersion( TWO_POINT_NINE );
                 activity.serialize( dout );
             }
@@ -150,9 +148,8 @@
         else
         {
             dout.writeInt( activitiesList.size() );
-            for ( int i = 0; i < activitiesList.size(); i++ )
+            for ( Activity activity : activitiesList )
             {
-                Activity activity = activitiesList.get( i );
                 activity.setClientVersion( TWO_POINT_TEN );
                 activity.serialize( dout );
             }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Program.java	2014-11-11 12:58:17 +0000
@@ -159,17 +159,15 @@
 
         // Write program stage
         dout.writeInt( programStages.size() );
-        for ( int i = 0; i < programStages.size(); i++ )
+        for ( ProgramStage ps : programStages )
         {
-            ProgramStage ps = programStages.get( i );
             ps.serialize( dout );
         }
 
         // Write program attribute
         dout.writeInt( programAttributes.size() );
-        for ( int i = 0; i < programAttributes.size(); i++ )
+        for ( PatientAttribute pa : programAttributes )
         {
-            PatientAttribute pa = programAttributes.get( i );
             pa.serialize( dout );
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java	2014-11-11 12:58:17 +0000
@@ -188,15 +188,15 @@
         dout.writeBoolean( isSingleEvent );
 
         dout.writeInt( dataElements.size() );
-        for ( int i = 0; i < dataElements.size(); i++ )
+        for ( ProgramStageDataElement dataElement : dataElements )
         {
-            dataElements.get( i ).serialize( dout );
+            dataElement.serialize( dout );
         }
 
         dout.writeInt( sections.size() );
-        for ( int i = 0; i < sections.size(); i++ )
+        for ( Section section : sections )
         {
-            sections.get( i ).serialize( dout );
+            section.serialize( dout );
         }
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Section.java	2014-11-11 12:58:17 +0000
@@ -82,9 +82,9 @@
         else
         {
             dout.writeInt( dataElementIds.size() );
-            for ( int i = 0; i < dataElementIds.size(); i++ )
+            for ( Integer dataElementId : dataElementIds )
             {
-                dout.writeInt( dataElementIds.get( i ) );
+                dout.writeInt( dataElementId );
             }
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ModelList.java	2014-11-11 12:58:17 +0000
@@ -75,9 +75,9 @@
 
         dataOutputStream.writeInt( models.size() );
 
-        for ( int i = 0; i < models.size(); i++ )
+        for ( Model model : models )
         {
-            models.get( i ).serialize( dataOutputStream );
+            model.serialize( dataOutputStream );
         }
     }
 
@@ -108,9 +108,9 @@
 
         dataOutputStream.writeInt( models.size() );
 
-        for ( int i = 0; i < models.size(); i++ )
+        for ( Model model : models )
         {
-            models.get( i ).serialize( dataOutputStream );
+            model.serialize( dataOutputStream );
         }
 
     }
@@ -126,9 +126,9 @@
 
         dataOutputStream.writeInt( models.size() );
 
-        for ( int i = 0; i < models.size(); i++ )
+        for ( Model model : models )
         {
-            models.get( i ).serializeVersion2_9( dataOutputStream );
+            model.serializeVersion2_9( dataOutputStream );
         }
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Program.java	2014-11-11 12:58:17 +0000
@@ -109,9 +109,8 @@
         dout.writeUTF( this.getName() );
         dout.writeInt( this.getVersion() );
         dout.writeInt( programStages.size() );
-        for ( int i = 0; i < programStages.size(); i++ )
+        for ( ProgramStage programStage : programStages )
         {
-            ProgramStage programStage = programStages.get( i );
             programStage.setClientVersion( TWO_POINT_EIGHT );
             programStage.serialize( dout );
         }
@@ -125,9 +124,8 @@
         dout.writeUTF( this.getName() );
         dout.writeInt( this.getVersion() );
         dout.writeInt( programStages.size() );
-        for ( int i = 0; i < programStages.size(); i++ )
+        for ( ProgramStage programStage : programStages )
         {
-            ProgramStage programStage = programStages.get( i );
             programStage.setClientVersion( TWO_POINT_NINE );
             programStage.serialize( dout );
         }
@@ -141,9 +139,8 @@
         dout.writeUTF( this.getName() );
         dout.writeInt( this.getVersion() );
         dout.writeInt( programStages.size() );
-        for ( int i = 0; i < programStages.size(); i++ )
+        for ( ProgramStage programStage : programStages )
         {
-            ProgramStage programStage = programStages.get( i );
             programStage.setClientVersion( TWO_POINT_TEN );
             programStage.serialize( dout );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/ProgramStage.java	2014-11-11 12:58:17 +0000
@@ -89,9 +89,8 @@
 
         dout.writeInt( dataElements.size() );
 
-        for ( int i = 0; i < dataElements.size(); i++ )
+        for ( DataElement de : dataElements )
         {
-            DataElement de = dataElements.get( i );
             de.setClientVersion( TWO_POINT_EIGHT );
             de.serialize( dout );
         }
@@ -106,9 +105,8 @@
 
         dout.writeInt( dataElements.size() );
 
-        for ( int i = 0; i < dataElements.size(); i++ )
+        for ( DataElement de : dataElements )
         {
-            DataElement de = dataElements.get( i );
             de.setClientVersion( TWO_POINT_NINE );
             de.serialize( dout );
         }
@@ -123,9 +121,8 @@
 
         dout.writeInt( dataElements.size() );
 
-        for ( int i = 0; i < dataElements.size(); i++ )
+        for ( DataElement de : dataElements )
         {
-            DataElement de = dataElements.get( i );
             de.setClientVersion( TWO_POINT_TEN );
             de.serialize( dout );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Section.java	2014-11-11 12:58:17 +0000
@@ -96,9 +96,8 @@
         else
         {
             dout.writeInt( dataElements.size() );
-            for ( int i = 0; i < dataElements.size(); i++ )
+            for ( DataElement de : dataElements )
             {
-                DataElement de = dataElements.get( i );
                 de.setClientVersion( TWO_POINT_EIGHT );
                 de.serialize( dout );
             }
@@ -119,10 +118,9 @@
         else
         {
             dout.writeInt( dataElements.size() );
-            for ( int i = 0; i < dataElements.size(); i++ )
+            for ( DataElement de : dataElements )
             {
-                DataElement de = dataElements.get( i );
-                de.setClientVersion( TWO_POINT_NINE);
+                de.setClientVersion( TWO_POINT_NINE );
                 de.serialize( dout );
             }
         }
@@ -142,10 +140,9 @@
         else
         {
             dout.writeInt( dataElements.size() );
-            for ( int i = 0; i < dataElements.size(); i++ )
+            for ( DataElement de : dataElements )
             {
-                DataElement de = dataElements.get( i );
-                de.setClientVersion( TWO_POINT_TEN);
+                de.setClientVersion( TWO_POINT_TEN );
                 de.serialize( dout );
             }
         }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-10-25 07:31:44 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2014-11-11 12:58:17 +0000
@@ -496,11 +496,11 @@
             List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
                 .getDataElements();
 
-            for ( int i = 0; i < dataElements.size(); i++ )
+            for ( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement dataElement1 : dataElements )
             {
-                DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
+                DataElement dataElement = dataElementService.getDataElement( dataElement1.getId() );
 
-                String value = dataElements.get( i ).getValue();
+                String value = dataElement1.getValue();
 
                 if ( dataElement.getType().equalsIgnoreCase( "date" ) && !value.trim().equals( "" ) )
                 {
@@ -528,10 +528,10 @@
             List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> dataElements = mobileProgramStage
                 .getDataElements();
 
-            for ( int i = 0; i < dataElements.size(); i++ )
+            for ( org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement dataElement1 : dataElements )
             {
-                DataElement dataElement = dataElementService.getDataElement( dataElements.get( i ).getId() );
-                String value = dataElements.get( i ).getValue();
+                DataElement dataElement = dataElementService.getDataElement( dataElement1.getId() );
+                String value = dataElement1.getValue();
                 if ( value != null )
                 {
 
@@ -1560,7 +1560,7 @@
             items[0] = keyword;
         }
 
-        for ( int i = 0; i < items.length; i++ )
+        for ( String item : items )
         {
             String[] split = keyword.split( ":" );
             if ( split == null || (split.length != 3 && split.length != 2) )

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java	2014-11-11 12:58:17 +0000
@@ -293,9 +293,8 @@
         List<ProgramTrackedEntityAttribute> programPatientAttributes = new ArrayList<>(
             program.getProgramAttributes() );
 
-        for ( int i = 0; i < programPatientAttributes.size(); i++ )
+        for ( ProgramTrackedEntityAttribute ppa : programPatientAttributes )
         {
-            ProgramTrackedEntityAttribute ppa = programPatientAttributes.get( i );
             pr.getProgramAttributes().add( this.getPatientAttributeForMobile( ppa ) );
         }
 

=== 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	2014-10-16 06:17:19 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2014-11-11 12:58:17 +0000
@@ -421,7 +421,7 @@
             throw new IllegalStateException( "Number of column values (" + columnValues.size() + ") is not equal to number of rows (" + grid.size() + ")" );
         }
 
-        for ( int i = 0; i < grid.size(); i++ )
+        for ( List<Object> aGrid : grid )
         {
             grid.get( rowIndex++ ).add( columnValues.get( columnIndex++ ) );
         }

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2014-10-23 10:07:41 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2014-11-11 12:58:17 +0000
@@ -1361,9 +1361,9 @@
         {
             String[] children = dir.list();
 
-            for ( int i = 0; i < children.length; i++ )
+            for ( String aChildren : children )
             {
-                boolean success = deleteDir( new File( dir, children[i] ) );
+                boolean success = deleteDir( new File( dir, aChildren ) );
 
                 if ( !success )
                 {

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/paging/ActionPagingSupport.java	2014-11-11 12:58:17 +0000
@@ -110,9 +110,9 @@
             if ( !paramName.equalsIgnoreCase( "pageSize" ) && !paramName.equalsIgnoreCase( "currentPage" ) )
             {
                 String[] values = request.getParameterValues( paramName );
-                for( int i=0; i<values.length; i++ )
+                for ( String value : values )
                 {
-                    baseLink += paramName + "=" + values[i] + "&";
+                    baseLink += paramName + "=" + value + "&";
                 }
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/incoming/ReceivingSMSAction.java	2014-11-11 12:58:17 +0000
@@ -208,15 +208,15 @@
         {
             SmsMessageStatus[] statusArray = SmsMessageStatus.values();
 
-            for ( int i = 0; i < statusArray.length; i++ )
+            for ( SmsMessageStatus aStatusArray : statusArray )
             {
-                if ( statusArray[i].toString().equalsIgnoreCase( smsStatus ) )
+                if ( aStatusArray.toString().equalsIgnoreCase( smsStatus ) )
                 {
-                    total = incomingSmsService.getSmsByStatus( statusArray[i], keyword ).size();
+                    total = incomingSmsService.getSmsByStatus( aStatusArray, keyword ).size();
 
                     this.paging = createPaging( total );
 
-                    listIncomingSms = new ArrayList<>( incomingSmsService.getSmsByStatus( statusArray[i],
+                    listIncomingSms = new ArrayList<>( incomingSmsService.getSmsByStatus( aStatusArray,
                         keyword.trim(), this.paging.getStartPos(), this.paging.getPageSize() ) );
 
                     break;