Search in sources :

Example 16 with ASTNumberLiteral

use of org.apache.commons.jexl2.parser.ASTNumberLiteral in project datawave by NationalSecurityAgency.

the class JexlNodeFactory method buildUntypedNewNode.

/**
 * Build a JexlNode with a Number literal
 *
 * @param fieldName
 * @param fieldValue
 * @return
 */
protected static JexlNode buildUntypedNewNode(JexlNode newNode, ASTIdentifier fieldName, Number fieldValue) {
    ASTNumberLiteral literal = new ASTNumberLiteral(ParserTreeConstants.JJTNUMBERLITERAL);
    literal.image = fieldValue.toString();
    if (NATURAL_NUMBERS.contains(fieldValue.getClass())) {
        literal.setNatural(fieldValue.toString());
    } else if (REAL_NUMBERS.contains(fieldValue.getClass())) {
        literal.setReal(fieldValue.toString());
    } else {
        QueryException qe = new QueryException(DatawaveErrorCode.ASTNUMBERLITERAL_TYPE_ASCERTAIN_ERROR, MessageFormat.format("{0}", literal));
        throw new DatawaveFatalQueryException(qe);
    }
    return buildUntypedNewNode(newNode, fieldName, literal);
}
Also used : DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) QueryException(datawave.webservice.query.exception.QueryException) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) ASTNumberLiteral(org.apache.commons.jexl2.parser.ASTNumberLiteral)

Aggregations

ASTNumberLiteral (org.apache.commons.jexl2.parser.ASTNumberLiteral)10 JexlNode (org.apache.commons.jexl2.parser.JexlNode)5 ASTNumberLiteral (org.apache.commons.jexl3.parser.ASTNumberLiteral)5 JexlNode (org.apache.commons.jexl3.parser.JexlNode)5 ASTReference (org.apache.commons.jexl2.parser.ASTReference)4 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)3 QueryException (datawave.webservice.query.exception.QueryException)3 ASTIdentifier (org.apache.commons.jexl2.parser.ASTIdentifier)3 ASTStringLiteral (org.apache.commons.jexl2.parser.ASTStringLiteral)3 ASTFunctionNode (org.apache.commons.jexl3.parser.ASTFunctionNode)3 ASTIdentifier (org.apache.commons.jexl3.parser.ASTIdentifier)3 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)2 ASTFunctionNode (org.apache.commons.jexl2.parser.ASTFunctionNode)2 ASTReferenceExpression (org.apache.commons.jexl2.parser.ASTReferenceExpression)2 JexlException (org.apache.commons.jexl3.JexlException)2 JexlMethod (org.apache.commons.jexl3.introspection.JexlMethod)2 ExceededTermThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededTermThresholdMarkerJexlNode)1 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)1 ASTAdditiveNode (org.apache.commons.jexl2.parser.ASTAdditiveNode)1 ASTAndNode (org.apache.commons.jexl2.parser.ASTAndNode)1