use of org.apache.commons.jexl2.parser.ASTStringLiteral in project datawave by NationalSecurityAgency.
the class JexlNodeFactory method createAssignment.
/**
* Create an assignment node
*
* @param name
* @param value
* @return the assignment node
*/
public static ASTAssignment createAssignment(String name, String value) {
ASTAssignment assignNode = new ASTAssignment(ParserTreeConstants.JJTASSIGNMENT);
ASTReference refNode2 = new ASTReference(ParserTreeConstants.JJTREFERENCE);
refNode2.jjtSetParent(assignNode);
assignNode.jjtAddChild(refNode2, 0);
ASTIdentifier idNode = new ASTIdentifier(ParserTreeConstants.JJTIDENTIFIER);
idNode.image = name;
idNode.jjtSetParent(refNode2);
refNode2.jjtAddChild(idNode, 0);
ASTStringLiteral literalNode = new ASTStringLiteral(ParserTreeConstants.JJTSTRINGLITERAL);
literalNode.jjtSetParent(assignNode);
literalNode.image = value;
assignNode.jjtAddChild(literalNode, 1);
return assignNode;
}
use of org.apache.commons.jexl2.parser.ASTStringLiteral in project datawave by NationalSecurityAgency.
the class JexlNodeFactory method buildUntypedNewNode.
/**
* Assign the field name and value to the given newNode
*
* @param newNode
* @param fieldName
* @param fieldValue
* @return
*/
protected static JexlNode buildUntypedNewNode(JexlNode newNode, ASTIdentifier fieldName, String fieldValue) {
ASTStringLiteral literal = new ASTStringLiteral(ParserTreeConstants.JJTSTRINGLITERAL);
literal.image = fieldValue;
return buildUntypedNewNode(newNode, fieldName, literal);
}
use of org.apache.commons.jexl2.parser.ASTStringLiteral in project nexus-public by sonatype.
the class DatastoreCselToSql method visit.
/**
* Transform `a =^ "something"` into `a like "something%"`
*/
@Override
protected Object visit(final ASTSWNode node, final Object data) {
JexlNode leftChild = node.jjtGetChild(LEFT);
JexlNode rightChild = node.jjtGetChild(RIGHT);
if (rightChild instanceof ASTStringLiteral) {
transformStartsWithOperator(leftChild, (ASTStringLiteral) rightChild, (SelectorSqlBuilder) data);
} else if (leftChild instanceof ASTStringLiteral) {
transformStartsWithOperator(rightChild, (ASTStringLiteral) leftChild, (SelectorSqlBuilder) data);
} else {
throw new JexlException(node, EXPECTED_STRING_LITERAL);
}
return data;
}
use of org.apache.commons.jexl2.parser.ASTStringLiteral in project nexus-public by sonatype.
the class OrientCselToSql method visit.
/**
* Transform `a != b` into `(a is null or a <> b)`
*/
@Override
protected Object visit(final ASTNENode node, final Object data) {
JexlNode leftChild = node.jjtGetChild(LEFT);
JexlNode rightChild = node.jjtGetChild(RIGHT);
if (rightChild instanceof ASTStringLiteral) {
transformNotEqualsOperator(leftChild, rightChild, (SelectorSqlBuilder) data);
} else {
transformNotEqualsOperator(rightChild, leftChild, (SelectorSqlBuilder) data);
}
return data;
}
use of org.apache.commons.jexl2.parser.ASTStringLiteral in project nexus-public by sonatype.
the class OrientCselToSql method visit.
/**
* Transform `a =^ "something"` into `a like "something%"`
*/
@Override
protected Object visit(final ASTSWNode node, final Object data) {
JexlNode leftChild = node.jjtGetChild(LEFT);
JexlNode rightChild = node.jjtGetChild(RIGHT);
if (rightChild instanceof ASTStringLiteral) {
transformStartsWithOperator(leftChild, rightChild, (SelectorSqlBuilder) data);
} else {
transformStartsWithOperator(rightChild, leftChild, (SelectorSqlBuilder) data);
}
return data;
}
Aggregations