Skip to content

Method: SoqlParameter()

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() {
22: }
23:
24: public String getAsParam() {
25: StringBuilder buildParam = new StringBuilder("?");
26: buildParam.append(firstNode.getValue());
27: SoqlNode pointer = firstNode;
28: while (pointer.hasNextChild()) {
29: pointer = pointer.getChild();
30: buildParam.append(pointer.getCapitalizedValue());
31: }
32: return buildParam.toString();
33: }
34:
35: public SoqlNode getFirstNode() {
36: return firstNode;
37: }
38:
39: public void setFirstNode(SoqlNode firstNode) {
40: this.firstNode = firstNode;
41: }
42:
43: public String getAsValue() {
44: StringBuilder buildParam = new StringBuilder("?");
45: SoqlNode firstNode = getFirstNode();
46: SoqlNode pointer;
47: if (firstNode.hasNextChild()) {
48: pointer = getFirstNode().getChild();
49: } else {
50: return "?x";
51: }
52: buildParam.append(pointer.getValue());
53: while (pointer.hasNextChild()) {
54: pointer = pointer.getChild();
55: buildParam.append(pointer.getCapitalizedValue());
56: }
57: return buildParam.toString();
58: }
59: }