Skip to contentMethod: toString()
1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.query.soql;
19:
20: class FunctionNode extends SoqlNode {
21:
22: // SOQL function name
23: private final String functionName;
24:
25: FunctionNode(SoqlNode child, String functionName) {
26: assert child != null;
27: assert functionName != null && !functionName.isEmpty();
28: this.child = child;
29: this.functionName = functionName;
30: }
31:
32: @Override
33: public boolean hasChild() {
34: return child.hasChild();
35: }
36:
37: @Override
38: public SoqlNode getChild() {
39: return child.getChild();
40: }
41:
42: @Override
43: public void setChild(SoqlNode child) {
44: child.setChild(child);
45: }
46:
47: @Override
48: public String getValue() {
49: return child.getValue();
50: }
51:
52: @Override
53: public void setValue(String value) {
54: child.setValue(value);
55: }
56:
57: @Override
58: public String getCapitalizedValue() {
59: return child.getCapitalizedValue();
60: }
61:
62: @Override
63: public String getIri() {
64: return child.getIri();
65: }
66:
67: @Override
68: public void setIri(String iri) {
69: child.setIri(iri);
70: }
71:
72: @Override
73: public boolean requiresFilterExpression() {
74: return true;
75: }
76:
77: @Override
78: public String toFilterExpression(String filterParam, String filterValue) {
79: return SoqlFunctionTranslator.getSparqlFunction(functionName) + "(" + child.toFilterExpression(filterParam,
80: filterValue) + ")";
81: }
82:
83: @Override
84: public String toString() {
85:• return functionName + "(" + (child != null ? child.toString() : "") + ")";
86: }
87: }