org.skyscreamer.yoga.util
Class ParenthesisUtil

java.lang.Object
  extended by org.skyscreamer.yoga.util.ParenthesisUtil

public class ParenthesisUtil
extends Object

Utility for finding nested parentheses

Author:
Solomon Duskis , Corby Page , Carter Page

Constructor Summary
ParenthesisUtil()
           
 
Method Summary
static int getMatchingParenthesisIndex(CharSequence selector, int index)
          Given an index of an opening parenthesis "(", find the matching closing parenthesis ")".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParenthesisUtil

public ParenthesisUtil()
Method Detail

getMatchingParenthesisIndex

public static int getMatchingParenthesisIndex(CharSequence selector,
                                              int index)
                                       throws ParseSelectorException
Given an index of an opening parenthesis "(", find the matching closing parenthesis ")". If there are embedded parenthesis inside the matching pair, this method will ignore them.

Example:

      getMatchingParenthesis("a(b(c))", 1) returns 6
      getMatchingParenthesis("a(b(c))", 3) returns 5
 

Parameters:
selector - String to analyze for the matching selector
index - Index of the opening parenthesis to match
Returns:
Index of matching closing parenthesis
Throws:
ParseSelectorException


Copyright © 2012. All Rights Reserved.