net.i2p.router.news

## Class NewsManager

- java.lang.Object
- - net.i2p.router.news.NewsManager

- All Implemented Interfaces:
    ClientApp

      public class NewsManager
      extends Object
      implements ClientApp

  Manages I2P router news entries with in-memory storage and disk persistence.

  Maintains current news entries in memory while providing methods to add new entries and persist them to disk storage. Handles both initial welcome news and dynamic news feed updates with proper sorting and deduplication logic.

  Implements ClientApp interface for lifecycle management with state tracking and notification capabilities. Supports legacy news.xml format for backward compatibility alongside newer structured formats.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `APP_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NewsManager(I2PAppContext ctx, ClientAppManager listener, String[] args)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEntries(List<NewsEntry> entries)` Add or replace each entry in the list.
    `String` | `getDisplayName()` The display name of the ClientApp, used in user interfaces.
    `List<NewsEntry>` | `getEntries()`
    `NewsEntry` | `getInitialNews()` The initial (Welcome to I2P) news
    `String` | `getName()` The generic name of the ClientApp, used for registration, e.g.
    `ClientAppState` | `getState()` The current state of the ClientApp.
    `void` | `shutdown(String[] args)` ClientApp interface
    `void` | `startup()` ClientApp interface
    `boolean` | `storeEntries(List<Node> entries)` Store each entry.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### APP_NAME

          public static final String APP_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NewsManager

          public NewsManager(I2PAppContext ctx,
                             ClientAppManager listener,
                             String[] args)

      Parameters:
        `args` - ignored

  - ### Method Detail

    - #### addEntries

          public void addEntries(List<NewsEntry> entries)

      Add or replace each entry in the list. Does NOT store them to disk.

    - #### getDisplayName

          public String getDisplayName()

      Description copied from interface: `ClientApp`
      The display name of the ClientApp, used in user interfaces. The app must translate.
      Specified by:
        `getDisplayName` in interface `ClientApp`
      Returns:
        non-null

    - #### getEntries

          public List<NewsEntry> getEntries()

      Returns:
        non-null, sorted by updated date, newest first

    - #### getInitialNews

          public NewsEntry getInitialNews()

      The initial (Welcome to I2P) news
      Returns:
        entry with first-installed date stamp, or null

    - #### getName

          public String getName()

      Description copied from interface: `ClientApp`
      The generic name of the ClientApp, used for registration, e.g. "console". Do not translate.
      Specified by:
        `getName` in interface `ClientApp`
      Returns:
        non-null

    - #### getState

          public ClientAppState getState()

      Description copied from interface: `ClientApp`
      The current state of the ClientApp.
      Specified by:
        `getState` in interface `ClientApp`
      Returns:
        non-null

    - #### shutdown

          public void shutdown(String[] args)

      ClientApp interface
      Specified by:
        `shutdown` in interface `ClientApp`
      Parameters:
        `args` - ignored

    - #### startup

          public void startup()

      ClientApp interface
      Specified by:
        `startup` in interface `ClientApp`

    - #### storeEntries

          public boolean storeEntries(List<Node> entries)

      Store each entry. Old entries are always overwritten, as they may change even without the updated date changing. Does NOT update the NewsEntry list.
      Parameters:
        `entries` - each one should be "entry" at the root
      Returns:
        true if any new entry was written (not if changed)