MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / read

Method read

src/main/java/fieldbox/boxes/plugins/PluginList.java:33–59  ·  view source on GitHub ↗
(String filename, boolean createOnDemand)

Source from the content-addressed store, hash-verified

31 public PluginList() {
32 Parser.Config.Builder builder = Parsers.newParserConfigBuilder();
33 parser = Parsers.newParser(builder.build());
34 }
35
36 public Map<String, List<Object>> read(String filename, boolean createOnDemand) throws IOException {
37
38 try {
39 if (!new File(filename).exists()) {
40 if (createOnDemand) createBlankFile(filename);
41 return Collections.emptyMap();
42 }
43
44 try (FileReader fr = new FileReader(new File(filename))) {
45 Parseable parseme = Parsers.newParseable(fr);
46
47 Map<String, List<Object>> r = new LinkedHashMap<>();
48
49 while (true) {
50 Object o = parser.nextValue(parseme);
51 if (o.equals(Parser.END_OF_INPUT)) break;
52
53 massageAndCollapse(o, r);
54 }
55 return r;
56 }
57 }
58 catch(EdnSyntaxException syntax)
59 {
60 syntax.printStackTrace();
61 Log.log("startup.error", ()->"Syntax error in plugins.edn file "+syntax+" "+filename);
62 return null;

Callers 1

mainMethod · 0.95

Calls 6

createBlankFileMethod · 0.95
massageAndCollapseMethod · 0.95
logMethod · 0.95
existsMethod · 0.80
nextValueMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected