------------------------------------------------------------ revno: 5014 committer: Bob Jolliffe bobjolli...@gmail.com branch nick: dhis2 timestamp: Sun 2011-10-23 21:18:55 +0100 message: Tidied up use of constants modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CodeGenerator.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/common/CodeGenerator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CodeGenerator.java 2011-10-23 13:33:34 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CodeGenerator.java 2011-10-23 20:18:55 +0000 @@ -37,7 +37,8 @@ public static final String allowedChars = "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - public static final int codeSize = 11; + public static final int NUMBER_OF_CODEPOINTS = allowedChars.length(); + public static final int CODESIZE = 11; /** * Generates a pseudo random string using the allowed characters @@ -49,10 +50,10 @@ // Using the system default algorithm and seed SecureRandom sr = new SecureRandom(); - char[] randomChars = new char[11]; - for ( int i = 0; i < codeSize; ++i ) + char[] randomChars = new char[CODESIZE]; + for ( int i = 0; i < CODESIZE; ++i ) { - randomChars[i] = allowedChars.charAt( sr.nextInt( 61 ) ); + randomChars[i] = allowedChars.charAt( sr.nextInt( NUMBER_OF_CODEPOINTS ) ); } return new String( randomChars ); }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp