dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37928
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19371: Fixed code style
------------------------------------------------------------
revno: 19371
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-11 22:37:27 +0100
message:
Fixed code style
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/adx/ADXPeriodTest.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/period/BiMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -180,7 +180,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -168,7 +168,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2015-06-11 21:37:27 +0000
@@ -74,7 +74,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -74,7 +74,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2015-06-11 21:37:27 +0000
@@ -74,7 +74,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -173,7 +173,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -199,7 +199,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2015-06-11 21:37:27 +0000
@@ -108,7 +108,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -109,7 +109,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -218,7 +218,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -191,7 +191,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2015-06-11 19:52:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2015-06-11 21:37:27 +0000
@@ -192,7 +192,8 @@
}
@Override
- public String getIso8601Duration() {
+ public String getIso8601Duration()
+ {
return ISO8601_DURATION;
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java 2015-06-11 19:53:44 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/ADXPeriod.java 2015-06-11 21:37:27 +0000
@@ -54,44 +54,51 @@
*
* @author bobj
*/
-public class ADXPeriod {
-
- public static class ADXPeriodException extends RuntimeException {
-
- ADXPeriodException(String message) {
- super(message);
+public class ADXPeriod
+{
+
+ public static class ADXPeriodException extends RuntimeException
+ {
+
+ ADXPeriodException( String message )
+ {
+ super( message );
}
}
- public static enum Duration {
+ public static enum Duration
+ {
P1D, // daily
P7D, // weekly
P1M, // monthly
P2M, // bi-monthly
-
P1Q, // quarterly
P6M, // 6monthly (including 6monthlyApril)
P1Y // yearly, financialApril, financialJuly, financialOctober
}
-
- private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- public static Period parse(String periodString) throws ADXPeriodException {
- String[] tokens = periodString.split("/");
- if (tokens.length != 2) {
- throw new ADXPeriodException(periodString + " not in valid <date>/<duration> format");
+
+ private static SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+
+ public static Period parse( String periodString ) throws ADXPeriodException
+ {
+ String[] tokens = periodString.split( "/" );
+ if ( tokens.length != 2 )
+ {
+ throw new ADXPeriodException( periodString + " not in valid <date>/<duration> format" );
}
- try {
+ try
+ {
Period period = null;
PeriodType periodType = null;
- Date startDate = dateFormat.parse(tokens[0]);
+ Date startDate = dateFormat.parse( tokens[0] );
Calendar cal = Calendar.getInstance();
- cal.setTime(startDate);
- Duration duration = Duration.valueOf(tokens[1]);
+ cal.setTime( startDate );
+ Duration duration = Duration.valueOf( tokens[1] );
- switch (duration) {
+ switch ( duration )
+ {
case P1D:
periodType = new DailyPeriodType();
break;
@@ -108,7 +115,8 @@
periodType = new QuarterlyPeriodType();
break;
case P6M:
- switch (cal.get(Calendar.MONTH)) {
+ switch ( cal.get( Calendar.MONTH ) )
+ {
case 0:
periodType = new SixMonthlyPeriodType();
break;
@@ -116,10 +124,11 @@
periodType = new SixMonthlyAprilPeriodType();
break;
default:
- throw new ADXPeriodException(periodString + "is invalid sixmonthly type");
+ throw new ADXPeriodException( periodString + "is invalid sixmonthly type" );
}
case P1Y:
- switch (cal.get(Calendar.MONTH)) {
+ switch ( cal.get( Calendar.MONTH ) )
+ {
case 0:
periodType = new YearlyPeriodType();
break;
@@ -133,28 +142,35 @@
periodType = new FinancialOctoberPeriodType();
break;
default:
- throw new ADXPeriodException(periodString + "is invalid yearly type");
+ throw new ADXPeriodException( periodString + "is invalid yearly type" );
}
}
- if (periodType != null) {
- period = periodType.createPeriod(startDate);
- } else {
- throw new ADXPeriodException("Failed to create period type from " + duration);
+ if ( periodType != null )
+ {
+ period = periodType.createPeriod( startDate );
+ }
+ else
+ {
+ throw new ADXPeriodException( "Failed to create period type from " + duration );
}
return period;
- } catch (ParseException ex) {
- throw new ADXPeriodException(tokens[0] + "is not a valid date in YYYY-MM-dd format");
- } catch (IllegalArgumentException ex) {
- throw new ADXPeriodException(tokens[1] + " is not a supported duration type");
+ }
+ catch ( ParseException ex )
+ {
+ throw new ADXPeriodException( tokens[0] + "is not a valid date in YYYY-MM-dd format" );
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ throw new ADXPeriodException( tokens[1] + " is not a supported duration type" );
}
}
-
- public static String serialize(Period period)
+
+ public static String serialize( Period period )
{
- return dateFormat.format(period.getStartDate()) + "/"
- + period.getPeriodType().getIso8601Duration();
+ return dateFormat.format( period.getStartDate() ) + "/"
+ + period.getPeriodType().getIso8601Duration();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/adx/ADXPeriodTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/adx/ADXPeriodTest.java 2015-06-11 19:53:44 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/adx/ADXPeriodTest.java 2015-06-11 21:37:27 +0000
@@ -37,82 +37,91 @@
*
* @author bobj
*/
-public class ADXPeriodTest {
-
+public class ADXPeriodTest
+{
+
private Period p;
-
- public ADXPeriodTest() {
- }
-
- @Test
- public void testParser() {
- p = ADXPeriod.parse("2015-01-01/P1Y");
- assertEquals("2015", p.getIsoDate());
- p = ADXPeriod.parse("2015-01-01/P1M");
- assertEquals("201501", p.getIsoDate());
- p = ADXPeriod.parse("2015-01-01/P1D");
- assertEquals("20150101", p.getIsoDate());
- p = ADXPeriod.parse("2015-01-01/P1Q");
- assertEquals("2015Q1", p.getIsoDate());
- p = ADXPeriod.parse("2015-04-01/P1Q");
- assertEquals("2015Q2", p.getIsoDate());
- p = ADXPeriod.parse("2015-01-01/P7D");
- assertEquals("2015W1", p.getIsoDate());
- p = ADXPeriod.parse("2015-01-05/P7D");
- assertEquals("2015W2", p.getIsoDate());
- }
-
- @Test
- public void testBadDuration() {
- try {
- p = ADXPeriod.parse("2014-01-01/P1");
- fail("Should have thrown exception parsing 2015-01-01/P1");
- }
- catch (Exception ex)
- {
- assertEquals(ADXPeriod.ADXPeriodException.class,ex.getClass());
- }
- }
-
- @Test
- public void testFinancialTypes() {
- p = ADXPeriod.parse("2015-01-01/P1Y");
- assertEquals("2015", p.getIsoDate());
- p = ADXPeriod.parse("2015-04-01/P1Y");
- assertEquals("2015April", p.getIsoDate());
- p = ADXPeriod.parse("2015-07-01/P1Y");
- assertEquals("2015July", p.getIsoDate());
- p = ADXPeriod.parse("2015-10-01/P1Y");
- assertEquals("2015Oct", p.getIsoDate());
- }
-
- @Test
- public void testFailFinancialType() {
- try {
- p = ADXPeriod.parse("2014-02-01/P1Y");
- fail("Should have thrown exception parsing 2014-02-01/P1Y");
- }
- catch (Exception ex)
- {
- assertEquals(ADXPeriod.ADXPeriodException.class,ex.getClass());
- }
- }
-
- @Test
- public void testSerialize() {
- p = PeriodType.getPeriodFromIsoString("2015");
- assertEquals("2015-01-01/P1Y", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("201503");
- assertEquals("2015-03-01/P1M", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("2015W1");
- assertEquals("2014-12-29/P7D", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("2015Q2");
- assertEquals("2015-04-01/P1Q", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("2015April");
- assertEquals("2015-04-01/P1Y", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("2015S2");
- assertEquals("2015-07-01/P6M", ADXPeriod.serialize(p));
- p = PeriodType.getPeriodFromIsoString("2015AprilS2");
- assertEquals("2015-10-01/P6M", ADXPeriod.serialize(p));
+
+ public ADXPeriodTest()
+ {
+ }
+
+ @Test
+ public void testParser()
+ {
+ p = ADXPeriod.parse( "2015-01-01/P1Y" );
+ assertEquals( "2015", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-01-01/P1M" );
+ assertEquals( "201501", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-01-01/P1D" );
+ assertEquals( "20150101", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-01-01/P1Q" );
+ assertEquals( "2015Q1", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-04-01/P1Q" );
+ assertEquals( "2015Q2", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-01-01/P7D" );
+ assertEquals( "2015W1", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-01-05/P7D" );
+ assertEquals( "2015W2", p.getIsoDate() );
+ }
+
+ @Test
+ public void testBadDuration()
+ {
+ try
+ {
+ p = ADXPeriod.parse( "2014-01-01/P1" );
+ fail( "Should have thrown exception parsing 2015-01-01/P1" );
+ }
+ catch ( Exception ex )
+ {
+ assertEquals( ADXPeriod.ADXPeriodException.class, ex.getClass() );
+ }
+ }
+
+ @Test
+ public void testFinancialTypes()
+ {
+ p = ADXPeriod.parse( "2015-01-01/P1Y" );
+ assertEquals( "2015", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-04-01/P1Y" );
+ assertEquals( "2015April", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-07-01/P1Y" );
+ assertEquals( "2015July", p.getIsoDate() );
+ p = ADXPeriod.parse( "2015-10-01/P1Y" );
+ assertEquals( "2015Oct", p.getIsoDate() );
+ }
+
+ @Test
+ public void testFailFinancialType()
+ {
+ try
+ {
+ p = ADXPeriod.parse( "2014-02-01/P1Y" );
+ fail( "Should have thrown exception parsing 2014-02-01/P1Y" );
+ }
+ catch ( Exception ex )
+ {
+ assertEquals( ADXPeriod.ADXPeriodException.class, ex.getClass() );
+ }
+ }
+
+ @Test
+ public void testSerialize()
+ {
+ p = PeriodType.getPeriodFromIsoString( "2015" );
+ assertEquals( "2015-01-01/P1Y", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "201503" );
+ assertEquals( "2015-03-01/P1M", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "2015W1" );
+ assertEquals( "2014-12-29/P7D", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "2015Q2" );
+ assertEquals( "2015-04-01/P1Q", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "2015April" );
+ assertEquals( "2015-04-01/P1Y", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "2015S2" );
+ assertEquals( "2015-07-01/P6M", ADXPeriod.serialize( p ) );
+ p = PeriodType.getPeriodFromIsoString( "2015AprilS2" );
+ assertEquals( "2015-10-01/P6M", ADXPeriod.serialize( p ) );
}
}