mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 04:57:58 +01:00
Remove deprecated constructor for FromMatchesFilter (SMACK-71)
This commit is contained in:
parent
62de78ef7c
commit
86a4bfa43f
8 changed files with 16 additions and 104 deletions
|
@ -313,7 +313,7 @@ public class ChatManager {
|
|||
|
||||
PacketCollector createPacketCollector(Chat chat) {
|
||||
return connection.createPacketCollector(new AndFilter(new ThreadFilter(chat.getThreadID()),
|
||||
new FromMatchesFilter(chat.getParticipant())));
|
||||
FromMatchesFilter.create(chat.getParticipant())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
* Copyright 2003-2014 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,14 +36,6 @@ public class FromMatchesFilter implements PacketFilter {
|
|||
*/
|
||||
private boolean matchBareJID = false;
|
||||
|
||||
/**
|
||||
* @see FromMatchesFilter#create(String)
|
||||
*/
|
||||
@Deprecated
|
||||
public FromMatchesFilter(String address) {
|
||||
this(address, "".equals(StringUtils.parseResource(address)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a filter matching on the "from" field. The from address must be the same as the
|
||||
* filter address. The second parameter specifies whether the full or the bare addresses are
|
||||
|
@ -106,6 +98,7 @@ public class FromMatchesFilter implements PacketFilter {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
return "FromMatchesFilter: " + address;
|
||||
String matchMode = matchBareJID ? "bare" : "full";
|
||||
return "FromMatchesFilter (" +matchMode + "): " + address;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,87 +40,6 @@ public class FromMatchesFilterTest {
|
|||
private static final String SERVICE_JID1 = "muc.myserver.com";
|
||||
private static final String SERVICE_JID2 = "pubsub.myserver.com";
|
||||
|
||||
@Test
|
||||
public void oldCompareMatchingFullJid()
|
||||
{
|
||||
FromMatchesFilter filter = new FromMatchesFilter(FULL_JID1_R1);
|
||||
Packet packet = new Packet() {
|
||||
@Override
|
||||
public String toXML() { return null; }
|
||||
};
|
||||
|
||||
packet.setFrom(FULL_JID1_R1);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID1);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID1_R2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID3);
|
||||
assertFalse(filter.accept(packet));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oldCompareMatchingBaseJid()
|
||||
{
|
||||
FromMatchesFilter filter = new FromMatchesFilter(BASE_JID1);
|
||||
Packet packet = new Packet() {
|
||||
@Override
|
||||
public String toXML() { return null; }
|
||||
};
|
||||
|
||||
packet.setFrom(BASE_JID1);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID1_R1);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID1_R2);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID3);
|
||||
assertFalse(filter.accept(packet));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oldCompareMatchingServiceJid()
|
||||
{
|
||||
FromMatchesFilter filter = new FromMatchesFilter(SERVICE_JID1);
|
||||
Packet packet = new Packet() {
|
||||
@Override
|
||||
public String toXML() { return null; }
|
||||
};
|
||||
|
||||
packet.setFrom(SERVICE_JID1);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet.setFrom(SERVICE_JID2);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID1);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(FULL_JID1_R1);
|
||||
assertFalse(filter.accept(packet));
|
||||
|
||||
packet.setFrom(BASE_JID3);
|
||||
assertFalse(filter.accept(packet));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoCompareMatchingFullJid()
|
||||
{
|
||||
|
|
|
@ -86,7 +86,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
*/
|
||||
this.manager.ignoreBytestreamRequestOnce(streamID);
|
||||
|
||||
return new AndFilter(new FromMatchesFilter(from), new IBBOpenSidFilter(streamID));
|
||||
return new AndFilter(FromMatchesFilter.create(from), new IBBOpenSidFilter(streamID));
|
||||
}
|
||||
|
||||
public String[] getNamespaces() {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
*/
|
||||
this.manager.ignoreBytestreamRequestOnce(streamID);
|
||||
|
||||
return new AndFilter(new FromMatchesFilter(from), new BytestreamSIDFilter(streamID));
|
||||
return new AndFilter(FromMatchesFilter.create(from), new BytestreamSIDFilter(streamID));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -348,7 +348,7 @@ public class MultiUserChat {
|
|||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room + "/" + nickname),
|
||||
FromMatchesFilter.createFull(room + "/" + nickname),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
PacketCollector response = connection.createPacketCollector(responseFilter);
|
||||
// Send create & join packet.
|
||||
|
@ -477,7 +477,7 @@ public class MultiUserChat {
|
|||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room + "/" + nickname),
|
||||
FromMatchesFilter.createFull(room + "/" + nickname),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
PacketCollector response = null;
|
||||
|
||||
|
@ -918,7 +918,7 @@ public class MultiUserChat {
|
|||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room + "/" + nickname),
|
||||
FromMatchesFilter.createFull(room + "/" + nickname),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
PacketCollector response = connection.createPacketCollector(responseFilter);
|
||||
// Send join packet.
|
||||
|
@ -1698,7 +1698,7 @@ public class MultiUserChat {
|
|||
// Wait for an error or confirmation message back from the server.
|
||||
PacketFilter responseFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room),
|
||||
FromMatchesFilter.create(room),
|
||||
new PacketTypeFilter(Message.class));
|
||||
responseFilter = new AndFilter(responseFilter, new PacketFilter() {
|
||||
public boolean accept(Packet packet) {
|
||||
|
@ -1860,7 +1860,7 @@ public class MultiUserChat {
|
|||
// Create filters
|
||||
messageFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room),
|
||||
FromMatchesFilter.create(room),
|
||||
new MessageTypeFilter(Message.Type.groupchat));
|
||||
messageFilter = new AndFilter(messageFilter, new PacketFilter() {
|
||||
public boolean accept(Packet packet) {
|
||||
|
@ -1869,7 +1869,7 @@ public class MultiUserChat {
|
|||
}
|
||||
});
|
||||
presenceFilter =
|
||||
new AndFilter(new FromMatchesFilter(room), new PacketTypeFilter(Presence.class));
|
||||
new AndFilter(FromMatchesFilter.create(room), new PacketTypeFilter(Presence.class));
|
||||
|
||||
// Create a collector for incoming messages.
|
||||
messageCollector = new ConnectionDetachedPacketCollector();
|
||||
|
|
|
@ -262,7 +262,7 @@ public class AgentSession {
|
|||
presence.addExtension(new DefaultPacketExtension(AgentStatus.ELEMENT_NAME,
|
||||
AgentStatus.NAMESPACE));
|
||||
|
||||
PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), new FromMatchesFilter(workgroupJID)));
|
||||
PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)));
|
||||
|
||||
connection.sendPacket(presence);
|
||||
|
||||
|
@ -359,7 +359,7 @@ public class AgentSession {
|
|||
presence.addExtension(agentStatus);
|
||||
presence.addExtension(new MetaData(this.metaData));
|
||||
|
||||
PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), new FromMatchesFilter(workgroupJID)));
|
||||
PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)));
|
||||
|
||||
this.connection.sendPacket(presence);
|
||||
|
||||
|
@ -402,7 +402,7 @@ public class AgentSession {
|
|||
presence.addExtension(new MetaData(this.metaData));
|
||||
|
||||
PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class),
|
||||
new FromMatchesFilter(workgroupJID)));
|
||||
FromMatchesFilter.create(workgroupJID)));
|
||||
|
||||
this.connection.sendPacket(presence);
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class Workgroup {
|
|||
Presence directedPresence = new Presence(Presence.Type.available);
|
||||
directedPresence.setTo(workgroupJID);
|
||||
PacketFilter typeFilter = new PacketTypeFilter(Presence.class);
|
||||
PacketFilter fromFilter = new FromMatchesFilter(workgroupJID);
|
||||
PacketFilter fromFilter = FromMatchesFilter.create(workgroupJID);
|
||||
PacketCollector collector = connection.createPacketCollector(new AndFilter(fromFilter,
|
||||
typeFilter));
|
||||
|
||||
|
|
Loading…
Reference in a new issue