< prev index next >

src/java.base/share/classes/sun/security/util/DomainName.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()


 346                                 match = matchOther(domain, rule);
 347                             }
 348                             break;
 349                         case EXCEPTION:
 350                             Match excMatch = matchException(domain, rule);
 351                             if (excMatch != null) {
 352                                 return excMatch;
 353                             }
 354                             break;
 355                     }
 356                 }
 357                 return match;
 358             }
 359 
 360             private static LinkedList<String> split(String rule) {
 361                 String[] labels = rule.split("\\.");
 362                 return new LinkedList<>(Arrays.asList(labels));
 363             }
 364 
 365             private static int numLabels(String rule) {
 366                 if (rule.equals("")) {
 367                     return 0;
 368                 }
 369                 int len = rule.length();
 370                 int count = 0;
 371                 int index = 0;
 372                 while (index < len) {
 373                     int pos;
 374                     if ((pos = rule.indexOf('.', index)) == -1) {
 375                         return count + 1;
 376                     }
 377                     index = pos + 1;
 378                     count++;
 379                 }
 380                 return count;
 381             }
 382 
 383             /**
 384              * Check for a match with an explicit name rule or a wildcard rule
 385              * (i.e., a non-exception rule).
 386              */




 346                                 match = matchOther(domain, rule);
 347                             }
 348                             break;
 349                         case EXCEPTION:
 350                             Match excMatch = matchException(domain, rule);
 351                             if (excMatch != null) {
 352                                 return excMatch;
 353                             }
 354                             break;
 355                     }
 356                 }
 357                 return match;
 358             }
 359 
 360             private static LinkedList<String> split(String rule) {
 361                 String[] labels = rule.split("\\.");
 362                 return new LinkedList<>(Arrays.asList(labels));
 363             }
 364 
 365             private static int numLabels(String rule) {
 366                 if (rule.isEmpty()) {
 367                     return 0;
 368                 }
 369                 int len = rule.length();
 370                 int count = 0;
 371                 int index = 0;
 372                 while (index < len) {
 373                     int pos;
 374                     if ((pos = rule.indexOf('.', index)) == -1) {
 375                         return count + 1;
 376                     }
 377                     index = pos + 1;
 378                     count++;
 379                 }
 380                 return count;
 381             }
 382 
 383             /**
 384              * Check for a match with an explicit name rule or a wildcard rule
 385              * (i.e., a non-exception rule).
 386              */


< prev index next >