package cs451.parser;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ConfigParser {

    private String path;

    private int messages;


    public boolean populate(String value) {
        File file = new File(value);
        path = file.getPath();

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {
            int lineNum = 1;
            for (String line; (line = br.readLine()) != null; lineNum++) {
                switch(lineNum){
                    case 1:
                        messages = Integer.parseInt(line);
                        break;
                    default:
                        break;
                }
            }
        } catch (IOException e) {
            System.err.println("Problem with the hosts file!");
            return false;
        }
        return true;
    }

    public String getPath() {
        return path;
    }

    public int getMessages() {
        return messages;
    }
}
