jdk/src/share/classes/java/net/URI.java
changeset 15272 b0055428d835
parent 10422 83581a2cf49d
child 18156 edb590d448c5
equal deleted inserted replaced
15271:570508dfed48 15272:b0055428d835
  1692         if ((c >= 'A') && (c <= 'Z'))
  1692         if ((c >= 'A') && (c <= 'Z'))
  1693             return c + ('a' - 'A');
  1693             return c + ('a' - 'A');
  1694         return c;
  1694         return c;
  1695     }
  1695     }
  1696 
  1696 
       
  1697     // US-ASCII only
       
  1698     private static int toUpper(char c) {
       
  1699         if ((c >= 'a') && (c <= 'z'))
       
  1700             return c - ('a' - 'A');
       
  1701         return c;
       
  1702     }
       
  1703 
  1697     private static boolean equal(String s, String t) {
  1704     private static boolean equal(String s, String t) {
  1698         if (s == t) return true;
  1705         if (s == t) return true;
  1699         if ((s != null) && (t != null)) {
  1706         if ((s != null) && (t != null)) {
  1700             if (s.length() != t.length())
  1707             if (s.length() != t.length())
  1701                 return false;
  1708                 return false;
  1742         return false;
  1749         return false;
  1743     }
  1750     }
  1744 
  1751 
  1745     private static int hash(int hash, String s) {
  1752     private static int hash(int hash, String s) {
  1746         if (s == null) return hash;
  1753         if (s == null) return hash;
  1747         return hash * 127 + s.hashCode();
  1754         return s.indexOf('%') < 0 ? hash * 127 + s.hashCode()
       
  1755                                   : normalizedHash(hash, s);
       
  1756     }
       
  1757 
       
  1758 
       
  1759     private static int normalizedHash(int hash, String s) {
       
  1760         int h = 0;
       
  1761         for (int index = 0; index < s.length(); index++) {
       
  1762             char ch = s.charAt(index);
       
  1763             h = 31 * h + ch;
       
  1764             if (ch == '%') {
       
  1765                 /*
       
  1766                  * Process the next two encoded characters
       
  1767                  */
       
  1768                 for (int i = index + 1; i < index + 3; i++)
       
  1769                     h = 31 * h + toUpper(s.charAt(i));
       
  1770                 index += 2;
       
  1771             }
       
  1772         }
       
  1773         return hash * 127 + h;
  1748     }
  1774     }
  1749 
  1775 
  1750     // US-ASCII only
  1776     // US-ASCII only
  1751     private static int hashIgnoringCase(int hash, String s) {
  1777     private static int hashIgnoringCase(int hash, String s) {
  1752         if (s == null) return hash;
  1778         if (s == null) return hash;