org.apache.el.parser.Node Java Examples
The following examples show how to use
org.apache.el.parser.Node.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 6 votes |
private void prepare(Node node) throws ELException { try { node.accept(this); } catch (Exception e) { if (e instanceof ELException) { throw (ELException) e; } else { throw (new ELException(e)); } } if (this.fnMapper instanceof FunctionMapperFactory) { this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create(); } if (this.varMapper instanceof VariableMapperFactory) { this.varMapper = ((VariableMapperFactory) this.varMapper).create(); } }
Example #2
Source File: RuleVerifyUtils.java From proctor with Apache License 2.0 | 6 votes |
private static Node checkUndefinedIdentifier(final Node node, final ELContext elContext, final Set<String> absentIdentifiers) { if (node instanceof AstIdentifier) { final String name = node.getImage(); final boolean hasVariable = elContext.getVariableMapper().resolveVariable(name) != null; if (!hasVariable && !absentIdentifiers.contains(name)) { return node; } } else { for (int i = 0; i < node.jjtGetNumChildren(); i++) { final Node result = checkUndefinedIdentifier(node.jjtGetChild(i), elContext, absentIdentifiers); if (result != null) { return result; } } } return null; }
Example #3
Source File: ExpressionBuilder.java From Tomcat8-Source-Read with MIT License | 6 votes |
private void prepare(Node node) throws ELException { try { node.accept(this); } catch (Exception e) { if (e instanceof ELException) { throw (ELException) e; } else { throw (new ELException(e)); } } if (this.fnMapper instanceof FunctionMapperFactory) { this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create(); } if (this.varMapper instanceof VariableMapperFactory) { this.varMapper = ((VariableMapperFactory) this.varMapper).create(); } }
Example #4
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public MethodExpression createMethodExpression(Class<?> expectedReturnType, Class<?>[] expectedParamTypes) throws ELException { Node n = this.build(); if (!n.isParametersProvided() && expectedParamTypes == null) { throw new NullPointerException(MessageFactory .get("error.method.nullParms")); } if (n instanceof AstValue || n instanceof AstIdentifier) { return new MethodExpressionImpl(expression, n, this.fnMapper, this.varMapper, expectedReturnType, expectedParamTypes); } else if (n instanceof AstLiteralExpression) { return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { throw new ELException("Not a Valid Method Expression: " + expression); } }
Example #5
Source File: ExpressionBuilder.java From Tomcat8-Source-Read with MIT License | 6 votes |
public MethodExpression createMethodExpression(Class<?> expectedReturnType, Class<?>[] expectedParamTypes) throws ELException { Node n = this.build(); if (!n.isParametersProvided() && expectedParamTypes == null) { throw new NullPointerException(MessageFactory .get("error.method.nullParms")); } if (n instanceof AstValue || n instanceof AstIdentifier) { return new MethodExpressionImpl(expression, n, this.fnMapper, this.varMapper, expectedReturnType, expectedParamTypes); } else if (n instanceof AstLiteralExpression) { return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { throw new ELException("Not a Valid Method Expression: " + expression); } }
Example #6
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private void prepare(Node node) throws ELException { try { node.accept(this); } catch (Exception e) { if (e instanceof ELException) { throw (ELException) e; } else { throw (new ELException(e)); } } if (this.fnMapper instanceof FunctionMapperFactory) { this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create(); } if (this.varMapper instanceof VariableMapperFactory) { this.varMapper = ((VariableMapperFactory) this.varMapper).create(); } }
Example #7
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 6 votes |
public MethodExpression createMethodExpression(Class<?> expectedReturnType, Class<?>[] expectedParamTypes) throws ELException { Node n = this.build(); if (!n.isParametersProvided() && expectedParamTypes == null) { throw new NullPointerException(MessageFactory .get("error.method.nullParms")); } if (n instanceof AstValue || n instanceof AstIdentifier) { return new MethodExpressionImpl(expression, n, this.fnMapper, this.varMapper, expectedReturnType, expectedParamTypes); } else if (n instanceof AstLiteralExpression) { return new MethodExpressionLiteral(expression, expectedReturnType, expectedParamTypes); } else { throw new ELException("Not a Valid Method Expression: " + expression); } }
Example #8
Source File: MethodExpressionImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * @param expr * @param node * @param fnMapper * @param expectedType * @param paramTypes */ public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; this.paramTypes = paramTypes; }
Example #9
Source File: ValueExpressionImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * */ public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #10
Source File: MethodExpressionImpl.java From Tomcat8-Source-Read with MIT License | 5 votes |
public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; this.paramTypes = paramTypes; }
Example #11
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void visit(Node node) throws ELException { if (node instanceof AstFunction) { AstFunction funcNode = (AstFunction) node; if (this.fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode .getLocalName()); if (m == null) { throw new ELException(MessageFactory.get( "error.fnMapper.method", funcNode.getOutputName())); } int pcnt = m.getParameterTypes().length; if (node.jjtGetNumChildren() != pcnt) { throw new ELException(MessageFactory.get( "error.fnMapper.paramcount", funcNode.getOutputName(), "" + pcnt, "" + node.jjtGetNumChildren())); } } else if (node instanceof AstIdentifier && this.varMapper != null) { String variable = ((AstIdentifier) node).getImage(); // simply capture it this.varMapper.resolveVariable(variable); } }
Example #12
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private Node build() throws ELException { Node n = createNodeInternal(this.expression); this.prepare(n); if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } return n; }
Example #13
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 5 votes |
private Node build() throws ELException { Node n = createNodeInternal(this.expression); this.prepare(n); if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } return n; }
Example #14
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void visit(Node node) throws ELException { if (node instanceof AstFunction) { AstFunction funcNode = (AstFunction) node; if (this.fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode .getLocalName()); if (m == null) { throw new ELException(MessageFactory.get( "error.fnMapper.method", funcNode.getOutputName())); } int pcnt = m.getParameterTypes().length; if (node.jjtGetNumChildren() != pcnt) { throw new ELException(MessageFactory.get( "error.fnMapper.paramcount", funcNode.getOutputName(), "" + pcnt, "" + node.jjtGetNumChildren())); } } else if (node instanceof AstIdentifier && this.varMapper != null) { String variable = ((AstIdentifier) node).getImage(); // simply capture it this.varMapper.resolveVariable(variable); } }
Example #15
Source File: MethodExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * @param expr * @param node * @param fnMapper * @param expectedType * @param paramTypes */ public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; this.paramTypes = paramTypes; }
Example #16
Source File: ValueExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * */ public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #17
Source File: ValueExpressionImpl.java From Tomcat8-Source-Read with MIT License | 5 votes |
public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #18
Source File: RuleVerifyUtils.java From proctor with Apache License 2.0 | 5 votes |
private static boolean isIgnorable(final Node node, final Set<String> absentIdentifiers) { final List<Node> leaves = getLeafNodes(node); for (final Node n : leaves) { final String image = n.getImage(); if (absentIdentifiers.contains(image)) { /* we can ignore this test failure since the identifier context is not provided **/ return true; } } return false; }
Example #19
Source File: ExpressionBuilder.java From Tomcat8-Source-Read with MIT License | 5 votes |
private Node build() throws ELException { Node n = createNodeInternal(this.expression); this.prepare(n); if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } return n; }
Example #20
Source File: RuleVerifyUtils.java From proctor with Apache License 2.0 | 5 votes |
private static void find(final Node node, final List<Node> res) { if (node.jjtGetNumChildren() > 0) { for (int i = 0; i < node.jjtGetNumChildren(); i++) { find(node.jjtGetChild(i), res); } } else { res.add(node); } }
Example #21
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 4 votes |
public static final Node createNode(String expr) throws ELException { Node n = createNodeInternal(expr); return n; }
Example #22
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 4 votes |
private static final Node createNodeInternal(String expr) throws ELException { if (expr == null) { throw new ELException(MessageFactory.get("error.null")); } Node n = cache.get(expr); if (n == null) { try { n = (new ELParser(new StringReader(expr))) .CompositeExpression(); // validate composite expression int numChildren = n.jjtGetNumChildren(); if (numChildren == 1) { n = n.jjtGetChild(0); } else { Class<?> type = null; Node child = null; for (int i = 0; i < numChildren; i++) { child = n.jjtGetChild(i); if (child instanceof AstLiteralExpression) continue; if (type == null) type = child.getClass(); else { if (!type.equals(child.getClass())) { throw new ELException(MessageFactory.get( "error.mixed", expr)); } } } } if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } cache.put(expr, n); } catch (Exception e) { throw new ELException( MessageFactory.get("error.parseFail", expr), e); } } return n; }
Example #23
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public ValueExpression createValueExpression(Class<?> expectedType) throws ELException { Node n = this.build(); return new ValueExpressionImpl(this.expression, n, this.fnMapper, this.varMapper, expectedType); }
Example #24
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 4 votes |
public ValueExpression createValueExpression(Class<?> expectedType) throws ELException { Node n = this.build(); return new ValueExpressionImpl(this.expression, n, this.fnMapper, this.varMapper, expectedType); }
Example #25
Source File: ValueExpressionImpl.java From tomcatsrc with Apache License 2.0 | 4 votes |
private Node getNode() throws ELException { if (this.node == null) { this.node = ExpressionBuilder.createNode(this.expr); } return this.node; }
Example #26
Source File: RuleVerifyUtils.java From proctor with Apache License 2.0 | 4 votes |
private static List<Node> getLeafNodes(final Node node) { final List<Node> nodes = Lists.newArrayList(); find(node, nodes); return nodes; }
Example #27
Source File: MethodExpressionImpl.java From tomcatsrc with Apache License 2.0 | 4 votes |
private Node getNode() throws ELException { if (this.node == null) { this.node = ExpressionBuilder.createNode(this.expr); } return this.node; }
Example #28
Source File: ValueExpressionImpl.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
private Node getNode() throws ELException { if (this.node == null) { this.node = ExpressionBuilder.createNode(this.expr); } return this.node; }
Example #29
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
private static final Node createNodeInternal(String expr) throws ELException { if (expr == null) { throw new ELException(MessageFactory.get("error.null")); } Node n = cache.get(expr); if (n == null) { try { n = (new ELParser(new StringReader(expr))) .CompositeExpression(); // validate composite expression int numChildren = n.jjtGetNumChildren(); if (numChildren == 1) { n = n.jjtGetChild(0); } else { Class<?> type = null; Node child = null; for (int i = 0; i < numChildren; i++) { child = n.jjtGetChild(i); if (child instanceof AstLiteralExpression) continue; if (type == null) type = child.getClass(); else { if (!type.equals(child.getClass())) { throw new ELException(MessageFactory.get( "error.mixed", expr)); } } } } if (n instanceof AstDeferredExpression || n instanceof AstDynamicExpression) { n = n.jjtGetChild(0); } cache.put(expr, n); } catch (Exception e) { throw new ELException( MessageFactory.get("error.parseFail", expr), e); } } return n; }
Example #30
Source File: ExpressionBuilder.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public static final Node createNode(String expr) throws ELException { Node n = createNodeInternal(expr); return n; }