package models.files;
import java.io.BufferedReader;
import java.io.IOException;
import models.StarStorage;
import models.coordinates.EquatorialCoordinates;
import views.Star;
public class DatDatabaseReader implements IDatabaseReader {
private String [] subline;
private EquatorialCoordinates c;
@Override
public void read(BufferedReader reader, StarStorage stars) throws IOException {
String line;
Star s;
while ((line = reader.readLine()) != null) {
s = readLine(line);
if (s != null)
stars.add(s);
}
}
public Star readLine(String line) {
if (line.charAt(0) != '#') {
subline = line.split(",");
c = new EquatorialCoordinates(Double.parseDouble(subline[1]), Double.parseDouble(subline[2]));
return new Star(subline[0], c, Double.parseDouble(subline[3]), subline[4]);
}
return null;
}
}