@Test public void testIndexOfParenthesisMatchWhenNoMatchPresent() throws URISyntaxException { try { String source = "a(bc"; URISupport.indexOfParenthesisMatch(source, 1); fail("Should have thrown URISyntaxException"); } catch (URISyntaxException use) {} try { String source = "("; URISupport.indexOfParenthesisMatch(source, 0); fail("Should have thrown URISyntaxException"); } catch (URISyntaxException use) {} try { String source = "a("; URISupport.indexOfParenthesisMatch(source, 1); fail("Should have thrown URISyntaxException"); } catch (URISyntaxException use) {} }
public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException { int index = -1; if (first < 0 || first > str.length()) { throw new IllegalArgumentException("Invalid position for first parenthesis: " + first); } if (str.charAt(first) != '(') { throw new IllegalArgumentException("character at indicated position is not a parenthesis"); } int depth = 1; char[] array = str.toCharArray(); for (index = first + 1; index < array.length; ++index) { char current = array[index]; if (current == '(') { depth++; } else if (current == ')') { if (--depth == 0) { break; } } } if (depth != 0) { throw new URISyntaxException(str, "URI did not contain a matching parenthesis."); } return index; }
URISupport { public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException { int index = -1; if (first < 0 || first > str.length()) { throw new IllegalArgumentException("Invalid position for first parenthesis: " + first); } if (str.charAt(first) != '(') { throw new IllegalArgumentException("character at indicated position is not a parenthesis"); } int depth = 1; char[] array = str.toCharArray(); for (index = first + 1; index < array.length; ++index) { char current = array[index]; if (current == '(') { depth++; } else if (current == ')') { if (--depth == 0) { break; } } } if (depth != 0) { throw new URISyntaxException(str, "URI did not contain a matching parenthesis."); } return index; } }
URISupport { public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException { int index = -1; if (first < 0 || first > str.length()) { throw new IllegalArgumentException("Invalid position for first parenthesis: " + first); } if (str.charAt(first) != '(') { throw new IllegalArgumentException("character at indicated position is not a parenthesis"); } int depth = 1; char[] array = str.toCharArray(); for (index = first + 1; index < array.length; ++index) { char current = array[index]; if (current == '(') { depth++; } else if (current == ')') { if (--depth == 0) { break; } } } if (depth != 0) { throw new URISyntaxException(str, "URI did not contain a matching parenthesis."); } return index; }  }
URISupport { public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException { int index = -1; if (first < 0 || first > str.length()) { throw new IllegalArgumentException("Invalid position for first parenthesis: " + first); } if (str.charAt(first) != '(') { throw new IllegalArgumentException("character at indicated position is not a parenthesis"); } int depth = 1; char[] array = str.toCharArray(); for (index = first + 1; index < array.length; ++index) { char current = array[index]; if (current == '(') { depth++; } else if (current == ')') { if (--depth == 0) { break; } } } if (depth != 0) { throw new URISyntaxException(str, "URI did not contain a matching parenthesis."); } return index; }  static CompositeData parseComposite(URI uri); static boolean isCompositeURI(URI uri); static boolean checkParenthesis(String str); static int indexOfParenthesisMatch(String str, int first); static String[] splitComponents(String str); static URI removeQuery(URI uri); static Map<String, String> parseParameters(URI uri); static URI applyParameters(URI uri, Map<String, String> queryParameters); static URI applyParameters(URI uri, Map<String, String> queryParameters, String optionPrefix); }
URISupport { public static int indexOfParenthesisMatch(String str, int first) throws URISyntaxException { int index = -1; if (first < 0 || first > str.length()) { throw new IllegalArgumentException("Invalid position for first parenthesis: " + first); } if (str.charAt(first) != '(') { throw new IllegalArgumentException("character at indicated position is not a parenthesis"); } int depth = 1; char[] array = str.toCharArray(); for (index = first + 1; index < array.length; ++index) { char current = array[index]; if (current == '(') { depth++; } else if (current == ')') { if (--depth == 0) { break; } } } if (depth != 0) { throw new URISyntaxException(str, "URI did not contain a matching parenthesis."); } return index; }  static CompositeData parseComposite(URI uri); static boolean isCompositeURI(URI uri); static boolean checkParenthesis(String str); static int indexOfParenthesisMatch(String str, int first); static String[] splitComponents(String str); static URI removeQuery(URI uri); static Map<String, String> parseParameters(URI uri); static URI applyParameters(URI uri, Map<String, String> queryParameters); static URI applyParameters(URI uri, Map<String, String> queryParameters, String optionPrefix);  }