1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package io.github.prolobjectlink.prolog.jlog;
23
24 import static io.github.prolobjectlink.prolog.PrologTermType.OBJECT_TYPE;
25
26 import io.github.prolobjectlink.prolog.PrologProvider;
27 import io.github.prolobjectlink.prolog.PrologReference;
28 import io.github.prolobjectlink.prolog.PrologTerm;
29 import ubc.cs.JLog.Terms.jObject;
30 import ubc.cs.JLog.Terms.jTerm;
31
32 public class JLogReference extends JLogTerm implements PrologReference {
33
34 JLogReference(PrologProvider provider, jTerm reference) {
35 super(OBJECT_TYPE, provider, reference);
36 }
37
38 JLogReference(PrologProvider provider, Object reference) {
39 super(OBJECT_TYPE, provider, new jObject(reference));
40 }
41
42 @Override
43 public Class<?> getReferenceType() {
44 return getObject().getClass();
45 }
46
47 public int getArity() {
48 return 0;
49 }
50
51 public String getFunctor() {
52 jObject object = (jObject) value;
53 return object.getName();
54 }
55
56 public PrologTerm[] getArguments() {
57 return new PrologTerm[0];
58 }
59
60 public Object getObject() {
61 jObject object = (jObject) value;
62 return object.getObjectReference();
63 }
64
65 public PrologTerm getTerm() {
66 String tag = "" + getObject() + "";
67 return provider.newAtom(tag);
68 }
69
70 }