(EvaluationContext ctx)
| 61 | } |
| 62 | |
| 63 | private Target getTarget(EvaluationContext ctx) throws ELException { |
| 64 | // evaluate expr-a to value-a |
| 65 | Object base = this.children[0].getValue(ctx); |
| 66 | |
| 67 | // if our base is null (we know there are more properties to evaluate) |
| 68 | if (base == null) { |
| 69 | throw new PropertyNotFoundException( |
| 70 | MessageFactory.get("error.unreachable.base", this.children[0].getImage())); |
| 71 | } |
| 72 | |
| 73 | // set up our start/end |
| 74 | Object property = null; |
| 75 | int propCount = this.jjtGetNumChildren(); |
| 76 | |
| 77 | int i = 1; |
| 78 | // Evaluate any properties or methods before our target |
| 79 | ELResolver resolver = ctx.getELResolver(); |
| 80 | while (i < propCount) { |
| 81 | if (i + 2 < propCount && this.children[i + 1] instanceof AstMethodParameters) { |
| 82 | // Method call not at end of expression |
| 83 | base = resolver.invoke(ctx, base, this.children[i].getValue(ctx), null, |
| 84 | ((AstMethodParameters) this.children[i + 1]).getParameters(ctx)); |
| 85 | i += 2; |
| 86 | } else if (i + 2 == propCount && this.children[i + 1] instanceof AstMethodParameters) { |
| 87 | // Method call at end of expression |
| 88 | ctx.setPropertyResolved(false); |
| 89 | property = this.children[i].getValue(ctx); |
| 90 | if (property == null) { |
| 91 | throw new PropertyNotFoundException( |
| 92 | MessageFactory.get("error.unreachable.property", this.children[i].getImage())); |
| 93 | } |
| 94 | i += 2; |
| 95 | } else if (i + 1 < propCount) { |
| 96 | // Object with property not at end of expression |
| 97 | property = this.children[i].getValue(ctx); |
| 98 | ctx.setPropertyResolved(false); |
| 99 | base = resolver.getValue(ctx, base, property); |
| 100 | i++; |
| 101 | } else { |
| 102 | // Object with property at end of expression |
| 103 | ctx.setPropertyResolved(false); |
| 104 | property = this.children[i].getValue(ctx); |
| 105 | if (property == null) { |
| 106 | throw new PropertyNotFoundException( |
| 107 | MessageFactory.get("error.unreachable.property", this.children[i].getImage())); |
| 108 | } |
| 109 | i++; |
| 110 | } |
| 111 | if (base == null) { |
| 112 | throw new PropertyNotFoundException( |
| 113 | MessageFactory.get("error.unreachable.property", this.children[propCount - 1].getImage())); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | Target t = new Target(); |
| 118 | t.base = base; |
| 119 | t.property = property; |
| 120 | return t; |
no test coverage detected