public static void readShoppingList(File file, Planner planner)
            throws FileNotFoundException, XMLStreamException {

        XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(file));
        ShoppingList shoppingList = new ShoppingList();
        while (xmlStreamReader.hasNext()) {
            if (xmlStreamReader.getEventType() == XMLStreamConstants.START_ELEMENT) {
                String localName = xmlStreamReader.getLocalName();
                if (localName.equals(PRODUCT)) {
                    Product product = new Product();
                    product.setCode(xmlStreamReader.getAttributeValue(0));
                    product.setName(xmlStreamReader.getElementText());
                    shoppingList.getProducts().add(product);
                } else if (localName.equals(COORDINATES)) {
                    Coordinates coordinates = new Coordinates();
                    coordinates.setX(Integer.parseInt(xmlStreamReader.getAttributeValue(0)));
                    coordinates.setY(Integer.parseInt(xmlStreamReader.getAttributeValue(1)));
                    shoppingList.setCoordinates(coordinates);
                    planner.getObjectStorage().setInitialCoordinates(coordinates);
                } else if (localName.equals(COST)) {
                    shoppingList.setOptimizationParameter(ShoppingList.OptimizationParameter.COST);
                } else if (localName.equals(DISTANCE)) {
                    shoppingList.setOptimizationParameter(ShoppingList.OptimizationParameter.DISTANCE);
                }
            } else if (xmlStreamReader.getEventType() == XMLStreamConstants.END_ELEMENT) {
                String localName = xmlStreamReader.getLocalName();
                if (localName.equals(SHOPPING_LIST)) {
                    planner.getPlannerContext().setShoppingList(shoppingList);
                    return;
                }
            }
            xmlStreamReader.next();
        }
        xmlStreamReader.close();
    }