Class PrivacyList

java.lang.Object
org.jivesoftware.openfire.privacy.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:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor added for Externalizable.
    PrivacyList(String username, String name, boolean isDefault, org.dom4j.Element listElement)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.dom4j.Element
    Returns an Element with the privacy list XML representation.
    boolean
    equals(Object object)
     
    Set<org.xmpp.packet.JID>
    Returns all JIDs that are on the blocklist (as defined in XEP-0191).
    int
    Returns the approximate size of the Object in bytes.
    Returns the 'raw' items on the privacy list.
    Returns the name that uniquely identifies this list among the users lists.
    org.xmpp.packet.JID
    Returns the JID of the user that owns this privacy list.
    int
     
    boolean
    Returns true if this privacy list is the default list to apply for the user.
    void
     
    void
    setDefaultList(boolean isDefault)
    Sets if this privacy list is the default list to apply for the user.
    boolean
    shouldBlockPacket(org.xmpp.packet.Packet packet)
    Returns true if the specified packet must be blocked based on this privacy list rules.
    void
    updateList(org.dom4j.Element listElement)
    Sets the new list items based on the specified Element.
    void
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 Details

    • 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
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException