UriComponent { public static boolean checkHexCharacters(String s, int p) { if (p > (s.length() - 3)) { return false; } try { getHexCharacter(s, ++p); getHexCharacter(s, ++p); return true; } catch (IllegalArgumentException e) { return false; } } private  UriComponent(); static URI normalize(URI uri); static String encode(String str, int component, boolean containsUriParams); static String validateUriComponent(String str, int component, boolean containsUriParams); static boolean isUriComponentContainsValidCharacters(int component, String str); static String recognizeEncode(String str, int component, boolean containsUriParams); static String decode(String str, int component); static boolean checkHexCharacters(String s, int p); static List<PathSegment> parsePathSegments(String path, boolean decode); static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode); static URI resolve(URI baseUri, URI resolvingUri); static final int SCHEME; static final int USER_INFO; static final int HOST; static final int PORT; static final int PATH_SEGMENT; static final int PATH; static final int QUERY; static final int FRAGMENT; static final int SSP; static final int MATRIX_PARAM; static final int QUERY_STRING; static final String PERCENT; }
@Test public void checksHexCharacters() { String str = "%20%23%a0%ag"; assertTrue(checkHexCharacters(str, 0)); assertFalse(checkHexCharacters(str, 1)); assertTrue(checkHexCharacters(str, 3)); assertTrue(checkHexCharacters(str, 6)); assertFalse(checkHexCharacters(str, 9)); assertFalse(checkHexCharacters(str, 11)); }