Skip to content

Package: AstString

AstString

nameinstructionbranchcomplexitylinemethod
AstString(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%
getString()
M: 17 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 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 AstString extends SimpleNode {
29: public AstString(int id) {
30: super(id);
31: }
32:
33: private String string;
34:
35: public String getString() {
36:• if (this.string == null) {
37: this.string = this.image.substring(1, this.image.length() - 1);
38: }
39: return this.string;
40: }
41:
42: @Override
43: public Class getType(EvaluationContext ctx) throws ELException {
44: return String.class;
45: }
46:
47: @Override
48: public Object getValue(EvaluationContext ctx) throws ELException {
49: return this.getString();
50: }
51:
52: @Override
53: public void setImage(String image) {
54:• if (image.indexOf('\\') == -1) {
55: this.image = image;
56: return;
57: }
58: int size = image.length();
59: StringBuilder buf = new StringBuilder(size);
60:• for (int i = 0; i < size; i++) {
61: char c = image.charAt(i);
62:• if (c == '\\' && i + 1 < size) {
63: char c1 = image.charAt(i + 1);
64:• if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#' || c1 == '$') {
65: c = c1;
66: i++;
67: }
68: }
69: buf.append(c);
70: }
71: this.image = buf.toString();
72: }
73: }