Class JournalArchive

java.lang.Object
mekhq.campaign.roleplay.JournalArchive

public final class JournalArchive extends Object
Reads journals back in from exported Markdown files.

A Markdown export ends with a hidden comment holding the entries exactly as saved, with their tags, answers and checks, so importing it loses nothing. Markdown renderers do not show the comment. Files exported before the comment existed are read from their text instead: each "## date - type" heading starts an entry, and notes are converted back from Markdown.

  • Method Details

    • read

      public static JournalArchive.Archive read(String document, Function<String,LocalDate> dateParser)
      Reads an exported journal.
      Parameters:
      document - the file's text
      dateParser - reads a date as the export wrote it, for files without the hidden data
      Returns:
      what was found; empty if the file holds no entries
    • importInto

      public static JournalArchive.ImportResult importInto(Roleplay roleplay, JournalArchive.Archive archive, int maximumRecords)
      Adds an archive's entries to a campaign's journal. Entries the journal already has (same date, type and text) are skipped. Tags are matched to this campaign's threads and cast by id, then by name; a thread tag that matches neither is dropped, and a cast member who matches neither is added to the cast as removed, so the tag is kept.
      Parameters:
      roleplay - the campaign's roleplay state
      archive - what to import
      maximumRecords - the Oracle log's size limit
      Returns:
      what was added