Search in sources :

Example 6 with ASTStringLiteral

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;
}
Also used : ASTStringLiteral(org.apache.commons.jexl2.parser.ASTStringLiteral) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) ASTAssignment(org.apache.commons.jexl2.parser.ASTAssignment) ASTReference(org.apache.commons.jexl2.parser.ASTReference)

Example 7 with ASTStringLiteral

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);
}
Also used : ASTStringLiteral(org.apache.commons.jexl2.parser.ASTStringLiteral)

Example 8 with ASTStringLiteral

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;
}
Also used : ASTStringLiteral(org.apache.commons.jexl3.parser.ASTStringLiteral) SelectorSqlBuilder(org.sonatype.nexus.selector.SelectorSqlBuilder) JexlException(org.apache.commons.jexl3.JexlException) JexlNode(org.apache.commons.jexl3.parser.JexlNode)

Example 9 with ASTStringLiteral

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;
}
Also used : ASTStringLiteral(org.apache.commons.jexl3.parser.ASTStringLiteral) JexlNode(org.apache.commons.jexl3.parser.JexlNode)

Example 10 with ASTStringLiteral

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;
}
Also used : ASTStringLiteral(org.apache.commons.jexl3.parser.ASTStringLiteral) JexlNode(org.apache.commons.jexl3.parser.JexlNode)

Aggregations

ASTStringLiteral (org.apache.commons.jexl2.parser.ASTStringLiteral)13 ASTReference (org.apache.commons.jexl2.parser.ASTReference)7 JexlNode (org.apache.commons.jexl2.parser.JexlNode)7 ASTStringLiteral (org.apache.commons.jexl3.parser.ASTStringLiteral)7 JexlNode (org.apache.commons.jexl3.parser.JexlNode)7 ASTIdentifier (org.apache.commons.jexl2.parser.ASTIdentifier)6 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)3 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)3 ASTFunctionNode (org.apache.commons.jexl2.parser.ASTFunctionNode)3 ASTNumberLiteral (org.apache.commons.jexl2.parser.ASTNumberLiteral)3 JexlException (org.apache.commons.jexl3.JexlException)3 ASTAssignment (org.apache.commons.jexl2.parser.ASTAssignment)2 ASTNRNode (org.apache.commons.jexl2.parser.ASTNRNode)2 ASTReferenceExpression (org.apache.commons.jexl2.parser.ASTReferenceExpression)2 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)1 FunctionJexlNodeVisitor (datawave.query.jexl.functions.FunctionJexlNodeVisitor)1 JexlArgumentDescriptor (datawave.query.jexl.functions.arguments.JexlArgumentDescriptor)1 ExceededTermThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededTermThresholdMarkerJexlNode)1 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)1 QueryException (datawave.webservice.query.exception.QueryException)1