{
aggComponent = matcher.group();
aggComponent = aggComponent.substring(1, aggComponent.length() - 1);
if (aggComponent.contains(")") || aggComponent.contains("("))
{
throw new HelixException(expression
+ " has invalid aggregate component");
}
}
else
{
throw new HelixException(expression + " has invalid aggregate component");
}
if (matcher.find())
{
statComponent = matcher.group();
statComponent = statComponent.substring(1, statComponent.length() - 1);
// statComponent must have at least 1 arg between paren
if (statComponent.contains(")") || statComponent.contains("(")
|| statComponent.length() == 0)
{
throw new HelixException(expression + " has invalid stat component");
}
lastMatchEnd = matcher.end();
}
else
{
throw new HelixException(expression + " has invalid stat component");
}
if (matcher.find())
{
throw new HelixException(expression
+ " has too many parenthesis components");
}
if (expression.length() >= lastMatchEnd + 1)
{ // lastMatchEnd is pos 1 past the pattern. check if there are paren there
if (expression.substring(lastMatchEnd).contains("(")
|| expression.substring(lastMatchEnd).contains(")"))
{
throw new HelixException(expression + " has extra parenthesis");
}
}
// check wildcard locations. each part can have at most 1 wildcard, and must
// be at end
// String expStatNamePart = expression.substring(expression.)
StringTokenizer fieldTok = new StringTokenizer(statComponent,
statFieldDelim);
while (fieldTok.hasMoreTokens())
{
String currTok = fieldTok.nextToken();
if (currTok.contains(wildcardChar))
{
if (currTok.indexOf(wildcardChar) != currTok.length() - 1
|| currTok.lastIndexOf(wildcardChar) != currTok.length() - 1)
{
throw new HelixException(currTok
+ " is illegal stat name. Single wildcard must appear at end.");
}
}
}
}