public class Privacy extends IQ
PrivacyListManager
and PrivacyProvider
to allow and block
communications from other users. It contains the appropriate structure to suit
user-defined privacy lists. Different configured Privacy packages are used in the
server and manager communication in order to:
PrivacyItem
IQ.IQChildElementXmlStringBuilder, IQ.Type
Modifier and Type | Field and Description |
---|---|
static String |
ELEMENT |
static String |
NAMESPACE |
IQ_ELEMENT, QUERY_ELEMENT
DEFAULT_LANGUAGE, ITEM, language, TEXT
Constructor and Description |
---|
Privacy() |
Modifier and Type | Method and Description |
---|---|
boolean |
changeDefaultList(String newDefault)
Sets a given privacy list as the new user default list.
|
void |
deleteList(String listName)
Remove the list.
|
void |
deletePrivacyList(String listName)
Deletes an existing privacy list.
|
String |
getActiveName()
Returns the name associated with the active list set for the session.
|
List<PrivacyItem> |
getActivePrivacyList()
Returns the active privacy list or null if none was found.
|
String |
getDefaultName()
Returns the name of the default list that applies to the user as a whole.
|
List<PrivacyItem> |
getDefaultPrivacyList()
Returns the default privacy list or null if none was found.
|
protected IQ.IQChildElementXmlStringBuilder |
getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf)
This method must be overwritten by IQ subclasses to create their child content.
|
PrivacyItem |
getItem(String listName,
int order)
Returns the privacy item in the specified order.
|
Map<String,List<PrivacyItem>> |
getItemLists()
Returns the collection of privacy list that the user holds.
|
List<PrivacyItem> |
getPrivacyList(String listName)
Returns a specific privacy list.
|
Set<String> |
getPrivacyListNames()
Returns all the list names the user has defined to group restrictions.
|
boolean |
isDeclineActiveList()
Returns whether the receiver allows or declines the use of an active list.
|
boolean |
isDeclineDefaultList()
Returns whether the receiver allows or declines the use of a default list.
|
void |
setActiveName(String activeName)
Sets the name associated with the active list set for the session.
|
List<PrivacyItem> |
setActivePrivacyList()
Set the active list based on the default list.
|
void |
setDeclineActiveList(boolean declineActiveList)
Sets whether the receiver allows or declines the use of an active list.
|
void |
setDeclineDefaultList(boolean declineDefaultList)
Sets whether the receiver allows or declines the use of a default list.
|
void |
setDefaultName(String defaultName)
Sets the name of the default list that applies to the user as a whole.
|
List<PrivacyItem> |
setPrivacyList(String listName,
List<PrivacyItem> listItem)
Set or update a privacy list with privacy items.
|
createErrorResponse, createErrorResponse, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementXML, getChildElementXML, getType, initializeAsResultFor, initialzeAsResultFor, isRequestIQ, setType, toString, toXML
addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensions, getFrom, getLanguage, getPacketID, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, removeExtension, setError, setError, setFrom, setFrom, setLanguage, setPacketID, setStanzaId, setStanzaId, setTo, setTo
public static final String ELEMENT
public static final String NAMESPACE
public Privacy()
public List<PrivacyItem> setPrivacyList(String listName, List<PrivacyItem> listItem)
listName
- the name of the new privacy list.listItem
- the PrivacyItem
that rules the list.public List<PrivacyItem> setActivePrivacyList()
public void deletePrivacyList(String listName)
listName
- the name of the list being deleted.public List<PrivacyItem> getActivePrivacyList()
PrivacyItem
or null if none was found.public List<PrivacyItem> getDefaultPrivacyList()
PrivacyItem
or null if none was found.public List<PrivacyItem> getPrivacyList(String listName)
listName
- the name of the list to get.PrivacyItem
public PrivacyItem getItem(String listName, int order)
listName
- the name of the privacy list.order
- the order of the element.PrivacyItem
public boolean changeDefaultList(String newDefault)
newDefault
- the new default privacy list.public void deleteList(String listName)
listName
- name of the list to remove.public String getActiveName()
public void setActiveName(String activeName)
activeName
- is the name of the active list.public String getDefaultName()
public void setDefaultName(String defaultName)
defaultName
- is the name of the default list.public Map<String,List<PrivacyItem>> getItemLists()
public boolean isDeclineActiveList()
public void setDeclineActiveList(boolean declineActiveList)
declineActiveList
- indicates if the receiver declines the use of an active list.public boolean isDeclineDefaultList()
public void setDeclineDefaultList(boolean declineDefaultList)
declineDefaultList
- indicates if the receiver declines the use of a default list.public Set<String> getPrivacyListNames()
protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf)
IQ
IQ.IQChildElementXmlStringBuilder
after eventual existing ExtensionElement
s have been added.
For example to create an IQ with a extra attribute and an additional child element
<iq to='foo@example.org' id='123'>
<bar xmlns='example:bar' extraAttribute='blaz'>
<extraElement>elementText</extraElement>
</bar>
</iq>
the body of the getIQChildElementBuilder
looks like
// The builder 'xml' will already have the child element and the 'xmlns' attribute added
// So the current builder state is "<bar xmlns='example:bar'"
xml.attribute("extraAttribute", "blaz");
xml.rightAngleBracket();
xml.element("extraElement", "elementText");
// Do not close the 'bar' attribute by calling xml.closeElement('bar')
If your IQ only contains attributes and no child elements, i.e. it can be represented as empty element, then you
can mark it as such.
xml.attribute("myAttribute", "myAttributeValue"); xml.setEmptyElement();If your IQ does not contain any attributes or child elements (besides
ExtensionElement
s), consider sub-classing
SimpleIQ
instead.getIQChildElementBuilder
in class IQ
buf
- a pre-created builder which already has the child element and the 'xmlns' attribute set.