src/java.base/share/classes/java/security/ProtectionDomain.java

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>

@@ -283,38 +283,36 @@
     }
 
     /**
      * Convert a ProtectionDomain to a String.
      */
-    @Override public String toString() {
+    @Override
+    public String toString() {
         String pals = "<no principals>";
         if (principals != null && principals.length > 0) {
-            StringBuilder palBuf = new StringBuilder("(principals ");
+            StringBuilder palBuilder = new StringBuilder("(principals ");
 
             for (int i = 0; i < principals.length; i++) {
-                palBuf.append(principals[i].getClass().getName() +
-                            " \"" + principals[i].getName() +
-                            "\"");
-                if (i < principals.length-1)
-                    palBuf.append(",\n");
-                else
-                    palBuf.append(")\n");
+                palBuilder.append(principals[i].getClass().getName());
+                palBuilder.append(" \"").append(principals[i].getName());
+                palBuilder.append('"');
+                if (i < principals.length - 1) {
+                    palBuilder.append(",\n");
+                } else {
+                    palBuilder.append(")\n");
+                }
             }
-            pals = palBuf.toString();
+            pals = palBuilder.toString();
         }
 
         // Check if policy is set; we don't want to load
         // the policy prematurely here
-        PermissionCollection pc = Policy.isSet() && seeAllp() ?
-                                      mergePermissions():
-                                      getPermissions();
-
-        return "ProtectionDomain "+
-            " "+codesource+"\n"+
-            " "+classloader+"\n"+
-            " "+pals+"\n"+
-            " "+pc+"\n";
+        PermissionCollection pc = Policy.isSet() && seeAllp() ? mergePermissions()
+                : getPermissions();
+
+        return "ProtectionDomain " + " " + codesource + "\n" + " "
+                + classloader + "\n" + " " + pals + "\n" + " " + pc + "\n";
     }
 
     /**
      * Return true (merge policy permissions) in the following cases:
      *