Package models.files

Source Code of models.files.DatDatabaseReader

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;
  }
 
}
TOP

Related Classes of models.files.DatDatabaseReader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.