use of org.apache.camel.language.simple.ast.SimpleFunctionEnd in project camel by apache.
the class SimplePredicateParser method createNode.
/**
* Creates a node from the given token
*
* @param token the token
* @param startSingle state of single quoted blocks
* @param startDouble state of double quoted blocks
* @param startFunction state of function blocks
* @return the created node, or <tt>null</tt> to let a default node be created instead.
*/
private SimpleNode createNode(SimpleToken token, AtomicBoolean startSingle, AtomicBoolean startDouble, AtomicBoolean startFunction) {
if (token.getType().isFunctionStart()) {
startFunction.set(true);
return new SimpleFunctionStart(token);
} else if (token.getType().isFunctionEnd()) {
startFunction.set(false);
return new SimpleFunctionEnd(token);
}
// as we want all the tokens to be literal instead
if (startFunction.get()) {
return null;
}
// okay so far we also want to support quotes
if (token.getType().isSingleQuote()) {
SimpleNode answer;
boolean start = startSingle.get();
if (!start) {
answer = new SingleQuoteStart(token);
} else {
answer = new SingleQuoteEnd(token);
}
// flip state on start/end flag
startSingle.set(!start);
return answer;
} else if (token.getType().isDoubleQuote()) {
SimpleNode answer;
boolean start = startDouble.get();
if (!start) {
answer = new DoubleQuoteStart(token);
} else {
answer = new DoubleQuoteEnd(token);
}
// flip state on start/end flag
startDouble.set(!start);
return answer;
}
// as we want to only support embedded functions and all other kinds to be literal tokens
if (startSingle.get() || startDouble.get()) {
return null;
}
// and the special null value as well
if (token.getType().isUnary()) {
return new UnaryExpression(token);
} else if (token.getType().isBinary()) {
return new BinaryExpression(token);
} else if (token.getType().isLogical()) {
return new LogicalExpression(token);
} else if (token.getType().isNullValue()) {
return new NullExpression(token);
}
// by returning null, we will let the parser determine what to do
return null;
}
Aggregations