< prev index next >

src/java.base/share/classes/sun/net/www/ParseUtil.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 519         sb.append('%');
 520         sb.append(hexDigits[(b >> 4) & 0x0f]);
 521         sb.append(hexDigits[(b >> 0) & 0x0f]);
 522     }
 523 
 524     // Tell whether the given character is permitted by the given mask pair
 525     private static boolean match(char c, long lowMask, long highMask) {
 526         if (c < 64)
 527             return ((1L << c) & lowMask) != 0;
 528         if (c < 128)
 529             return ((1L << (c - 64)) & highMask) != 0;
 530         return false;
 531     }
 532 
 533     // If a scheme is given then the path, if given, must be absolute
 534     //
 535     private static void checkPath(String s, String scheme, String path)
 536         throws URISyntaxException
 537     {
 538         if (scheme != null) {
 539             if ((path != null)
 540                 && ((path.length() > 0) && (path.charAt(0) != '/')))
 541                 throw new URISyntaxException(s,
 542                                              "Relative path in absolute URI");
 543         }
 544     }
 545 
 546 
 547     // -- Character classes for parsing --
 548 
 549     // To save startup time, we manually calculate the low-/highMask constants.
 550     // For reference, the following methods were used to calculate the values:
 551 
 552     // Compute a low-order mask for the characters
 553     // between first and last, inclusive
 554     //    private static long lowMask(char first, char last) {
 555     //        long m = 0;
 556     //        int f = Math.max(Math.min(first, 63), 0);
 557     //        int l = Math.max(Math.min(last, 63), 0);
 558     //        for (int i = f; i <= l; i++)
 559     //            m |= 1L << i;
 560     //        return m;




 519         sb.append('%');
 520         sb.append(hexDigits[(b >> 4) & 0x0f]);
 521         sb.append(hexDigits[(b >> 0) & 0x0f]);
 522     }
 523 
 524     // Tell whether the given character is permitted by the given mask pair
 525     private static boolean match(char c, long lowMask, long highMask) {
 526         if (c < 64)
 527             return ((1L << c) & lowMask) != 0;
 528         if (c < 128)
 529             return ((1L << (c - 64)) & highMask) != 0;
 530         return false;
 531     }
 532 
 533     // If a scheme is given then the path, if given, must be absolute
 534     //
 535     private static void checkPath(String s, String scheme, String path)
 536         throws URISyntaxException
 537     {
 538         if (scheme != null) {
 539             if (path != null && !path.isEmpty() && path.charAt(0) != '/')

 540                 throw new URISyntaxException(s,
 541                                              "Relative path in absolute URI");
 542         }
 543     }
 544 
 545 
 546     // -- Character classes for parsing --
 547 
 548     // To save startup time, we manually calculate the low-/highMask constants.
 549     // For reference, the following methods were used to calculate the values:
 550 
 551     // Compute a low-order mask for the characters
 552     // between first and last, inclusive
 553     //    private static long lowMask(char first, char last) {
 554     //        long m = 0;
 555     //        int f = Math.max(Math.min(first, 63), 0);
 556     //        int l = Math.max(Math.min(last, 63), 0);
 557     //        for (int i = f; i <= l; i++)
 558     //            m |= 1L << i;
 559     //        return m;


< prev index next >