this.featurePathString = featurePath;
this.builtInFunction = NO_BUILT_IN_FUNCTION;
// throw exception if featurePath is null
if (featurePath == null) {
throw new CASException(MESSAGE_DIGEST, "INVALID_FEATURE_PATH_SYNTAX",
new Object[] { featurePath, "null for a feature path" });
}
// check featurePath for invalid character sequences
if (this.featurePathString.indexOf("//") > -1) {
// invalid featurePath syntax
throw new CASException(MESSAGE_DIGEST, "INVALID_FEATURE_PATH_SYNTAX",
new Object[] { this.featurePathString, "//" });
}
// parse feature path into path elements
StringTokenizer tokenizer = new StringTokenizer(this.featurePathString,
FEATURE_PATH_SEPARATOR);
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
// check if there are more tokens available, if we are at the last
// token we have to check for built-in functions
if (tokenizer.hasMoreTokens()) {
this.featurePathElementNames.add(token);
} else {
// we have the last token, check for built-in functions
int index = -1;
if ((index = token.indexOf(BUILT_IN_FUNCTION_SEPARATOR)) != -1) {
if (index > 0) {
// we have a built-in function that is separated with a ":"
this.featurePathElementNames.add(token.substring(0, index));
}
// get built-in function
String builtInFunctionName = token.substring(index + 1)
.toLowerCase();
if (builtInFunctionName.equals(FUNCTION_NAME_COVERED_TEXT)) {
this.builtInFunction = FUNCTION_COVERED_TEXT;
} else if (builtInFunctionName.equals(FUNCTION_NAME_ID)) {
this.builtInFunction = FUNCTION_ID;
} else if (builtInFunctionName.equals(FUNCTION_NAME_TYPE_NAME)) {
this.builtInFunction = FUNCTION_TYPE_NAME;
} else {
throw new CASException(MESSAGE_DIGEST,
"INVALID_FEATURE_PATH_SYNTAX", new Object[] {
this.featurePathString, builtInFunctionName });
}
} else {
this.featurePathElementNames.add(token);