< prev index next >

src/java.rmi/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 172      * readObject is called to restore the state of the ExecOptionPermission
 173      * from a stream.
 174      */
 175     private synchronized void readObject(java.io.ObjectInputStream s)
 176          throws IOException, ClassNotFoundException
 177     {
 178         s.defaultReadObject();
 179         // init is called to initialize the rest of the values.
 180         init(getName());
 181     }
 182 
 183     /**
 184      * Initialize a ExecOptionPermission object. Common to all constructors.
 185      * Also called during de-serialization.
 186      */
 187     private void init(String name)
 188     {
 189         if (name == null)
 190             throw new NullPointerException("name can't be null");
 191 
 192         if (name.equals("")) {
 193             throw new IllegalArgumentException("name can't be empty");
 194         }
 195 
 196         if (name.endsWith(".*") || name.endsWith("=*") || name.equals("*")) {
 197             wildcard = true;
 198             if (name.length() == 1) {
 199                 this.name = "";
 200             } else {
 201                 this.name = name.substring(0, name.length()-1);
 202             }
 203         } else {
 204             this.name = name;
 205         }
 206     }
 207 
 208     /**
 209      * A ExecOptionPermissionCollection stores a collection
 210      * of ExecOptionPermission permissions. ExecOptionPermission objects
 211      * must be stored in a manner that allows them to be inserted in any
 212      * order, but enable the implies function to evaluate the implies




 172      * readObject is called to restore the state of the ExecOptionPermission
 173      * from a stream.
 174      */
 175     private synchronized void readObject(java.io.ObjectInputStream s)
 176          throws IOException, ClassNotFoundException
 177     {
 178         s.defaultReadObject();
 179         // init is called to initialize the rest of the values.
 180         init(getName());
 181     }
 182 
 183     /**
 184      * Initialize a ExecOptionPermission object. Common to all constructors.
 185      * Also called during de-serialization.
 186      */
 187     private void init(String name)
 188     {
 189         if (name == null)
 190             throw new NullPointerException("name can't be null");
 191 
 192         if (name.isEmpty()) {
 193             throw new IllegalArgumentException("name can't be empty");
 194         }
 195 
 196         if (name.endsWith(".*") || name.endsWith("=*") || name.equals("*")) {
 197             wildcard = true;
 198             if (name.length() == 1) {
 199                 this.name = "";
 200             } else {
 201                 this.name = name.substring(0, name.length()-1);
 202             }
 203         } else {
 204             this.name = name;
 205         }
 206     }
 207 
 208     /**
 209      * A ExecOptionPermissionCollection stores a collection
 210      * of ExecOptionPermission permissions. ExecOptionPermission objects
 211      * must be stored in a manner that allows them to be inserted in any
 212      * order, but enable the implies function to evaluate the implies


< prev index next >