/*
   * Generate a success message based on the number of decks and
   * Cards Parsed.
   */
  private String getParseSuccessMessage() {
    String message = "The Anki file was successfully parsed.";
    message += "\nTotal Decks Parsed: " + ankiFile.getTotalDeckModels();
    message += "\nTotal Cards Parsed: " + ankiFile.getTotalCards();
    message += "\n";

    return message;
  }
  /**
   * Write the Anki Cards and Decks to the output file that was specified during initialization.
   * Each Card will be written as a line to the output file based on the CardWriter returned by the
   * CardWriterFactory
   *
   * @return true if writing succeeds, false otherwise.
   */
  public boolean writeOutputFile() {
    try {
      writer = new BufferedWriter(new FileWriter(outputFilename));
      Collection<Deck> parsedDecks = ankiFile.getParsedDecks().values();
      Iterator<Deck> deckItr = parsedDecks.iterator();
      while (deckItr.hasNext()) {
        Deck deck = deckItr.next();

        Iterator<Card> cardItr = deck.getCardList().iterator();
        while (cardItr.hasNext()) {
          Card card = cardItr.next();
          String cardOutputLine = cardWriter.writeCard(card, deck);
          writer.write(cardOutputLine);
        }
      }

      writer.close();
      writeSucceeded = true;
      return true;
    } catch (IOException ioe) {
      // record error messages
      String errorMessage = "An error occurred writing to the output file: " + this.outputFilename;

      addStatusMessage(errorMessage);
      writeSucceeded = false;
      return false;
    }
  }