 |
Gridarta Editor
|
Go to the documentation of this file.
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;
static URL getResource(@NotNull final File dir, @NotNull final String fileName)
Get the URL of a resource.
AutojoinListsParser()
Creates a new instance.
Loader for AutojoinLists instances from files.
static< G extends GameObject< G, A, R > A extends 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)
Base package of all Gridarta classes.
Exception thrown if an Archetype does not exist.
static final int SIZE
The number of archetypes in an autojoin list.
Interface for classes displaying error messages.
Reflects a game object (object on a map).
static final String FILENAME
The file defining autojoin lists.
static final Pattern PATTERN_WHITESPACE
Pattern to match whitespace excluding NL and CR.
GameObjects are the objects based on Archetypes found on maps.
Defines possible error categories for ErrorView instances.
Interface for MapArchObjects.
Interface that captures similarities between different ArchetypeSet implementations.
Contains a list of (typically wall-)arches which do autojoining.
Exception thrown if an AutojoinList is invalid.
Utility class for string manipulation.
void addAutojoinList(@NotNull final AutojoinList< G, A, R > autojoinList)
Adds a new autojoin list.
static< G extends GameObject< G, A, R > A extends 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)
Utility-class for Gridarta's I/O.
static final String MAP_ENCODING
Encoding to use for maps and other data.