src/java.base/share/classes/java/security/cert/X509CertSelector.java

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

@@ -1812,76 +1812,79 @@
      */
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("X509CertSelector: [\n");
         if (x509Cert != null) {
-            sb.append("  Certificate: " + x509Cert.toString() + "\n");
+            sb.append("  Certificate: ").append(x509Cert)
+                    .append('\n');
         }
         if (serialNumber != null) {
-            sb.append("  Serial Number: " + serialNumber.toString() + "\n");
+            sb.append("  Serial Number: ").append(serialNumber)
+                    .append('\n');
         }
         if (issuer != null) {
-            sb.append("  Issuer: " + getIssuerAsString() + "\n");
+            sb.append("  Issuer: ").append(getIssuerAsString()).append('\n');
         }
         if (subject != null) {
-            sb.append("  Subject: " + getSubjectAsString() + "\n");
+            sb.append("  Subject: ").append(getSubjectAsString()).append('\n');
         }
-        sb.append("  matchAllSubjectAltNames flag: "
-                  + String.valueOf(matchAllSubjectAltNames) + "\n");
+        sb.append("  matchAllSubjectAltNames flag: ")
+                .append(matchAllSubjectAltNames).append('\n');
         if (subjectAlternativeNames != null) {
             sb.append("  SubjectAlternativeNames:\n");
             Iterator<List<?>> i = subjectAlternativeNames.iterator();
             while (i.hasNext()) {
                 List<?> list = i.next();
-                sb.append("    type " + list.get(0) +
-                          ", name " + list.get(1) + "\n");
+                sb.append("    type ").append(list.get(0)).append(", name ")
+                        .append(list.get(1)).append('\n');
             }
         }
         if (subjectKeyID != null) {
             HexDumpEncoder enc = new HexDumpEncoder();
-            sb.append("  Subject Key Identifier: " +
-                      enc.encodeBuffer(subjectKeyID) + "\n");
+            sb.append("  Subject Key Identifier: ")
+                    .append(enc.encodeBuffer(subjectKeyID)).append('\n');
         }
         if (authorityKeyID != null) {
             HexDumpEncoder enc = new HexDumpEncoder();
-            sb.append("  Authority Key Identifier: " +
-                      enc.encodeBuffer(authorityKeyID) + "\n");
+            sb.append("  Authority Key Identifier: ")
+                    .append(enc.encodeBuffer(authorityKeyID)).append('\n');
         }
         if (certificateValid != null) {
-            sb.append("  Certificate Valid: " +
-                      certificateValid.toString() + "\n");
+            sb.append("  Certificate Valid: ").append(certificateValid)
+                    .append('\n');
         }
         if (privateKeyValid != null) {
-            sb.append("  Private Key Valid: " +
-                      privateKeyValid.toString() + "\n");
+            sb.append("  Private Key Valid: ").append(privateKeyValid)
+                    .append('\n');
         }
         if (subjectPublicKeyAlgID != null) {
-            sb.append("  Subject Public Key AlgID: " +
-                      subjectPublicKeyAlgID.toString() + "\n");
+            sb.append("  Subject Public Key AlgID: ")
+                    .append(subjectPublicKeyAlgID).append('\n');
         }
         if (subjectPublicKey != null) {
-            sb.append("  Subject Public Key: " +
-                      subjectPublicKey.toString() + "\n");
+            sb.append("  Subject Public Key: ").append(subjectPublicKey)
+                    .append('\n');
         }
         if (keyUsage != null) {
-            sb.append("  Key Usage: " + keyUsageToString(keyUsage) + "\n");
+            sb.append("  Key Usage: ").append(keyUsageToString(keyUsage))
+                    .append('\n');
         }
         if (keyPurposeSet != null) {
-            sb.append("  Extended Key Usage: " +
-                      keyPurposeSet.toString() + "\n");
+            sb.append("  Extended Key Usage: ").append(keyPurposeSet)
+                    .append('\n');
         }
         if (policy != null) {
-            sb.append("  Policy: " + policy.toString() + "\n");
+            sb.append("  Policy: ").append(policy).append('\n');
         }
         if (pathToGeneralNames != null) {
             sb.append("  Path to names:\n");
             Iterator<GeneralNameInterface> i = pathToGeneralNames.iterator();
             while (i.hasNext()) {
-                sb.append("    " + i.next() + "\n");
+                sb.append("    ").append(i.next()).append('\n');
             }
         }
-        sb.append("]");
+        sb.append(']');
         return sb.toString();
     }
 
     // Copied from sun.security.x509.KeyUsageExtension
     // (without calling the superclass)