diff --git a/.gitignore b/.gitignore
index 597cf42..de172e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ target/
.settings/
bin
*.iml
+.idea
diff --git a/pom.xml b/pom.xml
index f519711..ea54b1f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
Provides Base64 encoding and decoding as defined by RFC 2045.
* @@ -114,9 +116,7 @@ public class Base64 // Populating the lookup and character arrays static { - for (int i = 0; i < BASELENGTH; i++) { - base64Alphabet[i] = (byte) -1; - } + Arrays.fill(base64Alphabet, (byte) -1); for (int i = 'Z'; i >= 'A'; i--) { base64Alphabet[i] = (byte) (i - 'A'); } @@ -174,8 +174,8 @@ public static boolean isArrayByteBase64(byte[] arrayOctect) { // return false; return true; } - for (int i = 0; i < length; i++) { - if (!isBase64(arrayOctect[i])) { + for (byte b : arrayOctect) { + if (!isBase64(b)) { return false; } } @@ -454,15 +454,15 @@ static byte[] discardWhitespace(byte[] data) { byte groomedData[] = new byte[data.length]; int bytesCopied = 0; - for (int i = 0; i < data.length; i++) { - switch (data[i]) { + for (byte datum : data) { + switch (datum) { case (byte) ' ': case (byte) '\n': case (byte) '\r': case (byte) '\t': break; default: - groomedData[bytesCopied++] = data[i]; + groomedData[bytesCopied++] = datum; } } @@ -486,9 +486,9 @@ static byte[] discardNonBase64(byte[] data) { byte groomedData[] = new byte[data.length]; int bytesCopied = 0; - for (int i = 0; i < data.length; i++) { - if (isBase64(data[i])) { - groomedData[bytesCopied++] = data[i]; + for (byte datum : data) { + if (isBase64(datum)) { + groomedData[bytesCopied++] = datum; } } diff --git a/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java b/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java index db5a9b6..4393604 100644 --- a/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java +++ b/src/main/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipher.java @@ -161,7 +161,7 @@ public static String[] getServiceTypes() result.add(key.substring(0, ix)); } } - return result.toArray( new String[result.size()] ); + return result.toArray(new String[0]); } /** @@ -189,7 +189,7 @@ else if (key.startsWith("Alg.Alias." + serviceType + ".")) { } } } - return result.toArray( new String[result.size()] ); + return result.toArray(new String[0]); } // --------------------------------------------------------------- diff --git a/src/test/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipherTest.java b/src/test/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipherTest.java index a259a02..57708ed 100644 --- a/src/test/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipherTest.java +++ b/src/test/java/org/sonatype/plexus/components/cipher/DefaultPlexusCipherTest.java @@ -83,16 +83,13 @@ public void testDefaultAlgorithmExists() assertNotNull( "No Cipher providers found in the current environment", res ); System.out.println( "\n=== Available ciphers :" ); - for ( int i = 0; i < res.length; i++ ) - { - System.out.println( res[i] ); + for (String re : res) { + System.out.println(re); } System.out.println( "====================" ); - for ( int i = 0; i < res.length; i++ ) - { - String provider = res[i]; - if ( PBECipher.KEY_ALG.equalsIgnoreCase( provider ) ) + for (String provider : res) { + if (PBECipher.KEY_ALG.equalsIgnoreCase(provider)) return; } @@ -111,18 +108,13 @@ public void stestFindDefaultAlgorithm() String[] impls = DefaultPlexusCipher.getCryptoImpls( "Cipher" ); assertNotNull( "No Cipher providers found in the current environment", impls ); - for ( int i = 0; i < impls.length; i++ ) - try - { - String provider = impls[i]; - - System.out.print( provider ); - pc.encrypt( str, passPhrase ); - System.out.println( "------------------> Success !!!!!!" ); - } - catch ( Exception e ) - { - System.out.println( e.getMessage() ); + for (String impl : impls) + try { + System.out.print(impl); + pc.encrypt(str, passPhrase); + System.out.println("------------------> Success !!!!!!"); + } catch (Exception e) { + System.out.println(e.getMessage()); } }