public static JexlNode createFromClass(Class<?> clz) { if (clz.equals(ASTEQNode.class)) { return new ASTEQNode(ParserTreeConstants.JJTEQNODE); } else if (clz.equals(ASTERNode.class)) { return new ASTERNode(ParserTreeConstants.JJTERNODE); } else if (clz.equals(ASTNENode.class)) { return new ASTNENode(ParserTreeConstants.JJTNENODE); } else if (clz.equals(ASTNRNode.class)) { return new ASTNRNode(ParserTreeConstants.JJTNRNODE); } else { throw new RuntimeException("unhandled class " + clz.getName()); } }
public JexlNode getIndexQuery(Set<String> termFrequencyFields, Set<String> indexedFields, Set<String> contentFields) { LinkedList<JexlNode> nodes = Lists.newLinkedList(); // get the cartesian product of all the fields and terms MutableBoolean oredFields = new MutableBoolean(); Set<String>[] fieldsAndTerms = fieldsAndTerms(termFrequencyFields, indexedFields, contentFields, oredFields, true); if (!fieldsAndTerms[0].isEmpty()) { final JexlNode eq = new ASTEQNode(ParserTreeConstants.JJTEQNODE); for (String field : fieldsAndTerms[0]) { nodes.add(JexlNodeFactory.createNodeTreeFromFieldValues(ContainerType.AND_NODE, eq, null, field, fieldsAndTerms[1])); } } // A single field needs no wrapper node. if (1 == fieldsAndTerms[0].size()) { return nodes.iterator().next(); } else if (oredFields.booleanValue()) { return JexlNodeFactory.createOrNode(nodes); } else { return JexlNodeFactory.createAndNode(nodes); } }
/** * Create a new ASTEQNode from the given field name and value * * @param original * @param fieldName * @param fieldValue * @return */ public static JexlNode buildNode(ASTEQNode original, String fieldName, String fieldValue) { ASTEQNode newNode = new ASTEQNode(ParserTreeConstants.JJTEQNODE); if (null != original) { newNode.jjtSetParent(original.jjtGetParent()); } return buildUntypedNewNode(newNode, buildIdentifier(fieldName), fieldValue); }
/** * Create a new ASTEQNode from the given field name and value * * @param original * @param fieldName * @param fieldValue * @return */ public static JexlNode buildNode(ASTEQNode original, String fieldName, Number fieldValue) { ASTEQNode newNode = new ASTEQNode(ParserTreeConstants.JJTEQNODE); if (null != original) { newNode.jjtSetParent(original.jjtGetParent()); } return buildUntypedNewNode(newNode, buildIdentifier(fieldName), fieldValue); }
/** * Create a new ASTEQNode from the given field name and value * * @param original * @param fieldName * @param fieldValue * @return */ public static JexlNode buildNode(ASTEQNode original, String fieldName, JexlNode fieldValue) { ASTEQNode newNode = new ASTEQNode(ParserTreeConstants.JJTEQNODE); if (null != original) { newNode.jjtSetParent(original.jjtGetParent()); } return buildUntypedNewNode(newNode, buildIdentifier(fieldName), fieldValue); }
@Override public Object visit(ASTNENode notEquals, Object data) { final JexlNode root = notEquals.jjtGetParent(); final JexlNode equals = children(new ASTEQNode(ParserTreeConstants.JJTEQNODE), children(notEquals)); swap(root, notEquals, negate(equals)); return null; }
JexlNode orNode = JexlNodeFactory.createNodeTreeFromFieldsToValues(JexlNodeFactory.ContainerType.OR_NODE, new ASTEQNode( ParserTreeConstants.JJTEQNODE), onlyRangeNodes, fieldsToTerms);
@Override public Object visit(ASTEQNode node, Object data) { if (node.jjtGetNumChildren() == 2) { JexlNode child1 = JexlASTHelper.dereference(node.jjtGetChild(0)); if (isLiteral(child1)) { return reparent(node, new ASTEQNode(ParserTreeConstants.JJTEQNODE)); } } return super.visit(node, data); }
copy = new ASTEmptyFunction(ParserTreeConstants.JJTEMPTYFUNCTION); } else if (ASTEQNode.class.isAssignableFrom(clz)) { copy = new ASTEQNode(ParserTreeConstants.JJTEQNODE); } else if (ASTERNode.class.isAssignableFrom(clz)) { copy = new ASTERNode(ParserTreeConstants.JJTERNODE);
@Test public void manualNestedJexlNodeOrderEquality() throws Exception { ASTJexlScript one = JexlASTHelper.parseJexlQuery("(FOO == '1' && (BAR == 'bar' || BAR == 'baz'))"); JexlNode or = JexlNodeFactory.createNodeTreeFromFieldValues(ContainerType.OR_NODE, new ASTEQNode(ParserTreeConstants.JJTEQNODE), new ASTEQNode( ParserTreeConstants.JJTEQNODE), "BAR", Lists.newArrayList("bar", "baz")); JexlNode and = JexlNodeFactory.createAndNode(Lists.newArrayList(JexlNodeFactory.buildEQNode("FOO", "1"), or)); ASTJexlScript two = JexlNodeFactory.createScript(and); Assert.assertTrue(JexlASTHelper.equals(one, two)); }
if (positive) { newNode = JexlNodeFactory.createNodeTreeFromFieldsToValues(ContainerType.OR_NODE, new ASTEQNode(ParserTreeConstants.JJTEQNODE), node, fieldsToValues); } else {
JexlNode node0 = arguments.get(0); if (node0 instanceof ASTIdentifier) { returnNode = JexlNodeFactory.buildNode(new ASTEQNode(ParserTreeConstants.JJTEQNODE), node0.image, new ASTNullLiteral( ParserTreeConstants.JJTNULLLITERAL));
public static JexlNode buildNullNode(JexlNode original, ASTIdentifier identifier) { JexlNode copy; if (original instanceof ASTEQNode) { copy = new ASTEQNode(ParserTreeConstants.JJTEQNODE); } else if (original instanceof ASTNENode) { copy = new ASTNENode(ParserTreeConstants.JJTNENODE); } else if (original instanceof ASTERNode) { copy = new ASTERNode(ParserTreeConstants.JJTERNODE); } else if (original instanceof ASTNRNode) { copy = new ASTNRNode(ParserTreeConstants.JJTNRNODE); } else if (original instanceof ASTGTNode) { copy = new ASTGTNode(ParserTreeConstants.JJTGTNODE); } else if (original instanceof ASTGENode) { copy = new ASTGENode(ParserTreeConstants.JJTGENODE); } else if (original instanceof ASTLTNode) { copy = new ASTLTNode(ParserTreeConstants.JJTLTNODE); } else if (original instanceof ASTLENode) { copy = new ASTLENode(ParserTreeConstants.JJTLENODE); } else { throw new UnsupportedOperationException("Cannot handle " + original); } copy.jjtSetParent(original.jjtGetParent()); ASTNullLiteral literalNode = new ASTNullLiteral(ParserTreeConstants.JJTNULLLITERAL); return buildUntypedNewLiteralNode(copy, identifier, literalNode); }
@Override public JexlNode apply(ByteArrayRange input) { if (input.getStart().equals(input.getEnd())) { return JexlNodeFactory.buildNode(new ASTEQNode(ParserTreeConstants.JJTEQNODE), fieldName, GeometryNormalizer.getEncodedStringFromIndexBytes(input.getStart())); } else { JexlNode geNode = JexlNodeFactory.buildNode(new ASTGENode(ParserTreeConstants.JJTGENODE), fieldName, GeometryNormalizer.getEncodedStringFromIndexBytes(input.getStart())); JexlNode leNode = JexlNodeFactory.buildNode(new ASTLENode(ParserTreeConstants.JJTLENODE), fieldName, GeometryNormalizer.getEncodedStringFromIndexBytes(input.getEnd())); // now link em up return JexlNodeFactory.createAndNode(Arrays.asList(geNode, leNode)); } }
public static JexlNode buildBooleanNode(JexlNode original, ASTIdentifier identifier, Boolean literal) { JexlNode copy; if (original instanceof ASTEQNode) { copy = new ASTEQNode(ParserTreeConstants.JJTEQNODE); } else if (original instanceof ASTNENode) { copy = new ASTNENode(ParserTreeConstants.JJTNENODE);
case eq: jj_consume_token(eq); ASTEQNode jjtn001 = new ASTEQNode(JJTEQNODE); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001);