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

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


 162      * super.toString() (
 163      *   // enumerate all the Permission
 164      *   // objects and call toString() on them,
 165      *   // one per line..
 166      * )</pre>
 167      *
 168      * {@code super.toString} is a call to the {@code toString}
 169      * method of this
 170      * object's superclass, which is Object. The result is
 171      * this PermissionCollection's type name followed by this object's
 172      * hashcode, thus enabling clients to differentiate different
 173      * PermissionCollections object, even if they contain the same permissions.
 174      *
 175      * @return information about this PermissionCollection object,
 176      *         as described above.
 177      *
 178      */
 179     public String toString() {
 180         Enumeration<Permission> enum_ = elements();
 181         StringBuilder sb = new StringBuilder();
 182         sb.append(super.toString()+" (\n");
 183         while (enum_.hasMoreElements()) {
 184             try {
 185                 sb.append(" ");
 186                 sb.append(enum_.nextElement().toString());
 187                 sb.append("\n");
 188             } catch (NoSuchElementException e){
 189                 // ignore
 190             }
 191         }
 192         sb.append(")\n");
 193         return sb.toString();
 194     }
 195 }


 162      * super.toString() (
 163      *   // enumerate all the Permission
 164      *   // objects and call toString() on them,
 165      *   // one per line..
 166      * )</pre>
 167      *
 168      * {@code super.toString} is a call to the {@code toString}
 169      * method of this
 170      * object's superclass, which is Object. The result is
 171      * this PermissionCollection's type name followed by this object's
 172      * hashcode, thus enabling clients to differentiate different
 173      * PermissionCollections object, even if they contain the same permissions.
 174      *
 175      * @return information about this PermissionCollection object,
 176      *         as described above.
 177      *
 178      */
 179     public String toString() {
 180         Enumeration<Permission> enum_ = elements();
 181         StringBuilder sb = new StringBuilder();
 182         sb.append(super.toString()).append(" (\n");
 183         while (enum_.hasMoreElements()) {
 184             try {
 185                 sb.append(' ');
 186                 sb.append(enum_.nextElement().toString());
 187                 sb.append('\n');
 188             } catch (NoSuchElementException e) {
 189                 // ignore
 190             }
 191         }
 192         sb.append(")\n");
 193         return sb.toString();
 194     }
 195 }