### Question:
KeepsCleaner extends JCasAnnotator_ImplBase { public static boolean isBalanced(final String expression) { final char LEFT_NORMAL = '(', RIGHT_NORMAL = ')'; final char LEFT_CURLY = '{', RIGHT_CURLY = '}'; final char LEFT_SQUARE = '[', RIGHT_SQUARE = ']'; Stack<Character> stack = new Stack<Character>(); int i; boolean failed = false; for (i = 0; !failed && (i < expression.length()); i++) { switch (expression.charAt(i)) { case LEFT_NORMAL: case LEFT_CURLY: case LEFT_SQUARE: stack.push(expression.charAt(i)); break; case RIGHT_NORMAL: if (stack.isEmpty() || (stack.pop() != LEFT_NORMAL)) failed = true; break; case RIGHT_CURLY: if (stack.isEmpty() || (stack.pop() != LEFT_CURLY)) failed = true; break; case RIGHT_SQUARE: if (stack.isEmpty() || (stack.pop() != LEFT_SQUARE)) failed = true; break; } } return (stack.isEmpty() && !failed); }  @Override void process(JCas jCas); static boolean isOnlyPunctAndNumbers(String txt); static boolean isBalanced(final String expression);  }### Answer:
@Test public void testBalancedParenth() { assertTrue(isBalanced("a{b}c(dd[e]v)g")); assertFalse(isBalanced("([}])")); assertTrue(isBalanced("([])")); assertTrue(isBalanced("()[]{}[][]")); }