Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
_BeanValidatorUELUtils |
|
| 6.0;6 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package javax.faces.validator; | |
20 | ||
21 | import javax.el.ELContext; | |
22 | import javax.el.ValueExpression; | |
23 | import javax.el.ValueReference; | |
24 | import javax.faces.el.CompositeComponentExpressionHolder; | |
25 | ||
26 | /** | |
27 | * Utility class that isolates UEL calls, to prevent ClassNotFoundException | |
28 | * when bean validation is used without it. It is a similar hack to the one | |
29 | * used in portlet case. | |
30 | * | |
31 | * @since 2.0 | |
32 | */ | |
33 | 0 | final class _BeanValidatorUELUtils |
34 | { | |
35 | ||
36 | /** | |
37 | * Get the ValueReference from the ValueExpression. | |
38 | * | |
39 | * @param valueExpression | |
40 | * @param elCtx | |
41 | * @return A ValueReferenceWrapper with the necessary information about the ValueReference. | |
42 | */ | |
43 | public static _ValueReferenceWrapper getUELValueReferenceWrapper(ValueExpression valueExpression, | |
44 | final ELContext elCtx) | |
45 | { | |
46 | 0 | ValueReference valueReference = valueExpression.getValueReference(elCtx); |
47 | ||
48 | 0 | while (valueReference != null |
49 | && valueReference.getBase() instanceof CompositeComponentExpressionHolder) | |
50 | { | |
51 | 0 | valueExpression = ((CompositeComponentExpressionHolder) valueReference.getBase()) |
52 | .getExpression((String) valueReference.getProperty()); | |
53 | 0 | if(valueExpression == null) |
54 | { | |
55 | 0 | break; |
56 | } | |
57 | 0 | valueReference = valueExpression.getValueReference(elCtx); |
58 | } | |
59 | ||
60 | 0 | if (valueReference != null) |
61 | { | |
62 | 0 | return new _ValueReferenceWrapper(valueReference.getBase(), valueReference.getProperty()); |
63 | } | |
64 | ||
65 | 0 | return null; |
66 | } | |
67 | ||
68 | } |