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
30
31
32
33 package io.github.prolobjectlink.prolog.jpl7.swi7;
34
35 import java.io.File;
36 import java.util.ArrayList;
37 import java.util.List;
38
39 import org.jpl7.JPL;
40 import org.jpl7.Query;
41 import org.jpl7.Term;
42
43 import io.github.prolobjectlink.prolog.Licenses;
44 import io.github.prolobjectlink.prolog.PrologEngine;
45 import io.github.prolobjectlink.prolog.PrologProvider;
46 import io.github.prolobjectlink.prolog.jpl7.JplEngine;
47
48
49
50
51
52
53 public class SwiProlog7Engine extends JplEngine implements PrologEngine {
54
55 protected SwiProlog7Engine(PrologProvider provider) {
56 super(provider);
57 }
58
59 protected SwiProlog7Engine(PrologProvider provider, String file) {
60 super(provider, file);
61 }
62
63 public final String getLicense() {
64 return Licenses.LGPL_V3;
65 }
66
67 public final String getVersion() {
68 Term swi = Query.oneSolution("current_prolog_flag(version_data,Swi)").get("Swi");
69 return "" + swi.arg(1) + "." + swi.arg(2) + "." + swi.arg(3) + " (JPL v" + JPL.version_string() + ")";
70 }
71
72 public final String getVendor() {
73 return "SWI-Prolog";
74 }
75
76 public final String getName() {
77 return "SWI-Prolog";
78 }
79
80 public final List<String> verify() {
81 String slash = File.separator;
82 List<String> list = new ArrayList<String>();
83 String javaHome = System.getProperty("java.home");
84 String javaVersion = System.getProperty("java.version");
85 String pathSeparator = System.getProperty("path.separator");
86 if (runOnWindows()) {
87 list.add(javaHome.replace(slash + "jre", slash) + "/jdk" + javaVersion + "/bin" + pathSeparator);
88 list.add(javaHome.replace(slash + "jre", slash) + "/jdk" + javaVersion + "/lib/tools.jar" + pathSeparator);
89 list.add(
90 javaHome.replace(slash + "jre", slash) + "/jdk" + javaVersion + "/jre/lib/rt.jar;" + pathSeparator);
91 list.add("C:/Program Files/swipl/lib/jpl.jar" + pathSeparator);
92 list.add("C:/Program Files/swipl/bin");
93 } else if (runOnOSX()) {
94
95 } else if (runOnLinux()) {
96 list.add("/usr/lib/jvm/java-" + javaVersion + "-openjdk-" + getOSArch() + "/bin" + pathSeparator);
97 list.add("/usr/lib/jvm/java-" + javaVersion + "-openjdk-" + getOSArch() + "/lib/tools.jar" + pathSeparator);
98 list.add(
99 "/usr/lib/jvm/java-" + javaVersion + "-openjdk-" + getOSArch() + "/jre/lib/rt.jar" + pathSeparator);
100 list.add("/usr/local/bin/swipl/lib/jpl.jar" + pathSeparator);
101 list.add("/usr/local/bin");
102 }
103 return list;
104 }
105
106 }