river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1463106 [3/4] - in /river/jtsk/skunk/qa_refactor/trunk: ./ qa/ qa/jtreg/net/jini/loader/pref/PreferredClassProvider/registryRetainCodebase/ qa/jtreg/net/jini/loader/pref/PreferredResources/correctInterpretation/ qa/src/com/sun/jini/test/im...
Date Mon, 01 Apr 2013 07:47:45 GMT
Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/UriParser.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/UriParser.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/UriParser.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/UriParser.java Mon Apr  1 07:47:44 2013
@@ -19,972 +19,18 @@ package org.apache.river.api.net;
 import java.io.File;
 import java.net.URISyntaxException;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
 import org.apache.river.impl.Messages;
 
 /**
  *
- * @author peter
+ * 
  */
 final class UriParser {
     
-    private static final char [] latin = new char[256];
-    private static final String [] latinEsc = new String[256];
-    private final static Map<String, Character> unreserved = new HashMap<String, Character>(66); // To be unescaped during normalisation.
-    
-    /* 2.1.  Percent-Encoding
-     * 
-     * A percent-encoding mechanism is used to represent a data octet in a
-     * component when that octet's corresponding character is outside the
-     * allowed set or is being used as a delimiter of, or within, the
-     * component.  A percent-encoded octet is encoded as a character
-     * triplet, consisting of the percent character "%" followed by the two
-     * hexadecimal digits representing that octet's numeric value.  For
-     * example, "%20" is the percent-encoding for the binary octet
-     * "00100000" (ABNF: %x20), which in US-ASCII corresponds to the space
-     * character (SP).  Section 2.4 describes when percent-encoding and
-     * decoding is applied.
-     * 
-     *    pct-encoded = "%" HEXDIG HEXDIG
-     * 
-     * The uppercase hexadecimal digits 'A' through 'F' are equivalent to
-     * the lowercase digits 'a' through 'f', respectively.  If two URIs
-     * differ only in the case of hexadecimal digits used in percent-encoded
-     * octets, they are equivalent.  For consistency, URI producers and
-     * normalizers should use uppercase hexadecimal digits for all percent-
-     * encodings.
-     */
-    // Any character that is not part of the reserved and unreserved sets must
-    // be encoded.
-    // Section 2.1 Percent encoding must be converted to upper case during normalisation.
-    private static final char escape = '%';
-     /* RFC3986 obsoletes RFC2396 and RFC2732
-     * 
-     * reserved    = gen-delims / sub-delims
-     * 
-     * gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
-     * 
-     * sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
-     *               / "*" / "+" / "," / ";" / "="
-     */
-    // Section 2.2 Reserved set is protected from normalisation.
-    private static final char [] gen_delims = {':', '/', '?', '#', '[', ']', '@'};
-    private static final char [] sub_delims = {'!', '$', '&', '\'', '(', ')', '*',
-                                                            '+', ',', ';', '='};
-    
-    /*
-     * For consistency, percent-encoded octets in the ranges of ALPHA
-     * (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E),
-     * underscore (%5F), or tilde (%7E) should not be created by URI
-     * producers and, when found in a URI, should be decoded to their
-     * corresponding unreserved characters by URI normalizers.
-     */
-    // Section 2.3 Unreserved characters (Allowed) must be decoded during normalisation if % encoded.
-    private static final char [] lowalpha = "abcdefghijklmnopqrstuvwxyz".toCharArray();
-    private static final char [] upalpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
-    private static final char [] numeric = "0123456789".toCharArray();
-    private static final char [] unres_punct =  {'-' , '.' , '_' , '~'};
-    private static final char [] schemeEx = "+-.".toCharArray(); // + ALPHA and numeric.
-     
-    static {
-        processLatin();
-        processUnreserved();
-    }
-    
-    private static void processUnreserved(){
-        int l = lowalpha.length;
-        for (int i = 0, n = 97; i < l; i++, n++){
-            unreserved.put(String.valueOf(latinEsc[n]), Character.valueOf(lowalpha[i]));
-        }
-        l = upalpha.length;
-        for (int i = 0, n = 65; i < l; i++, n++){
-            unreserved.put(String.valueOf(latinEsc[n]), Character.valueOf(upalpha[i]));
-        }
-        l = numeric.length;
-        for (int i = 0, n = 48; i < l; i++, n++){
-            unreserved.put(String.valueOf(latinEsc[n]), Character.valueOf(numeric[i]));
-        }
-        l = unres_punct.length;
-        for (int i = 0; i < l; i++){
-            int n = index(latin, unres_punct[i]);
-            unreserved.put(String.valueOf(latinEsc[n]), Character.valueOf(unres_punct[i]));
-        }
-        l = schemeEx.length;
-        for (int i = 0; i < l; i++){
-            int n = index(latin, schemeEx[i]);
-            unreserved.put(String.valueOf(latinEsc[n]), Character.valueOf(schemeEx[i]));
-        }
-    } 
-    
-    /**
-     * Finds a character in an array and returns the index at which it exists,
-     * or returns -1 if it doesn't
-     * 
-     * @param array
-     * @param character
-     * @return 
-     */
-    public static int index(char [] array, char character){
-        int l = array.length;
-        for (int i = 0; i < l; i++){
-            if (array[i] == character) return i;
-        }
-        return -1;
-    }
-    
-    /**
-     * Encodes illegal characters according to RFC3986, "%" characters are not 
-     * encoded, since they are legal and in case the string already
-     * contains escaped characters.  The percent character must be encoded
-     * manually prior to calling this method.
-     * <p>
-     * No normalisation or platform specific changes are performed.
-     * 
-     * @param str
-     * @return
-     * @throws URISyntaxException  
-     */
-    public static String escapeIllegalCharacters(String str) throws URISyntaxException {
-        if (str == null) return null;
-        char [] chars = str.toCharArray();
-        int len = chars.length;
-        StringBuilder sb = new StringBuilder(len + 12);
-        boolean esc = false;
-        for (int i = 0; i < len; i++){
-            if (chars[i] == escape){
-                /*  Section 2.4
-                 * Because the percent ("%") character serves as the indicator for
-                 * percent-encoded octets, it must be percent-encoded as "%25" for that
-                 * octet to be used as data within a URI.  Implementations must not
-                 * percent-encode or decode the same string more than once, as decoding
-                 * an already decoded string might lead to misinterpreting a percent
-                 * data octet as the beginning of a percent-encoding, or vice versa in
-                 * the case of percent-encoding an already percent-encoded string.
-                 */
-                sb.append(chars[i]);
-            }else if ( index(gen_delims, chars[i]) != -1 
-                    || index(sub_delims, chars[i]) != -1
-                    || index(lowalpha, chars[i]) != -1
-                    || index(upalpha, chars[i]) != -1
-                    || index(numeric, chars[i]) != -1
-                    || index(unres_punct, chars[i]) != -1){
-                sb.append(chars[i]);
-            }else {
-                int n = index(latin, chars[i]);
-                if (n < 0) throw new URISyntaxException(str, "String contains unescapable character");
-                sb.append(latinEsc[n]);
-                esc = true;
-            }
-        }
-        if (!esc) return str;
-        return sb.toString();
-    }
-    
-    /** Fixes windows file URI string by converting back slashes to forward
-     * slashes and inserting a forward slash before the drive letter if it is
-     * missing.  No normalisation or modification of case is performed.
-     */
-    public static String fixWindowsURI(String uri) {
-        if (uri == null) return null;
-        if ( uri.startsWith("file:") || uri.startsWith("FILE:")){
-            char [] u = uri.toCharArray();
-            int l = u.length; 
-            StringBuilder sb = new StringBuilder();
-            for (int i=0; i<l; i++){
-                // Ensure we use forward slashes
-                if (u[i] == File.separatorChar) {
-                    sb.append('/');
-                    continue;
-                }
-                if (i == 5 && uri.startsWith(":", 6 )) {
-                    // Windows drive letter without leading slashes doesn't comply
-                    // with URI spec, fix it here
-                    sb.append("/");
-                }
-                sb.append(u[i]);
-            }
-            return sb.toString();
-        }
-        return uri;
-    }
-    
-    private static void processLatin(){
-        /*  Complete list of Unicode Latin possible to represent with percentage encoding.*/
-        //          Basic Latin 
-        //            Position Decimal Name Appearance 
-        //            0x0000 0 <control>: NULL 
-        latin[0] = '\u0000';
-        latinEsc[0] = "%00";
-        //            0x0001 1 <control>: START OF HEADING  
-        latin[1] = '\u0001';
-        latinEsc[1] = "%01";
-        //            0x0002 2 <control>: START OF TEXT 
-        latin[2] = '\u0002';
-        latinEsc[2] = "%02";
-        //            0x0003 3 <control>: END OF TEXT  
-        latin[3] = '\u0003';
-        latinEsc[3] = "%03";
-        //            0x0004 4 <control>: END OF TRANSMISSION 
-        latin[4] = '\u0004';
-        latinEsc[4] = "%04";
-        //            0x0005 5 <control>: ENQUIRY  
-        latin[5] = '\u0005';
-        latinEsc[5] = "%05";
-        //            0x0006 6 <control>: ACKNOWLEDGE  
-        latin[6] = '\u0006';
-        latinEsc[6] = "%06";
-        //            0x0007 7 <control>: BELL  
-        latin[7] = '\u0007';
-        latinEsc[7] = "%07";
-        //            0x0008 8 <control>: BACKSPACE 
-        latin[8] = '\u0008';
-        latinEsc[8] = "%08";
-        //            0x0009 9 <control>: HORIZONTAL TABULATION  
-        latin[9] = '\u0009';
-        latinEsc[9] = "%09";
-        //            0x000A 10 <control>: LINE FEED  
-        latin[10] = '\n';
-        latinEsc[10] = "%0A";
-        //            0x000B 11 <control>: VERTICAL TABULATION 
-        latin[11] = '\u000B';
-        latinEsc[11] = "%0B";
-        //            0x000C 12 <control>: FORM FEED  
-        latin[12] = '\u000C';
-        latinEsc[12] = "%0C";
-        //            0x000D 13 <control>: CARRIAGE RETURN 
-        latin[13] = '\r';
-        latinEsc[13] = "%0D";
-        //            0x000E 14 <control>: SHIFT OUT 
-        latin[14] = '\u000E';
-        latinEsc[14] = "%0E";
-        //            0x000F 15 <control>: SHIFT IN  
-        latin[15] = '\u000F';
-        latinEsc[15] = "%0F";
-        //            0x0010 16 <control>: DATA LINK ESCAPE 
-        latin[16] = '\u0010';
-        latinEsc[16] = "%10";
-        //            0x0011 17 <control>: DEVICE CONTROL ONE 
-        latin[17] = '\u0011';
-        latinEsc[17] = "%11";
-        //            0x0012 18 <control>: DEVICE CONTROL TWO 
-        latin[18] = '\u0012';
-        latinEsc[18] = "%12";
-        //            0x0013 19 <control>: DEVICE CONTROL THREE 
-        latin[19] = '\u0013';
-        latinEsc[19] = "%13";
-        //            0x0014 20 <control>: DEVICE CONTROL FOUR 
-        latin[20] = '\u0014';
-        latinEsc[20] = "%14";
-        //            0x0015 21 <control>: NEGATIVE ACKNOWLEDGE 
-        latin[21] = '\u0015';
-        latinEsc[21] = "%15";
-        //            0x0016 22 <control>: SYNCHRONOUS IDLE 
-        latin[22] = '\u0016';
-        latinEsc[22] = "%16"; 
-        //            0x0017 23 <control>: END OF TRANSMISSION BLOCK  
-        latin[23] = '\u0017';
-        latinEsc[23] = "%17";
-        //            0x0018 24 <control>: CANCEL  
-        latin[24] = '\u0018';
-        latinEsc[24] = "%18";
-        //            0x0019 25 <control>: END OF MEDIUM  
-        latin[25] = '\u0019';
-        latinEsc[25] = "%19";
-        //            0x001A 26 <control>: SUBSTITUTE  
-        latin[26] = '\u001A';
-        latinEsc[26] = "%1A";
-        //            0x001B 27 <control>: ESCAPE  
-        latin[27] = '\u001B';
-        latinEsc[27] = "%1B";
-        //            0x001C 28 <control>: FILE SEPARATOR  
-        latin[28] = '\u001C';
-        latinEsc[28] = "%1C";
-        //            0x001D 29 <control>: GROUP SEPARATOR  
-        latin[29] = '\u001D';
-        latinEsc[29] = "%1D";
-        //            0x001E 30 <control>: RECORD SEPARATOR  
-        latin[30] = '\u001E';
-        latinEsc[30] = "%1E";
-        //            0x001F 31 <control>: UNIT SEPARATOR  
-        latin[31] = '\u001F';
-        latinEsc[31] = "%1F";
-        //            0x0020 32 SPACE  
-        latin[32] = '\u0020';
-        latinEsc[32] = "%20";
-        //            0x0021 33 EXCLAMATION MARK ! 
-        latin[33] = '\u0021';
-        latinEsc[33] = "%21";
-        //            0x0022 34 QUOTATION MARK " 
-        latin[34] = '\u0022';
-        latinEsc[34] = "%22";
-        //            0x0023 35 NUMBER SIGN # 
-        latin[35] = '\u0023';
-        latinEsc[35] = "%23";
-        //            0x0024 36 DOLLAR SIGN $ 
-        latin[36] = '\u0024';
-        latinEsc[36] = "%24";
-        //            0x0025 37 PERCENT SIGN % 
-        latin[37] = '\u0025';
-        latinEsc[37] = "%25";
-        //            0x0026 38 AMPERSAND & 
-        latin[38] = '\u0026';
-        latinEsc[38] = "%26";
-        //            0x0027 39 APOSTROPHE ' 
-        latin[39] = '\'';
-        latinEsc[39] = "%27";
-        //            0x0028 40 LEFT PARENTHESIS ( 
-        latin[40] = '\u0028';
-        latinEsc[40] = "%28";
-        //            0x0029 41 RIGHT PARENTHESIS ) 
-        latin[41] = '\u0029';
-        latinEsc[41] = "%29";
-        //            0x002A 42 ASTERISK * 
-        latin[42] = '\u002A';
-        latinEsc[42] = "%2A";
-        //            0x002B 43 PLUS SIGN + 
-        latin[43] = '\u002B';
-        latinEsc[43] = "%2B";
-        //            0x002C 44 COMMA , 
-        latin[44] = '\u002C';
-        latinEsc[44] = "%2C";
-        //            0x002D 45 HYPHEN-MINUS - 
-        latin[45] = '\u002D';
-        latinEsc[0] = "%2D";
-        //            0x002E 46 FULL STOP . 
-        latin[46] = '\u002E';
-        latinEsc[46] = "%2E";
-        //            0x002F 47 SOLIDUS / 
-        latin[47] = '\u002F';
-        latinEsc[47] = "%2F";
-        //            0x0030 48 DIGIT ZERO 0 
-        latin[48] = '\u0030';
-        latinEsc[48] = "%30";
-        //            0x0031 49 DIGIT ONE 1 
-        latin[49] = '\u0031';
-        latinEsc[49] = "%31";
-        //            0x0032 50 DIGIT TWO 2 
-        latin[50] = '\u0032';
-        latinEsc[50] = "%32";
-        //            0x0033 51 DIGIT THREE 3 
-        latin[51] = '\u0033';
-        latinEsc[51] = "%33";
-        //            0x0034 52 DIGIT FOUR 4 
-        latin[52] = '\u0034';
-        latinEsc[52] = "%34";
-        //            0x0035 53 DIGIT FIVE 5 
-        latin[53] = '\u0035';
-        latinEsc[53] = "%35";
-        //            0x0036 54 DIGIT SIX 6 
-        latin[54] = '\u0036';
-        latinEsc[54] = "%36";
-        //            0x0037 55 DIGIT SEVEN 7 
-        latin[55] = '\u0037';
-        latinEsc[55] = "%37";
-        //            0x0038 56 DIGIT EIGHT 8 
-        latin[56] = '\u0038';
-        latinEsc[56] = "%38";
-        //            0x0039 57 DIGIT NINE 9 
-        latin[57] = '\u0039';
-        latinEsc[57] = "%39";
-        //            0x003A 58 COLON : 
-        latin[58] = '\u003A';
-        latinEsc[58] = "%3A";
-        //            0x003B 59 SEMICOLON ; 
-        latin[59] = '\u003B';
-        latinEsc[59] = "%3B";
-        //            0x003C 60 LESS-THAN SIGN < 
-        latin[60] = '\u003C';
-        latinEsc[60] = "%3C";
-        //            0x003D 61 EQUALS SIGN = 
-        latin[61] = '\u003D';
-        latinEsc[61] = "%3D";
-        //            0x003E 62 GREATER-THAN SIGN > 
-        latin[62] = '\u003E';
-        latinEsc[62] = "%3E";
-        //            0x003F 63 QUESTION MARK ? 
-        latin[63] = '\u003F';
-        latinEsc[63] = "%3F";
-        //            0x0040 64 COMMERCIAL AT @ 
-        latin[64] = '\u0040';
-        latinEsc[64] = "%40";
-        //            0x0041 65 LATIN CAPITAL LETTER A A 
-        latin[65] = '\u0041';
-        latinEsc[65] = "%41";
-        //            0x0042 66 LATIN CAPITAL LETTER B B 
-        latin[66] = '\u0042';
-        latinEsc[66] = "%42";
-        //            0x0043 67 LATIN CAPITAL LETTER C C 
-        latin[67] = '\u0043';
-        latinEsc[67] = "%43";
-        //            0x0044 68 LATIN CAPITAL LETTER D D 
-        latin[68] = '\u0044';
-        latinEsc[68] = "%44";
-        //            0x0045 69 LATIN CAPITAL LETTER E E 
-        latin[69] = '\u0045';
-        latinEsc[69] = "%45";
-        //            0x0046 70 LATIN CAPITAL LETTER F F 
-        latin[70] = '\u0046';
-        latinEsc[70] = "%46";
-        //            0x0047 71 LATIN CAPITAL LETTER G G 
-        latin[71] = '\u0047';
-        latinEsc[71] = "%47";
-        //            0x0048 72 LATIN CAPITAL LETTER H H 
-        latin[72] = '\u0048';
-        latinEsc[72] = "%48";
-        //            0x0049 73 LATIN CAPITAL LETTER I I 
-        latin[73] = '\u0049';
-        latinEsc[73] = "%49";
-        //            0x004A 74 LATIN CAPITAL LETTER J J 
-        latin[74] = '\u004A';
-        latinEsc[74] = "%4A";
-        //            0x004B 75 LATIN CAPITAL LETTER K K 
-        latin[75] = '\u004B';
-        latinEsc[75] = "%4B";
-        //            0x004C 76 LATIN CAPITAL LETTER L L 
-        latin[76] = '\u004C';
-        latinEsc[76] = "%4C";
-        //            0x004D 77 LATIN CAPITAL LETTER M M 
-        latin[77] = '\u004D';
-        latinEsc[77] = "%4D";
-        //            0x004E 78 LATIN CAPITAL LETTER N N 
-        latin[78] = '\u004E';
-        latinEsc[78] = "%4E";
-        //            0x004F 79 LATIN CAPITAL LETTER O O 
-        latin[79] = '\u004F';
-        latinEsc[79] = "%4F";
-        //            0x0050 80 LATIN CAPITAL LETTER P P 
-        latin[80] = '\u0050';
-        latinEsc[80] = "%50";
-        //            0x0051 81 LATIN CAPITAL LETTER Q Q 
-        latin[81] = '\u0051';
-        latinEsc[81] = "%51";
-        //            0x0052 82 LATIN CAPITAL LETTER R R 
-        latin[82] = '\u0052';
-        latinEsc[82] = "%52";
-        //            0x0053 83 LATIN CAPITAL LETTER S S 
-        latin[83] = '\u0053';
-        latinEsc[83] = "%53";
-        //            0x0054 84 LATIN CAPITAL LETTER T T 
-        latin[84] = '\u0054';
-        latinEsc[84] = "%54";
-        //            0x0055 85 LATIN CAPITAL LETTER U U 
-        latin[85] = '\u0055';
-        latinEsc[85] = "%55";
-        //            0x0056 86 LATIN CAPITAL LETTER V V 
-        latin[86] = '\u0056';
-        latinEsc[86] = "%56";
-        //            0x0057 87 LATIN CAPITAL LETTER W W 
-        latin[87] = '\u0057';
-        latinEsc[87] = "%57";
-        //            0x0058 88 LATIN CAPITAL LETTER X X 
-        latin[88] = '\u0058';
-        latinEsc[88] = "%58";
-        //            0x0059 89 LATIN CAPITAL LETTER Y Y 
-        latin[89] = '\u0059';
-        latinEsc[89] = "%59";
-        //            0x005A 90 LATIN CAPITAL LETTER Z Z 
-        latin[90] = '\u005A';
-        latinEsc[90] = "%5A";
-        //            0x005B 91 LEFT SQUARE BRACKET [ 
-        latin[91] = '\u005B';
-        latinEsc[91] = "%5B";
-        //            0x005C 92 REVERSE SOLIDUS \ 
-        latin[92] = '\\';
-        latinEsc[92] = "%5C";
-        //            0x005D 93 RIGHT SQUARE BRACKET ] 
-        latin[93] = '\u005D';
-        latinEsc[93] = "%5D";
-        //            0x005E 94 CIRCUMFLEX ACCENT ^ 
-        latin[94] = '\u005E';
-        latinEsc[94] = "%5E";
-        //            0x005F 95 LOW LINE _ 
-        latin[95] = '\u005F';
-        latinEsc[95] = "%5F";
-        //            0x0060 96 GRAVE ACCENT ` 
-        latin[96] = '\u0060';
-        latinEsc[96] = "%60";
-        //            0x0061 97 LATIN SMALL LETTER A a 
-        latin[97] = '\u0061';
-        latinEsc[97] = "%61";
-        //            0x0062 98 LATIN SMALL LETTER B b 
-        latin[98] = '\u0062';
-        latinEsc[98] = "%62";
-        //            0x0063 99 LATIN SMALL LETTER C c 
-        latin[99] = '\u0063';
-        latinEsc[99] = "%63";
-        //            0x0064 100 LATIN SMALL LETTER D d 
-        latin[100] = '\u0064';
-        latinEsc[100] = "%64";
-        //            0x0065 101 LATIN SMALL LETTER E e 
-        latin[101] = '\u0065';
-        latinEsc[101] = "%65";
-        //            0x0066 102 LATIN SMALL LETTER F f 
-        latin[102] = '\u0066';
-        latinEsc[102] = "%66";
-        //            0x0067 103 LATIN SMALL LETTER G g 
-        latin[103] = '\u0067';
-        latinEsc[103] = "%67";
-        //            0x0068 104 LATIN SMALL LETTER H h 
-        latin[104] = '\u0068';
-        latinEsc[104] = "%68";
-        //            0x0069 105 LATIN SMALL LETTER I i 
-        latin[105] = '\u0069';
-        latinEsc[105] = "%69";
-        //            0x006A 106 LATIN SMALL LETTER J j 
-        latin[106] = '\u006A';
-        latinEsc[106] = "%6A";
-        //            0x006B 107 LATIN SMALL LETTER K k 
-        latin[107] = '\u006B';
-        latinEsc[107] = "%6B";
-        //            0x006C 108 LATIN SMALL LETTER L l 
-        latin[108] = '\u006C';
-        latinEsc[108] = "%6C";
-        //            0x006D 109 LATIN SMALL LETTER M m 
-        latin[109] = '\u006D';
-        latinEsc[109] = "%6D";
-        //            0x006E 110 LATIN SMALL LETTER N n 
-        latin[110] = '\u006E';
-        latinEsc[110] = "%6E";
-        //            0x006F 111 LATIN SMALL LETTER O o 
-        latin[111] = '\u006F';
-        latinEsc[111] = "%6F";
-        //            0x0070 112 LATIN SMALL LETTER P p 
-        latin[112] = '\u0070';
-        latinEsc[112] = "%70";
-        //            0x0071 113 LATIN SMALL LETTER Q q 
-        latin[113] = '\u0071';
-        latinEsc[113] = "%71";
-        //            0x0072 114 LATIN SMALL LETTER R r 
-        latin[114] = '\u0072';
-        latinEsc[114] = "%72";
-        //            0x0073 115 LATIN SMALL LETTER S s 
-        latin[115] = '\u0073';
-        latinEsc[115] = "%73";
-        //            0x0074 116 LATIN SMALL LETTER T t 
-        latin[116] = '\u0074';
-        latinEsc[116] = "%74";
-        //            0x0075 117 LATIN SMALL LETTER U u 
-        latin[117] = '\u0075';
-        latinEsc[117] = "%75";
-        //            0x0076 118 LATIN SMALL LETTER V v 
-        latin[118] = '\u0076';
-        latinEsc[118] = "%76";
-        //            0x0077 119 LATIN SMALL LETTER W w 
-        latin[119] = '\u0077';
-        latinEsc[119] = "%77";
-        //            0x0078 120 LATIN SMALL LETTER X x 
-        latin[120] = '\u0078';
-        latinEsc[120] = "%78";
-        //            0x0079 121 LATIN SMALL LETTER Y y 
-        latin[121] = '\u0079';
-        latinEsc[121] = "%79";
-        //            0x007A 122 LATIN SMALL LETTER Z z 
-        latin[122] = '\u007A';
-        latinEsc[122] = "%7A";
-        //            0x007B 123 LEFT CURLY BRACKET { 
-        latin[123] = '\u007B';
-        latinEsc[123] = "%7B";
-        //            0x007C 124 VERTICAL LINE | 
-        latin[124] = '\u007C';
-        latinEsc[124] = "%7C";
-        //            0x007D 125 RIGHT CURLY BRACKET } 
-        latin[125] = '\u007D';
-        latinEsc[125] = "%7D";
-        //            0x007E 126 TILDE ~ 
-        latin[126] = '\u007E';
-        latinEsc[126] = "%7E";
-        //            0x007F 127 <control>: DELETE  
-        latin[127] = '\u007F';
-        latinEsc[127] = "%7F";
-        
-        //            Latin-1 Supplement 
-        //            Position Decimal Name Appearance 
-        //            0x0080 128 <control>:  
-        latin[128] = '\u0080';
-        latinEsc[128] = "%80";
-        //            0x0081 129 <control>:  ? 
-        latin[129] = '\u0081';
-        latinEsc[129] = "%81";
-        //            0x0082 130 <control>: BREAK PERMITTED HERE 
-        latin[130] = '\u0082';
-        latinEsc[130] = "%82";
-        //            0x0083 131 <control>: NO BREAK HERE 
-        latin[131] = '\u0083';
-        latinEsc[131] = "%83";
-        //            0x0084 132 <control>:  
-        latin[132] = '\u0084';
-        latinEsc[132] = "%84";
-        //            0x0085 133 <control>: NEXT LINE 
-        latin[133] = '\u0085';
-        latinEsc[133] = "%85";
-        //            0x0086 134 <control>: START OF SELECTED AREA 
-        latin[134] = '\u0086';
-        latinEsc[134] = "%86";
-        //            0x0087 135 <control>: END OF SELECTED AREA 
-        latin[135] = '\u0087';
-        latinEsc[135] = "%87";
-        //            0x0088 136 <control>: CHARACTER TABULATION SET 
-        latin[136] = '\u0088';
-        latinEsc[136] = "%88";
-        //            0x0089 137 <control>: CHARACTER TABULATION WITH JUSTIFICATION 
-        latin[137] = '\u0089';
-        latinEsc[137] = "%89";
-        //            0x008A 138 <control>: LINE TABULATION SET 
-        latin[138] = '\u008A';
-        latinEsc[138] = "%8A";
-        //            0x008B 139 <control>: PARTIAL LINE DOWN 
-        latin[139] = '\u008B';
-        latinEsc[139] = "%8B";
-        //            0x008C 140 <control>: PARTIAL LINE UP 
-        latin[140] = '\u008C';
-        latinEsc[140] = "%8C";
-        //            0x008D 141 <control>: REVERSE LINE FEED 
-        latin[141] = '\u008D';
-        latinEsc[141] = "%8D";
-        //            0x008E 142 <control>: SINGLE SHIFT TWO 
-        latin[142] = '\u008E';
-        latinEsc[142] = "%8E";
-        //            0x008F 143 <control>: SINGLE SHIFT THREE 
-        latin[143] = '\u008F';
-        latinEsc[143] = "%8F";
-        //            0x0090 144 <control>: DEVICE CONTROL STRING 
-        latin[144] = '\u0090';
-        latinEsc[144] = "%90";
-        //            0x0091 145 <control>: PRIVATE USE ONE 
-        latin[145] = '\u0091';
-        latinEsc[145] = "%91";
-        //            0x0092 146 <control>: PRIVATE USE TWO 
-        latin[146] = '\u0092';
-        latinEsc[146] = "%92";
-        //            0x0093 147 <control>: SET TRANSMIT STATE 
-        latin[147] = '\u0093';
-        latinEsc[147] = "%93";
-        //            0x0094 148 <control>: CANCEL CHARACTER 
-        latin[148] = '\u0094';
-        latinEsc[148] = "%94";
-        //            0x0095 149 <control>: MESSAGE WAITING 
-        latin[149] = '\u0095';
-        latinEsc[149] = "%95";
-        //            0x0096 150 <control>: START OF GUARDED AREA 
-        latin[150] = '\u0096';
-        latinEsc[150] = "%96";
-        //            0x0097 151 <control>: END OF GUARDED AREA 
-        latin[151] = '\u0097';
-        latinEsc[151] = "%97";
-        //            0x0098 152 <control>: START OF STRING 
-        latin[152] = '\u0098';
-        latinEsc[152] = "%98";
-        //            0x0099 153 <control>:  
-        latin[153] = '\u0099';
-        latinEsc[153] = "%99";
-        //            0x009A 154 <control>: SINGLE CHARACTER INTRODUCER 
-        latin[154] = '\u009A';
-        latinEsc[154] = "%9A";
-        //            0x009B 155 <control>: CONTROL SEQUENCE INTRODUCER 
-        latin[155] = '\u009B';
-        latinEsc[155] = "%9B";
-        //            0x009C 156 <control>: STRING TERMINATOR 
-        latin[156] = '\u009C';
-        latinEsc[156] = "%9C";
-        //            0x009D 157 <control>: OPERATING SYSTEM COMMAND 
-        latin[157] = '\u009D';
-        latinEsc[157] = "%9D";
-        //            0x009E 158 <control>: PRIVACY MESSAGE 
-        latin[158] = '\u009E';
-        latinEsc[158] = "%9E";
-        //            0x009F 159 <control>: APPLICATION PROGRAM COMMAND 
-        latin[159] = '\u009F';
-        latinEsc[159] = "%9F";
-        //            0x00A0 160 NO-BREAK SPACE   
-        latin[160] = '\u00A0';
-        latinEsc[160] = "%A0";
-        //            0x00A1 161 INVERTED EXCLAMATION MARK 
-        latin[161] = '\u00A1';
-        latinEsc[161] = "%A1";
-        //            0x00A2 162 CENT SIGN 
-        latin[162] = '\u00A2';
-        latinEsc[162] = "%A2";
-        //            0x00A3 163 POUND SIGN 
-        latin[163] = '\u00A3';
-        latinEsc[163] = "%A3";
-        //            0x00A4 164 CURRENCY SIGN 
-        latin[164] = '\u00A4';
-        latinEsc[164] = "%A4";
-        //            0x00A5 165 YEN SIGN 
-        latin[165] = '\u00A5';
-        latinEsc[165] = "%A5";
-        //            0x00A6 166 BROKEN BAR 
-        latin[166] = '\u00A6';
-        latinEsc[166] = "%A6";
-        //            0x00A7 167 SECTION SIGN 
-        latin[167] = '\u00A7';
-        latinEsc[167] = "%A7";
-        //            0x00A8 168 DIAERESIS 
-        latin[168] = '\u00A8';
-        latinEsc[168] = "%A8";
-        //            0x00A9 169 COPYRIGHT SIGN 
-        latin[169] = '\u00A9';
-        latinEsc[169] = "%A9";
-        //            0x00AA 170 FEMININE ORDINAL INDICATOR 
-        latin[170] = '\u00AA';
-        latinEsc[170] = "%AA";
-        //            0x00AB 171 LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 
-        latin[171] = '\u00AB';
-        latinEsc[171] = "%AB";
-        //            0x00AC 172 NOT SIGN 
-        latin[172] = '\u00AC';
-        latinEsc[172] = "%AC";
-        //            0x00AD 173 SOFT HYPHEN 
-        latin[173] = '\u00AD';
-        latinEsc[173] = "%AD";
-        //            0x00AE 174 REGISTERED SIGN 
-        latin[174] = '\u00AE';
-        latinEsc[174] = "%AE";
-        //            0x00AF 175 MACRON 
-        latin[175] = '\u00AF';
-        latinEsc[175] = "%AF";
-        //            0x00B0 176 DEGREE SIGN 
-        latin[176] = '\u00B0';
-        latinEsc[176] = "%B0";
-        //            0x00B1 177 PLUS-MINUS SIGN 
-        latin[177] = '\u00B1';
-        latinEsc[177] = "%B1";
-        //            0x00B2 178 SUPERSCRIPT TWO 
-        latin[178] = '\u00B2';
-        latinEsc[178] = "%B2";
-        //            0x00B3 179 SUPERSCRIPT THREE 
-        latin[179] = '\u00B3';
-        latinEsc[179] = "%B3";
-        //            0x00B4 180 ACUTE ACCENT 
-        latin[180] = '\u00B4';
-        latinEsc[180] = "%B4";
-        //            0x00B5 181 MICRO SIGN 
-        latin[181] = '\u00B5';
-        latinEsc[181] = "%B5";
-        //            0x00B6 182 PILCROW SIGN 
-        latin[182] = '\u00B6';
-        latinEsc[182] = "%B6";
-        //            0x00B7 183 MIDDLE DOT 
-        latin[183] = '\u00B7';
-        latinEsc[183] = "%B7";
-        //            0x00B8 184 CEDILLA 
-        latin[184] = '\u00B8';
-        latinEsc[184] = "%B8";
-        //            0x00B9 185 SUPERSCRIPT ONE 
-        latin[185] = '\u00B9';
-        latinEsc[185] = "%B9";
-        //            0x00BA 186 MASCULINE ORDINAL INDICATOR 
-        latin[186] = '\u00BA';
-        latinEsc[186] = "%BA";
-        //            0x00BB 187 RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 
-        latin[187] = '\u00BB';
-        latinEsc[187] = "%BB";
-        //            0x00BC 188 VULGAR FRACTION ONE QUARTER 
-        latin[188] = '\u00BC';
-        latinEsc[188] = "%BC";
-        //            0x00BD 189 VULGAR FRACTION ONE HALF 
-        latin[189] = '\u00BD';
-        latinEsc[189] = "%BD";
-        //            0x00BE 190 VULGAR FRACTION THREE QUARTERS 
-        latin[190] = '\u00BE';
-        latinEsc[190] = "%BE";
-        //            0x00BF 191 INVERTED QUESTION MARK 
-        latin[191] = '\u00BF';
-        latinEsc[191] = "%BF";
-        //            0x00C0 192 LATIN CAPITAL LETTER A WITH GRAVE 
-        latin[192] = '\u00C0';
-        latinEsc[192] = "%C0";
-        //            0x00C1 193 LATIN CAPITAL LETTER A WITH ACUTE 
-        latin[193] = '\u00C1';
-        latinEsc[193] = "%C1";
-        //            0x00C2 194 LATIN CAPITAL LETTER A WITH CIRCUMFLEX 
-        latin[194] = '\u00C2';
-        latinEsc[194] = "%C2";
-        //            0x00C3 195 LATIN CAPITAL LETTER A WITH TILDE 
-        latin[195] = '\u00C3';
-        latinEsc[195] = "%C3";
-        //            0x00C4 196 LATIN CAPITAL LETTER A WITH DIAERESIS 
-        latin[196] = '\u00C4';
-        latinEsc[196] = "%C4";
-        //            0x00C5 197 LATIN CAPITAL LETTER A WITH RING ABOVE 
-        latin[197] = '\u00C5';
-        latinEsc[197] = "%C5";
-        //            0x00C6 198 LATIN CAPITAL LETTER AE 
-        latin[198] = '\u00C6';
-        latinEsc[198] = "%C6";
-        //            0x00C7 199 LATIN CAPITAL LETTER C WITH CEDILLA 
-        latin[199] = '\u00C7';
-        latinEsc[199] = "%C7";
-        //            0x00C8 200 LATIN CAPITAL LETTER E WITH GRAVE 
-        latin[200] = '\u00C8';
-        latinEsc[200] = "%C8";
-        //            0x00C9 201 LATIN CAPITAL LETTER E WITH ACUTE 
-        latin[201] = '\u00C9';
-        latinEsc[201] = "%C9";
-        //            0x00CA 202 LATIN CAPITAL LETTER E WITH CIRCUMFLEX 
-        latin[202] = '\u00CA';
-        latinEsc[202] = "%CA";
-        //            0x00CB 203 LATIN CAPITAL LETTER E WITH DIAERESIS 
-        latin[203] = '\u00CB';
-        latinEsc[203] = "%CB";
-        //            0x00CC 204 LATIN CAPITAL LETTER I WITH GRAVE 
-        latin[204] = '\u00CC';
-        latinEsc[204] = "%CC";
-        //            0x00CD 205 LATIN CAPITAL LETTER I WITH ACUTE 
-        latin[205] = '\u00CD';
-        latinEsc[205] = "%CD";
-        //            0x00CE 206 LATIN CAPITAL LETTER I WITH CIRCUMFLEX 
-        latin[206] = '\u00CE';
-        latinEsc[206] = "%CE";
-        //            0x00CF 207 LATIN CAPITAL LETTER I WITH DIAERESIS 
-        latin[207] = '\u00CF';
-        latinEsc[207] = "%CF";
-        //            0x00D0 208 LATIN CAPITAL LETTER ETH 
-        latin[208] = '\u00D0';
-        latinEsc[208] = "%D0";
-        //            0x00D1 209 LATIN CAPITAL LETTER N WITH TILDE 
-        latin[209] = '\u00D1';
-        latinEsc[209] = "%D1";
-        //            0x00D2 210 LATIN CAPITAL LETTER O WITH GRAVE 
-        latin[210] = '\u00D2';
-        latinEsc[210] = "%D2";
-        //            0x00D3 211 LATIN CAPITAL LETTER O WITH ACUTE 
-        latin[211] = '\u00D3';
-        latinEsc[211] = "%D3";
-        //            0x00D4 212 LATIN CAPITAL LETTER O WITH CIRCUMFLEX 
-        latin[212] = '\u00D4';
-        latinEsc[212] = "%D4";
-        //            0x00D5 213 LATIN CAPITAL LETTER O WITH TILDE 
-        latin[213] = '\u00D5';
-        latinEsc[213] = "%D5";
-        //            0x00D6 214 LATIN CAPITAL LETTER O WITH DIAERESIS 
-        latin[214] = '\u00D6';
-        latinEsc[214] = "%D6";
-        //            0x00D7 215 MULTIPLICATION SIGN 
-        latin[215] = '\u00D7';
-        latinEsc[215] = "%D7";
-        //            0x00D8 216 LATIN CAPITAL LETTER O WITH STROKE 
-        latin[216] = '\u00D8';
-        latinEsc[216] = "%D8";
-        //            0x00D9 217 LATIN CAPITAL LETTER U WITH GRAVE 
-        latin[217] = '\u00D9';
-        latinEsc[217] = "%D9";
-        //            0x00DA 218 LATIN CAPITAL LETTER U WITH ACUTE 
-        latin[218] = '\u00DA';
-        latinEsc[218] = "%DA";
-        //            0x00DB 219 LATIN CAPITAL LETTER U WITH CIRCUMFLEX 
-        latin[219] = '\u00DB';
-        latinEsc[219] = "%DB";
-        //            0x00DC 220 LATIN CAPITAL LETTER U WITH DIAERESIS 
-        latin[220] = '\u00DC';
-        latinEsc[220] = "%DC";
-        //            0x00DD 221 LATIN CAPITAL LETTER Y WITH ACUTE 
-        latin[221] = '\u00DD';
-        latinEsc[221] = "%DD";
-        //            0x00DE 222 LATIN CAPITAL LETTER THORN 
-        latin[222] = '\u00DE';
-        latinEsc[222] = "%DE";
-        //            0x00DF 223 LATIN SMALL LETTER SHARP S 
-        latin[223] = '\u00DF';
-        latinEsc[223] = "%DF";
-        //            0x00E0 224 LATIN SMALL LETTER A WITH GRAVE 
-        latin[224] = '\u00E0';
-        latinEsc[224] = "%E0";
-        //            0x00E1 225 LATIN SMALL LETTER A WITH ACUTE 
-        latin[225] = '\u00E1';
-        latinEsc[225] = "%E1";
-        //            0x00E2 226 LATIN SMALL LETTER A WITH CIRCUMFLEX 
-        latin[226] = '\u00E2';
-        latinEsc[226] = "%E2";
-        //            0x00E3 227 LATIN SMALL LETTER A WITH TILDE 
-        latin[227] = '\u00E3';
-        latinEsc[227] = "%E3";
-        //            0x00E4 228 LATIN SMALL LETTER A WITH DIAERESIS 
-        latin[228] = '\u00E4';
-        latinEsc[228] = "%E4";
-        //            0x00E5 229 LATIN SMALL LETTER A WITH RING ABOVE 
-        latin[229] = '\u00E5';
-        latinEsc[229] = "%E5";
-        //            0x00E6 230 LATIN SMALL LETTER AE 
-        latin[230] = '\u00E6';
-        latinEsc[230] = "%E6";
-        //            0x00E7 231 LATIN SMALL LETTER C WITH CEDILLA 
-        latin[231] = '\u00E7';
-        latinEsc[231] = "%E7";
-        //            0x00E8 232 LATIN SMALL LETTER E WITH GRAVE 
-        latin[232] = '\u00E8';
-        latinEsc[232] = "%E8";
-        //            0x00E9 233 LATIN SMALL LETTER E WITH ACUTE 
-        latin[233] = '\u00E9';
-        latinEsc[233] = "%E9";
-        //            0x00EA 234 LATIN SMALL LETTER E WITH CIRCUMFLEX 
-        latin[234] = '\u00EA';
-        latinEsc[234] = "%EA";
-        //            0x00EB 235 LATIN SMALL LETTER E WITH DIAERESIS 
-        latin[235] = '\u00EB';
-        latinEsc[235] = "%EB";
-        //            0x00EC 236 LATIN SMALL LETTER I WITH GRAVE 
-        latin[236] = '\u00EC';
-        latinEsc[236] = "%EC";
-        //            0x00ED 237 LATIN SMALL LETTER I WITH ACUTE 
-        latin[237] = '\u00ED';
-        latinEsc[237] = "%ED";
-        //            0x00EE 238 LATIN SMALL LETTER I WITH CIRCUMFLEX 
-        latin[238] = '\u00EE';
-        latinEsc[238] = "%EE";
-        //            0x00EF 239 LATIN SMALL LETTER I WITH DIAERESIS 
-        latin[239] = '\u00EF';
-        latinEsc[239] = "%EF";
-        //            0x00F0 240 LATIN SMALL LETTER ETH 
-        latin[240] = '\u00F0';
-        latinEsc[240] = "%F0";
-        //            0x00F1 241 LATIN SMALL LETTER N WITH TILDE 
-        latin[241] = '\u00F1';
-        latinEsc[241] = "%F1";
-        //            0x00F2 242 LATIN SMALL LETTER O WITH GRAVE 
-        latin[242] = '\u00F2';
-        latinEsc[242] = "%F2";
-        //            0x00F3 243 LATIN SMALL LETTER O WITH ACUTE 
-        latin[243] = '\u00F3';
-        latinEsc[243] = "%F3";
-        //            0x00F4 244 LATIN SMALL LETTER O WITH CIRCUMFLEX 
-        latin[244] = '\u00F4';
-        latinEsc[244] = "%F4";
-        //            0x00F5 245 LATIN SMALL LETTER O WITH TILDE 
-        latin[245] = '\u00F5';
-        latinEsc[245] = "%F5";
-        //            0x00F6 246 LATIN SMALL LETTER O WITH DIAERESIS 
-        latin[246] = '\u00F6';
-        latinEsc[246] = "%F6";
-        //            0x00F7 247 DIVISION SIGN 
-        latin[247] = '\u00F7';
-        latinEsc[247] = "%F7";
-        //            0x00F8 248 LATIN SMALL LETTER O WITH STROKE 
-        latin[248] = '\u00F8';
-        latinEsc[248] = "%F8";
-        //            0x00F9 249 LATIN SMALL LETTER U WITH GRAVE 
-        latin[249] = '\u00F9';
-        latinEsc[249] = "%F9";
-        //            0x00FA 250 LATIN SMALL LETTER U WITH ACUTE 
-        latin[250] = '\u00FA';
-        latinEsc[250] = "%FA";
-        //            0x00FB 251 LATIN SMALL LETTER U WITH CIRCUMFLEX 
-        latin[251] = '\u00FB';
-        latinEsc[251] = "%FB";
-        //            0x00FC 252 LATIN SMALL LETTER U WITH DIAERESIS 
-        latin[252] = '\u00FC';
-        latinEsc[252] = "%FC";
-        //            0x00FD 253 LATIN SMALL LETTER Y WITH ACUTE 
-        latin[253] = '\u00FD';
-        latinEsc[253] = "%FD";
-        //            0x00FE 254 LATIN SMALL LETTER THORN 
-        latin[254] = '\u00FE';
-        latinEsc[254] = "%FE";
-        //            0x00FF 255 LATIN SMALL LETTER Y WITH DIAERESIS 
-        latin[255] = '\u00FF';
-        latinEsc[255] = "%FF";
-    }
+    private static final boolean isFileCaseInsensitiveOS = File.separatorChar == '\\';
     
     String string;
     String scheme;
@@ -1000,9 +46,11 @@ final class UriParser {
     boolean absolute;
     boolean serverAuthority = false;
     int hash = -1;
+    boolean fileSchemeCaseInsensitiveOS;
 
     void parseURI(String uri, boolean forceServer) throws URISyntaxException {
         char fSlash = '/';
+        boolean fileURI;
         StringBuilder temp = new StringBuilder(uri);
         // assign uri string to the input value per spec
         string = uri;
@@ -1030,11 +78,13 @@ final class UriParser {
         if (index != -1 && (index2 >= index || index2 == -1) && (index3 >= index || index3 == -1)) {
             // the characters up to the first ':' comprise the scheme
             absolute = true;
-            scheme = temp.substring(0, index);
+            scheme = temp.substring(0, index).toLowerCase(Locale.ENGLISH);
             if (scheme.length() == 0) {
                 throw new URISyntaxException(uri, Messages.getString("luni.83"), index);
             }
             validateScheme(uri, scheme, 0);
+            fileURI = (scheme.equalsIgnoreCase("file"));
+            fileSchemeCaseInsensitiveOS = (fileURI && isFileCaseInsensitiveOS);
             schemespecificpart = temp.substring(index + 1);
             if (schemespecificpart.length() == 0) {
                 throw new URISyntaxException(uri, Messages.getString("luni.84"), index + 1);
@@ -1054,6 +104,7 @@ final class UriParser {
                 query = temp.substring(index + 1);
                 temp.delete(index, temp.length());
                 validateQuery(uri, query, index2 + 1 + index);
+                if (query == "") query = null;
             }
             // Authority and Path
             if (temp.length() >= 2 && temp.charAt(0) == fSlash && temp.charAt(1) == fSlash) {
@@ -1061,7 +112,15 @@ final class UriParser {
                 index = temp.indexOf("/", 2);
                 if (index != -1) {
                     authority = temp.substring(2, index);
-                    path = temp.substring(index);
+                    path = temp.substring(index);// begins with "/"
+                    //  path        = path-abempty    ; begins with "/" or is empty
+                    String [] segment = path.split("/");
+                    int l = segment.length;
+                    int index4 = 1;
+                    for (int i = 0; i < l ; i++){
+                        validateSegment(uri, segment[i], index1 + index + index4, Uri.segmentLegal);
+                        index4 += (segment[i].length() + 1);
+                    }
                 } else {
                     authority = temp.substring(2);
                     if (authority.length() == 0 && query == null && fragment == null) {
@@ -1073,27 +132,73 @@ final class UriParser {
                 }
                 if (authority.length() == 0) {
                     authority = null;
-                } else {
-                    validateAuthority(uri, authority, index1 + 3);
-                }
+                } 
+                // Authority validated by userinfo, host and port, later.
+//                else {
+//                    validateAuthority(uri, authority, index1 + 3);
+//                }
             } else {
                 // no authority specified
+                String legal;
+                int index4 = 0;
+                if (scheme == null){
+                    // path-noscheme   ; begins with a non-colon segment
+                    // path-noscheme = segment-nz-nc *( "/" segment )
+                    legal = Uri.segmentNzNcLegal;
+                } else {
+                    legal = Uri.segmentLegal;
+                    index4 = index;
+                    // increment index4 if starts with slash.
+                    //if (temp.charAt(0) == fSlash) index4 ++;
+                }
                 path = temp.toString();
+                String [] segment = path.split("/");
+                int l = segment.length;
+                for (int i = 0; i < l ; i++){
+                    // in case scheme == null only first segment is segment-nz-nc
+                    if (i == 1) legal = Uri.segmentLegal;
+                    validateSegment(uri, segment[i], index4, legal);
+                    index4 += (segment[i].length() + 1);
+                }
             }
-            int pathIndex = 0;
-            if (index2 > -1) {
-                pathIndex += index2;
-            }
-            if (index > -1) {
-                pathIndex += index;
-            }
-            validatePath(uri, path, pathIndex);
         } else {
             // if not hierarchical, URI is opaque
             opaque = true;
             validateSsp(uri, schemespecificpart, index2 + 2 + index);
         }
         parseAuthority(forceServer);
+        // Normalise path and replace string.
+        if (!opaque){
+            StringBuilder result = new StringBuilder();
+            String normalizedPath = normalize(path);
+            if (scheme != null) {
+                result.append(scheme);
+                result.append(':');
+            }
+            
+            schemespecificpart = setSchemeSpecificPart(authority, normalizedPath , query);
+            
+            if (authority != null) {
+                result.append("//"); //$NON-NLS-1$
+                result.append(authority);
+            }
+
+            if (path != null) {
+                result.append(normalizedPath);
+            }
+
+            if (query != null) {
+                result.append('?');
+                result.append(query);
+            }
+
+            if (fragment != null) {
+                result.append('#');
+                result.append(fragment);
+            }
+
+            this.string = result.toString();
+        }      
     }
 
     private void validateScheme(String uri, String scheme, int index) throws URISyntaxException {
@@ -1111,31 +216,37 @@ final class UriParser {
 
     private void validateSsp(String uri, String ssp, int index) throws URISyntaxException {
         try {
-            URIEncoderDecoder.validate(ssp, Uri.allLegal);
+            URIEncoderDecoder.validate(ssp, Uri.allLegalUnescaped);
         } catch (URISyntaxException e) {
             throw new URISyntaxException(uri, Messages.getString("luni.86", e.getReason()), index + e.getIndex());
         }
     }
 
-    private void validateAuthority(String uri, String authority, int index) throws URISyntaxException {
-        try {
-            URIEncoderDecoder.validate(authority, "@[]" + Uri.someLegal); //$NON-NLS-1$
-        } catch (URISyntaxException e) {
-            throw new URISyntaxException(uri, Messages.getString("luni.87", e.getReason()), index + e.getIndex());
-        }
-    }
-
-    private void validatePath(String uri, String path, int index) throws URISyntaxException {
+//    private void validateAuthority(String uri, String authority, int index) throws URISyntaxException {
+//        try {
+//            URIEncoderDecoder.validate(authority, "@[]" + Uri.someLegal); //$NON-NLS-1$
+//        } catch (URISyntaxException e) {
+//            throw new URISyntaxException(uri, Messages.getString("luni.87", e.getReason()), index + e.getIndex());
+//        }
+//    }
+//
+//    private void validatePath(String uri, String path, int index) throws URISyntaxException {
+//        try {
+//            URIEncoderDecoder.validate(path, "/@" + Uri.someLegal); //$NON-NLS-1$
+//        } catch (URISyntaxException e) {
+//            throw new URISyntaxException(uri, Messages.getString("luni.88", e.getReason()), index + e.getIndex());
+//        }
+//    }
+    private void validateSegment(String uri, String segment, int index, String legal) throws URISyntaxException {
         try {
-            URIEncoderDecoder.validate(path, "/@" + Uri.someLegal); //$NON-NLS-1$
+            URIEncoderDecoder.validate(segment, legal); //$NON-NLS-1$
         } catch (URISyntaxException e) {
             throw new URISyntaxException(uri, Messages.getString("luni.88", e.getReason()), index + e.getIndex());
         }
     }
-
     private void validateQuery(String uri, String query, int index) throws URISyntaxException {
         try {
-            URIEncoderDecoder.validate(query, Uri.queryLegal);
+            URIEncoderDecoder.validate(query, Uri.queryFragLegal);
         } catch (URISyntaxException e) {
             throw new URISyntaxException(uri, Messages.getString("luni.89", e.getReason()), index + e.getIndex());
         }
@@ -1143,7 +254,7 @@ final class UriParser {
 
     private void validateFragment(String uri, String fragment, int index) throws URISyntaxException {
         try {
-            URIEncoderDecoder.validate(fragment, Uri.allLegal);
+            URIEncoderDecoder.validate(fragment, Uri.queryFragLegal);
         } catch (URISyntaxException e) {
             throw new URISyntaxException(uri, Messages.getString("luni.8A", e.getReason()), index + e.getIndex());
         }
@@ -1224,12 +335,18 @@ final class UriParser {
     }
 
     private void validateUserinfo(String uri, String userinfo, int index) throws URISyntaxException {
-        for (int i = 0; i < userinfo.length(); i++) {
-            char ch = userinfo.charAt(i);
-            if (ch == ']' || ch == '[') {
-                throw new URISyntaxException(uri, Messages.getString("luni.8C"), index + i);
-            }
+        try {
+            URIEncoderDecoder.validate(userinfo, Uri.userinfoLegal); //$NON-NLS-1$
+        } catch (URISyntaxException e) {
+            throw new URISyntaxException(uri, Messages.getString("luni.8C", e.getReason()), index + e.getIndex());
         }
+//        
+//        for (int i = 0; i < userinfo.length(); i++) {
+//            char ch = userinfo.charAt(i);
+//            if (ch == ']' || ch == '[') {
+//                throw new URISyntaxException(uri, Messages.getString("luni.8C"), index + i);
+//            }
+//        }
     }
 
     /**
@@ -1238,10 +355,12 @@ final class UriParser {
      */
     private boolean isValidHost(boolean forceServer, String host) throws URISyntaxException {
         if (host.charAt(0) == '[') {
-            // ipv6 address
+            // ipv6 address or IPvFuture
             if (host.charAt(host.length() - 1) != ']') {
                 throw new URISyntaxException(host, Messages.getString("luni.8D"), 0); //$NON-NLS-1$
             }
+            // check for valid IPvFuture syntax.
+            if (isValidIPvFutureAddress(host)) return true;
             if (!isValidIP6Address(host)) {
                 throw new URISyntaxException(host, Messages.getString("luni.8E")); //$NON-NLS-1$
             }
@@ -1273,12 +392,8 @@ final class UriParser {
         return false;
     }
 
-    private boolean isValidDomainName(String host) {
-        try {
-            URIEncoderDecoder.validateSimple(host, "-."); //$NON-NLS-1$
-        } catch (URISyntaxException e) {
-            return false;
-        }
+    private boolean isValidDomainName(String host) throws URISyntaxException {
+        URIEncoderDecoder.validate(host, Uri.hostRegNameLegal); //$NON-NLS-1$
         String label = null;
         StringTokenizer st = new StringTokenizer(host, "."); //$NON-NLS-1$
         while (st.hasMoreTokens()) {
@@ -1456,5 +571,125 @@ final class UriParser {
     private boolean isValidHexChar(char c) {
         return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
     }
+
+    private boolean isValidIPvFutureAddress(String ipvFuture) throws URISyntaxException {
+        // [ at index 0 has been checked.
+        if (ipvFuture.charAt(1) != 'v') return false;
+        if (!isValidHexChar(ipvFuture.charAt(2))) return false;
+        if (ipvFuture.charAt(3) != '.') return false;
+        String sub = ipvFuture.substring(4, ipvFuture.length()-1);
+        URIEncoderDecoder.validate(sub, Uri.iPvFuture);
+        return true;
+    }
+    
+    /*
+     * normalize path, and return the resulting string
+     */
+    private String normalize(String path) {
+        // count the number of '/'s, to determine number of segments
+        int index = -1;
+        int pathlen = path.length();
+        int size = 0;
+        if (pathlen > 0 && path.charAt(0) != '/') {
+            size++;
+        }
+        while ((index = path.indexOf('/', index + 1)) != -1) {
+            if (index + 1 < pathlen && path.charAt(index + 1) != '/') {
+                size++;
+            }
+        }
+
+        String[] seglist = new String[size];
+        boolean[] include = new boolean[size];
+
+        // break the path into segments and store in the list
+        int current = 0;
+        int index2 = 0;
+        index = (pathlen > 0 && path.charAt(0) == '/') ? 1 : 0;
+        while ((index2 = path.indexOf('/', index + 1)) != -1) {
+            seglist[current++] = path.substring(index, index2);
+            index = index2 + 1;
+        }
+
+        // if current==size, then the last character was a slash
+        // and there are no more segments
+        if (current < size) {
+            seglist[current] = path.substring(index);
+        }
+
+        // determine which segments get included in the normalized path
+        for (int i = 0; i < size; i++) {
+            include[i] = true;
+            if (seglist[i].equals("..")) { //$NON-NLS-1$
+                int remove = i - 1;
+                // search back to find a segment to remove, if possible
+                while (remove > -1 && !include[remove]) {
+                    remove--;
+                }
+                // if we find a segment to remove, remove it and the ".."
+                // segment
+                if (remove > -1 && !seglist[remove].equals("..")) { //$NON-NLS-1$
+                    include[remove] = false;
+                    include[i] = false;
+                }
+            } else if (seglist[i].equals(".")) { //$NON-NLS-1$
+                include[i] = false;
+            }
+        }
+
+        // put the path back together
+        StringBuilder newpath = new StringBuilder();
+        if (path.startsWith("/")) { //$NON-NLS-1$
+            newpath.append('/');
+        }
+
+        for (int i = 0; i < seglist.length; i++) {
+            if (include[i]) {
+                newpath.append(seglist[i]);
+                newpath.append('/');
+            }
+        }
+
+        // if we used at least one segment and the path previously ended with
+        // a slash and the last segment is still used, then delete the extra
+        // trailing '/'
+        if (!path.endsWith("/") && seglist.length > 0 //$NON-NLS-1$
+                && include[seglist.length - 1]) {
+            newpath.deleteCharAt(newpath.length() - 1);
+        }
+
+        String result = newpath.toString();
+
+        // check for a ':' in the first segment if one exists,
+        // prepend "./" to normalize
+        index = result.indexOf(':');
+        index2 = result.indexOf('/');
+        if (index != -1 && (index < index2 || index2 == -1)) {
+            newpath.insert(0, "./"); //$NON-NLS-1$
+            result = newpath.toString();
+        }
+        return result;
+    }
     
+    /**
+     * UriParser method used to re-calculate the scheme specific part of the
+     * resolved or normalized URIs
+     */
+    private String setSchemeSpecificPart(String authority,
+                                         String path,
+                                         String query) {
+        // ssp = [//authority][path][?query]
+        StringBuilder ssp = new StringBuilder();
+        if (authority != null) {
+            ssp.append("//" + authority); //$NON-NLS-1$
+        }
+        if (path != null) {
+            ssp.append(path);
+        }
+        if (query != null) {
+            ssp.append("?" + query); //$NON-NLS-1$
+        }
+        // reset string, so that it can be re-calculated correctly when asked.
+        return ssp.toString();
+    }
 }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java Mon Apr  1 07:47:44 2013
@@ -189,7 +189,7 @@ class DefaultPolicyParser implements Pol
     PermissionGrant resolveGrant(DefaultPolicyScanner.GrantEntry ge,
             KeyStore ks, Properties system, boolean resolve) throws Exception {
         if ( ge == null ) return null;
-        List<URI> codebases = new ArrayList<URI>(8);
+        List<String> codebases = new ArrayList<String>(8);
         Certificate[] signers = null;
         Set<Principal> principals = new HashSet<Principal>();
         Set<Permission> permissions = new HashSet<Permission>();
@@ -249,7 +249,7 @@ class DefaultPolicyParser implements Pol
             }
         }
         PermissionGrantBuilder pgb = PermissionGrantBuilder.newBuilder();
-        Iterator<URI> iter = codebases.iterator();
+        Iterator<String> iter = codebases.iterator();
         while (iter.hasNext()){
             pgb.uri(iter.next());
         }
@@ -261,13 +261,11 @@ class DefaultPolicyParser implements Pol
             .build();
     }
     
-    URI getURI(String uriString) throws MalformedURLException, URISyntaxException{
+    String getURI(String uriString) throws MalformedURLException, URISyntaxException{
         // We do this to support windows, this is to ensure that path
         // capitalisation is correct and illegal strings are escaped correctly.
         if (uriString == null) return null;
-        uriString = UriString.fixWindowsURI(uriString);
-        uriString = UriString.escapeIllegalCharacters(uriString);
-        return new URI(uriString);
+        return UriString.fixWindowsURI(uriString);
     }
     
     Segment segment(String s, Properties p) throws ExpansionFailedException{

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilder.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilder.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilder.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilder.java Mon Apr  1 07:47:44 2013
@@ -211,7 +211,7 @@ public abstract class PermissionGrantBui
      * @param uri - RFC3986 compliant URI or null.
      * @return 
      */
-    public abstract PermissionGrantBuilder uri(URI uri);
+    public abstract PermissionGrantBuilder uri(String path);
     /**
      * Extracts ProtectionDomain
      * from the Class for use in the PermissionGrantBuilder.  The ClassLoader

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilderImp.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilderImp.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilderImp.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PermissionGrantBuilderImp.java Mon Apr  1 07:47:44 2013
@@ -36,6 +36,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.river.api.net.Uri;
 
 /**
  * PermissionGrantBuilderImp represents the serialized form of all
@@ -56,7 +57,7 @@ class PermissionGrantBuilderImp extends 
     
    
     /*@serial */
-    private URI[] uri;
+    private String[] uri;
     /*@serial */
     private Certificate[] certs;
     /*@serial */
@@ -69,7 +70,7 @@ class PermissionGrantBuilderImp extends 
     private boolean hasDomain;
     
     // Transient Fields
-    private transient Collection<URI> uris;
+    private transient Collection<String> uris;
     private transient WeakReference<ProtectionDomain> domain;
     
     PermissionGrantBuilderImp() {
@@ -105,9 +106,9 @@ class PermissionGrantBuilderImp extends 
     }
     
         @Override
-    public PermissionGrantBuilder uri(java.net.URI uri) {
-        if (this.uris == null) this.uris = new ArrayList<URI>(6);
-        this.uris.add(uri);
+    public PermissionGrantBuilder uri(String path) {
+        if (this.uris == null) this.uris = new ArrayList<String>(6);
+        this.uris.add(path);
         return this;
     }
     
@@ -152,8 +153,8 @@ class PermissionGrantBuilderImp extends 
                 // are treated special.
                 return new ClassLoaderGrant(domain, principals, permissions );
             case URI:
-                if (uris != null && !uris.isEmpty() ) uri = uris.toArray(new URI[uris.size()]);
-                if (uri == null ) uri = new URI[0];
+                if (uris != null && !uris.isEmpty() ) uri = uris.toArray(new String[uris.size()]);
+                if (uri == null ) uri = new String[0];
                 return new URIGrant(uri, certs, principals, permissions);              
             case CODESOURCE_CERTS:
                 return new CertificateGrant(certs, principals, permissions);
@@ -180,7 +181,7 @@ class PermissionGrantBuilderImp extends 
     }
     
     private void writeObject(ObjectOutputStream out) throws IOException{
-        if (uris != null && !uris.isEmpty()) uri = uris.toArray(new URI[uris.size()]);
+        if (uris != null && !uris.isEmpty()) uri = uris.toArray(new String[uris.size()]);
         out.defaultWriteObject();
     }
     

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java Mon Apr  1 07:47:44 2013
@@ -36,6 +36,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.apache.river.api.net.Uri;
 import org.apache.river.impl.net.UriString;
 
 /**
@@ -44,20 +45,21 @@ import org.apache.river.impl.net.UriStri
  */
 class URIGrant extends CertificateGrant {
     private static final long serialVersionUID = 1L;
-    private final Collection<URI> location;
+    private final Collection<Uri> location;
     private final int hashCode;
     
     @SuppressWarnings("unchecked")
-    URIGrant(URI[] uri, Certificate[] certs, Principal[] pals, Permission[] perm){
+    URIGrant(String[] uri, Certificate[] certs, Principal[] pals, Permission[] perm){
         super( certs, pals, perm);
         int l = uri.length;
-        Collection<URI> uris = new ArrayList<URI>(l);
+        Collection<Uri> uris = new ArrayList<Uri>(l);
         for ( int i = 0; i < l ; i++ ){
             try {
-                // REMIND: Do we need to move all normalisation into the URIGrant and
+                // Do we need to move all normalisation into the URIGrant and
                 // store the normalised and original forms separately? File uri are platform
                 // dependant and someone may want to make a grant applicable many different platforms.
-                uris.add(uri[i] != null ? UriString.normalise(uri[i]) : null);
+                // Uri resolves this issue - fixed 31st Mar 2013
+                uris.add(uri[i] != null ? Uri.parseAndCreate(uri[i]) : null);
             } catch (URISyntaxException ex) {
                 ex.printStackTrace(System.err);
             }
@@ -103,7 +105,7 @@ class URIGrant extends CertificateGrant 
     public boolean implies(ClassLoader cl, Principal[] p){
 	if ( !implies(p)) return false;
 	if ( location.isEmpty() ) return true;
-        Iterator<URI> it = location.iterator();
+        Iterator<Uri> it = location.iterator();
         while (it.hasNext()){
             if (it.next() == null) return true;
         }
@@ -125,13 +127,13 @@ class URIGrant extends CertificateGrant 
         if (codeSource == null)  return false; // Null CodeSource is not implied.
         if (location.isEmpty()) return true; // But CodeSource with null URL is implied, if this location is empty.
         int l = location.size();
-        URI[] uris = location.toArray(new URI[l]);
+        Uri[] uris = location.toArray(new Uri[l]);
         for (int i = 0; i<l ; i++ ){
             if (uris[i] == null) return true;
         }
         URL url = codeSource.getLocation();
         if (url == null ) return false;
-        URI implied = null;
+        Uri implied = null;
         try {
             implied = AccessController.doPrivileged(new NormaliseURLAction(url));
         } catch (PrivilegedActionException ex) {
@@ -210,7 +212,7 @@ class URIGrant extends CertificateGrant 
      * @return {@code true} if the argument code source is implied by this
      *         {@code CodeSource}, otherwise {@code false}.
      */
-    final boolean implies(URI grant, URI implied) { // package private for junit
+    final boolean implies(Uri grant, Uri implied) { // package private for junit
         //
         // Here, javadoc:N refers to the appropriate item in the API spec for 
         // the CodeSource.implies()
@@ -414,9 +416,9 @@ class URIGrant extends CertificateGrant 
     @Override
     public PermissionGrantBuilder getBuilderTemplate() {
         PermissionGrantBuilder pgb = super.getBuilderTemplate();
-        Iterator<URI> it = location.iterator();
+        Iterator<Uri> it = location.iterator();
         while (it.hasNext()){
-            pgb.uri(it.next());
+            pgb.uri(it.next().toString());
         }
         pgb.context(PermissionGrantBuilder.URI);
         return pgb;
@@ -433,7 +435,7 @@ class URIGrant extends CertificateGrant 
         throw new InvalidObjectException("PermissionGrantBuilder required");
     }
     
-    private static class NormaliseURLAction implements PrivilegedExceptionAction<URI> {
+    private static class NormaliseURLAction implements PrivilegedExceptionAction<Uri> {
         private final URL codesource;
         
         NormaliseURLAction(URL codebase){
@@ -441,8 +443,8 @@ class URIGrant extends CertificateGrant 
         }
 
         @Override
-        public URI run() throws Exception {
-            return PolicyUtils.normalizeURL(codesource);
+        public Uri run() throws Exception {
+            return Uri.urlToUri(codesource);
         }
     
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/util/Facade.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/util/Facade.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/util/Facade.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/util/Facade.java Mon Apr  1 07:47:44 2013
@@ -21,7 +21,7 @@ package org.apache.river.api.util;
 /**
  * Interface definition of the facade pattern.
  * @author Peter Firmstone.
- * @since 2.2.0
+ * @since 2.3.0
  */
 public interface Facade<T> {
     /**

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java Mon Apr  1 07:47:44 2013
@@ -248,8 +248,8 @@ public class UriString {
                 if (path.endsWith(forwardSlash)) directory = true;
                 path = new File(path).getAbsolutePath();
                 if (directory) {
-                    if (! (path.endsWith(File.pathSeparator))){
-                        path = path + File.pathSeparator;
+                    if (! (path.endsWith(File.separator))){
+                        path = path + File.separator;
                     }
                 }
                 return normalisation(filePathToURI(path));

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/net/UriTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/net/UriTest.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/net/UriTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/net/UriTest.java Mon Apr  1 07:47:44 2013
@@ -38,7 +38,8 @@ public class UriTest extends TestCase {
                 new Uri(
                         "http://user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g"),
                 // escaped octets for unicode chars
-                new Uri(
+                Uri.escapeAndCreate(
+            
                         "ascheme://user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g"),
                 // unicode chars equivalent to = new
                 // Uri("ascheme://user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery#fr\u00e4\u00e8g"),
@@ -125,7 +126,7 @@ public class UriTest extends TestCase {
 
         for (int i = 0; i < constructorTests.length; i++) {
             try {
-                new Uri(constructorTests[i]);
+                Uri.parseAndCreate(constructorTests[i]);
             } catch (URISyntaxException e) {
                 fail("Failed to construct Uri for: " + constructorTests[i]
                         + " : " + e);
@@ -174,6 +175,7 @@ public class UriTest extends TestCase {
                         + constructorTestsInvalidIndices[i] + ", received: "
                         + e.getIndex(),
                         e.getIndex() == constructorTestsInvalidIndices[i]);
+                e.printStackTrace(System.err);
             }
         }
 
@@ -329,8 +331,8 @@ public class UriTest extends TestCase {
                 "fragment"); // unicode chars in host name
         // equivalent to construct1("http", "user", "host\u00dfname", -1,
         // "/file", "query", "fragment");
-        construct1("http", "user", "host%20name", -1, "/file", "query",
-                "fragment"); // escaped octets in host name
+//        construct1("http", "user", "host%20name", -1, "/file", "query",
+//                "fragment"); // escaped octets in host name
         construct1("http", "user", "host name", -1, "/file", "query",
                 "fragment"); // illegal char in host name
         construct1("http", "user", "host]name", -1, "/file", "query",
@@ -486,18 +488,18 @@ public class UriTest extends TestCase {
         assertEquals("wrong fragment", "f/r\u00DFag", uri.getFragment());
         // equivalent to = assertTrue("wrong fragment",
         // uri.getFragment().equals("f/r\u00dfag"));
-        assertEquals("wrong SchemeSpecificPart", "///p#a%E2%82%ACth?q^u%25ery",
+        assertEquals("wrong SchemeSpecificPart", "/p#a%E2%82%ACth?q^u%25ery",
                 uri.getSchemeSpecificPart());
         assertEquals("wrong RawSchemeSpecificPart",
-                "///p%23a%25E2%2582%25ACth?q%5Eu%2525ery", uri
+                "/p%23a%25E2%2582%25ACth?q%5Eu%2525ery", uri
                         .getRawSchemeSpecificPart());
         assertEquals(
                 "incorrect toString()",
-                "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r\u00dfag",
+                "ht12-3+tp:/p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r%C3%9Fag",
                 uri.toString());
         assertEquals("incorrect toASCIIString()",
 
-        "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r%C3%9Fag", uri
+        "ht12-3+tp:/p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r%C3%9Fag", uri
                 .toASCIIString());
     }
 
@@ -708,8 +710,8 @@ public class UriTest extends TestCase {
             Uri b = new Uri(equalsData[i][0]);
             Uri r = new Uri(equalsData[i][1]);
             if (b.equals(r) != equalsResults[i]) {
-                fail("Error: " + equalsData[i][0] + " == " + equalsData[i][1]
-                        + "? -> " + b.equals(r) + " expected "
+                fail("Error: " + b.toString() + " == " + r.toString()
+                        + " ? -> " + b.equals(r) + " expected "
                         + equalsResults[i]);
             }
         }
@@ -783,19 +785,19 @@ public class UriTest extends TestCase {
         assertNull("Authority not null for URI: " + uri, uri.getAuthority());
         assertNull("Host not null for Uri " + uri, uri.getHost());
         assertEquals("testA, toString() returned incorrect value",
-                "file:///tmp/", uri.toString());
+                "file:/tmp/", uri.toString());
 
         uri = new Uri("file", "", "/tmp", "frag");
         assertNull("Authority not null for URI: " + uri, uri.getAuthority());
         assertNull("Host not null for Uri " + uri, uri.getHost());
         assertEquals("testB, toString() returned incorrect value",
-                "file:///tmp#frag", uri.toString());
+                "file:/tmp#frag", uri.toString());
 
         uri = new Uri("file", "", "/tmp", "query", "frag");
         assertNull("Authority not null for URI: " + uri, uri.getAuthority());
         assertNull("Host not null for Uri " + uri, uri.getHost());
         assertEquals("test C, toString() returned incorrect value",
-                "file:///tmp?query#frag", uri.toString());
+                "file:/tmp?query#frag", uri.toString());
 
         // after normalization the host string info may be lost since the
         // uri string is reconstructed
@@ -804,7 +806,7 @@ public class UriTest extends TestCase {
         assertNull("Authority not null for URI: " + uri2, uri.getAuthority());
         assertNull("Host not null for Uri " + uri2, uri.getHost());
         assertEquals("test D, toString() returned incorrect value",
-                "file:///tmp/a/../b/c?query#frag", uri.toString());
+                "file:/tmp/b/c?query#frag", uri.toString());
         assertEquals("test E, toString() returned incorrect value",
                 "file:/tmp/b/c?query#frag", uri2.toString());
 
@@ -966,11 +968,11 @@ public class UriTest extends TestCase {
         String[] getRawAuthorityResults = {
                 "user%60%20info@host",
                 "user%C3%9F%C2%A3info@host:80",
-                "user\u00DF\u00A3info@host:0", // =
+                "user%C3%9F%C2%A3info@host:0", // =
                 // "user\u00df\u00a3info@host:0",
                 "user%2560%2520info@host:80",
                 "user%25C3%259F%25C2%25A3info@host",
-                "user\u00DF\u00A3info@host:80", // =
+                "user%C3%9F%C2%A3info@host:80", // =
                 // "user\u00df\u00a3info@host:80",
                 "user%60%20info@host:81", "user%25info@host:0", null, null,
                 null, null, "server.org", "reg:istry", null };
@@ -994,9 +996,9 @@ public class UriTest extends TestCase {
 
         String[] getRawFragmentResults = { "fr%5E%20ag",
                 "fr%C3%A4%C3%A8g",
-                "fr\u00E4\u00E8g", // = "fr\u00e4\u00e8g",
+                "fr%C3%A4%C3%A8g", // = "fr\u00e4\u00e8g",
                 "fr%255E%2520ag", "fr%25C3%25A4%25C3%25A8g",
-                "fr\u00E4\u00E8g", // =
+                "fr%C3%A4%C3%A8g", // =
                 // "fr\u00e4\u00e8g",
                 "fr%5E%20ag", "f%25rag", null, "", null, "fragment", null,
                 null, null };
@@ -1020,9 +1022,9 @@ public class UriTest extends TestCase {
 
         String[] getRawPathResults = { "/a%20path",
                 "/a%E2%82%ACpath",
-                "/a\u20ACpath", // = "/a\u0080path",
+                "/a%E2%82%ACpath", // = "/a\u0080path",
                 "/a%2520path", "/a%25E2%2582%25ACpath",
-                "/a\u20ACpath", // =
+                "/a%E2%82%ACpath", // =
                 // "/a\u0080path",
                 "/a%20path", "/a%25path", null, "../adirectory/file.html",
                 null, "", "", "", "/c:/temp/calculate.pl" };
@@ -1047,10 +1049,10 @@ public class UriTest extends TestCase {
         String[] getRawQueryResults = {
                 "qu%60%20ery",
                 "qu%C2%A9%C2%AEery",
-                "qu\u00A9\u00AEery", // = "qu\u00a9\u00aeery",
+                "qu%C2%A9%C2%AEery", // = "qu\u00a9\u00aeery",
                 "qu%2560%2520ery",
                 "qu%25C2%25A9%25C2%25AEery",
-                "qu\u00A9\u00AEery", // = "qu\u00a9\u00aeery",
+                "qu%C2%A9%C2%AEery", // = "qu\u00a9\u00aeery",
                 "qu%60%20ery", "que%25ry", null, null, null, null, null,
                 "query", "" };
 
@@ -1075,17 +1077,17 @@ public class UriTest extends TestCase {
         String[] getRawSspResults = {
                 "//user%60%20info@host/a%20path?qu%60%20ery",
                 "//user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery",
-                "//user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery", // =
+                "//user%C3%9F%C2%A3info@host:0/a%E2%82%ACpath?qu%C2%A9%C2%AEery", // =
                 // "//user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery"
                 "//user%2560%2520info@host:80/a%2520path?qu%2560%2520ery",
                 "//user%25C3%259F%25C2%25A3info@host/a%25E2%2582%25ACpath?qu%25C2%25A9%25C2%25AEery",
-                "//user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery", // =
+                "//user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery", // =
                 // "//user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery"
                 "//user%60%20info@host:81/a%20path?qu%60%20ery",
                 "//user%25info@host:0/a%25path?que%25ry", "user@domain.com",
                 "../adirectory/file.html", "comp.infosystems.www.servers.unix",
                 "", "//server.org", "//reg:istry?query",
-                "///c:/temp/calculate.pl?" };
+                "/c:/temp/calculate.pl?" };
 
         for (int i = 0; i < uris.length; i++) {
             String result = uris[i].getRawSchemeSpecificPart();
@@ -1106,10 +1108,10 @@ public class UriTest extends TestCase {
         String[] getRawUserInfoResults = {
                 "user%60%20info",
                 "user%C3%9F%C2%A3info",
-                "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
+                "user%C3%9F%C2%A3info", // = "user\u00df\u00a3info",
                 "user%2560%2520info",
                 "user%25C3%259F%25C2%25A3info",
-                "user\u00DF\u00A3info", // = "user\u00df\u00a3info",
+                "user%C3%9F%C2%A3info", // = "user\u00df\u00a3info",
                 "user%60%20info", "user%25info", null, null, null, null, null,
                 null, null };
 
@@ -1165,7 +1167,7 @@ public class UriTest extends TestCase {
                 "//user%info@host:0/a%path?que%ry", "user@domain.com",
                 "../adirectory/file.html", "comp.infosystems.www.servers.unix",
                 "", "//server.org", "//reg:istry?query",
-                "///c:/temp/calculate.pl?" };
+                "/c:/temp/calculate.pl?" };
 
         for (int i = 0; i < uris.length; i++) {
             String result = uris[i].getSchemeSpecificPart();
@@ -1424,14 +1426,14 @@ public class UriTest extends TestCase {
 
                 // unicode char in the hostname = new
                 // Uri("http://host\u00dfname/")
-                new Uri("http://host\u00DFname/"),
+//                Uri.parseAndCreate("http://host\u00DFname/"),
 
-                new Uri("http", "//host\u00DFname/", null),
+//                new Uri("http", "//host\u00DFname/", null),
                 // = new Uri("http://host\u00dfname/", null),
 
                 // escaped octets in host name
-                new Uri("http://host%20name/"),
-                new Uri("http", "//host%20name/", null),
+//                new Uri("http://host%20name/"),
+//                new Uri("http", "//host%20name/", null),
 
                 // missing host name, port number
                 new Uri("http://joe@:80"),
@@ -1446,7 +1448,7 @@ public class UriTest extends TestCase {
                 new Uri("telnet", "//256.197.221.200", null),
 
                 new Uri("telnet://198.256.221.200"),
-                new Uri("//te%ae.com"), // misc ..
+//                new Uri("//te%ae.com"), // misc ..
                 new Uri("//:port"), new Uri("//:80"),
 
                 // last label has to start with alpha char
@@ -1459,16 +1461,16 @@ public class UriTest extends TestCase {
                 new Uri("//domain-"),
 
                 // illegal char in host name
-                new Uri("//doma*in"),
+////                new Uri("//doma^in"),
 
                 // host expected
                 new Uri("http://:80/"), new Uri("http://user@/"),
 
                 // ipv6 address not enclosed in "[]"
-                new Uri("http://3ffe:2a00:100:7031:22:1:80:89/"),
+//                new Uri("http://[3ffe:2a00:100:7031:22:1:80:89]/"),
 
                 // expected ipv6 addresses to be enclosed in "[]"
-                new Uri("http", "34::56:78", "/path", "query", "fragment"),
+//                new Uri("http", "[34::56:78]", "/path", "query", "fragment"),
 
                 // expected host
                 new Uri("http", "user@", "/path", "query", "fragment") };
@@ -1748,7 +1750,7 @@ public class UriTest extends TestCase {
                 "mailto:user@domain.com", "../adirectory/file.html#",
                 "news:comp.infosystems.www.servers.unix", "#fragment",
                 "telnet://server.org", "http://reg:istry?query",
-                "file:///c:/temp/calculate.pl?" };
+                "file:/c:/temp/calculate.pl?" };
 
         for (int i = 0; i < uris.length; i++) {
             String result = uris[i].toASCIIString();
@@ -1772,7 +1774,7 @@ public class UriTest extends TestCase {
                 "mailto://user@domain.com", "mailto://user%C3%9F@domain.com", };
 
         for (int i = 0; i < toASCIIStringData.length; i++) {
-            Uri test = new Uri(toASCIIStringData[i]);
+            Uri test = Uri.parseAndCreate(toASCIIStringData[i]);
             String result = test.toASCIIString();
             assertTrue("Error: new Uri(\"" + toASCIIStringData[i]
                     + "\").toASCIIString() returned: " + result
@@ -1790,12 +1792,12 @@ public class UriTest extends TestCase {
         String[] toStringResults = {
                 "http://user%60%20info@host/a%20path?qu%60%20ery#fr%5E%20ag",
                 "http://user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g",
-                "ascheme://user\u00DF\u00A3info@host:0/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g",
+                "ascheme://user%C3%9F%C2%A3info@host:0/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g",
                 // =
                 // "ascheme://user\u00df\u00a3info@host:0/a\u0080path?qu\u00a9\u00aeery#fr\u00e4\u00e8g",
                 "http://user%2560%2520info@host:80/a%2520path?qu%2560%2520ery#fr%255E%2520ag",
                 "http://user%25C3%259F%25C2%25A3info@host/a%25E2%2582%25ACpath?qu%25C2%25A9%25C2%25AEery#fr%25C3%25A4%25C3%25A8g",
-                "ascheme://user\u00DF\u00A3info@host:80/a\u20ACpath?qu\u00A9\u00AEery#fr\u00E4\u00E8g",
+                "ascheme://user%C3%9F%C2%A3info@host:80/a%E2%82%ACpath?qu%C2%A9%C2%AEery#fr%C3%A4%C3%A8g",
                 // =
                 // "ascheme://user\u00df\u00a3info@host:80/a\u0080path?qu\u00a9\u00aeery#fr\u00e4\u00e8g",
                 "http://user%60%20info@host:81/a%20path?qu%60%20ery#fr%5E%20ag",
@@ -1803,7 +1805,7 @@ public class UriTest extends TestCase {
                 "mailto:user@domain.com", "../adirectory/file.html#",
                 "news:comp.infosystems.www.servers.unix", "#fragment",
                 "telnet://server.org", "http://reg:istry?query",
-                "file:///c:/temp/calculate.pl?" };
+                "file:/c:/temp/calculate.pl?" };
 
         for (int i = 0; i < uris.length; i++) {
             String result = uris[i].toString();

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/ConcurrentPolicyFileTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/ConcurrentPolicyFileTest.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/ConcurrentPolicyFileTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/ConcurrentPolicyFileTest.java Mon Apr  1 07:47:44 2013
@@ -120,7 +120,7 @@ public class ConcurrentPolicyFileTest ex
                 .permissions(new Permission[] { sp1 })
                 .build();
         pgb.reset().context(PermissionGrantBuilder.URI);
-        PermissionGrant pe2 = pgb.uri(new URI("http://a.b.c"))
+        PermissionGrant pe2 = pgb.uri("http://a.b.c")
                 .principals(new Principal[0])
                 .permissions(new Permission[] { sp2 })
                 .build();
@@ -168,7 +168,7 @@ public class ConcurrentPolicyFileTest ex
         PermissionGrant pe1 = pgb.uri(null)
                 .permissions(new Permission[] { sp1 })
                 .build();
-        PermissionGrant pe2 = pgb.uri(cs2.getLocation().toURI())
+        PermissionGrant pe2 = pgb.uri(cs2.getLocation().toString())
                 .principals(new Principal[] { new UnresolvedPrincipal(
                 UnresolvedPrincipal.WILDCARD, UnresolvedPrincipal.WILDCARD) })
                 .permissions(new Permission[] { sp2 })
@@ -178,7 +178,7 @@ public class ConcurrentPolicyFileTest ex
                 FakePrincipal.class.getName(), "qqq") })
                 .permissions(new Permission[] { sp3 })
                 .build();
-        PermissionGrant pe4 = pgb.uri(cs2.getLocation().toURI())
+        PermissionGrant pe4 = pgb.uri(cs2.getLocation().toString())
                 .principals(new Principal[] { new UnresolvedPrincipal(
                 FakePrincipal.class.getName(), "ttt") })
                 .permissions(new Permission[] { sp4 })

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/DefaultPolicyParserTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/DefaultPolicyParserTest.java?rev=1463106&r1=1463105&r2=1463106&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/DefaultPolicyParserTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/api/security/DefaultPolicyParserTest.java Mon Apr  1 07:47:44 2013
@@ -111,12 +111,7 @@ public class DefaultPolicyParserTest ext
        permissions.add(perm2);
        permissions.add(perm3);
        PermissionGrantBuilder pgb = PermissionGrantBuilder.newBuilder();
-       URI uri = null;
-        try {
-            uri = new URI("file:/opt/src/river/trunk/lib/group.jar");
-        } catch (URISyntaxException ex) {
-            System.err.println(ex);
-        }
+       String uri = "file:/opt/src/river/trunk/lib/group.jar";
        grant = pgb
                .uri(uri)
                .permissions(permissions.toArray(new Permission[4]))



Mime
View raw message