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
27
28
29 package io.github.prolobjectlink.prolog.jpl7;
30
31 import static io.github.prolobjectlink.prolog.PrologTermType.VARIABLE_TYPE;
32
33 import org.jpl7.Term;
34 import org.jpl7.Variable;
35
36 import io.github.prolobjectlink.prolog.ArityError;
37 import io.github.prolobjectlink.prolog.FunctorError;
38 import io.github.prolobjectlink.prolog.PrologProvider;
39 import io.github.prolobjectlink.prolog.PrologTerm;
40 import io.github.prolobjectlink.prolog.PrologVariable;
41
42
43
44
45
46
47 public class JplVariable extends JplTerm implements PrologVariable {
48
49 protected JplVariable(PrologProvider provider) {
50 super(VARIABLE_TYPE, provider, new Variable("_"));
51 }
52
53 protected JplVariable(PrologProvider provider, String name) {
54 super(VARIABLE_TYPE, provider, new Variable(name));
55 }
56
57 protected JplVariable(int type, PrologProvider provider) {
58 super(type, provider);
59 }
60
61 protected JplVariable(int type, PrologProvider provider, String name) {
62 super(type, provider, new Variable(name));
63 }
64
65 protected JplVariable(int type, PrologProvider provider, Term var) {
66 super(type, provider, var);
67 }
68
69 public boolean isAnonymous() {
70 return ((Variable) value).name().equals("_");
71 }
72
73 public String getName() {
74 return ((Variable) value).name();
75 }
76
77 public void setName(String name) {
78 this.value = new Variable(name);
79 }
80
81 public PrologTerm[] getArguments() {
82 return new JplVariable[0];
83 }
84
85 public int getArity() {
86 throw new ArityError(this);
87 }
88
89 public String getFunctor() {
90 throw new FunctorError(this);
91 }
92
93 public int getPosition() {
94 throw new UnsupportedOperationException("getPosition()");
95 }
96
97 }