1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 02:58:00 +01:00

Type enum is now public.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6026 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-11-09 23:19:54 +00:00 committed by gato
parent 0e0f1701a4
commit 97824ebc1c

View file

@ -1,15 +1,15 @@
package org.jivesoftware.smack.packet; package org.jivesoftware.smack.packet;
/** /**
* A privacy item acts a rule that when matched defines if a packet should be blocked or not. * A privacy item acts a rule that when matched defines if a packet should be blocked or not.
* *
* Privacy Items can handle different kind of blocking communications based on JID, group, * Privacy Items can handle different kind of blocking communications based on JID, group,
* subscription type or globally by:<ul> * subscription type or globally by:<ul>
* <li>Allowing or blocking messages. * <li>Allowing or blocking messages.
* <li>Allowing or blocking inbound presence notifications. * <li>Allowing or blocking inbound presence notifications.
* <li>Allowing or blocking outbound presence notifications. * <li>Allowing or blocking outbound presence notifications.
* <li>Allowing or blocking IQ stanzas. * <li>Allowing or blocking IQ stanzas.
* <li>Allowing or blocking all communications. * <li>Allowing or blocking all communications.
* </ul> * </ul>
* @author Francisco Vives * @author Francisco Vives
*/ */
@ -18,12 +18,12 @@ public class PrivacyItem {
private boolean allow; private boolean allow;
/** order is a non-negative integer that is unique among all items in the list. */ /** order is a non-negative integer that is unique among all items in the list. */
private int order; private int order;
/** rule hold the kind of communication ([jid|group|subscription]) it will allow or block and /** rule hold the kind of communication ([jid|group|subscription]) it will allow or block and
* identifier to apply the action. * identifier to apply the action.
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". */ * "from", or "none". */
private PrivacyRule rule; private PrivacyRule rule;
@ -47,19 +47,19 @@ public class PrivacyItem {
this.setOrder(order); this.setOrder(order);
} }
/** /**
* Returns the action associated with the item, it MUST be filled and will allow or deny * Returns the action associated with the item, it MUST be filled and will allow or deny
* the communication. * the communication.
* *
* @return the allow communication status. * @return the allow communication status.
*/ */
public boolean isAllow() { public boolean isAllow() {
return allow; return allow;
} }
/** /**
* Sets the action associated with the item, it can allow or deny the communication. * Sets the action associated with the item, it can allow or deny the communication.
* *
* @param allow indicates if the receiver allow or deny the communication. * @param allow indicates if the receiver allow or deny the communication.
*/ */
private void setAllow(boolean allow) { private void setAllow(boolean allow) {
@ -67,9 +67,9 @@ public class PrivacyItem {
} }
/** /**
* Returns whether the receiver allow or deny incoming IQ stanzas or not. * Returns whether the receiver allow or deny incoming IQ stanzas or not.
* *
* @return the iq filtering status. * @return the iq filtering status.
*/ */
public boolean isFilterIQ() { public boolean isFilterIQ() {
@ -77,9 +77,9 @@ public class PrivacyItem {
} }
/** /**
* Sets whether the receiver allows or denies incoming IQ stanzas or not. * Sets whether the receiver allows or denies incoming IQ stanzas or not.
* *
* @param filterIQ indicates if the receiver allows or denies incoming IQ stanzas. * @param filterIQ indicates if the receiver allows or denies incoming IQ stanzas.
*/ */
public void setFilterIQ(boolean filterIQ) { public void setFilterIQ(boolean filterIQ) {
@ -87,9 +87,9 @@ public class PrivacyItem {
} }
/** /**
* Returns whether the receiver allows or denies incoming messages or not. * Returns whether the receiver allows or denies incoming messages or not.
* *
* @return the message filtering status. * @return the message filtering status.
*/ */
public boolean isFilterMessage() { public boolean isFilterMessage() {
@ -97,9 +97,9 @@ public class PrivacyItem {
} }
/** /**
* Sets wheather the receiver allows or denies incoming messages or not. * Sets wheather the receiver allows or denies incoming messages or not.
* *
* @param filterMessage indicates if the receiver allows or denies incoming messages or not. * @param filterMessage indicates if the receiver allows or denies incoming messages or not.
*/ */
public void setFilterMessage(boolean filterMessage) { public void setFilterMessage(boolean filterMessage) {
@ -107,9 +107,9 @@ public class PrivacyItem {
} }
/** /**
* Returns whether the receiver allows or denies incoming presence or not. * Returns whether the receiver allows or denies incoming presence or not.
* *
* @return the iq filtering incoming presence status. * @return the iq filtering incoming presence status.
*/ */
public boolean isFilterPresence_in() { public boolean isFilterPresence_in() {
@ -117,9 +117,9 @@ public class PrivacyItem {
} }
/** /**
* Sets whether the receiver allows or denies incoming presence or not. * Sets whether the receiver allows or denies incoming presence or not.
* *
* @param filterPresence_in indicates if the receiver allows or denies filtering incoming presence. * @param filterPresence_in indicates if the receiver allows or denies filtering incoming presence.
*/ */
public void setFilterPresence_in(boolean filterPresence_in) { public void setFilterPresence_in(boolean filterPresence_in) {
@ -127,9 +127,9 @@ public class PrivacyItem {
} }
/** /**
* Returns whether the receiver allows or denies incoming presence or not. * Returns whether the receiver allows or denies incoming presence or not.
* *
* @return the iq filtering incoming presence status. * @return the iq filtering incoming presence status.
*/ */
public boolean isFilterPresence_out() { public boolean isFilterPresence_out() {
@ -137,9 +137,9 @@ public class PrivacyItem {
} }
/** /**
* Sets whether the receiver allows or denies outgoing presence or not. * Sets whether the receiver allows or denies outgoing presence or not.
* *
* @param filterPresence_out indicates if the receiver allows or denies filtering outgoing presence * @param filterPresence_out indicates if the receiver allows or denies filtering outgoing presence
*/ */
public void setFilterPresence_out(boolean filterPresence_out) { public void setFilterPresence_out(boolean filterPresence_out) {
@ -147,13 +147,13 @@ public class PrivacyItem {
} }
/** /**
* Returns the order where the receiver is processed. List items are processed in * Returns the order where the receiver is processed. List items are processed in
* ascending order. * ascending order.
* *
* The order MUST be filled and its value MUST be a non-negative integer * The order MUST be filled and its value MUST be a non-negative integer
* that is unique among all items in the list. * that is unique among all items in the list.
* *
* @return the order number. * @return the order number.
*/ */
public int getOrder() { public int getOrder() {
@ -161,27 +161,27 @@ public class PrivacyItem {
} }
/** /**
* Sets the order where the receiver is processed. * Sets the order where the receiver is processed.
* *
* The order MUST be filled and its value MUST be a non-negative integer * The order MUST be filled and its value MUST be a non-negative integer
* that is unique among all items in the list. * that is unique among all items in the list.
* *
* @param order indicates the order in the list. * @param order indicates the order in the list.
*/ */
private void setOrder(int order) { private void setOrder(int order) {
this.order = order; this.order = order;
} }
/** /**
* Sets the element identifier to apply the action. * Sets the element identifier to apply the action.
* *
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". * "from", or "none".
* *
* @param value is the identifier to apply the action. * @param value is the identifier to apply the action.
*/ */
public void setValue(String value) { public void setValue(String value) {
@ -189,11 +189,11 @@ public class PrivacyItem {
this.getRule().setValue(value); this.getRule().setValue(value);
} }
} }
/** /**
* Returns the type hold the kind of communication it will allow or block. * Returns the type hold the kind of communication it will allow or block.
* It MUST be filled with one of these values: jid, group or subscription. * It MUST be filled with one of these values: jid, group or subscription.
* *
* @return the type of communication it represent. * @return the type of communication it represent.
*/ */
public Type getType() { public Type getType() {
@ -203,16 +203,16 @@ public class PrivacyItem {
return this.getRule().getType(); return this.getRule().getType();
} }
} }
/** /**
* Returns the element identifier to apply the action. * Returns the element identifier to apply the action.
* *
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". * "from", or "none".
* *
* @return the identifier to apply the action. * @return the identifier to apply the action.
*/ */
public String getValue() { public String getValue() {
@ -224,12 +224,12 @@ public class PrivacyItem {
} }
/** /**
* Returns whether the receiver allows or denies every kind of communication. * Returns whether the receiver allows or denies every kind of communication.
* *
* When filterIQ, filterMessage, filterPresence_in and filterPresence_out are not set * When filterIQ, filterMessage, filterPresence_in and filterPresence_out are not set
* the receiver will block all communications. * the receiver will block all communications.
* *
* @return the all communications status. * @return the all communications status.
*/ */
public boolean isFilterEverything() { public boolean isFilterEverything() {
@ -245,9 +245,9 @@ public class PrivacyItem {
private void setRule(PrivacyRule rule) { private void setRule(PrivacyRule rule) {
this.rule = rule; this.rule = rule;
} }
/** /**
* Answer an xml representation of the receiver according to the RFC 3921. * Answer an xml representation of the receiver according to the RFC 3921.
* *
* @return the text xml representation. * @return the text xml representation.
*/ */
public String toXML() { public String toXML() {
@ -285,11 +285,11 @@ public class PrivacyItem {
} }
return buf.toString(); return buf.toString();
} }
/** /**
* Privacy Rule represents the kind of action to apply. * Privacy Rule represents the kind of action to apply.
* It holds the kind of communication ([jid|group|subscription]) it will allow or block and * It holds the kind of communication ([jid|group|subscription]) it will allow or block and
* identifier to apply the action. * identifier to apply the action.
*/ */
@ -299,18 +299,18 @@ public class PrivacyItem {
* Available values are: [jid|group|subscription] * Available values are: [jid|group|subscription]
*/ */
private Type type; private Type type;
/** /**
* The value hold the element identifier to apply the action. * The value hold the element identifier to apply the action.
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". * "from", or "none".
*/ */
private String value; private String value;
/** /**
* If the type is "subscription", then the 'value' attribute MUST be one of "both", * If the type is "subscription", then the 'value' attribute MUST be one of "both",
* "to", "from", or "none" * "to", "from", or "none"
*/ */
public static final String SUBSCRIPTION_BOTH = "both"; public static final String SUBSCRIPTION_BOTH = "both";
@ -329,50 +329,50 @@ public class PrivacyItem {
rule.setType(Type.valueOf(value.toLowerCase())); rule.setType(Type.valueOf(value.toLowerCase()));
return rule; return rule;
} }
/** /**
* Returns the type hold the kind of communication it will allow or block. * Returns the type hold the kind of communication it will allow or block.
* It MUST be filled with one of these values: jid, group or subscription. * It MUST be filled with one of these values: jid, group or subscription.
* *
* @return the type of communication it represent. * @return the type of communication it represent.
*/ */
public Type getType() { public Type getType() {
return type; return type;
} }
/** /**
* Sets the action associated with the item, it can allow or deny the communication. * Sets the action associated with the item, it can allow or deny the communication.
* *
* @param type indicates if the receiver allows or denies the communication. * @param type indicates if the receiver allows or denies the communication.
*/ */
private void setType(Type type) { private void setType(Type type) {
this.type = type; this.type = type;
} }
/** /**
* Returns the element identifier to apply the action. * Returns the element identifier to apply the action.
* *
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". * "from", or "none".
* *
* @return the identifier to apply the action. * @return the identifier to apply the action.
*/ */
public String getValue() { public String getValue() {
return value; return value;
} }
/** /**
* Sets the element identifier to apply the action. * Sets the element identifier to apply the action.
* *
* If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID. * If the type is "jid", then the 'value' attribute MUST contain a valid Jabber ID.
* If the type is "group", then the 'value' attribute SHOULD contain the name of a group * If the type is "group", then the 'value' attribute SHOULD contain the name of a group
* in the user's roster. * in the user's roster.
* If the type is "subscription", then the 'value' attribute MUST be one of "both", "to", * If the type is "subscription", then the 'value' attribute MUST be one of "both", "to",
* "from", or "none". * "from", or "none".
* *
* @param value is the identifier to apply the action. * @param value is the identifier to apply the action.
*/ */
protected void setValue(String value) { protected void setValue(String value) {
@ -382,12 +382,12 @@ public class PrivacyItem {
this.value = value; this.value = value;
} }
} }
/** /**
* Sets the element identifier to apply the action. * Sets the element identifier to apply the action.
* *
* The 'value' attribute MUST be one of "both", "to", "from", or "none". * The 'value' attribute MUST be one of "both", "to", "from", or "none".
* *
* @param value is the identifier to apply the action. * @param value is the identifier to apply the action.
*/ */
private void setSuscriptionValue(String value) { private void setSuscriptionValue(String value) {
@ -403,7 +403,7 @@ public class PrivacyItem {
} }
else if (SUBSCRIPTION_FROM.equalsIgnoreCase(value)) { else if (SUBSCRIPTION_FROM.equalsIgnoreCase(value)) {
setValue = SUBSCRIPTION_FROM; setValue = SUBSCRIPTION_FROM;
} }
else if (SUBSCRIPTION_NONE.equalsIgnoreCase(value)) { else if (SUBSCRIPTION_NONE.equalsIgnoreCase(value)) {
setValue = SUBSCRIPTION_NONE; setValue = SUBSCRIPTION_NONE;
} }
@ -413,21 +413,21 @@ public class PrivacyItem {
} }
this.value = setValue; this.value = setValue;
} }
/** /**
* Returns if the receiver represents a subscription rule. * Returns if the receiver represents a subscription rule.
* *
* @return if the receiver represents a subscription rule. * @return if the receiver represents a subscription rule.
*/ */
public boolean isSuscription () { public boolean isSuscription () {
return this.getType() == Type.subscription; return this.getType() == Type.subscription;
} }
} }
/** /**
* Type defines if the rule is based on JIDs, roster groups or presence subscription types. * Type defines if the rule is based on JIDs, roster groups or presence subscription types.
*/ */
protected static enum Type { public static enum Type {
/** /**
* JID being analyzed should belong to a roster group of the list's owner. * JID being analyzed should belong to a roster group of the list's owner.
*/ */