示例#1
0
  private void parseAndAddEntry(String type) {
    /**
     * Morten Alver 13 Aug 2006: Trying to make the parser more robust. If an exception is thrown
     * when parsing an entry, drop the entry and try to resume parsing. Add a warning for the user.
     */
    try {
      BibEntry entry = parseEntry(type);

      boolean duplicateKey = database.insertEntry(entry);
      entry.setParsedSerialization(dumpTextReadSoFarToString());
      if (duplicateKey) {
        parserResult.addDuplicateKey(entry.getCiteKey());
      } else if ((entry.getCiteKey() == null) || entry.getCiteKey().isEmpty()) {
        parserResult.addWarning(
            Localization.lang("Empty BibTeX key")
                + ": "
                + entry.getAuthorTitleYear(40)
                + " ("
                + Localization.lang("Grouping may not work for this entry.")
                + ")");
      }
    } catch (IOException ex) {
      LOGGER.warn("Could not parse entry", ex);
      parserResult.addWarning(
          Localization.lang("Error occurred when parsing entry")
              + ": '"
              + ex.getMessage()
              + "'. "
              + Localization.lang("Skipped entry."));
    }
  }