From 86a4bfa43faab494abcef144431f57d7af880ca5 Mon Sep 17 00:00:00 2001 From: Lars Noschinski Date: Thu, 6 Mar 2014 21:05:49 +0100 Subject: [PATCH] Remove deprecated constructor for FromMatchesFilter (SMACK-71) --- .../org/jivesoftware/smack/ChatManager.java | 2 +- .../smack/filter/FromMatchesFilter.java | 13 +-- .../smack/filters/FromMatchesFilterTest.java | 81 ------------------- .../filetransfer/IBBTransferNegotiator.java | 2 +- .../Socks5TransferNegotiator.java | 2 +- .../smackx/muc/MultiUserChat.java | 12 +-- .../smackx/workgroup/agent/AgentSession.java | 6 +- .../smackx/workgroup/user/Workgroup.java | 2 +- 8 files changed, 16 insertions(+), 104 deletions(-) diff --git a/core/src/main/java/org/jivesoftware/smack/ChatManager.java b/core/src/main/java/org/jivesoftware/smack/ChatManager.java index ccc489ab0..e36ddbc0e 100644 --- a/core/src/main/java/org/jivesoftware/smack/ChatManager.java +++ b/core/src/main/java/org/jivesoftware/smack/ChatManager.java @@ -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()))); } /** diff --git a/core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java b/core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java index 7d576735b..6c98ff4de 100644 --- a/core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java +++ b/core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java @@ -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; } } diff --git a/core/src/test/java/org/jivesoftware/smack/filters/FromMatchesFilterTest.java b/core/src/test/java/org/jivesoftware/smack/filters/FromMatchesFilterTest.java index e6f530391..958e79c53 100644 --- a/core/src/test/java/org/jivesoftware/smack/filters/FromMatchesFilterTest.java +++ b/core/src/test/java/org/jivesoftware/smack/filters/FromMatchesFilterTest.java @@ -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() { diff --git a/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java b/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java index 53796209d..018b68727 100644 --- a/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java +++ b/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java @@ -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() { diff --git a/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java b/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java index 8d6aec0e9..5569acd68 100644 --- a/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java +++ b/extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java @@ -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 diff --git a/extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 5ca3a21de..cd20514d0 100644 --- a/extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -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(); diff --git a/legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index 952097fd1..13c41c3f7 100644 --- a/legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -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); diff --git a/legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java b/legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java index 225848f4f..5a74c264a 100644 --- a/legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java +++ b/legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java @@ -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));