Archived
0

add support import Maddavo's Market Share files

This commit is contained in:
iMoHax
2015-02-28 19:27:54 +03:00
parent d1f89de30a
commit d22a5bbcd8
3 changed files with 93 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
package ru.trader.maddavo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.trader.core.Market;
import java.io.*;
public class Parser {
private final static Logger LOG = LoggerFactory.getLogger(Parser.class);
public static void parseSystems(File file, Market market) throws IOException {
parseFile(file, new SystemHandler(market), 1);
}
public static void parseStations(File file, Market market) throws IOException {
parseFile(file, new StationHandler(market), 1);
}
public static void parsePrices(File file, Market market) throws IOException {
parseFile(file, new OffersHandler(market, true), 0);
}
private static void parseFile(File file, ParseHandler handler, int skip) throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
int row = 0;
String line;
while ((line = reader.readLine()) != null) {
row++;
if (row <= skip) continue;
handler.parse(line);
}
}
}
}