Class PrivacyList

  • All Implemented Interfaces:
    Externalizable, Serializable, Cacheable

    public class PrivacyList
    extends Object
    implements Cacheable, Externalizable
    A privacy list contains a set of rules that define if communication with the list owner is allowed or denied. Users may have zero, one or more privacy lists. When a list is the default list then that list is going to be used by default for all user sessions or analyze, when user is offline, if communication may proceed (e.g. define if a message should be stored offline). A user may configure is he wants to have a default list or not. When no default list is defined then communication will not be blocked. However, users may define an active list for a particular session. Active lists override default list (if there is one) and will be used only for the duration of the session.
    Author:
    Gaston Dombiak
    See Also:
    Serialized Form
    • Constructor Detail

      • PrivacyList

        public PrivacyList()
        Constructor added for Externalizable. Do not use this constructor.
      • PrivacyList

        public PrivacyList​(String username,
                           String name,
                           boolean isDefault,
                           org.dom4j.Element listElement)
    • Method Detail

      • getUserJID

        public org.xmpp.packet.JID getUserJID()
        Returns the JID of the user that owns this privacy list.
        Returns:
        the JID of the user that owns this privacy list.
      • getName

        public String getName()
        Returns the name that uniquely identifies this list among the users lists.
        Returns:
        the name that uniquely identifies this list among the users lists.
      • isDefault

        public boolean isDefault()
        Returns true if this privacy list is the default list to apply for the user. Default privacy lists can be overridden per session by setting an active privacy list.
        Returns:
        true if this privacy list is the default list to apply for the user.
      • setDefaultList

        public void setDefaultList​(boolean isDefault)
        Sets if this privacy list is the default list to apply for the user. Default privacy lists can be overridden per session by setting an active privacy list.
        Parameters:
        isDefault - true if this privacy list is the default list to apply for the user.
      • shouldBlockPacket

        public boolean shouldBlockPacket​(org.xmpp.packet.Packet packet)
        Returns true if the specified packet must be blocked based on this privacy list rules. Rules are going to be analyzed based on their order (in ascending order). When a rule is matched then communication will be blocked or allowed based on that rule. No more further analysis is going to be made.
        Parameters:
        packet - the packet to analyze if it must be blocked.
        Returns:
        true if the specified packet must be blocked based on this privacy list rules.
      • getBlockedJIDs

        public Set<org.xmpp.packet.JID> getBlockedJIDs()
        Returns all JIDs that are on the blocklist (as defined in XEP-0191).
        Returns:
        a collection of JIDs (possibly empty, never null)
      • getItems

        public List<PrivacyItem> getItems()
        Returns the 'raw' items on the privacy list.
        Returns:
        privacy list items.
      • asElement

        public org.dom4j.Element asElement()
        Returns an Element with the privacy list XML representation.
        Returns:
        an Element with the privacy list XML representation.
      • updateList

        public void updateList​(org.dom4j.Element listElement)
        Sets the new list items based on the specified Element. The Element must contain a list of item elements.
        Parameters:
        listElement - the element containing a list of items.
      • getCachedSize

        public int getCachedSize()
                          throws CannotCalculateSizeException
        Description copied from interface: Cacheable
        Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

        Specified by:
        getCachedSize in interface Cacheable
        Returns:
        the size of the Object in bytes.
        Throws:
        CannotCalculateSizeException - if the size cannot be calculated
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object