*/
@Override
public void validate(final String expression) {
if (!expression.trim().startsWith(LEFT_PARENTHESIS) && !expression.trim().startsWith(QUOTED_LEFT_PARENTHESIS))
throw new LException(LException.MISSING_INITIAL_OPENING + expression);
if (!expression.trim().endsWith(RIGHT_PARENTHESIS))
throw new LException(LException.MISSING_FINAL_CLOSING + expression);
int count = 0;
char[] chars = expression.toCharArray();
for (int i = 0; i < chars.length; i++) {
char currentChar = chars[i];
if (SINGLE_QUOTE.equals(String.valueOf(currentChar)) && i == 0)
continue;
if (LEFT_PARENTHESIS.equals(String.valueOf(currentChar)))
count++;
if (RIGHT_PARENTHESIS.equals(String.valueOf(currentChar)))
count--;
if (i == chars.length - 1 && count > 0)
throw new LException(LException.MISSING_CLOSING);
if (i != chars.length - 1 && count <= 0)
throw new LException(LException.MISSING_OPENING_NEAR_INDEX + i);
}
}