< prev index next >

src/java.base/share/classes/sun/net/www/protocol/mailto/Handler.java

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


 110      * @param   u the URL to receive the result of parsing the spec
 111      * @param   spec the URL string to parse
 112      * @param   start the character position to start parsing at.  This is
 113      *          just past the ':'.
 114      * @param   limit the character position to stop parsing at.
 115      */
 116     public void parseURL(URL u, String spec, int start, int limit) {
 117 
 118         String protocol = u.getProtocol();
 119         String host = "";
 120         int port = u.getPort();
 121         String file = "";
 122 
 123         if (start < limit) {
 124             file = spec.substring(start, limit);
 125         }
 126         /*
 127          * Let's just make sure we DO have an Email address in the URL.
 128          */
 129         boolean nogood = false;
 130         if (file == null || file.equals(""))
 131             nogood = true;
 132         else {
 133             boolean allwhites = true;
 134             for (int i = 0; i < file.length(); i++)
 135                 if (!Character.isWhitespace(file.charAt(i)))
 136                     allwhites = false;
 137             if (allwhites)
 138                 nogood = true;
 139         }
 140         if (nogood)
 141             throw new RuntimeException("No email address");
 142         setURLHandler(u, protocol, host, port, file, null);
 143     }
 144 
 145     /**
 146      * This method is used to suppress the deprecated warning
 147      *
 148      * @param   u the URL to receive the result of parsing the spec
 149      * @param   spec the URL string to parse
 150      * @param   start the character position to start parsing at.  This is


 110      * @param   u the URL to receive the result of parsing the spec
 111      * @param   spec the URL string to parse
 112      * @param   start the character position to start parsing at.  This is
 113      *          just past the ':'.
 114      * @param   limit the character position to stop parsing at.
 115      */
 116     public void parseURL(URL u, String spec, int start, int limit) {
 117 
 118         String protocol = u.getProtocol();
 119         String host = "";
 120         int port = u.getPort();
 121         String file = "";
 122 
 123         if (start < limit) {
 124             file = spec.substring(start, limit);
 125         }
 126         /*
 127          * Let's just make sure we DO have an Email address in the URL.
 128          */
 129         boolean nogood = false;
 130         if (file == null || file.isEmpty())
 131             nogood = true;
 132         else {
 133             boolean allwhites = true;
 134             for (int i = 0; i < file.length(); i++)
 135                 if (!Character.isWhitespace(file.charAt(i)))
 136                     allwhites = false;
 137             if (allwhites)
 138                 nogood = true;
 139         }
 140         if (nogood)
 141             throw new RuntimeException("No email address");
 142         setURLHandler(u, protocol, host, port, file, null);
 143     }
 144 
 145     /**
 146      * This method is used to suppress the deprecated warning
 147      *
 148      * @param   u the URL to receive the result of parsing the spec
 149      * @param   spec the URL string to parse
 150      * @param   start the character position to start parsing at.  This is
< prev index next >