private boolean isTLDValid(int hostStartPos) { int step = 0; boolean illegalCharFound = false; while(pos + step > hostStartPos) { int currChar = peek(--step); if ('.' == currChar) { return !illegalCharFound; } // TLDs should start with a letter if (!isMember(ALPHA, currChar)) { illegalCharFound = true; } } return true; }
private boolean isTLDValid(int hostStartPos) { int step = 0; boolean illegalCharFound = false; while(pos + step > hostStartPos) { int currChar = peek(--step); if ('.' == currChar) { return !illegalCharFound; } // TLDs should start with a letter if (!isMember(ALPHA, currChar)) { illegalCharFound = true; } } return true; }
private boolean isTLDValid(int hostStartPos) { int step = 0; boolean illegalCharFound = false; while(pos + step > hostStartPos) { int currChar = peek(--step); if ('.' == currChar) { return !illegalCharFound; } // TLDs should start with a letter if (!isMember(ALPHA, currChar)) { illegalCharFound = true; } } return true; }
private String parseMember(int[][] set, int end) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end) { break; } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
private String parseMember(int[][] set, int end) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end) { break; } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
private String normalizePctEncoding(String encoded) { int cidx = Arrays.binarySearch(common_pct, encoded); if (cidx >= 0 && isMember(unreserved, common[cidx])) { return new String(Character.toChars(common[cidx])); // quickly decode unreserved encodings } else if (cidx >= 0) { return encoded; // pass through reserved encodings } String decoded = pctDecode(encoded); String ns = Normalizer.normalize(decoded, Normalizer.Form.NFC); StringBuilder sb = new StringBuilder(ns.length()); for (int c = 0, n = ns.codePointCount(0, ns.length()); c < n; c++) { int chr = ns.codePointAt(ns.offsetByCodePoints(0, c)); if (isMember(unreserved, chr)) { sb.appendCodePoint(chr); } else if (n == 1) { return toUpperCase(encoded); } else { sb.append(pctEncode(chr)); } } return sb.toString(); }
private String normalizePctEncoding(String encoded) { int cidx = Arrays.binarySearch(common_pct, encoded); if (cidx >= 0 && isMember(unreserved, common[cidx])) { return new String(Character.toChars(common[cidx])); // quickly decode unreserved encodings } else if (cidx >= 0) { return encoded; // pass through reserved encodings } String decoded = pctDecode(encoded); String ns = Normalizer.normalize(decoded, Normalizer.Form.NFC); StringBuilder sb = new StringBuilder(ns.length()); for (int c = 0, n = ns.codePointCount(0, ns.length()); c < n; c++) { int chr = ns.codePointAt(ns.offsetByCodePoints(0, c)); if (isMember(unreserved, chr)) { sb.appendCodePoint(chr); } else if (n == 1) { return toUpperCase(encoded); } else { sb.append(pctEncode(chr)); } } return sb.toString(); }
private String parseMember(int[][] set, int end) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end) { break; } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
private String normalizePctEncoding(String encoded) { int cidx = Arrays.binarySearch(common_pct, encoded); if (cidx >= 0 && isMember(unreserved, common[cidx])) { return new String(Character.toChars(common[cidx])); // quickly decode unreserved encodings } else if (cidx >= 0) { return encoded; // pass through reserved encodings } String decoded = pctDecode(encoded); String ns = Normalizer.normalize(decoded, Normalizer.Form.NFC); StringBuilder sb = new StringBuilder(ns.length()); for (int c = 0, n = ns.codePointCount(0, ns.length()); c < n; c++) { int chr = ns.codePointAt(ns.offsetByCodePoints(0, c)); if (isMember(unreserved, chr)) { sb.appendCodePoint(chr); } else if (n == 1) { return toUpperCase(encoded); } else { sb.append(pctEncode(chr)); } } return sb.toString(); }
private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }
private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }
private String normalizePath(String path) { if ("".equals(path)) { return isScheme("http") || isScheme("https") ? "/" : ""; } else if (isScheme("file")) { if (path.indexOf("%5C") >= 0) { // replace "/c:\path\to\file" with "/c:/path/to/file" return normalizePath(path.replace("%5C", "/")); } else if (!path.startsWith("/") && isMember(ALPHA, path.codePointAt(0)) && (':' == path.charAt(1) || path.length() >= 4 && "%7C".equals(path.substring(1, 4)))) { // replace "c:/path/to/file" with "/c:/path/to/file" return normalizePath("/" + path); } else if (path.length() >= 5 && "%7C".equals(path.substring(2, 5)) && isMember(ALPHA, path.codePointAt(1))) { // replace "/c|/path/to/file" with "/c:/path/to/file" return normalizePath(path.substring(0, 2) + ':' + path.substring(5)); } } return pctEncodingNormalization(pathSegmentNormalization(path)); }
private String parseScheme() throws URISyntaxException { if (isMember(ALPHA, peek())) { int start = pos; String scheme = parseMember(schar, ':'); if (':' == peek()) { advance(1); return scheme; } else { pos = start; // reset } } return null; }
private String parseScheme() throws URISyntaxException { if (isMember(ALPHA, peek())) { int start = pos; String scheme = parseMember(schar, ':'); if (':' == peek()) { advance(1); return scheme; } else { pos = start; // reset } } return null; }
private String parseScheme() throws URISyntaxException { if (isMember(ALPHA, peek())) { int start = pos; String scheme = parseMember(schar, ':'); if (':' == peek()) { advance(1); return scheme; } else { pos = start; // reset } } return null; }
private String parsePctEncoded(int[][] set, int end1, int end2) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end1 || chr == end2) { break; // optimize end character } else if (('a' <= chr && chr <= 'z') || ('A' <= chr && chr <= 'Z') || ('0' <= chr && chr <= '9')) { advance(1); } else if ('%' == chr) { if (Arrays.binarySearch(HEXDIG, peek(1)) >= 0 && Arrays.binarySearch(HEXDIG, peek(2)) >= 0) { advance(3); } else { throw error("Illegal percent encoding"); } } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
private String parsePctEncoded(int[][] set, int end1, int end2) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end1 || chr == end2) { break; // optimize end character } else if (('a' <= chr && chr <= 'z') || ('A' <= chr && chr <= 'Z') || ('0' <= chr && chr <= '9')) { advance(1); } else if ('%' == chr) { if (Arrays.binarySearch(HEXDIG, peek(1)) >= 0 && Arrays.binarySearch(HEXDIG, peek(2)) >= 0) { advance(3); } else { throw error("Illegal percent encoding"); } } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
private String parsePctEncoded(int[][] set, int end1, int end2) throws URISyntaxException { int start = pos; while (true) { int chr = peek(); if (chr == EOF || chr == end1 || chr == end2) { break; // optimize end character } else if (('a' <= chr && chr <= 'z') || ('A' <= chr && chr <= 'Z') || ('0' <= chr && chr <= '9')) { advance(1); } else if ('%' == chr) { if (Arrays.binarySearch(HEXDIG, peek(1)) >= 0 && Arrays.binarySearch(HEXDIG, peek(2)) >= 0) { advance(3); } else { throw error("Illegal percent encoding"); } } else if (isMember(set, chr)) { advance(1); } else { break; } } return iri.substring(start, pos); }
path = parsePath(); else if ('%' == peek || ':' != peek && isMember(pchar, peek)) { path = parsePath();
path = parsePath(); else if ('%' == peek || ':' != peek && isMember(pchar, peek)) { path = parsePath();