20 package net.sf.gridarta.model.io;
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.util.regex.Matcher;
25 import java.util.regex.Pattern;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
48 public void load(@NotNull
final BufferedReader reader, @NotNull
final A mapArchObject)
throws IOException {
49 final String firstLine = reader.readLine();
50 if (firstLine ==
null) {
51 throw new IOException(
"unexpected end of file in map header");
55 if (!trimmedFirstLine.equals(
"arch map")) {
56 throw new InvalidMapFormatException(
"unexpected first line of map file: '" + trimmedFirstLine +
"', expected 'arch map'");
60 final String line = reader.readLine();
62 throw new IOException(
"unexpected end of file in map header");
67 @Nullable
final String value;
68 if (matcher.matches()) {
69 key = matcher.group(1);
70 value = matcher.group(2);
77 if (!
parseLine(trimmedLine, key, value, mapArchObject, reader)) {
95 protected abstract boolean parseLine(@NotNull String line, @NotNull String key, @NotNull String value, @NotNull A mapArchObject, @NotNull BufferedReader reader)
throws IOException;