Skip to content

Package: AstLiteralExpression

AstLiteralExpression

nameinstructionbranchcomplexitylinemethod
AstLiteralExpression(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getType(EvaluationContext)
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%
getValue(EvaluationContext)
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%
setImage(String)
M: 69 C: 0
0%
M: 18 C: 0
0%
M: 10 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3: * Copyright (c) 2021 Payara Services Ltd.
4: *
5: * This program and the accompanying materials are made available under the
6: * terms of the Eclipse Public License v. 2.0, which is available at
7: * http://www.eclipse.org/legal/epl-2.0.
8: *
9: * This Source Code may also be made available under the following Secondary
10: * Licenses when the conditions for such availability set forth in the
11: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12: * version 2 with the GNU Classpath Exception, which is available at
13: * https://www.gnu.org/software/classpath/license.html.
14: *
15: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16: */
17:
18: package com.sun.el.parser;
19:
20: import jakarta.el.ELException;
21:
22: import com.sun.el.lang.EvaluationContext;
23:
24: /**
25: * @author Jacob Hookom [jacob@hookom.net]
26: * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: kchung $
27: */
28: public final class AstLiteralExpression extends SimpleNode {
29: public AstLiteralExpression(int id) {
30: super(id);
31: }
32:
33: @Override
34: public Class getType(EvaluationContext ctx) throws ELException {
35: return String.class;
36: }
37:
38: @Override
39: public Object getValue(EvaluationContext ctx) throws ELException {
40: return this.image;
41: }
42:
43: @Override
44: public void setImage(String image) {
45:• if (image.indexOf('\\') == -1) {
46: this.image = image;
47: return;
48: }
49: int size = image.length();
50: StringBuilder buf = new StringBuilder(size);
51:• for (int i = 0; i < size; i++) {
52: char c = image.charAt(i);
53:• if (c == '\\' && i + 1 < size) {
54: char c1 = image.charAt(i + 1);
55:• if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#' || c1 == '$') {
56: c = c1;
57: i++;
58: }
59: }
60: buf.append(c);
61: }
62: this.image = buf.toString();
63: }
64: }