class SurvexImporter extends Importer {

    public static void parse(String text, Survey survey) throws Exception {

        Map<String, Station> nameToStation = new HashMap<>();

        String[] lines = text.split("\n");
        for (String line : lines) {

            String trimmed = line.trim();
            if (trimmed.equals("") || trimmed.startsWith(";") || trimmed.startsWith("*")) {
                continue;
            }

            try {
                String comment = "";
                if (line.contains(";")) {
                    comment = line.substring(line.indexOf(";") + 1).trim();
                }

                String[] fields = line.trim().split("\\s+");
                addLegToSurvey(survey, nameToStation, fields, comment);

            } catch (Exception exception) {
                throw new Exception("Error importing this line: " + line);
            }
        }
    }

}