1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 08:12:05 +01:00

Add IQ.isRequestIQ()

and check IQ argument in IQReplyFilter.
This commit is contained in:
Florian Schmaus 2015-01-21 14:06:27 +01:00
parent 2f739662e5
commit dc6af6dd99
2 changed files with 19 additions and 0 deletions

View file

@ -81,6 +81,9 @@ public class IQReplyFilter implements PacketFilter {
* @param iqPacket An IQ request. Filter for replies to this packet. * @param iqPacket An IQ request. Filter for replies to this packet.
*/ */
public IQReplyFilter(IQ iqPacket, XMPPConnection conn) { public IQReplyFilter(IQ iqPacket, XMPPConnection conn) {
if (!iqPacket.isRequestIQ()) {
throw new IllegalArgumentException("IQ must be a request IQ, i.e. of type 'get' or 'set'.");
}
if (iqPacket.getTo() != null) { if (iqPacket.getTo() != null) {
to = iqPacket.getTo().toLowerCase(Locale.US); to = iqPacket.getTo().toLowerCase(Locale.US);
} else { } else {

View file

@ -90,6 +90,22 @@ public abstract class IQ extends Packet {
this.type = type; this.type = type;
} }
/**
* Return true if this IQ is a request IQ, i.e. an IQ of type {@link Type#get} or {@link Type#set}.
*
* @return true if IQ type is 'get' or 'set', false otherwise.
* @since 4.1
*/
public boolean isRequestIQ() {
switch (type) {
case get:
case set:
return true;
default:
return false;
}
}
public final String getChildElementName() { public final String getChildElementName() {
return childElementName; return childElementName;
} }