private List<RteType> createRoute(GpxRoute route, int startIndex, int endIndex) { ObjectFactory objectFactory = new ObjectFactory(); List<RteType> rteTypes = new ArrayList<RteType>(); RteType rteType = route.getOrigin(RteType.class); if (rteType != null) rteType.getRtept().clear(); else rteType = objectFactory.createRteType(); if (isWriteName()) { rteType.setName(asRouteName(route.getName())); rteType.setDesc(asDescription(route.getDescription())); } rteTypes.add(rteType); List<GpxPosition> positions = route.getPositions(); for (int i = startIndex; i < endIndex; i++) { GpxPosition position = positions.get(i); WptType wptType = createWptType(position); if (wptType != null) rteType.getRtept().add(wptType); } return rteTypes; }