20 package net.sf.gridarta.model.autojoin;
22 import java.io.BufferedReader;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.io.Reader;
29 import java.util.ArrayList;
30 import java.util.List;
40 import org.jetbrains.annotations.NotNull;
51 private static final String
FILENAME =
"autojoin.txt";
67 public static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
AutojoinLists<G, A, R> loadList(@NotNull
final ErrorView errorView,
final ArchetypeSet<G, A, R> archetypeSet, @NotNull
final File baseDir) {
71 try (InputStream inputStream = url.openStream()) {
73 try (BufferedReader stream =
new BufferedReader(reader)) {
74 return loadList(errorView, archetypeSet, url, stream);
78 }
catch (
final IOException ex) {
81 }
catch (
final IOException ex) {
98 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
AutojoinLists<G, A, R> loadList(@NotNull
final ErrorView errorView,
final ArchetypeSet<G, A, R> archetypeSet, @NotNull
final URL url, @NotNull
final BufferedReader bufferedReader)
throws IOException {
100 boolean sectionFlag =
false;
102 final StringBuilder undefinedArchetypes =
new StringBuilder();
103 boolean skipList =
true;
105 final String line2 = bufferedReader.readLine();
109 if (!line2.startsWith(
"#") && !line2.isEmpty()) {
110 final String line = line2.trim();
114 if (line.equals(
"end")) {
115 if (undefinedArchetypes.length() > 0) {
128 final List<R> tmp =
new ArrayList<>();
131 final R archetype = archetypeSet.getArchetype(archetypeName);
132 if (archetype.isMulti()) {
139 undefinedArchetypes.append(
' ').append(ex.getMessage());
147 if (line.equals(
"start")) {
151 undefinedArchetypes.setLength(0);
156 return autojoinLists;