List<RailArc> railArcList = new ArrayList<RailArc>();
String line = bufferedReader.readLine();
long id = 0L;
while (!line.equals(";;;;;;")) {
String[] lineTokens = splitBySemicolonSeparatedValue(line, 6);
RailArc railArc = new RailArc();
RailArc reverseRailArc = new RailArc();
railArc.setId(id);
id++;
reverseRailArc.setId(id);
id++;
RailNode origin = nameToRailNodeMap.get(lineTokens[0]);
if (origin == null) {
throw new IllegalArgumentException("Read line (" + line
+ ") has a non existing origin (" + lineTokens[0] + ").");
}
railArc.setOrigin(origin);
origin.getOriginatingRailArcList().add(railArc);
reverseRailArc.setDestination(origin);
RailNode destination = nameToRailNodeMap.get(lineTokens[1]);
if (destination == null) {
throw new IllegalArgumentException("Read line (" + line
+ ") has a non existing destination (" + lineTokens[1] + ").");
}
railArc.setDestination(destination);
reverseRailArc.setOrigin(destination);
destination.getOriginatingRailArcList().add(reverseRailArc);
int distance = readDistance(lineTokens[2]);
railArc.setDistance(distance);
reverseRailArc.setDistance(distance);
int maximumTrainLength = Integer.parseInt(lineTokens[3]);
railArc.setMaximumTrainLength(maximumTrainLength);
reverseRailArc.setMaximumTrainLength(maximumTrainLength);
int maximumTonnage = Integer.parseInt(lineTokens[4]);
railArc.setMaximumTonnage(maximumTonnage);
reverseRailArc.setMaximumTonnage(maximumTonnage);
int maximumNumberOfTrains = Integer.parseInt(lineTokens[5]);
railArc.setMaximumNumberOfTrains(maximumNumberOfTrains);
reverseRailArc.setMaximumNumberOfTrains(maximumNumberOfTrains);
railArc.setReverse(reverseRailArc);
reverseRailArc.setReverse(railArc);
railArcList.add(railArc);
railArcList.add(reverseRailArc);
line = bufferedReader.readLine();
}
trainDesign.setRailArcList(railArcList);