< prev index next >

src/java.base/share/classes/javax/crypto/Cipher.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb

@@ -339,11 +339,11 @@
             }
         } catch (NoSuchElementException e) {
             throw new NoSuchAlgorithmException("Invalid transformation " +
                                            "format:" + transformation);
         }
-        if ((parts[0] == null) || (parts[0].length() == 0)) {
+        if ((parts[0] == null) || (parts[0].isEmpty())) {
             throw new NoSuchAlgorithmException("Invalid transformation:" +
                                    "algorithm not specified-"
                                    + transformation);
         }
         return parts;

@@ -443,14 +443,14 @@
         String[] parts = tokenizeTransformation(transformation);
 
         String alg = parts[0];
         String mode = parts[1];
         String pad = parts[2];
-        if ((mode != null) && (mode.length() == 0)) {
+        if ((mode != null) && (mode.isEmpty())) {
             mode = null;
         }
-        if ((pad != null) && (pad.length() == 0)) {
+        if ((pad != null) && (pad.isEmpty())) {
             pad = null;
         }
 
         if ((mode == null) && (pad == null)) {
             // AES

@@ -612,11 +612,11 @@
             NoSuchPaddingException
     {
         if ((transformation == null) || transformation.equals("")) {
             throw new NoSuchAlgorithmException("Null or empty transformation");
         }
-        if ((provider == null) || (provider.length() == 0)) {
+        if ((provider == null) || (provider.isEmpty())) {
             throw new IllegalArgumentException("Missing provider");
         }
         Provider p = Security.getProvider(provider);
         if (p == null) {
             throw new NoSuchProviderException("No such provider: " +
< prev index next >