mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 04:57:58 +01:00
Add IQ.isRequestIQ()
and check IQ argument in IQReplyFilter.
This commit is contained in:
parent
2f739662e5
commit
dc6af6dd99
2 changed files with 19 additions and 0 deletions
|
@ -81,6 +81,9 @@ public class IQReplyFilter implements PacketFilter {
|
|||
* @param iqPacket An IQ request. Filter for replies to this packet.
|
||||
*/
|
||||
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) {
|
||||
to = iqPacket.getTo().toLowerCase(Locale.US);
|
||||
} else {
|
||||
|
|
|
@ -90,6 +90,22 @@ public abstract class IQ extends Packet {
|
|||
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() {
|
||||
return childElementName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue