Skip to content

Method: getAsValue(String)

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.query.soql;
16:
17: public class SoqlParameter {
18:
19: private SoqlNode firstNode;
20:
21: public SoqlParameter(SoqlNode firstNode) {
22: this.firstNode = firstNode;
23: }
24:
25: public String getAsParam() {
26: StringBuilder buildParam = new StringBuilder("?");
27: buildParam.append(firstNode.getValue());
28: SoqlNode pointer = firstNode;
29: while (pointer.hasChild()) {
30: pointer = pointer.getChild();
31: buildParam.append(pointer.getCapitalizedValue());
32: }
33: return buildParam.toString();
34: }
35:
36: public void setFirstNode(SoqlNode firstNode) {
37: this.firstNode = firstNode;
38: }
39:
40: public SoqlNode getFirstNode() {
41: return firstNode;
42: }
43:
44: public String getAsValue(String rootVariable) {
45: StringBuilder buildParam = new StringBuilder("?");
46:• if (!firstNode.hasChild()) {
47: return rootVariable;
48: }
49: SoqlNode pointer = firstNode.getChild();
50: buildParam.append(pointer.getValue());
51:• while (pointer.hasChild()) {
52: pointer = pointer.getChild();
53: buildParam.append(pointer.getCapitalizedValue());
54: }
55: return buildParam.toString();
56: }
57: }