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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PrivacyList()
Constructor added for Externalizable.PrivacyList(String username, String name, boolean isDefault, org.dom4j.Element listElement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.dom4j.Element
asElement()
Returns an Element with the privacy list XML representation.boolean
equals(Object object)
Set<org.xmpp.packet.JID>
getBlockedJIDs()
Returns all JIDs that are on the blocklist (as defined in XEP-0191).int
getCachedSize()
Returns the approximate size of the Object in bytes.List<PrivacyItem>
getItems()
Returns the 'raw' items on the privacy list.String
getName()
Returns the name that uniquely identifies this list among the users lists.org.xmpp.packet.JID
getUserJID()
Returns the JID of the user that owns this privacy list.int
hashCode()
boolean
isDefault()
Returns true if this privacy list is the default list to apply for the user.void
readExternal(ObjectInput in)
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
writeExternal(ObjectOutput out)
-
-
-
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 interfaceCacheable
- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException
- if the size cannot be calculated
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
-