1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package io.github.prolobjectlink.prolog;
27
28
29
30
31
32
33 final class DefaultQueryBuilder extends AbstractBuilder implements PrologQueryBuilder {
34
35 DefaultQueryBuilder(PrologEngine engine) {
36 super(engine);
37 }
38
39 public PrologQueryBuilder begin(String functor, PrologTerm... arguments) {
40 append(functor, arguments);
41 return this;
42 }
43
44 public PrologQueryBuilder begin(PrologTerm term) {
45 append(term);
46 return this;
47 }
48
49 public PrologQueryBuilder comma(PrologTerm body) {
50 append(',');
51 append(' ');
52 append(body);
53 return this;
54 }
55
56 public PrologQueryBuilder comma(String functor, PrologTerm... arguments) {
57 append(',');
58 append(' ');
59 append(functor, arguments);
60 return this;
61 }
62
63 public PrologQueryBuilder comma(PrologTerm left, String operator, PrologTerm right) {
64 append(',');
65 append(' ');
66 append(left, operator, right);
67 return this;
68 }
69
70 public PrologQueryBuilder semicolon(PrologTerm term) {
71 append(';');
72 append(' ');
73 append(term);
74 return this;
75 }
76
77 public PrologQueryBuilder semicolon(String functor, PrologTerm... arguments) {
78 append(';');
79 append(' ');
80 append(functor, arguments);
81 return this;
82 }
83
84 public PrologQueryBuilder semicolon(PrologTerm left, String operator, PrologTerm right) {
85 append(';');
86 append(' ');
87 append(left, operator, right);
88 return this;
89 }
90
91 public PrologQuery query() {
92 String q = "" + builder + "";
93 builder = new StringBuilder();
94 return engine.query(q);
95 }
96
97 public String getQueryString() {
98 return "" + builder + "";
99 }
100
101 }