Package net.i2p.util

Class UIMessages


  • public class UIMessages
    extends Object
    A queue of messages, where each has an ID number. Provide the ID back to the clear call, so you don't erase messages you haven't seen yet. Thread-safe.
    Since:
    0.9.33 adapted from SnarkManager
    • Constructor Detail

      • UIMessages

        public UIMessages​(int maxSize)
        Parameters:
        maxSize -
    • Method Detail

      • addMessage

        public int addMessage​(String message)
        Will remove an old message if over the max size. Use if it does not include a link. Escapes '<' and '>' before queueing
        Returns:
        the message id
      • addMessageNoEscape

        public int addMessageNoEscape​(String message)
        Use if it includes a link. Does not escape '<' and '>' before queueing
        Returns:
        the message id
      • getLastMessageID

        public int getLastMessageID()
        The ID of the last message added, or -1 if never.
      • getMessages

        public List<UIMessages.Message> getMessages()
        Newest last, or empty list. Provide id of last one back to clearThrough().
        Returns:
        a copy
      • getMessageStrings

        public List<String> getMessageStrings()
        Newest last, or empty list.
        Returns:
        a copy
        Since:
        0.9.46
      • clear

        public void clear()
        clear all
      • clearThrough

        public void clearThrough​(int id)
        clear all up to and including this id
      • isEmpty

        public boolean isEmpty()
        Since:
        0.9.46