for (final Object element : r)
if (element instanceof RouteHeader)
anzHeader++;
// 2. Durchgang: Routes bauen
final Route[] routes = new Route[anzHeader];
Route t = null;
List<Waypoint> waypoints = null;
List<RouteLink> links = null;
i = 0;
for (final Object element : r)
if (element instanceof RouteHeader) {
if (t != null) {
t.setWaypoints(waypoints);
if (links.size() > 0)
t.setLinks(links);
}
t = new Route((RouteHeader) element);
routes[i++] = t;
waypoints = new ArrayList<Waypoint>();
links = new ArrayList<RouteLink>();
}
else if (element instanceof Waypoint)
waypoints.add((Waypoint) element);
else if (element instanceof RouteLink)
links.add((RouteLink) element);
if (t != null) {
t.setWaypoints(waypoints);
if (links.size() > 0)
t.setLinks(links);
}
return routes;
}
else
return r;