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