Skip to content

Package: NotFoundELResolver

NotFoundELResolver

nameinstructionbranchcomplexitylinemethod
NotFoundELResolver()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCommonPropertyType(ELContext, Object)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType(ELContext, Object, Object)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getValue(ELContext, Object, Object)
M: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
isReadOnly(ELContext, Object, Object)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setValue(ELContext, Object, Object, Object)
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2021 Contributors to the Eclipse Foundation.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16: package jakarta.servlet.jsp.el;
17:
18: import java.util.ResourceBundle;
19:
20: import jakarta.el.ELContext;
21: import jakarta.el.ELResolver;
22: import jakarta.el.ELException;
23: import jakarta.el.PropertyNotFoundException;
24:
25: /**
26: * Defines variable resolution when all other resolvers fail.
27: *
28: * @since JSP 3.1
29: */
30: public class NotFoundELResolver extends ELResolver {
31:
32: private static final String LSTRING_FILE = "jakarta.servlet.jsp.LocalStrings";
33: private static final ResourceBundle lStrings = ResourceBundle.getBundle(LSTRING_FILE);
34:
35: /**
36: * Always returns {@code null} since in normal usage {@link ScopedAttributeELResolver} will handle calls to
37: * {@link ELResolver#getValue(ELContext, Object, Object)}.
38: *
39: * <p>
40: * The <code>propertyResolved</code> property of the <code>ELContext</code> object is always set to {@code true}
41: * by this resolver before returning.
42: * </p>
43: *
44: * @param context The context of this evaluation.
45: * @param base Ignored
46: * @param property Ignored
47: * @return Always {@code null}
48: * @throws NullPointerException if context is <code>null</code>
49: * @throws PropertyNotFoundException
50: * If the provided context contains a Boolean object with value {@code Boolean.TRUE} as
51: * the value associated with the key
52: * {@code jakarta.servlet.jsp.el.NotFoundELResolver.class}. This is to support
53: * implementation of the {@code errorOnELNotFound} page/tag directive.
54: * @throws ELException if an exception was thrown while performing the property or variable resolution. The
55: * thrown exception must be included as the cause property of this exception, if
56: * available.
57: */
58: @Override
59: public Object getValue(ELContext context, Object base, Object property) {
60:
61:• if (context == null) {
62: throw new NullPointerException();
63: }
64:
65: Object obj = context.getContext(this.getClass());
66:• if (obj instanceof Boolean && ((Boolean) obj).booleanValue()) {
67: throw new PropertyNotFoundException(
68: lStrings.getString("el.unknown.identifier") + " [" + property.toString() + "]");
69: }
70:
71: context.setPropertyResolved(true);
72:
73: return null;
74: }
75:
76: /**
77: * Always returns {@code null} since in normal usage {@link ScopedAttributeELResolver} will handle calls to
78: * {@link ELResolver#getType(ELContext, Object, Object)}.
79: *
80: * @param context The context of this evaluation.
81: * @param base Ignored
82: * @param property Ignored
83: * @return Always {@code null}
84: * @throws NullPointerException if context is <code>null</code>
85: * @throws ELException if an exception was thrown while performing the property or variable resolution. The
86: * thrown exception must be included as the cause property of this exception, if
87: * available.
88: */
89: @Override
90: public Class<Object> getType(ELContext context, Object base, Object property) {
91:
92:• if (context == null) {
93: throw new NullPointerException();
94: }
95:
96: return null;
97: }
98:
99: /**
100: * Always a NO-OP since in normal usage {@link ScopedAttributeELResolver} will handle calls to
101: * {@link ELResolver#setValue(ELContext, Object, Object, Object)}.
102: *
103: * @param context The context of this evaluation.
104: * @param base Ignored
105: * @param property Ignored
106: * @param val Ignored
107: * @throws NullPointerException if context is <code>null</code>.
108: * @throws ELException if an exception was thrown while performing the property or variable resolution. The
109: * thrown exception must be included as the cause property of this exception, if
110: * available.
111: */
112: @Override
113: public void setValue(ELContext context, Object base, Object property, Object val) {
114:• if (context == null) {
115: throw new NullPointerException();
116: }
117: }
118:
119: /**
120: * Always returns {@code false} since in normal usage {@link ScopedAttributeELResolver} will handle calls to
121: * {@link ELResolver#isReadOnly(ELContext, Object, Object)}.
122: *
123: * @param context The context of this evaluation.
124: * @param base Ignored
125: * @param property Ignored
126: * @return Always {@code false}
127: * @throws NullPointerException if context is <code>null</code>.
128: * @throws ELException if an exception was thrown while performing the property or variable resolution. The
129: * thrown exception must be included as the cause property of this exception, if
130: * available.
131: */
132: @Override
133: public boolean isReadOnly(ELContext context, Object base, Object property) {
134:• if (context == null) {
135: throw new NullPointerException();
136: }
137: return false;
138: }
139:
140: /**
141: * Always returns {@code null} since in normal usage {@link ScopedAttributeELResolver} will handle calls to
142: * {@link ELResolver#getCommonPropertyType(ELContext, Object)}.
143: *
144: * @param context Ignored
145: * @param base Ignored
146: *
147: * @return Always {@code null}
148: */
149: @Override
150: public Class<String> getCommonPropertyType(ELContext context, Object base) {
151: return null;
152: }
153: }