From 9b5dafe54157d7b70fdeb5e31459f0e0a7967fbc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 6 Apr 2018 10:21:46 +0200 Subject: [PATCH] Enable LeftCurly checkstyle check --- config/checkstyle.xml | 1 + .../smack/provider/ProviderManager.java | 6 +- .../proxy/HTTPProxySocketConnection.java | 42 ++-- .../smack/proxy/ProxyException.java | 6 +- .../jivesoftware/smack/proxy/ProxyInfo.java | 33 +-- .../proxy/Socks4ProxySocketConnection.java | 42 ++-- .../proxy/Socks5ProxySocketConnection.java | 57 ++---- .../smack/StanzaCollectorTest.java | 107 ++++------ .../smack/filter/FromMatchesFilterTest.java | 27 +-- .../smackx/debugger/EnhancedDebugger.java | 3 +- .../address/MultipleRecipientManager.java | 9 +- .../smackx/bookmarks/BookmarkManager.java | 6 +- .../bookmarks/BookmarkedConference.java | 3 +- .../smackx/bookmarks/Bookmarks.java | 6 +- .../smackx/commands/AdHocCommandManager.java | 9 +- .../smackx/disco/ServiceDiscoveryManager.java | 3 +- .../smackx/filetransfer/FileTransfer.java | 3 +- .../filetransfer/OutgoingFileTransfer.java | 3 +- .../Socks5TransferNegotiator.java | 3 +- .../smackx/filetransfer/StreamNegotiator.java | 3 +- .../smackx/iqprivate/PrivateDataManager.java | 6 +- .../smackx/muc/MultiUserChat.java | 3 +- .../smackx/pubsub/AccessModel.java | 4 +- .../smackx/pubsub/Affiliation.java | 6 +- .../smackx/pubsub/AffiliationsExtension.java | 15 +- .../pubsub/ChildrenAssociationPolicy.java | 3 +- .../smackx/pubsub/CollectionNode.java | 3 +- .../smackx/pubsub/ConfigurationEvent.java | 15 +- .../smackx/pubsub/ConfigureForm.java | 189 ++++++------------ .../smackx/pubsub/ConfigureNodeFields.java | 6 +- .../pubsub/EmbeddedPacketExtension.java | 3 +- .../smackx/pubsub/EventElement.java | 21 +- .../smackx/pubsub/EventElementType.java | 4 +- .../jivesoftware/smackx/pubsub/FormNode.java | 24 +-- .../smackx/pubsub/FormNodeType.java | 9 +- .../smackx/pubsub/GetItemsRequest.java | 21 +- .../org/jivesoftware/smackx/pubsub/Item.java | 27 +-- .../smackx/pubsub/ItemDeleteEvent.java | 12 +- .../smackx/pubsub/ItemPublishEvent.java | 24 +-- .../jivesoftware/smackx/pubsub/ItemReply.java | 3 +- .../smackx/pubsub/ItemsExtension.java | 54 ++--- .../jivesoftware/smackx/pubsub/LeafNode.java | 59 ++---- .../org/jivesoftware/smackx/pubsub/Node.java | 129 ++++-------- .../jivesoftware/smackx/pubsub/NodeEvent.java | 9 +- .../smackx/pubsub/NodeExtension.java | 24 +-- .../jivesoftware/smackx/pubsub/NodeType.java | 3 +- .../smackx/pubsub/OptionsExtension.java | 18 +- .../smackx/pubsub/PayloadItem.java | 24 +-- .../smackx/pubsub/PresenceState.java | 3 +- .../smackx/pubsub/PubSubElementType.java | 18 +- .../smackx/pubsub/PubSubManager.java | 39 ++-- .../smackx/pubsub/PublishItem.java | 15 +- .../smackx/pubsub/PublishModel.java | 3 +- .../smackx/pubsub/RetractItem.java | 18 +- .../smackx/pubsub/SimplePayload.java | 18 +- .../smackx/pubsub/SubscribeExtension.java | 18 +- .../smackx/pubsub/SubscribeForm.java | 75 +++---- .../smackx/pubsub/SubscribeOptionFields.java | 9 +- .../smackx/pubsub/Subscription.java | 36 ++-- .../smackx/pubsub/SubscriptionEvent.java | 15 +- .../smackx/pubsub/SubscriptionsExtension.java | 27 +-- .../smackx/pubsub/UnsubscribeExtension.java | 18 +- .../pubsub/listener/ItemDeleteListener.java | 3 +- .../pubsub/listener/ItemEventListener.java | 3 +- .../pubsub/listener/NodeConfigListener.java | 3 +- .../smackx/pubsub/packet/PubSub.java | 6 +- .../smackx/pubsub/packet/PubSubNamespace.java | 12 +- .../pubsub/provider/AffiliationsProvider.java | 6 +- .../pubsub/provider/ConfigEventProvider.java | 6 +- .../smackx/pubsub/provider/EventProvider.java | 6 +- .../pubsub/provider/FormNodeProvider.java | 6 +- .../smackx/pubsub/provider/ItemProvider.java | 15 +- .../smackx/pubsub/provider/ItemsProvider.java | 6 +- .../pubsub/provider/PubSubProvider.java | 6 +- .../pubsub/provider/RetractEventProvider.java | 6 +- .../pubsub/provider/SimpleNodeProvider.java | 6 +- .../pubsub/provider/SubscriptionProvider.java | 6 +- .../provider/SubscriptionsProvider.java | 6 +- .../smackx/pubsub/util/NodeUtils.java | 6 +- .../smackx/receipts/DeliveryReceipt.java | 24 +-- .../receipts/DeliveryReceiptRequest.java | 12 +- .../smackx/pubsub/ConfigureFormTest.java | 18 +- .../smackx/pubsub/ItemValidationTest.java | 24 +-- .../smackx/workgroup/agent/AgentSession.java | 6 +- .../smackx/workgroup/agent/Offer.java | 3 +- .../workgroup/packet/AgentStatusRequest.java | 6 +- .../packet/OfferRequestProvider.java | 3 +- .../workgroup/packet/OfferRevokeProvider.java | 3 +- .../smackx/workgroup/packet/QueueDetails.java | 6 +- .../workgroup/packet/QueueOverview.java | 3 +- .../util/ListenerEventDispatcher.java | 3 +- .../DefaultMessageEventRequestListener.java | 12 +- .../smackx/xevent/MessageEventManager.java | 3 +- 93 files changed, 549 insertions(+), 1087 deletions(-) diff --git a/config/checkstyle.xml b/config/checkstyle.xml index e2ec041ed..bf564dd63 100644 --- a/config/checkstyle.xml +++ b/config/checkstyle.xml @@ -80,6 +80,7 @@ + diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java index b8528569e..0e581bc7d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java @@ -193,8 +193,7 @@ public final class ProviderManager { */ @SuppressWarnings("unchecked") public static void addIQProvider(String elementName, String namespace, - Object provider) - { + Object provider) { validate(elementName, namespace); // First remove existing providers String key = removeIQProvider(elementName, namespace); @@ -255,8 +254,7 @@ public final class ProviderManager { */ @SuppressWarnings("unchecked") public static void addExtensionProvider(String elementName, String namespace, - Object provider) - { + Object provider) { validate(elementName, namespace); // First remove existing providers String key = removeExtensionProvider(elementName, namespace); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java index 5c222f9b2..39288f7db 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketConnection.java @@ -37,8 +37,7 @@ class HTTPProxySocketConnection implements ProxySocketConnection { private final ProxyInfo proxy; - HTTPProxySocketConnection(ProxyInfo proxy) - { + HTTPProxySocketConnection(ProxyInfo proxy) { this.proxy = proxy; } @@ -51,12 +50,10 @@ class HTTPProxySocketConnection implements ProxySocketConnection { String hostport = "CONNECT " + host + ":" + port; String proxyLine; String username = proxy.getProxyUsername(); - if (username == null) - { + if (username == null) { proxyLine = ""; } - else - { + else { String password = proxy.getProxyPassword(); proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password); } @@ -67,41 +64,33 @@ class HTTPProxySocketConnection implements ProxySocketConnection { StringBuilder got = new StringBuilder(100); int nlchars = 0; - while (true) - { + while (true) { int inByte = in.read(); - if (inByte == -1) - { + if (inByte == -1) { throw new ProxyException(ProxyInfo.ProxyType.HTTP); } char c = (char) inByte; got.append(c); - if (got.length() > 1024) - { + if (got.length() > 1024) { throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Received " + "header of >1024 characters from " + proxyhost + ", cancelling connection"); } - if ((nlchars == 0 || nlchars == 2) && c == '\r') - { + if ((nlchars == 0 || nlchars == 2) && c == '\r') { nlchars++; } - else if ((nlchars == 1 || nlchars == 3) && c == '\n') - { + else if ((nlchars == 1 || nlchars == 3) && c == '\n') { nlchars++; } - else - { + else { nlchars = 0; } - if (nlchars == 4) - { + if (nlchars == 4) { break; } } - if (nlchars != 4) - { + if (nlchars != 4) { throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Never " + "received blank line from " + proxyhost + ", cancelling connection"); @@ -112,23 +101,20 @@ class HTTPProxySocketConnection implements ProxySocketConnection { BufferedReader br = new BufferedReader(new StringReader(gotstr)); String response = br.readLine(); - if (response == null) - { + if (response == null) { throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Empty proxy " + "response from " + proxyhost + ", cancelling"); } Matcher m = RESPONSE_PATTERN.matcher(response); - if (!m.matches()) - { + if (!m.matches()) { throw new ProxyException(ProxyInfo.ProxyType.HTTP , "Unexpected " + "proxy response from " + proxyhost + ": " + response); } int code = Integer.parseInt(m.group(1)); - if (code != HttpURLConnection.HTTP_OK) - { + if (code != HttpURLConnection.HTTP_OK) { throw new ProxyException(ProxyInfo.ProxyType.HTTP); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java index 551b06876..2efa4aa26 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java @@ -29,13 +29,11 @@ public class ProxyException extends IOException { */ private static final long serialVersionUID = 1L; - public ProxyException(ProxyInfo.ProxyType type, String ex) - { + public ProxyException(ProxyInfo.ProxyType type, String ex) { super("Proxy Exception " + type.toString() + " : " + ex); } - public ProxyException(ProxyInfo.ProxyType type) - { + public ProxyException(ProxyInfo.ProxyType type) { super("Proxy Exception " + type.toString() + " : " + "Unknown Error"); } } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java index 7b312e2d3..af5855271 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java @@ -23,10 +23,8 @@ package org.jivesoftware.smack.proxy; * @author Atul Aggarwal */ -public class ProxyInfo -{ - public enum ProxyType - { +public class ProxyInfo { + public enum ProxyType { HTTP, SOCKS4, SOCKS5 @@ -40,8 +38,7 @@ public class ProxyInfo private final ProxySocketConnection proxySocketConnection; public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser, - String pPass) - { + String pPass) { this.proxyType = pType; this.proxyAddress = pHost; this.proxyPort = pPort; @@ -63,45 +60,37 @@ public class ProxyInfo } public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser, - String pPass) - { + String pPass) { return new ProxyInfo(ProxyType.HTTP, pHost, pPort, pUser, pPass); } public static ProxyInfo forSocks4Proxy(String pHost, int pPort, String pUser, - String pPass) - { + String pPass) { return new ProxyInfo(ProxyType.SOCKS4, pHost, pPort, pUser, pPass); } public static ProxyInfo forSocks5Proxy(String pHost, int pPort, String pUser, - String pPass) - { + String pPass) { return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass); } - public ProxyType getProxyType() - { + public ProxyType getProxyType() { return proxyType; } - public String getProxyAddress() - { + public String getProxyAddress() { return proxyAddress; } - public int getProxyPort() - { + public int getProxyPort() { return proxyPort; } - public String getProxyUsername() - { + public String getProxyUsername() { return proxyUsername; } - public String getProxyPassword() - { + public String getProxyPassword() { return proxyPassword; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java index a1fcd1b65..34c58376b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketConnection.java @@ -33,8 +33,7 @@ import org.jivesoftware.smack.util.StringUtils; public class Socks4ProxySocketConnection implements ProxySocketConnection { private final ProxyInfo proxy; - Socks4ProxySocketConnection(ProxyInfo proxy) - { + Socks4ProxySocketConnection(ProxyInfo proxy) { this.proxy = proxy; } @@ -47,8 +46,7 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection { int proxy_port = proxy.getProxyPort(); String user = proxy.getProxyUsername(); - try - { + try { socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout); in = socket.getInputStream(); out = socket.getOutputStream(); @@ -84,13 +82,11 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection { InetAddress inetAddress = InetAddress.getByName(proxy_host); byte[] byteAddress = inetAddress.getAddress(); - for (int i = 0; i < byteAddress.length; i++) - { + for (int i = 0; i < byteAddress.length; i++) { buf[index++] = byteAddress[i]; } - if (user != null) - { + if (user != null) { byte[] userBytes = user.getBytes(StringUtils.UTF8); System.arraycopy(userBytes, 0, buf, index, user.length()); index += user.length(); @@ -127,29 +123,23 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection { int len = 6; int s = 0; - while (s < len) - { + while (s < len) { int i = in.read(buf, s, len - s); - if (i <= 0) - { + if (i <= 0) { throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, "stream is closed"); } s += i; } - if (buf[0] != 0) - { + if (buf[0] != 0) { throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, "server returns VN " + buf[0]); } - if (buf[1] != 90) - { - try - { + if (buf[1] != 90) { + try { socket.close(); } - catch (Exception eee) - { + catch (Exception eee) { } String message = "ProxySOCKS4: server returns CD " + buf[1]; throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, message); @@ -157,18 +147,14 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection { byte[] temp = new byte[2]; in.read(temp, 0, 2); } - catch (RuntimeException e) - { + catch (RuntimeException e) { throw e; } - catch (Exception e) - { - try - { + catch (Exception e) { + try { socket.close(); } - catch (Exception eee) - { + catch (Exception eee) { } throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, e.toString()); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java index 33c887ea2..9951c13b2 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketConnection.java @@ -32,8 +32,7 @@ import org.jivesoftware.smack.util.StringUtils; public class Socks5ProxySocketConnection implements ProxySocketConnection { private final ProxyInfo proxy; - Socks5ProxySocketConnection(ProxyInfo proxy) - { + Socks5ProxySocketConnection(ProxyInfo proxy) { this.proxy = proxy; } @@ -47,8 +46,7 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { String user = proxy.getProxyUsername(); String passwd = proxy.getProxyPassword(); - try - { + try { socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout); in = socket.getInputStream(); out = socket.getOutputStream(); @@ -100,14 +98,12 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { fill(in, buf, 2); boolean check = false; - switch ((buf[1]) & 0xff) - { + switch ((buf[1]) & 0xff) { case 0: // NO AUTHENTICATION REQUIRED check = true; break; case 2: // USERNAME/PASSWORD - if (user == null || passwd == null) - { + if (user == null || passwd == null) { break; } @@ -160,22 +156,18 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { connection. */ fill(in, buf, 2); - if (buf[1] == 0) - { + if (buf[1] == 0) { check = true; } break; default: } - if (!check) - { - try - { + if (!check) { + try { socket.close(); } - catch (Exception eee) - { + catch (Exception eee) { } throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, "fail in SOCKS5 proxy"); @@ -260,21 +252,17 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { fill(in, buf, 4); - if (buf[1] != 0) - { - try - { + if (buf[1] != 0) { + try { socket.close(); } - catch (Exception eee) - { + catch (Exception eee) { } throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, "server returns " + buf[1]); } - switch (buf[3] & 0xff) - { + switch (buf[3] & 0xff) { case 1: fill(in, buf, 6); break; @@ -288,18 +276,14 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { default: } } - catch (RuntimeException e) - { + catch (RuntimeException e) { throw e; } - catch (Exception e) - { - try - { + catch (Exception e) { + try { socket.close(); } - catch (Exception eee) - { + catch (Exception eee) { } // TODO convert to IOException(e) when minimum Android API level is 9 or higher throw new IOException(e.getLocalizedMessage()); @@ -307,14 +291,11 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection { } private static void fill(InputStream in, byte[] buf, int len) - throws IOException - { + throws IOException { int s = 0; - while (s < len) - { + while (s < len) { int i = in.read(buf, s, len - s); - if (i <= 0) - { + if (i <= 0) { throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, "stream " + "is closed"); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java b/smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java index 49265ed28..40bd8f6fc 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/StanzaCollectorTest.java @@ -24,16 +24,13 @@ import org.jivesoftware.smack.packet.Stanza; import org.junit.Test; -public class StanzaCollectorTest -{ +public class StanzaCollectorTest { @Test - public void verifyRollover() throws InterruptedException - { + public void verifyRollover() throws InterruptedException { TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), 5); - for (int i = 0; i < 6; i++) - { + for (int i = 0; i < 6; i++) { Stanza testPacket = new TestPacket(i); collector.processStanza(testPacket); } @@ -46,8 +43,7 @@ public class StanzaCollectorTest assertEquals("5", collector.pollResult().getStanzaId()); assertNull(collector.pollResult()); - for (int i = 10; i < 15; i++) - { + for (int i = 10; i < 15; i++) { Stanza testPacket = new TestPacket(i); collector.processStanza(testPacket); } @@ -67,26 +63,18 @@ public class StanzaCollectorTest * catch problems. */ @Test - public void verifyThreadSafety() - { + public void verifyThreadSafety() { int insertCount = 500; final TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), insertCount); - Thread consumer1 = new Thread(new Runnable() - { + Thread consumer1 = new Thread(new Runnable() { @Override - public void run() - { - try - { - while (true) - { - try - { + public void run() { + try { + while (true) { + try { Thread.sleep(3); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { } @SuppressWarnings("unused") Stanza packet = collector.nextResultBlockForever(); @@ -100,55 +88,41 @@ public class StanzaCollectorTest }); consumer1.setName("consumer 1"); - Thread consumer2 = new Thread(new Runnable() - { + Thread consumer2 = new Thread(new Runnable() { @Override - public void run() - { + public void run() { Stanza p; - do - { - try - { + do { + try { Thread.sleep(3); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { } try { p = collector.nextResult(1); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new RuntimeException(e); } -// System.out.println(Thread.currentThread().getName() + " packet: " + p); + // System.out.println(Thread.currentThread().getName() + " packet: " + p); } while (p != null); } }); consumer2.setName("consumer 2"); - Thread consumer3 = new Thread(new Runnable() - { + Thread consumer3 = new Thread(new Runnable() { @Override - public void run() - { + public void run() { Stanza p; - do - { - try - { + do { + try { Thread.sleep(3); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { } p = collector.pollResult(); -// System.out.println(Thread.currentThread().getName() + " packet: " + p); - } - while (p != null); + // System.out.println(Thread.currentThread().getName() + " packet: " + p); + } while (p != null); } }); consumer3.setName("consumer 3"); @@ -157,54 +131,43 @@ public class StanzaCollectorTest consumer2.start(); consumer3.start(); - for (int i = 0; i < insertCount; i++) - { + for (int i = 0; i < insertCount; i++) { collector.processStanza(new TestPacket(i)); } - try - { + try { Thread.sleep(5000); consumer3.join(); consumer2.join(); consumer1.interrupt(); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { } // We cannot guarantee that this is going to pass due to the possible issue of timing between consumer 1 // and main, but the probability is extremely remote. assertNull(collector.pollResult()); } - static class OKEverything implements StanzaFilter - { + static class OKEverything implements StanzaFilter { @Override - public boolean accept(Stanza packet) - { + public boolean accept(Stanza packet) { return true; } } - static class TestStanzaCollector extends StanzaCollector - { - protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) - { + static class TestStanzaCollector extends StanzaCollector { + protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) { super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size)); } } - static class TestPacket extends Stanza - { - TestPacket(int i) - { + static class TestPacket extends Stanza { + TestPacket(int i) { setStanzaId(String.valueOf(i)); } @Override - public String toXML() - { + public String toXML() { return "" + getStanzaId() + ""; } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/filter/FromMatchesFilterTest.java b/smack-core/src/test/java/org/jivesoftware/smack/filter/FromMatchesFilterTest.java index 3be624c99..c6f7089d4 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/filter/FromMatchesFilterTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/filter/FromMatchesFilterTest.java @@ -45,8 +45,7 @@ public class FromMatchesFilterTest { private static final Jid SERVICE_JID2 = JidTestUtil.PUBSUB_EXAMPLE_ORG; @Test - public void autoCompareMatchingEntityFullJid() - { + public void autoCompareMatchingEntityFullJid() { FromMatchesFilter filter = FromMatchesFilter.create(FULL_JID1_R1); Stanza packet = new Message(); @@ -70,8 +69,7 @@ public class FromMatchesFilterTest { } @Test - public void autoCompareMatchingBaseJid() - { + public void autoCompareMatchingBaseJid() { FromMatchesFilter filter = FromMatchesFilter.create(BASE_JID1); Stanza packet = new Message(); @@ -95,8 +93,7 @@ public class FromMatchesFilterTest { } @Test - public void autoCompareMatchingServiceJid() - { + public void autoCompareMatchingServiceJid() { FromMatchesFilter filter = FromMatchesFilter.create(SERVICE_JID1); Stanza packet = new Message(); @@ -117,8 +114,7 @@ public class FromMatchesFilterTest { } @Test - public void bareCompareMatchingEntityFullJid() - { + public void bareCompareMatchingEntityFullJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1); Stanza packet = new Message(); @@ -142,8 +138,7 @@ public class FromMatchesFilterTest { } @Test - public void bareCompareMatchingBaseJid() - { + public void bareCompareMatchingBaseJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1); Stanza packet = new Message(); @@ -167,8 +162,7 @@ public class FromMatchesFilterTest { } @Test - public void bareCompareMatchingServiceJid() - { + public void bareCompareMatchingServiceJid() { FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1); Stanza packet = new Message(); @@ -189,8 +183,7 @@ public class FromMatchesFilterTest { } @Test - public void fullCompareMatchingEntityFullJid() - { + public void fullCompareMatchingEntityFullJid() { FromMatchesFilter filter = FromMatchesFilter.createFull(FULL_JID1_R1); Stanza packet = new Message(); @@ -214,8 +207,7 @@ public class FromMatchesFilterTest { } @Test - public void fullCompareMatchingBaseJid() - { + public void fullCompareMatchingBaseJid() { FromMatchesFilter filter = FromMatchesFilter.createFull(BASE_JID1); Stanza packet = new Message(); @@ -239,8 +231,7 @@ public class FromMatchesFilterTest { } @Test - public void fullCompareMatchingServiceJid() - { + public void fullCompareMatchingServiceJid() { FromMatchesFilter filter = FromMatchesFilter.createFull(SERVICE_JID1); Stanza packet = new Message(); diff --git a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java index 17d38418a..f2b7a074d 100644 --- a/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java +++ b/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java @@ -434,8 +434,7 @@ public class EnhancedDebugger extends SmackDebugger { int index = str.lastIndexOf(">"); if (index != -1) { - if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) - { + if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { try { receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0)); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java index 2b45123d4..e221d8eb1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java @@ -71,8 +71,9 @@ public class MultipleRecipientManager { * @throws NotConnectedException * @throws InterruptedException */ - public static void send(XMPPConnection connection, Stanza packet, Collection to, Collection cc, Collection bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException, InterruptedException - { + public static void send(XMPPConnection connection, Stanza packet, Collection to, + Collection cc, Collection bcc) throws NoResponseException, XMPPErrorException, + FeatureNotSupportedException, NotConnectedException, InterruptedException { send(connection, packet, to, cc, bcc, null, null, false); } @@ -143,8 +144,8 @@ public class MultipleRecipientManager { * @throws XMPPErrorException * @throws InterruptedException */ - public static void reply(XMPPConnection connection, Message original, Message reply) throws SmackException, XMPPErrorException, InterruptedException - { + public static void reply(XMPPConnection connection, Message original, Message reply) + throws SmackException, XMPPErrorException, InterruptedException { MultipleRecipientInfo info = getMultipleRecipientInfo(original); if (info == null) { throw new SmackException("Original message does not contain multiple recipient info"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkManager.java index c85d925e3..fb1395c7c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkManager.java @@ -60,8 +60,7 @@ public final class BookmarkManager { * exist it is created. * @throws IllegalArgumentException when the connection is null. */ - public static synchronized BookmarkManager getBookmarkManager(XMPPConnection connection) - { + public static synchronized BookmarkManager getBookmarkManager(XMPPConnection connection) { BookmarkManager manager = bookmarkManagerMap.get(connection); if (manager == null) { manager = new BookmarkManager(connection); @@ -114,8 +113,7 @@ public final class BookmarkManager { * @throws InterruptedException */ public void addBookmarkedConference(String name, EntityBareJid jid, boolean isAutoJoin, - Resourcepart nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + Resourcepart nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { retrieveBookmarks(); BookmarkedConference bookmark = new BookmarkedConference(name, jid, isAutoJoin, nickname, password); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedConference.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedConference.java index 555af7e2c..a6da6afa2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedConference.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/BookmarkedConference.java @@ -40,8 +40,7 @@ public class BookmarkedConference implements SharedBookmark { } protected BookmarkedConference(String name, EntityBareJid jid, boolean autoJoin, Resourcepart nickname, - String password) - { + String password) { this.name = name; this.jid = jid; this.autoJoin = autoJoin; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java index 9b97e8528..322d0c8bb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java @@ -232,13 +232,11 @@ public class Bookmarks implements PrivateData { } } else if (eventType == XmlPullParser.START_TAG && - "conference".equals(parser.getName())) - { + "conference".equals(parser.getName())) { final BookmarkedConference conference = getConferenceStorage(parser); storage.addBookmarkedConference(conference); } - else if (eventType == XmlPullParser.END_TAG && "storage".equals(parser.getName())) - { + else if (eventType == XmlPullParser.END_TAG && "storage".equals(parser.getName())) { done = true; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java index c32d7372a..81fd9fbf2 100755 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java @@ -606,8 +606,7 @@ public final class AdHocCommandManager extends Manager { * @throws NotConnectedException */ private static IQ respondError(AdHocCommandData response, XMPPError.Condition condition, - AdHocCommand.SpecificErrorCondition specificCondition) - { + AdHocCommand.SpecificErrorCondition specificCondition) { XMPPError.Builder error = XMPPError.getBuilder(condition).addExtension(new AdHocCommandData.SpecificError(specificCondition)); return respondError(response, error); } @@ -672,8 +671,7 @@ public final class AdHocCommandManager extends Manager { private LocalCommandFactory factory; private AdHocCommandInfo(String node, String name, Jid ownerJID, - LocalCommandFactory factory) - { + LocalCommandFactory factory) { this.node = node; this.name = name; this.ownerJID = ownerJID; @@ -681,8 +679,7 @@ public final class AdHocCommandManager extends Manager { } public LocalCommand getCommandInstance() throws InstantiationException, - IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException - { + IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { return factory.getInstance(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java index a08c953d5..d42fc481c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java @@ -654,8 +654,7 @@ public final class ServiceDiscoveryManager extends Manager { */ @Deprecated // TODO: Remove in Smack 4.4 - public void publishItems(Jid entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void publishItems(Jid entityID, String node, DiscoverItems discoverItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { discoverItems.setType(IQ.Type.set); discoverItems.setTo(entityID); discoverItems.setNode(node); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransfer.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransfer.java index a4dcf9231..3d5c1c87a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransfer.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransfer.java @@ -204,8 +204,7 @@ public abstract class FileTransfer { } protected void writeToStream(final InputStream in, final OutputStream out) - throws IOException - { + throws IOException { final byte[] b = new byte[BUFFER_SIZE]; int count = 0; amountWritten = 0; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java index 5d9498bfe..eb1b2fceb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/OutgoingFileTransfer.java @@ -161,8 +161,7 @@ public class OutgoingFileTransfer extends FileTransfer { */ public synchronized void sendFile(final String fileName, final long fileSize, final String description, - final NegotiationProgress progress) - { + final NegotiationProgress progress) { if (progress == null) { throw new IllegalArgumentException("Callback progress cannot be null."); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java index d42522350..908abe6a9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java @@ -51,8 +51,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator { } @Override - public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws SmackException, XMPPException - { + public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws SmackException, XMPPException { try { return this.manager.establishSession(target, streamID).getOutputStream(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java index 69c15bf69..a71254dae 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java @@ -73,8 +73,7 @@ public abstract class StreamNegotiator extends Manager { * @return The response to be forwarded to the initiator. */ protected static StreamInitiation createInitiationAccept( - StreamInitiation streamInitiationOffer, String[] namespaces) - { + StreamInitiation streamInitiationOffer, String[] namespaces) { StreamInitiation response = new StreamInitiation(); response.setTo(streamInitiationOffer.getFrom()); response.setFrom(streamInitiationOffer.getTo()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java index 0a4fea036..b9534ac7b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java @@ -115,8 +115,7 @@ public final class PrivateDataManager extends Manager { * @param provider the private data provider. */ public static void addPrivateDataProvider(String elementName, String namespace, - PrivateDataProvider provider) - { + PrivateDataProvider provider) { String key = XmppStringUtils.generateKey(elementName, namespace); privateDataProviders.put(key, provider); } @@ -159,8 +158,7 @@ public final class PrivateDataManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public PrivateData getPrivateData(final String elementName, final String namespace) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Create an IQ packet to get the private data. IQ privateDataGet = new PrivateDataIQ(elementName, namespace); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index c887e8495..c51eab7b4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -1583,8 +1583,7 @@ public class MultiUserChat { * @throws NotConnectedException * @throws InterruptedException */ - private void changeAffiliationByAdmin(Jid jid, MUCAffiliation affiliation, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + private void changeAffiliationByAdmin(Jid jid, MUCAffiliation affiliation, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCAdmin iq = new MUCAdmin(); iq.setTo(room); iq.setType(IQ.Type.set); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AccessModel.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AccessModel.java index 3fe69c74b..772446d38 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AccessModel.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AccessModel.java @@ -22,8 +22,8 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum AccessModel -{ +public enum AccessModel { + /** Anyone may subscribe and retrieve items. */ open, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java index c2c00ca81..2eb44cb8b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java @@ -35,8 +35,7 @@ import org.jxmpp.jid.BareJid; * * @author Robin Collier */ -public class Affiliation implements ExtensionElement -{ +public class Affiliation implements ExtensionElement { public static final String ELEMENT = "affiliation"; private final BareJid jid; @@ -44,8 +43,7 @@ public class Affiliation implements ExtensionElement private final Type affiliation; private final PubSubNamespace namespace; - public enum Type - { + public enum Type { member, none, outcast, owner, publisher } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AffiliationsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AffiliationsExtension.java index dd19877b9..ab1561ed0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AffiliationsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AffiliationsExtension.java @@ -28,8 +28,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Robin Collier */ -public class AffiliationsExtension extends NodeExtension -{ +public class AffiliationsExtension extends NodeExtension { protected List items = Collections.emptyList(); private final String node; @@ -47,20 +46,16 @@ public class AffiliationsExtension extends NodeExtension this.node = node; } - public List getAffiliations() - { + public List getAffiliations() { return items; } @Override - public CharSequence toXML() - { - if ((items == null) || (items.size() == 0)) - { + public CharSequence toXML() { + if ((items == null) || (items.size() == 0)) { return super.toXML(); } - else - { + else { // Can't use XmlStringBuilder(this), because we don't want the namespace to be included XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(getElementName()); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ChildrenAssociationPolicy.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ChildrenAssociationPolicy.java index 26fc085c3..217b554e0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ChildrenAssociationPolicy.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ChildrenAssociationPolicy.java @@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum ChildrenAssociationPolicy -{ +public enum ChildrenAssociationPolicy { /** Anyone may associate leaf nodes with the collection. */ all, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/CollectionNode.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/CollectionNode.java index 867de52da..0b0b09557 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/CollectionNode.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/CollectionNode.java @@ -18,8 +18,7 @@ package org.jivesoftware.smackx.pubsub; public class CollectionNode extends Node { - CollectionNode(PubSubManager pubSubManager, String nodeId) - { + CollectionNode(PubSubManager pubSubManager, String nodeId) { super(pubSubManager, nodeId); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java index 73ee417de..d45561146 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java @@ -29,29 +29,24 @@ import org.jivesoftware.smack.packet.ExtensionElement; * * @author Robin Collier */ -public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension -{ +public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension { private ConfigureForm form; - public ConfigurationEvent(String nodeId) - { + public ConfigurationEvent(String nodeId) { super(PubSubElementType.CONFIGURATION, nodeId); } - public ConfigurationEvent(String nodeId, ConfigureForm configForm) - { + public ConfigurationEvent(String nodeId, ConfigureForm configForm) { super(PubSubElementType.CONFIGURATION, nodeId); form = configForm; } - public ConfigureForm getConfiguration() - { + public ConfigureForm getConfiguration() { return form; } @Override - public List getExtensions() - { + public List getExtensions() { if (getConfiguration() == null) return Collections.emptyList(); else diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java index 2b18325be..a0555e6b8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java @@ -33,16 +33,14 @@ import org.jivesoftware.smackx.xdata.packet.DataForm; * * @author Robin Collier */ -public class ConfigureForm extends Form -{ +public class ConfigureForm extends Form { /** * Create a decorator from an existing {@link DataForm} that has been * retrieved from parsing a node configuration request. * * @param configDataForm */ - public ConfigureForm(DataForm configDataForm) - { + public ConfigureForm(DataForm configDataForm) { super(configDataForm); } @@ -53,8 +51,7 @@ public class ConfigureForm extends Form * * @param nodeConfigForm */ - public ConfigureForm(Form nodeConfigForm) - { + public ConfigureForm(Form nodeConfigForm) { super(nodeConfigForm.getDataFormToSend()); } @@ -65,8 +62,7 @@ public class ConfigureForm extends Form * using the resulting form to create a answer form. See {@link #ConfigureForm(Form)}. * @param formType */ - public ConfigureForm(DataForm.Type formType) - { + public ConfigureForm(DataForm.Type formType) { super(formType); } @@ -75,8 +71,7 @@ public class ConfigureForm extends Form * * @return The current {@link AccessModel} */ - public AccessModel getAccessModel() - { + public AccessModel getAccessModel() { String value = getFieldValue(ConfigureNodeFields.access_model); if (value == null) @@ -90,8 +85,7 @@ public class ConfigureForm extends Form * * @param accessModel */ - public void setAccessModel(AccessModel accessModel) - { + public void setAccessModel(AccessModel accessModel) { addField(ConfigureNodeFields.access_model, FormField.Type.list_single); setAnswer(ConfigureNodeFields.access_model.getFieldName(), getListSingle(accessModel.toString())); } @@ -102,8 +96,7 @@ public class ConfigureForm extends Form * * @return URL to an XSL */ - public String getBodyXSLT() - { + public String getBodyXSLT() { return getFieldValue(ConfigureNodeFields.body_xslt); } @@ -113,8 +106,7 @@ public class ConfigureForm extends Form * * @param bodyXslt The URL of an XSL */ - public void setBodyXSLT(String bodyXslt) - { + public void setBodyXSLT(String bodyXslt) { addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single); setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt); } @@ -124,8 +116,7 @@ public class ConfigureForm extends Form * * @return list of child nodes. */ - public List getChildren() - { + public List getChildren() { return getFieldValues(ConfigureNodeFields.children); } @@ -134,8 +125,7 @@ public class ConfigureForm extends Form * * @param children */ - public void setChildren(List children) - { + public void setChildren(List children) { addField(ConfigureNodeFields.children, FormField.Type.text_multi); setAnswer(ConfigureNodeFields.children.getFieldName(), children); } @@ -145,8 +135,7 @@ public class ConfigureForm extends Form * * @return The current policy */ - public ChildrenAssociationPolicy getChildrenAssociationPolicy() - { + public ChildrenAssociationPolicy getChildrenAssociationPolicy() { String value = getFieldValue(ConfigureNodeFields.children_association_policy); if (value == null) @@ -160,8 +149,7 @@ public class ConfigureForm extends Form * * @param policy The policy being set */ - public void setChildrenAssociationPolicy(ChildrenAssociationPolicy policy) - { + public void setChildrenAssociationPolicy(ChildrenAssociationPolicy policy) { addField(ConfigureNodeFields.children_association_policy, FormField.Type.list_single); List values = new ArrayList<>(1); values.add(policy.toString()); @@ -175,8 +163,7 @@ public class ConfigureForm extends Form * * @return List of the whitelist */ - public List getChildrenAssociationWhitelist() - { + public List getChildrenAssociationWhitelist() { return getFieldValues(ConfigureNodeFields.children_association_whitelist); } @@ -187,8 +174,7 @@ public class ConfigureForm extends Form * * @param whitelist The list of JID's */ - public void setChildrenAssociationWhitelist(List whitelist) - { + public void setChildrenAssociationWhitelist(List whitelist) { addField(ConfigureNodeFields.children_association_whitelist, FormField.Type.jid_multi); setAnswer(ConfigureNodeFields.children_association_whitelist.getFieldName(), whitelist); } @@ -198,8 +184,7 @@ public class ConfigureForm extends Form * * @return The maximum number of child nodes */ - public int getChildrenMax() - { + public int getChildrenMax() { return Integer.parseInt(getFieldValue(ConfigureNodeFields.children_max)); } @@ -208,8 +193,7 @@ public class ConfigureForm extends Form * * @param max The maximum number of child nodes. */ - public void setChildrenMax(int max) - { + public void setChildrenMax(int max) { addField(ConfigureNodeFields.children_max, FormField.Type.text_single); setAnswer(ConfigureNodeFields.children_max.getFieldName(), max); } @@ -219,8 +203,7 @@ public class ConfigureForm extends Form * * @return The collection node id */ - public String getCollection() - { + public String getCollection() { return getFieldValue(ConfigureNodeFields.collection); } @@ -229,8 +212,7 @@ public class ConfigureForm extends Form * * @param collection The node id of the collection node */ - public void setCollection(String collection) - { + public void setCollection(String collection) { addField(ConfigureNodeFields.collection, FormField.Type.text_single); setAnswer(ConfigureNodeFields.collection.getFieldName(), collection); } @@ -242,8 +224,7 @@ public class ConfigureForm extends Form * * @return The URL of an XSL transformation */ - public String getDataformXSLT() - { + public String getDataformXSLT() { return getFieldValue(ConfigureNodeFields.dataform_xslt); } @@ -254,8 +235,7 @@ public class ConfigureForm extends Form * * @param url The URL of an XSL transformation */ - public void setDataformXSLT(String url) - { + public void setDataformXSLT(String url) { addField(ConfigureNodeFields.dataform_xslt, FormField.Type.text_single); setAnswer(ConfigureNodeFields.dataform_xslt.getFieldName(), url); } @@ -265,8 +245,7 @@ public class ConfigureForm extends Form * * @return true if it does, false otherwise */ - public boolean isDeliverPayloads() - { + public boolean isDeliverPayloads() { return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads)); } @@ -275,8 +254,7 @@ public class ConfigureForm extends Form * * @param deliver true if the payload will be delivered, false otherwise */ - public void setDeliverPayloads(boolean deliver) - { + public void setDeliverPayloads(boolean deliver) { addField(ConfigureNodeFields.deliver_payloads, FormField.Type.bool); setAnswer(ConfigureNodeFields.deliver_payloads.getFieldName(), deliver); } @@ -286,8 +264,7 @@ public class ConfigureForm extends Form * * @return Who should get the reply */ - public ItemReply getItemReply() - { + public ItemReply getItemReply() { String value = getFieldValue(ConfigureNodeFields.itemreply); if (value == null) @@ -301,8 +278,7 @@ public class ConfigureForm extends Form * * @param reply Defines who should get the reply */ - public void setItemReply(ItemReply reply) - { + public void setItemReply(ItemReply reply) { addField(ConfigureNodeFields.itemreply, FormField.Type.list_single); setAnswer(ConfigureNodeFields.itemreply.getFieldName(), getListSingle(reply.toString())); } @@ -313,8 +289,7 @@ public class ConfigureForm extends Form * * @return The maximum number of items to persist */ - public int getMaxItems() - { + public int getMaxItems() { return Integer.parseInt(getFieldValue(ConfigureNodeFields.max_items)); } @@ -324,8 +299,7 @@ public class ConfigureForm extends Form * * @param max The maximum number of items to persist */ - public void setMaxItems(int max) - { + public void setMaxItems(int max) { addField(ConfigureNodeFields.max_items, FormField.Type.text_single); setAnswer(ConfigureNodeFields.max_items.getFieldName(), max); } @@ -335,8 +309,7 @@ public class ConfigureForm extends Form * * @return The maximum payload size */ - public int getMaxPayloadSize() - { + public int getMaxPayloadSize() { return Integer.parseInt(getFieldValue(ConfigureNodeFields.max_payload_size)); } @@ -345,8 +318,7 @@ public class ConfigureForm extends Form * * @param max The maximum payload size */ - public void setMaxPayloadSize(int max) - { + public void setMaxPayloadSize(int max) { addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single); setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max); } @@ -356,8 +328,7 @@ public class ConfigureForm extends Form * * @return The node type */ - public NodeType getNodeType() - { + public NodeType getNodeType() { String value = getFieldValue(ConfigureNodeFields.node_type); if (value == null) @@ -371,8 +342,7 @@ public class ConfigureForm extends Form * * @param type The node type */ - public void setNodeType(NodeType type) - { + public void setNodeType(NodeType type) { addField(ConfigureNodeFields.node_type, FormField.Type.list_single); setAnswer(ConfigureNodeFields.node_type.getFieldName(), getListSingle(type.toString())); } @@ -382,8 +352,7 @@ public class ConfigureForm extends Form * * @return true if they should be notified, false otherwise */ - public boolean isNotifyConfig() - { + public boolean isNotifyConfig() { return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config)); } @@ -392,8 +361,7 @@ public class ConfigureForm extends Form * * @param notify true if subscribers should be notified, false otherwise */ - public void setNotifyConfig(boolean notify) - { + public void setNotifyConfig(boolean notify) { addField(ConfigureNodeFields.notify_config, FormField.Type.bool); setAnswer(ConfigureNodeFields.notify_config.getFieldName(), notify); } @@ -403,8 +371,7 @@ public class ConfigureForm extends Form * * @return true if subscribers should be notified, false otherwise */ - public boolean isNotifyDelete() - { + public boolean isNotifyDelete() { return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete)); } @@ -413,8 +380,7 @@ public class ConfigureForm extends Form * * @param notify true if subscribers should be notified, false otherwise */ - public void setNotifyDelete(boolean notify) - { + public void setNotifyDelete(boolean notify) { addField(ConfigureNodeFields.notify_delete, FormField.Type.bool); setAnswer(ConfigureNodeFields.notify_delete.getFieldName(), notify); } @@ -425,8 +391,7 @@ public class ConfigureForm extends Form * * @return true if subscribers should be notified, false otherwise */ - public boolean isNotifyRetract() - { + public boolean isNotifyRetract() { return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract)); } @@ -436,8 +401,7 @@ public class ConfigureForm extends Form * * @param notify true if subscribers should be notified, false otherwise */ - public void setNotifyRetract(boolean notify) - { + public void setNotifyRetract(boolean notify) { addField(ConfigureNodeFields.notify_retract, FormField.Type.bool); setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify); } @@ -447,8 +411,7 @@ public class ConfigureForm extends Form * * @return true if items are persisted */ - public boolean isPersistItems() - { + public boolean isPersistItems() { return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items)); } @@ -457,8 +420,7 @@ public class ConfigureForm extends Form * * @param persist true if items should be persisted, false otherwise */ - public void setPersistentItems(boolean persist) - { + public void setPersistentItems(boolean persist) { addField(ConfigureNodeFields.persist_items, FormField.Type.bool); setAnswer(ConfigureNodeFields.persist_items.getFieldName(), persist); } @@ -468,8 +430,7 @@ public class ConfigureForm extends Form * * @return true if users must be available */ - public boolean isPresenceBasedDelivery() - { + public boolean isPresenceBasedDelivery() { return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery)); } @@ -478,8 +439,7 @@ public class ConfigureForm extends Form * * @param presenceBased true if user must be available, false otherwise */ - public void setPresenceBasedDelivery(boolean presenceBased) - { + public void setPresenceBasedDelivery(boolean presenceBased) { addField(ConfigureNodeFields.presence_based_delivery, FormField.Type.bool); setAnswer(ConfigureNodeFields.presence_based_delivery.getFieldName(), presenceBased); } @@ -489,8 +449,7 @@ public class ConfigureForm extends Form * * @return The publishing model */ - public PublishModel getPublishModel() - { + public PublishModel getPublishModel() { String value = getFieldValue(ConfigureNodeFields.publish_model); if (value == null) @@ -504,8 +463,7 @@ public class ConfigureForm extends Form * * @param publish The enum representing the possible options for the publishing model */ - public void setPublishModel(PublishModel publish) - { + public void setPublishModel(PublishModel publish) { addField(ConfigureNodeFields.publish_model, FormField.Type.list_single); setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString())); } @@ -515,8 +473,7 @@ public class ConfigureForm extends Form * * @return The reply room JID's */ - public List getReplyRoom() - { + public List getReplyRoom() { return getFieldValues(ConfigureNodeFields.replyroom); } @@ -525,8 +482,7 @@ public class ConfigureForm extends Form * * @param replyRooms The multi user chat room to use as reply rooms */ - public void setReplyRoom(List replyRooms) - { + public void setReplyRoom(List replyRooms) { addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi); setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms); } @@ -536,8 +492,7 @@ public class ConfigureForm extends Form * * @return The JID's */ - public List getReplyTo() - { + public List getReplyTo() { return getFieldValues(ConfigureNodeFields.replyto); } @@ -546,8 +501,7 @@ public class ConfigureForm extends Form * * @param replyTos The JID's to reply to */ - public void setReplyTo(List replyTos) - { + public void setReplyTo(List replyTos) { addField(ConfigureNodeFields.replyto, FormField.Type.list_multi); setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos); } @@ -557,8 +511,7 @@ public class ConfigureForm extends Form * * @return The roster groups */ - public List getRosterGroupsAllowed() - { + public List getRosterGroupsAllowed() { return getFieldValues(ConfigureNodeFields.roster_groups_allowed); } @@ -567,8 +520,7 @@ public class ConfigureForm extends Form * * @param groups The roster groups */ - public void setRosterGroupsAllowed(List groups) - { + public void setRosterGroupsAllowed(List groups) { addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi); setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups); } @@ -580,8 +532,7 @@ public class ConfigureForm extends Form * @deprecated use {@link #isSubscribe()} instead */ @Deprecated - public boolean isSubscibe() - { + public boolean isSubscibe() { return isSubscribe(); } @@ -599,8 +550,7 @@ public class ConfigureForm extends Form * * @param subscribe true if they are, false otherwise */ - public void setSubscribe(boolean subscribe) - { + public void setSubscribe(boolean subscribe) { addField(ConfigureNodeFields.subscribe, FormField.Type.bool); setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe); } @@ -611,8 +561,7 @@ public class ConfigureForm extends Form * @return The node title */ @Override - public String getTitle() - { + public String getTitle() { return getFieldValue(ConfigureNodeFields.title); } @@ -622,8 +571,7 @@ public class ConfigureForm extends Form * @param title The node title */ @Override - public void setTitle(String title) - { + public void setTitle(String title) { addField(ConfigureNodeFields.title, FormField.Type.text_single); setAnswer(ConfigureNodeFields.title.getFieldName(), title); } @@ -633,8 +581,7 @@ public class ConfigureForm extends Form * * @return The type of node data */ - public String getDataType() - { + public String getDataType() { return getFieldValue(ConfigureNodeFields.type); } @@ -643,27 +590,23 @@ public class ConfigureForm extends Form * * @param type The type of node data */ - public void setDataType(String type) - { + public void setDataType(String type) { addField(ConfigureNodeFields.type, FormField.Type.text_single); setAnswer(ConfigureNodeFields.type.getFieldName(), type); } @Override - public String toString() - { + public String toString() { StringBuilder result = new StringBuilder(getClass().getName() + " Content ["); - for (FormField formField : getFields()) - { + for (FormField formField : getFields()) { result.append('('); result.append(formField.getVariable()); result.append(':'); StringBuilder valuesBuilder = new StringBuilder(); - for (String value : formField.getValues()) - { + for (String value : formField.getValues()) { if (valuesBuilder.length() > 0) result.append(','); valuesBuilder.append(value); @@ -678,39 +621,33 @@ public class ConfigureForm extends Form return result.toString(); } - private static boolean parseBoolean(String fieldValue) - { + private static boolean parseBoolean(String fieldValue) { return ("1".equals(fieldValue) || "true".equals(fieldValue)); } - private String getFieldValue(ConfigureNodeFields field) - { + private String getFieldValue(ConfigureNodeFields field) { FormField formField = getField(field.getFieldName()); return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0); } - private List getFieldValues(ConfigureNodeFields field) - { + private List getFieldValues(ConfigureNodeFields field) { FormField formField = getField(field.getFieldName()); return formField.getValues(); } - private void addField(ConfigureNodeFields nodeField, FormField.Type type) - { + private void addField(ConfigureNodeFields nodeField, FormField.Type type) { String fieldName = nodeField.getFieldName(); - if (getField(fieldName) == null) - { + if (getField(fieldName) == null) { FormField field = new FormField(fieldName); field.setType(type); addField(field); } } - private static List getListSingle(String value) - { + private static List getListSingle(String value) { List list = new ArrayList<>(1); list.add(value); return list; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java index 47d01b80a..6a3ce0be9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java @@ -27,8 +27,7 @@ import org.jivesoftware.smackx.xdata.Form; * * @author Robin Collier */ -public enum ConfigureNodeFields -{ +public enum ConfigureNodeFields { /** * Determines who may subscribe and retrieve items. * @@ -214,8 +213,7 @@ public enum ConfigureNodeFields */ type; - public String getFieldName() - { + public String getFieldName() { return "pubsub#" + toString(); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java index 50cdc25ac..efc4a7c38 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EmbeddedPacketExtension.java @@ -37,8 +37,7 @@ import org.jivesoftware.smack.util.PacketParserUtils; * * @author Robin Collier */ -public interface EmbeddedPacketExtension extends ExtensionElement -{ +public interface EmbeddedPacketExtension extends ExtensionElement { /** * Get the list of embedded {@link ExtensionElement} objects. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java index 8a0ab03e6..e057ae2b3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java @@ -33,8 +33,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; * * @author Robin Collier */ -public class EventElement implements EmbeddedPacketExtension -{ +public class EventElement implements EmbeddedPacketExtension { /** * The constant String "event". */ @@ -48,37 +47,31 @@ public class EventElement implements EmbeddedPacketExtension private final EventElementType type; private final NodeExtension ext; - public EventElement(EventElementType eventType, NodeExtension eventExt) - { + public EventElement(EventElementType eventType, NodeExtension eventExt) { type = eventType; ext = eventExt; } - public EventElementType getEventType() - { + public EventElementType getEventType() { return type; } @Override - public List getExtensions() - { + public List getExtensions() { return Arrays.asList(new ExtensionElement[] {getEvent()}); } - public NodeExtension getEvent() - { + public NodeExtension getEvent() { return ext; } @Override - public String getElementName() - { + public String getElementName() { return "event"; } @Override - public String getNamespace() - { + public String getNamespace() { return PubSubNamespace.EVENT.getXmlns(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElementType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElementType.java index 5a4a6d589..1c00797c7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElementType.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElementType.java @@ -22,8 +22,8 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum EventElementType -{ +public enum EventElementType { + /** A node has been associated or disassociated with a collection node. */ collection, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNode.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNode.java index ebdcea34b..68d5573e5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNode.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNode.java @@ -26,8 +26,7 @@ import org.jivesoftware.smackx.xdata.Form; * * @author Robin Collier */ -public class FormNode extends NodeExtension -{ +public class FormNode extends NodeExtension { private final Form configForm; /** @@ -36,8 +35,7 @@ public class FormNode extends NodeExtension * @param formType The type of form being sent * @param submitForm The form */ - public FormNode(FormNodeType formType, Form submitForm) - { + public FormNode(FormNodeType formType, Form submitForm) { super(formType.getNodeElement()); if (submitForm == null) @@ -53,8 +51,7 @@ public class FormNode extends NodeExtension * @param nodeId The node the form is associated with * @param submitForm The form */ - public FormNode(FormNodeType formType, String nodeId, Form submitForm) - { + public FormNode(FormNodeType formType, String nodeId, Form submitForm) { super(formType.getNodeElement(), nodeId); if (submitForm == null) @@ -67,25 +64,20 @@ public class FormNode extends NodeExtension * * @return The form */ - public Form getForm() - { + public Form getForm() { return configForm; } @Override - public CharSequence toXML() - { - if (configForm == null) - { + public CharSequence toXML() { + if (configForm == null) { return super.toXML(); } - else - { + else { StringBuilder builder = new StringBuilder("<"); builder.append(getElementName()); - if (getNode() != null) - { + if (getNode() != null) { builder.append(" node='"); builder.append(getNode()); builder.append("'>"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNodeType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNodeType.java index 38668bff7..31298d941 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNodeType.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNodeType.java @@ -38,15 +38,12 @@ public enum FormNodeType { /** Form which represents the default node configuration options. */ DEFAULT; - public PubSubElementType getNodeElement() - { + public PubSubElementType getNodeElement() { return PubSubElementType.valueOf(toString()); } - public static FormNodeType valueOfFromElementName(String elem, String configNamespace) - { - if ("configure".equals(elem) && PubSubNamespace.OWNER.getXmlns().equals(configNamespace)) - { + public static FormNodeType valueOfFromElementName(String elem, String configNamespace) { + if ("configure".equals(elem) && PubSubNamespace.OWNER.getXmlns().equals(configNamespace)) { return CONFIGURE_OWNER; } return valueOf(elem.toUpperCase(Locale.US)); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/GetItemsRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/GetItemsRequest.java index 05b94b716..f35963d5c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/GetItemsRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/GetItemsRequest.java @@ -23,40 +23,33 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Robin Collier */ -public class GetItemsRequest extends NodeExtension -{ +public class GetItemsRequest extends NodeExtension { protected final String subId; protected final int maxItems; - public GetItemsRequest(String nodeId) - { + public GetItemsRequest(String nodeId) { this(nodeId, null, -1); } - public GetItemsRequest(String nodeId, String subscriptionId) - { + public GetItemsRequest(String nodeId, String subscriptionId) { this(nodeId, subscriptionId, -1); } - public GetItemsRequest(String nodeId, int maxItemsToReturn) - { + public GetItemsRequest(String nodeId, int maxItemsToReturn) { this(nodeId, null, maxItemsToReturn); } - public GetItemsRequest(String nodeId, String subscriptionId, int maxItemsToReturn) - { + public GetItemsRequest(String nodeId, String subscriptionId, int maxItemsToReturn) { super(PubSubElementType.ITEMS, nodeId); maxItems = maxItemsToReturn; subId = subscriptionId; } - public String getSubscriptionId() - { + public String getSubscriptionId() { return subId; } - public int getMaxItems() - { + public int getMaxItems() { return maxItems; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java index 0d54c823a..8207a56a1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java @@ -49,8 +49,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * * @author Robin Collier */ -public class Item extends NodeExtension -{ +public class Item extends NodeExtension { private String id; /** @@ -60,8 +59,7 @@ public class Item extends NodeExtension * set to false, no Item is sent to the node, you have to use the {@link LeafNode#publish()} * method in this case. */ - public Item() - { + public Item() { super(PubSubElementType.ITEM); } @@ -72,8 +70,7 @@ public class Item extends NodeExtension * @param itemId The id if the item. It must be unique within the node unless overwriting and existing item. * Passing null is the equivalent of calling {@link #Item()}. */ - public Item(String itemId) - { + public Item(String itemId) { // The element type is actually irrelevant since we override getNamespace() to return null super(PubSubElementType.ITEM); id = itemId; @@ -90,8 +87,7 @@ public class Item extends NodeExtension * @param itemId The id of the item. * @param nodeId The id of the node which the item was published to. */ - public Item(String itemId, String nodeId) - { + public Item(String itemId, String nodeId) { super(PubSubElementType.ITEM_EVENT, nodeId); id = itemId; } @@ -101,24 +97,20 @@ public class Item extends NodeExtension * * @return The id */ - public String getId() - { + public String getId() { return id; } @Override - public String getNamespace() - { + public String getNamespace() { return null; } @Override - public String toXML() - { + public String toXML() { StringBuilder builder = new StringBuilder(" itemIds = Collections.emptyList(); /** @@ -38,8 +37,7 @@ public class ItemDeleteEvent extends SubscriptionEvent * @param deletedItemIds The item ids of the items that were deleted. * @param subscriptionIds The subscriptions that match the event. */ - public ItemDeleteEvent(String nodeId, List deletedItemIds, List subscriptionIds) - { + public ItemDeleteEvent(String nodeId, List deletedItemIds, List subscriptionIds) { super(nodeId, subscriptionIds); if (deletedItemIds == null) @@ -52,14 +50,12 @@ public class ItemDeleteEvent extends SubscriptionEvent * * @return List of item id's */ - public List getItemIds() - { + public List getItemIds() { return Collections.unmodifiableList(itemIds); } @Override - public String toString() - { + public String toString() { return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']'; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemPublishEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemPublishEvent.java index 2111ea09c..454cef3f7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemPublishEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemPublishEvent.java @@ -25,8 +25,7 @@ import java.util.List; * * @author Robin Collier */ -public class ItemPublishEvent extends SubscriptionEvent -{ +public class ItemPublishEvent extends SubscriptionEvent { private List items; private Date originalDate; @@ -37,8 +36,7 @@ public class ItemPublishEvent extends SubscriptionEvent * @param nodeId The id of the node the event came from * @param eventItems The list of {@link Item} that were published */ - public ItemPublishEvent(String nodeId, List eventItems) - { + public ItemPublishEvent(String nodeId, List eventItems) { super(nodeId); items = eventItems; } @@ -53,8 +51,7 @@ public class ItemPublishEvent extends SubscriptionEvent * @param eventItems The list of {@link Item} that were published * @param subscriptionIds The list of subscriptionIds */ - public ItemPublishEvent(String nodeId, List eventItems, List subscriptionIds) - { + public ItemPublishEvent(String nodeId, List eventItems, List subscriptionIds) { super(nodeId, subscriptionIds); items = eventItems; } @@ -71,8 +68,7 @@ public class ItemPublishEvent extends SubscriptionEvent * @param subscriptionIds The list of subscriptionIds * @param publishedDate date of publication. */ - public ItemPublishEvent(String nodeId, List eventItems, List subscriptionIds, Date publishedDate) - { + public ItemPublishEvent(String nodeId, List eventItems, List subscriptionIds, Date publishedDate) { super(nodeId, subscriptionIds); items = eventItems; @@ -85,8 +81,7 @@ public class ItemPublishEvent extends SubscriptionEvent * * @return The list of published {@link Item} */ - public List getItems() - { + public List getItems() { return Collections.unmodifiableList(items); } @@ -100,8 +95,7 @@ public class ItemPublishEvent extends SubscriptionEvent * * @return true if the items are delayed, false otherwise. */ - public boolean isDelayed() - { + public boolean isDelayed() { return (originalDate != null); } @@ -111,14 +105,12 @@ public class ItemPublishEvent extends SubscriptionEvent * * @return date of publication. */ - public Date getPublishedDate() - { + public Date getPublishedDate() { return originalDate; } @Override - public String toString() - { + public String toString() { return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " + (isDelayed() ? originalDate.toString() : "false") + ']'; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemReply.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemReply.java index 1000ae042..1c4e01c8e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemReply.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemReply.java @@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum ItemReply -{ +public enum ItemReply { /** The node owner. */ owner, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java index 7918ea10f..bad417083 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java @@ -34,14 +34,12 @@ import org.jivesoftware.smack.packet.ExtensionElement; * * @author Robin Collier */ -public class ItemsExtension extends NodeExtension implements EmbeddedPacketExtension -{ +public class ItemsExtension extends NodeExtension implements EmbeddedPacketExtension { protected ItemsElementType type; protected Boolean notify; protected List items; - public enum ItemsElementType - { + public enum ItemsElementType { /** An items element, which has an optional max_items attribute when requesting items. */ items(PubSubElementType.ITEMS, "max_items"), @@ -51,19 +49,16 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten private final PubSubElementType elem; private final String att; - ItemsElementType(PubSubElementType nodeElement, String attribute) - { + ItemsElementType(PubSubElementType nodeElement, String attribute) { elem = nodeElement; att = attribute; } - public PubSubElementType getNodeElement() - { + public PubSubElementType getNodeElement() { return elem; } - public String getElementAttribute() - { + public String getElementAttribute() { return att; } } @@ -87,8 +82,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * @param nodeId The node to which the items are being sent or deleted * @param items The list of {@link Item} or {@link RetractItem} */ - public ItemsExtension(ItemsElementType itemsType, String nodeId, List items) - { + public ItemsExtension(ItemsElementType itemsType, String nodeId, List items) { super(itemsType.getNodeElement(), nodeId); type = itemsType; this.items = items; @@ -113,8 +107,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * @param items The list of {@link Item} or {@link RetractItem} * @param notify */ - public ItemsExtension(String nodeId, List items, boolean notify) - { + public ItemsExtension(String nodeId, List items, boolean notify) { super(ItemsElementType.retract.getNodeElement(), nodeId); type = ItemsElementType.retract; this.items = items; @@ -126,15 +119,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * * @return The element type */ - public ItemsElementType getItemsElementType() - { + public ItemsElementType getItemsElementType() { return type; } @Override @SuppressWarnings("unchecked") - public List getExtensions() - { + public List getExtensions() { return (List) getItems(); } @@ -143,8 +134,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * * @return List of {@link Item}, {@link RetractItem}, or null */ - public List getItems() - { + public List getItems() { return items; } @@ -153,38 +143,31 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten * * @return The attribute value */ - public boolean getNotify() - { + public boolean getNotify() { return notify; } @Override - public CharSequence toXML() - { - if ((items == null) || (items.size() == 0)) - { + public CharSequence toXML() { + if ((items == null) || (items.size() == 0)) { return super.toXML(); } - else - { + else { StringBuilder builder = new StringBuilder("<"); builder.append(getElementName()); builder.append(" node='"); builder.append(getNode()); - if (notify != null) - { + if (notify != null) { builder.append("' "); builder.append(type.getElementAttribute()); builder.append("='"); builder.append(notify.equals(Boolean.TRUE) ? 1 : 0); builder.append("'>"); } - else - { + else { builder.append("'>"); - for (ExtensionElement item : items) - { + for (ExtensionElement item : items) { builder.append(item.toXML()); } } @@ -197,8 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten } @Override - public String toString() - { + public String toString() { return getClass().getName() + "Content [" + toXML() + "]"; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java index bd07e1a20..d882d36a2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java @@ -37,10 +37,8 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub; * * @author Robin Collier */ -public class LeafNode extends Node -{ - LeafNode(PubSubManager pubSubManager, String nodeId) - { +public class LeafNode extends Node { + LeafNode(PubSubManager pubSubManager, String nodeId) { super(pubSubManager, nodeId); } @@ -54,8 +52,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems items = new DiscoverItems(); items.setTo(pubSubManager.getServiceJid()); items.setNode(getId()); @@ -72,8 +69,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public List getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return getItems((List) null, null); } @@ -92,8 +88,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public List getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId)); return getItems(request); } @@ -114,12 +109,10 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public List getItems(Collection ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getItems(Collection ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List itemList = new ArrayList<>(ids.size()); - for (String id : ids) - { + for (String id : ids) { itemList.add(new Item(id)); } PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList)); @@ -138,8 +131,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public List getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems)); return getItems(request); } @@ -160,8 +152,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public List getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems)); return getItems(request); } @@ -224,8 +215,7 @@ public class LeafNode extends Node * @deprecated use {@link #publish()} instead. */ @Deprecated - public void send() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException - { + public void send() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { publish(); } @@ -248,8 +238,7 @@ public class LeafNode extends Node */ @SuppressWarnings("unchecked") @Deprecated - public void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException - { + public void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { publish(item); } @@ -269,8 +258,7 @@ public class LeafNode extends Node * @deprecated use {@link #publish(Collection)} instead. */ @Deprecated - public void send(Collection items) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException - { + public void send(Collection items) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { publish(items); } @@ -287,8 +275,7 @@ public class LeafNode extends Node * @throws InterruptedException * */ - public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId())); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); @@ -316,8 +303,7 @@ public class LeafNode extends Node * */ @SuppressWarnings("unchecked") - public void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Collection items = new ArrayList<>(1); items.add((item == null ? (T) new Item() : item)); publish(items); @@ -338,8 +324,7 @@ public class LeafNode extends Node * @throws InterruptedException * */ - public void publish(Collection items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void publish(Collection items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items)); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); @@ -355,8 +340,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace()); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); @@ -371,8 +355,7 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Collection items = new ArrayList<>(1); items.add(itemId); deleteItem(items); @@ -387,13 +370,11 @@ public class LeafNode extends Node * @throws NotConnectedException * @throws InterruptedException */ - public void deleteItem(Collection itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void deleteItem(Collection itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List items = new ArrayList<>(itemIds.size()); - for (String id : itemIds) - { - items.add(new Item(id)); + for (String id : itemIds) { + items.add(new Item(id)); } PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items)); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java index 077482f8e..398a4b4e4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java @@ -44,8 +44,7 @@ import org.jivesoftware.smackx.shim.packet.Header; import org.jivesoftware.smackx.shim.packet.HeadersExtension; import org.jivesoftware.smackx.xdata.Form; -public abstract class Node -{ +public abstract class Node { protected final PubSubManager pubSubManager; protected final String id; @@ -60,8 +59,7 @@ public abstract class Node * @param pubSubManager The PubSubManager for the connection the node is associated with * @param nodeId The node id */ - Node(PubSubManager pubSubManager, String nodeId) - { + Node(PubSubManager pubSubManager, String nodeId) { this.pubSubManager = pubSubManager; id = nodeId; } @@ -71,8 +69,7 @@ public abstract class Node * * @return the node id */ - public String getId() - { + public String getId() { return id; } /** @@ -85,8 +82,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension( PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER); Stanza reply = sendPubsubPacket(pubSub); @@ -102,8 +98,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub packet = createPubsubPacket(Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); @@ -118,8 +113,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = new DiscoverInfo(); info.setTo(pubSubManager.getServiceJid()); info.setNode(getId()); @@ -136,8 +130,7 @@ public abstract class Node * @throws InterruptedException * */ - public List getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return getSubscriptions(null, null); } @@ -365,8 +358,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub pubSub = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId())); PubSub reply = sendPubsubPacket(pubSub); return reply.getExtension(PubSubElementType.SUBSCRIPTION); @@ -394,8 +386,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId())); request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm)); PubSub reply = sendPubsubPacket(request); @@ -414,8 +405,7 @@ public abstract class Node * @throws InterruptedException * */ - public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void unsubscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { unsubscribe(jid, null); } @@ -429,8 +419,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { sendPubsubPacket(createPubsubPacket(Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId))); } @@ -446,8 +435,7 @@ public abstract class Node * @throws NotConnectedException * @throws InterruptedException */ - public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public SubscribeForm getSubscriptionOptions(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return getSubscriptionOptions(jid, null); } @@ -465,8 +453,7 @@ public abstract class Node * @throws InterruptedException * */ - public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub packet = sendPubsubPacket(createPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId))); FormNode ext = packet.getExtension(PubSubElementType.OPTIONS); return new SubscribeForm(ext.getForm()); @@ -480,8 +467,7 @@ public abstract class Node * @param listener The handler for the event */ @SuppressWarnings("unchecked") - public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) - { + public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) { StanzaListener conListener = new ItemEventTranslator(listener); itemEventToListenerMap.put(listener, conListener); pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item")); @@ -492,8 +478,7 @@ public abstract class Node * * @param listener The handler to unregister */ - public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) - { + public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) { StanzaListener conListener = itemEventToListenerMap.remove(listener); if (conListener != null) @@ -506,8 +491,7 @@ public abstract class Node * * @param listener The handler for the event */ - public void addConfigurationListener(NodeConfigListener listener) - { + public void addConfigurationListener(NodeConfigListener listener) { StanzaListener conListener = new NodeConfigTranslator(listener); configEventToListenerMap.put(listener, conListener); pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.configuration.toString())); @@ -518,8 +502,7 @@ public abstract class Node * * @param listener The handler to unregister */ - public void removeConfigurationListener(NodeConfigListener listener) - { + public void removeConfigurationListener(NodeConfigListener listener) { StanzaListener conListener = configEventToListenerMap .remove(listener); if (conListener != null) @@ -532,8 +515,7 @@ public abstract class Node * * @param listener The handler for the event */ - public void addItemDeleteListener(ItemDeleteListener listener) - { + public void addItemDeleteListener(ItemDeleteListener listener) { StanzaListener delListener = new ItemDeleteTranslator(listener); itemDeleteToListenerMap.put(listener, delListener); EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract"); @@ -547,8 +529,7 @@ public abstract class Node * * @param listener The handler to unregister */ - public void removeItemDeleteListener(ItemDeleteListener listener) - { + public void removeItemDeleteListener(ItemDeleteListener listener) { StanzaListener conListener = itemDeleteToListenerMap .remove(listener); if (conListener != null) @@ -556,38 +537,31 @@ public abstract class Node } @Override - public String toString() - { + public String toString() { return super.toString() + " " + getClass().getName() + " id: " + id; } - protected PubSub createPubsubPacket(Type type, ExtensionElement ext) - { + protected PubSub createPubsubPacket(Type type, ExtensionElement ext) { return createPubsubPacket(type, ext, null); } - protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns) - { + protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns) { return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext, ns); } - protected PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + protected PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return pubSubManager.sendPubsubPacket(packet); } - private static List getSubscriptionIds(Stanza packet) - { + private static List getSubscriptionIds(Stanza packet) { HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim"); List values = null; - if (headers != null) - { + if (headers != null) { values = new ArrayList<>(headers.getHeaders().size()); - for (Header header : headers.getHeaders()) - { + for (Header header : headers.getHeaders()) { values.add(header.getValue()); } } @@ -600,20 +574,17 @@ public abstract class Node * * @author Robin Collier */ - public static class ItemEventTranslator implements StanzaListener - { + public static class ItemEventTranslator implements StanzaListener { @SuppressWarnings("rawtypes") private final ItemEventListener listener; - public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener) - { + public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener) { listener = eventListener; } @Override @SuppressWarnings({ "rawtypes", "unchecked" }) - public void processStanza(Stanza packet) - { + public void processStanza(Stanza packet) { EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); ItemsExtension itemsElem = (ItemsExtension) event.getEvent(); ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet)); @@ -627,36 +598,30 @@ public abstract class Node * * @author Robin Collier */ - public static class ItemDeleteTranslator implements StanzaListener - { + public static class ItemDeleteTranslator implements StanzaListener { private final ItemDeleteListener listener; - public ItemDeleteTranslator(ItemDeleteListener eventListener) - { + public ItemDeleteTranslator(ItemDeleteListener eventListener) { listener = eventListener; } @Override - public void processStanza(Stanza packet) - { + public void processStanza(Stanza packet) { // CHECKSTYLE:OFF EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); List extList = event.getExtensions(); - if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) - { + if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) { listener.handlePurge(); } - else - { + else { ItemsExtension itemsElem = (ItemsExtension)event.getEvent(); @SuppressWarnings("unchecked") Collection pubItems = (Collection) itemsElem.getItems(); List items = new ArrayList<>(pubItems.size()); - for (RetractItem item : pubItems) - { + for (RetractItem item : pubItems) { items.add(item.getId()); } @@ -673,18 +638,15 @@ public abstract class Node * * @author Robin Collier */ - public static class NodeConfigTranslator implements StanzaListener - { + public static class NodeConfigTranslator implements StanzaListener { private final NodeConfigListener listener; - public NodeConfigTranslator(NodeConfigListener eventListener) - { + public NodeConfigTranslator(NodeConfigListener eventListener) { listener = eventListener; } @Override - public void processStanza(Stanza packet) - { + public void processStanza(Stanza packet) { EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); ConfigurationEvent config = (ConfigurationEvent) event.getEvent(); @@ -698,19 +660,16 @@ public abstract class Node * * @author Robin Collier */ - class EventContentFilter extends FlexibleStanzaTypeFilter - { + class EventContentFilter extends FlexibleStanzaTypeFilter { private final String firstElement; private final String secondElement; private final boolean allowEmpty; - EventContentFilter(String elementName) - { + EventContentFilter(String elementName) { this(elementName, null); } - EventContentFilter(String firstLevelElement, String secondLevelElement) - { + EventContentFilter(String firstLevelElement, String secondLevelElement) { firstElement = firstLevelElement; secondElement = secondLevelElement; allowEmpty = firstElement.equals(EventElementType.items.toString()) @@ -729,16 +688,14 @@ public abstract class Node if (embedEvent == null) return false; - if (embedEvent.getElementName().equals(firstElement)) - { + if (embedEvent.getElementName().equals(firstElement)) { if (!embedEvent.getNode().equals(getId())) return false; if (secondElement == null) return true; - if (embedEvent instanceof EmbeddedPacketExtension) - { + if (embedEvent instanceof EmbeddedPacketExtension) { List secondLevelList = ((EmbeddedPacketExtension) embedEvent).getExtensions(); // XEP-0060 allows no elements on second level for notifications. See schema or diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeEvent.java index 67b861f7a..d0ccff912 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeEvent.java @@ -16,17 +16,14 @@ */ package org.jivesoftware.smackx.pubsub; -public abstract class NodeEvent -{ +public abstract class NodeEvent { private String nodeId; - protected NodeEvent(String id) - { + protected NodeEvent(String id) { nodeId = id; } - public String getNodeId() - { + public String getNodeId() { return nodeId; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java index 41393b7f6..fd6667c79 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java @@ -26,8 +26,7 @@ import org.jivesoftware.smack.packet.ExtensionElement; * * @author Robin Collier */ -public class NodeExtension implements ExtensionElement -{ +public class NodeExtension implements ExtensionElement { private final PubSubElementType element; private final String node; @@ -38,8 +37,7 @@ public class NodeExtension implements ExtensionElement * @param elem Defines the element name and namespace * @param nodeId Specifies the id of the node */ - public NodeExtension(PubSubElementType elem, String nodeId) - { + public NodeExtension(PubSubElementType elem, String nodeId) { element = elem; this.node = nodeId; } @@ -50,8 +48,7 @@ public class NodeExtension implements ExtensionElement * * @param elem Defines the element name and namespace */ - public NodeExtension(PubSubElementType elem) - { + public NodeExtension(PubSubElementType elem) { this(elem, null); } @@ -60,32 +57,27 @@ public class NodeExtension implements ExtensionElement * * @return The node id */ - public String getNode() - { + public String getNode() { return node; } @Override - public String getElementName() - { + public String getElementName() { return element.getElementName(); } @Override - public String getNamespace() - { + public String getNamespace() { return element.getNamespace().getXmlns(); } @Override - public CharSequence toXML() - { + public CharSequence toXML() { return '<' + getElementName() + (node == null ? "" : " node='" + node + '\'') + "/>"; } @Override - public String toString() - { + public String toString() { return getClass().getName() + " - content [" + toXML() + "]"; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeType.java index 35efd39a6..ff5f8a936 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeType.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeType.java @@ -21,8 +21,7 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum NodeType -{ +public enum NodeType { leaf, collection } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/OptionsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/OptionsExtension.java index 82dce9a4c..9e1903a36 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/OptionsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/OptionsExtension.java @@ -23,35 +23,29 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Robin Collier */ -public class OptionsExtension extends NodeExtension -{ +public class OptionsExtension extends NodeExtension { protected String jid; protected String id; - public OptionsExtension(String subscriptionJid) - { + public OptionsExtension(String subscriptionJid) { this(subscriptionJid, null, null); } - public OptionsExtension(String subscriptionJid, String nodeId) - { + public OptionsExtension(String subscriptionJid, String nodeId) { this(subscriptionJid, nodeId, null); } - public OptionsExtension(String jid, String nodeId, String subscriptionId) - { + public OptionsExtension(String jid, String nodeId, String subscriptionId) { super(PubSubElementType.OPTIONS, nodeId); this.jid = jid; id = subscriptionId; } - public String getJid() - { + public String getJid() { return jid; } - public String getId() - { + public String getId() { return id; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java index d21443553..6fb8aef42 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java @@ -48,8 +48,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider; * * @author Robin Collier */ -public class PayloadItem extends Item -{ +public class PayloadItem extends Item { private final E payload; /** @@ -57,8 +56,7 @@ public class PayloadItem extends Item * * @param payloadExt A {@link ExtensionElement} which represents the payload data. */ - public PayloadItem(E payloadExt) - { + public PayloadItem(E payloadExt) { super(); if (payloadExt == null) @@ -72,8 +70,7 @@ public class PayloadItem extends Item * @param itemId The id of this item. It can be null if we want the server to set the id. * @param payloadExt A {@link ExtensionElement} which represents the payload data. */ - public PayloadItem(String itemId, E payloadExt) - { + public PayloadItem(String itemId, E payloadExt) { super(itemId); if (payloadExt == null) @@ -95,8 +92,7 @@ public class PayloadItem extends Item * @param nodeId The id of the node the item was published to. * @param payloadExt A {@link ExtensionElement} which represents the payload data. */ - public PayloadItem(String itemId, String nodeId, E payloadExt) - { + public PayloadItem(String itemId, String nodeId, E payloadExt) { super(itemId, nodeId); if (payloadExt == null) @@ -110,18 +106,15 @@ public class PayloadItem extends Item * * @return The payload as a {@link ExtensionElement}. */ - public E getPayload() - { + public E getPayload() { return payload; } @Override - public String toXML() - { + public String toXML() { StringBuilder builder = new StringBuilder(" extends Item } @Override - public String toString() - { + public String toString() { return getClass().getName() + " | Content [" + toXML() + "]"; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PresenceState.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PresenceState.java index f6ca9f928..f05e92cab 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PresenceState.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PresenceState.java @@ -22,7 +22,6 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum PresenceState -{ +public enum PresenceState { chat, online, away, xa, dnd } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubElementType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubElementType.java index f786681eb..d6f1cac8a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubElementType.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubElementType.java @@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; * * @author Robin Collier */ -public enum PubSubElementType -{ +public enum PubSubElementType { CREATE("create", PubSubNamespace.BASIC), DELETE("delete", PubSubNamespace.OWNER), DELETE_EVENT("delete", PubSubNamespace.EVENT), @@ -54,29 +53,24 @@ public enum PubSubElementType private final String eName; private final PubSubNamespace nSpace; - PubSubElementType(String elemName, PubSubNamespace ns) - { + PubSubElementType(String elemName, PubSubNamespace ns) { eName = elemName; nSpace = ns; } - public PubSubNamespace getNamespace() - { + public PubSubNamespace getNamespace() { return nSpace; } - public String getElementName() - { + public String getElementName() { return eName; } - public static PubSubElementType valueOfFromElemName(String elemName, String namespace) - { + public static PubSubElementType valueOfFromElemName(String elemName, String namespace) { int index = namespace.lastIndexOf('#'); String fragment = (index == -1 ? null : namespace.substring(index + 1)); - if (fragment != null) - { + if (fragment != null) { return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US)); } return valueOf(elemName.toUpperCase(Locale.US).replace('-', '_')); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java index 75078750e..df7d9320c 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java @@ -141,8 +141,7 @@ public final class PubSubManager extends Manager { * @param connection The XMPP connection * @param toAddress The pubsub specific to address (required for some servers) */ - PubSubManager(XMPPConnection connection, BareJid toAddress) - { + PubSubManager(XMPPConnection connection, BareJid toAddress) { super(connection); pubSubService = toAddress; } @@ -156,8 +155,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null); NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns()); @@ -178,8 +176,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public LeafNode createNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public LeafNode createNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return (LeafNode) createNode(nodeId, null); } @@ -197,13 +194,11 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public Node createNode(String nodeId, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public Node createNode(String nodeId, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId), null); boolean isLeafNode = true; - if (config != null) - { + if (config != null) { request.addExtension(new FormNode(FormNodeType.CONFIGURE, config)); FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName()); @@ -234,12 +229,10 @@ public final class PubSubManager extends Manager { * @throws InterruptedException * @throws NotAPubSubNodeException */ - public T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException - { + public T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { Node node = nodeMap.get(id); - if (node == null) - { + if (node == null) { DiscoverInfo info = new DiscoverInfo(); info.setTo(pubSubService); info.setNode(id); @@ -429,8 +422,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems items = new DiscoverItems(); if (nodeId != null) @@ -449,8 +441,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public List getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null); SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); return subElem.getSubscriptions(); @@ -466,8 +457,7 @@ public final class PubSubManager extends Manager { * @throws InterruptedException * */ - public List getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public List getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null); AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS); return listElem.getAffiliations(); @@ -482,8 +472,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace()); nodeMap.remove(nodeId); } @@ -497,8 +486,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Errors will cause exceptions in getReply, so it only returns // on success. PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace()); @@ -524,8 +512,7 @@ public final class PubSubManager extends Manager { * @throws NotConnectedException * @throws InterruptedException */ - public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(connection()); return mgr.discoverInfo(pubSubService); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishItem.java index 560906230..16638f578 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishItem.java @@ -24,8 +24,7 @@ import java.util.Collection; * * @author Robin Collier */ -public class PublishItem extends NodeExtension -{ +public class PublishItem extends NodeExtension { protected Collection items; /** @@ -34,8 +33,7 @@ public class PublishItem extends NodeExtension * @param nodeId The node to publish to * @param toPublish The {@link Item} to publish */ - public PublishItem(String nodeId, T toPublish) - { + public PublishItem(String nodeId, T toPublish) { super(PubSubElementType.PUBLISH, nodeId); items = new ArrayList<>(1); items.add(toPublish); @@ -47,23 +45,20 @@ public class PublishItem extends NodeExtension * @param nodeId The node to publish to * @param toPublish The list of {@link Item} to publish */ - public PublishItem(String nodeId, Collection toPublish) - { + public PublishItem(String nodeId, Collection toPublish) { super(PubSubElementType.PUBLISH, nodeId); items = toPublish; } @Override - public String toXML() - { + public String toXML() { StringBuilder builder = new StringBuilder("<"); builder.append(getElementName()); builder.append(" node='"); builder.append(getNode()); builder.append("'>"); - for (Item item : items) - { + for (Item item : items) { builder.append(item.toXML()); } builder.append(""); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishModel.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishModel.java index 7342dcc6e..b5da5c30b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishModel.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PublishModel.java @@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public enum PublishModel -{ +public enum PublishModel { /** Only publishers may publish. */ publishers, diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java index 2b8ff321f..ab01ef5c4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/RetractItem.java @@ -25,8 +25,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; * * @author Robin Collier */ -public class RetractItem implements ExtensionElement -{ +public class RetractItem implements ExtensionElement { private final String id; /** @@ -34,33 +33,28 @@ public class RetractItem implements ExtensionElement * * @param itemId The id if the item deleted */ - public RetractItem(String itemId) - { + public RetractItem(String itemId) { if (itemId == null) throw new IllegalArgumentException("itemId must not be 'null'"); id = itemId; } - public String getId() - { + public String getId() { return id; } @Override - public String getElementName() - { + public String getElementName() { return "retract"; } @Override - public String getNamespace() - { + public String getNamespace() { return PubSubNamespace.EVENT.getXmlns(); } @Override - public String toXML() - { + public String toXML() { return ""; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java index 1e747f62d..9fc523a37 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SimplePayload.java @@ -24,8 +24,7 @@ import org.jivesoftware.smack.packet.ExtensionElement; * * @author Robin Collier */ -public class SimplePayload implements ExtensionElement -{ +public class SimplePayload implements ExtensionElement { private final String elemName; private final String ns; private final CharSequence payload; @@ -38,34 +37,29 @@ public class SimplePayload implements ExtensionElement * @param namespace The namespace of the payload, null if there is none * @param xmlPayload The payload data */ - public SimplePayload(String elementName, String namespace, CharSequence xmlPayload) - { + public SimplePayload(String elementName, String namespace, CharSequence xmlPayload) { elemName = elementName; payload = xmlPayload; ns = namespace; } @Override - public String getElementName() - { + public String getElementName() { return elemName; } @Override - public String getNamespace() - { + public String getNamespace() { return ns; } @Override - public CharSequence toXML() - { + public CharSequence toXML() { return payload; } @Override - public String toString() - { + public String toString() { return getClass().getName() + "payload [" + toXML() + "]"; } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java index ca4f82b6a..90da90d89 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeExtension.java @@ -21,35 +21,29 @@ package org.jivesoftware.smackx.pubsub; * * @author Robin Collier */ -public class SubscribeExtension extends NodeExtension -{ +public class SubscribeExtension extends NodeExtension { protected String jid; - public SubscribeExtension(String subscribeJid) - { + public SubscribeExtension(String subscribeJid) { super(PubSubElementType.SUBSCRIBE); jid = subscribeJid; } - public SubscribeExtension(String subscribeJid, String nodeId) - { + public SubscribeExtension(String subscribeJid, String nodeId) { super(PubSubElementType.SUBSCRIBE, nodeId); jid = subscribeJid; } - public String getJid() - { + public String getJid() { return jid; } @Override - public String toXML() - { + public String toXML() { StringBuilder builder = new StringBuilder("<"); builder.append(getElementName()); - if (getNode() != null) - { + if (getNode() != null) { builder.append(" node='"); builder.append(getNode()); builder.append('\''); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java index 74f3f54e4..fbfab6af1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java @@ -39,20 +39,16 @@ import org.jxmpp.util.XmppDateTime; * * @author Robin Collier */ -public class SubscribeForm extends Form -{ - public SubscribeForm(DataForm configDataForm) - { +public class SubscribeForm extends Form { + public SubscribeForm(DataForm configDataForm) { super(configDataForm); } - public SubscribeForm(Form subscribeOptionsForm) - { + public SubscribeForm(Form subscribeOptionsForm) { super(subscribeOptionsForm.getDataFormToSend()); } - public SubscribeForm(DataForm.Type formType) - { + public SubscribeForm(DataForm.Type formType) { super(formType); } @@ -61,8 +57,7 @@ public class SubscribeForm extends Form * * @return true if want to receive, false otherwise */ - public boolean isDeliverOn() - { + public boolean isDeliverOn() { return parseBoolean(getFieldValue(SubscribeOptionFields.deliver)); } @@ -71,8 +66,7 @@ public class SubscribeForm extends Form * * @param deliverNotifications */ - public void setDeliverOn(boolean deliverNotifications) - { + public void setDeliverOn(boolean deliverNotifications) { addField(SubscribeOptionFields.deliver, FormField.Type.bool); setAnswer(SubscribeOptionFields.deliver.getFieldName(), deliverNotifications); } @@ -82,8 +76,7 @@ public class SubscribeForm extends Form * * @return true to aggregate, false otherwise */ - public boolean isDigestOn() - { + public boolean isDigestOn() { return parseBoolean(getFieldValue(SubscribeOptionFields.digest)); } @@ -92,8 +85,7 @@ public class SubscribeForm extends Form * * @param digestOn true to aggregate, false otherwise */ - public void setDigestOn(boolean digestOn) - { + public void setDigestOn(boolean digestOn) { addField(SubscribeOptionFields.deliver, FormField.Type.bool); setAnswer(SubscribeOptionFields.deliver.getFieldName(), digestOn); } @@ -103,8 +95,7 @@ public class SubscribeForm extends Form * * @return The frequency in milliseconds */ - public int getDigestFrequency() - { + public int getDigestFrequency() { return Integer.parseInt(getFieldValue(SubscribeOptionFields.digest_frequency)); } @@ -113,8 +104,7 @@ public class SubscribeForm extends Form * * @param frequency The frequency in milliseconds */ - public void setDigestFrequency(int frequency) - { + public void setDigestFrequency(int frequency) { addField(SubscribeOptionFields.digest_frequency, FormField.Type.text_single); setAnswer(SubscribeOptionFields.digest_frequency.getFieldName(), frequency); } @@ -124,15 +114,12 @@ public class SubscribeForm extends Form * * @return The expiry date */ - public Date getExpiry() - { + public Date getExpiry() { String dateTime = getFieldValue(SubscribeOptionFields.expire); - try - { + try { return XmppDateTime.parseDate(dateTime); } - catch (ParseException e) - { + catch (ParseException e) { UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime); exc.initCause(e); throw exc; @@ -144,8 +131,7 @@ public class SubscribeForm extends Form * * @param expire The expiry date */ - public void setExpiry(Date expire) - { + public void setExpiry(Date expire) { addField(SubscribeOptionFields.expire, FormField.Type.text_single); setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire)); } @@ -156,8 +142,7 @@ public class SubscribeForm extends Form * * @return true to receive the message body, false otherwise */ - public boolean isIncludeBody() - { + public boolean isIncludeBody() { return parseBoolean(getFieldValue(SubscribeOptionFields.include_body)); } @@ -167,8 +152,7 @@ public class SubscribeForm extends Form * * @param include true to receive the message body, false otherwise */ - public void setIncludeBody(boolean include) - { + public void setIncludeBody(boolean include) { addField(SubscribeOptionFields.include_body, FormField.Type.bool); setAnswer(SubscribeOptionFields.include_body.getFieldName(), include); } @@ -179,12 +163,10 @@ public class SubscribeForm extends Form * * @return the list of states */ - public List getShowValues() - { + public List getShowValues() { ArrayList result = new ArrayList<>(5); - for (String state : getFieldValues(SubscribeOptionFields.show_values)) - { + for (String state : getFieldValues(SubscribeOptionFields.show_values)) { result.add(PresenceState.valueOf(state)); } return result; @@ -196,12 +178,10 @@ public class SubscribeForm extends Form * * @param stateValues The list of states */ - public void setShowValues(Collection stateValues) - { + public void setShowValues(Collection stateValues) { ArrayList values = new ArrayList<>(stateValues.size()); - for (PresenceState state : stateValues) - { + for (PresenceState state : stateValues) { values.add(state.toString()); } addField(SubscribeOptionFields.show_values, FormField.Type.list_multi); @@ -209,31 +189,26 @@ public class SubscribeForm extends Form } - private static boolean parseBoolean(String fieldValue) - { + private static boolean parseBoolean(String fieldValue) { return ("1".equals(fieldValue) || "true".equals(fieldValue)); } - private String getFieldValue(SubscribeOptionFields field) - { + private String getFieldValue(SubscribeOptionFields field) { FormField formField = getField(field.getFieldName()); return formField.getValues().get(0); } - private List getFieldValues(SubscribeOptionFields field) - { + private List getFieldValues(SubscribeOptionFields field) { FormField formField = getField(field.getFieldName()); return formField.getValues(); } - private void addField(SubscribeOptionFields nodeField, FormField.Type type) - { + private void addField(SubscribeOptionFields nodeField, FormField.Type type) { String fieldName = nodeField.getFieldName(); - if (getField(fieldName) == null) - { + if (getField(fieldName) == null) { FormField field = new FormField(fieldName); field.setType(type); addField(field); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeOptionFields.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeOptionFields.java index 3929c43db..2bbec515e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeOptionFields.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeOptionFields.java @@ -24,8 +24,7 @@ import java.util.Calendar; * * @author Robin Collier */ -public enum SubscribeOptionFields -{ +public enum SubscribeOptionFields { /** * Whether an entity wants to receive or disable notifications. * @@ -83,15 +82,13 @@ public enum SubscribeOptionFields */ subscription_depth; - public String getFieldName() - { + public String getFieldName() { if (this == show_values) return "pubsub#" + toString().replace('_', '-'); return "pubsub#" + toString(); } - public static SubscribeOptionFields valueOfFromElement(String elementName) - { + public static SubscribeOptionFields valueOfFromElement(String elementName) { String portion = elementName.substring(elementName.lastIndexOf('#' + 1)); if ("show-values".equals(portion)) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Subscription.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Subscription.java index c0eb5e26c..144dc308d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Subscription.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Subscription.java @@ -25,15 +25,13 @@ import org.jxmpp.jid.Jid; * * @author Robin Collier */ -public class Subscription extends NodeExtension -{ +public class Subscription extends NodeExtension { protected Jid jid; protected String id; protected State state; protected boolean configRequired = false; - public enum State - { + public enum State { subscribed, unconfigured, pending, none } @@ -43,8 +41,7 @@ public class Subscription extends NodeExtension * * @param subscriptionJid The subscriber JID */ - public Subscription(Jid subscriptionJid) - { + public Subscription(Jid subscriptionJid) { this(subscriptionJid, null, null, null); } @@ -55,8 +52,7 @@ public class Subscription extends NodeExtension * @param subscriptionJid The subscriber JID * @param nodeId The node id */ - public Subscription(Jid subscriptionJid, String nodeId) - { + public Subscription(Jid subscriptionJid, String nodeId) { this(subscriptionJid, nodeId, null, null); } @@ -69,8 +65,7 @@ public class Subscription extends NodeExtension * @param subscriptionId The id of this subscription * @param state The current state of the subscription */ - public Subscription(Jid jid, String nodeId, String subscriptionId, State state) - { + public Subscription(Jid jid, String nodeId, String subscriptionId, State state) { super(PubSubElementType.SUBSCRIPTION, nodeId); this.jid = jid; id = subscriptionId; @@ -88,8 +83,7 @@ public class Subscription extends NodeExtension * @param state The current state of the subscription * @param configRequired Is configuration required to complete the subscription */ - public Subscription(Jid jid, String nodeId, String subscriptionId, State state, boolean configRequired) - { + public Subscription(Jid jid, String nodeId, String subscriptionId, State state, boolean configRequired) { super(PubSubElementType.SUBSCRIPTION, nodeId); this.jid = jid; id = subscriptionId; @@ -102,8 +96,7 @@ public class Subscription extends NodeExtension * * @return The JID */ - public Jid getJid() - { + public Jid getJid() { return jid; } @@ -112,8 +105,7 @@ public class Subscription extends NodeExtension * * @return The subscription id */ - public String getId() - { + public String getId() { return id; } @@ -122,8 +114,7 @@ public class Subscription extends NodeExtension * * @return Current subscription state */ - public State getState() - { + public State getState() { return state; } @@ -132,14 +123,12 @@ public class Subscription extends NodeExtension * * @return true if configuration is required, false otherwise */ - public boolean isConfigRequired() - { + public boolean isConfigRequired() { return configRequired; } @Override - public XmlStringBuilder toXML() - { + public XmlStringBuilder toXML() { XmlStringBuilder builder = new XmlStringBuilder(this); builder.attribute("jid", jid); @@ -151,8 +140,7 @@ public class Subscription extends NodeExtension return builder; } - private static void appendAttribute(StringBuilder builder, String att, String value) - { + private static void appendAttribute(StringBuilder builder, String att, String value) { builder.append(' '); builder.append(att); builder.append("='"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionEvent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionEvent.java index 72b8f1859..c00f0db35 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionEvent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionEvent.java @@ -24,8 +24,7 @@ import java.util.List; * * @author Robin Collier */ -public abstract class SubscriptionEvent extends NodeEvent -{ +public abstract class SubscriptionEvent extends NodeEvent { private List subIds = Collections.emptyList(); /** @@ -36,8 +35,7 @@ public abstract class SubscriptionEvent extends NodeEvent * * @param nodeId The id of the node the event came from */ - protected SubscriptionEvent(String nodeId) - { + protected SubscriptionEvent(String nodeId) { super(nodeId); } @@ -47,8 +45,7 @@ public abstract class SubscriptionEvent extends NodeEvent * @param nodeId The id of the node the event came from * @param subscriptionIds The list of subscription id's */ - protected SubscriptionEvent(String nodeId, List subscriptionIds) - { + protected SubscriptionEvent(String nodeId, List subscriptionIds) { super(nodeId); if (subscriptionIds != null) @@ -60,8 +57,7 @@ public abstract class SubscriptionEvent extends NodeEvent * * @return List of subscription id's */ - public List getSubscriptions() - { + public List getSubscriptions() { return Collections.unmodifiableList(subIds); } @@ -70,8 +66,7 @@ public abstract class SubscriptionEvent extends NodeEvent * * @param subscriptionIds The list of subscription id's */ - protected void setSubscriptions(List subscriptionIds) - { + protected void setSubscriptions(List subscriptionIds) { if (subscriptionIds != null) subIds = subscriptionIds; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionsExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionsExtension.java index 59b64f16f..ec70ce2f1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionsExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscriptionsExtension.java @@ -24,8 +24,7 @@ import java.util.List; * * @author Robin Collier */ -public class SubscriptionsExtension extends NodeExtension -{ +public class SubscriptionsExtension extends NodeExtension { protected List items = Collections.emptyList(); /** @@ -33,8 +32,7 @@ public class SubscriptionsExtension extends NodeExtension * * @param subList The list of subscriptions */ - public SubscriptionsExtension(List subList) - { + public SubscriptionsExtension(List subList) { super(PubSubElementType.SUBSCRIPTIONS); if (subList != null) @@ -47,8 +45,7 @@ public class SubscriptionsExtension extends NodeExtension * @param nodeId The node subscribed to * @param subList The list of subscriptions */ - public SubscriptionsExtension(String nodeId, List subList) - { + public SubscriptionsExtension(String nodeId, List subList) { super(PubSubElementType.SUBSCRIPTIONS, nodeId); if (subList != null) @@ -60,33 +57,27 @@ public class SubscriptionsExtension extends NodeExtension * * @return List of subscriptions */ - public List getSubscriptions() - { + public List getSubscriptions() { return items; } @Override - public CharSequence toXML() - { - if ((items == null) || (items.size() == 0)) - { + public CharSequence toXML() { + if ((items == null) || (items.size() == 0)) { return super.toXML(); } - else - { + else { StringBuilder builder = new StringBuilder("<"); builder.append(getElementName()); - if (getNode() != null) - { + if (getNode() != null) { builder.append(" node='"); builder.append(getNode()); builder.append('\''); } builder.append('>'); - for (Subscription item : items) - { + for (Subscription item : items) { builder.append(item.toXML()); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/UnsubscribeExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/UnsubscribeExtension.java index 0e4d9c009..810752f74 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/UnsubscribeExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/UnsubscribeExtension.java @@ -24,35 +24,29 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Robin Collier */ -public class UnsubscribeExtension extends NodeExtension -{ +public class UnsubscribeExtension extends NodeExtension { protected String jid; protected String id; - public UnsubscribeExtension(String subscriptionJid) - { + public UnsubscribeExtension(String subscriptionJid) { this(subscriptionJid, null, null); } - public UnsubscribeExtension(String subscriptionJid, String nodeId) - { + public UnsubscribeExtension(String subscriptionJid, String nodeId) { this(subscriptionJid, nodeId, null); } - public UnsubscribeExtension(String jid, String nodeId, String subscriptionId) - { + public UnsubscribeExtension(String jid, String nodeId, String subscriptionId) { super(PubSubElementType.UNSUBSCRIBE, nodeId); this.jid = jid; id = subscriptionId; } - public String getJid() - { + public String getJid() { return jid; } - public String getId() - { + public String getId() { return id; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemDeleteListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemDeleteListener.java index 7b72ae52e..43879f38f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemDeleteListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemDeleteListener.java @@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode; * * @author Robin Collier */ -public interface ItemDeleteListener -{ +public interface ItemDeleteListener { /** * Called when items are deleted from a node the listener is * registered with. diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemEventListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemEventListener.java index 6d4c6a9a4..4e4c3aae7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemEventListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/ItemEventListener.java @@ -27,8 +27,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode; * * @author Robin Collier */ -public interface ItemEventListener -{ +public interface ItemEventListener { /** * Called whenever an item is published to the node the listener * is registered with. diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/NodeConfigListener.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/NodeConfigListener.java index 03bd71d9a..c9fa39be7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/NodeConfigListener.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/listener/NodeConfigListener.java @@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode; * * @author Robin Collier */ -public interface NodeConfigListener -{ +public interface NodeConfigListener { /** * Called whenever the node the listener * is registered with is configured. diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java index 24dc778ac..4e0ebea7b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java @@ -30,8 +30,7 @@ import org.jxmpp.jid.Jid; * * @author Robin Collier */ -public class PubSub extends IQ -{ +public class PubSub extends IQ { public static final String ELEMENT = "pubsub"; public static final String NAMESPACE = "http://jabber.org/protocol/pubsub"; @@ -50,8 +49,7 @@ public class PubSub extends IQ } @SuppressWarnings("unchecked") - public PE getExtension(PubSubElementType elem) - { + public PE getExtension(PubSubElementType elem) { return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSubNamespace.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSubNamespace.java index 211c18111..83d319420 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSubNamespace.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSubNamespace.java @@ -42,22 +42,18 @@ public enum PubSubNamespace { } } - public String getXmlns() - { + public String getXmlns() { return fullNamespace; } - public String getFragment() - { + public String getFragment() { return fragment; } - public static PubSubNamespace valueOfFromXmlns(String ns) - { + public static PubSubNamespace valueOfFromXmlns(String ns) { int index = ns.lastIndexOf('#'); - if (index != -1) - { + if (index != -1) { String suffix = ns.substring(ns.lastIndexOf('#') + 1); return valueOf(suffix.toUpperCase(Locale.US)); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java index 24789d314..14bf80dee 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/AffiliationsProvider.java @@ -30,12 +30,10 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension; * as specified in the affiliation schema. * * @author Robin Collier - */public class AffiliationsProvider extends EmbeddedExtensionProvider -{ + */public class AffiliationsProvider extends EmbeddedExtensionProvider { @SuppressWarnings("unchecked") @Override - protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new AffiliationsExtension((List) content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java index 35c7a98a1..55119989b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ConfigEventProvider.java @@ -32,11 +32,9 @@ import org.jivesoftware.smackx.xdata.packet.DataForm; * * @author Robin Collier */ -public class ConfigEventProvider extends EmbeddedExtensionProvider -{ +public class ConfigEventProvider extends EmbeddedExtensionProvider { @Override - protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) - { + protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { if (content.size() == 0) return new ConfigurationEvent(attMap.get("node")); else diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java index dc42b6065..af09a2bc9 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/EventProvider.java @@ -32,11 +32,9 @@ import org.jivesoftware.smackx.pubsub.NodeExtension; * * @author Robin Collier */ -public class EventProvider extends EmbeddedExtensionProvider -{ +public class EventProvider extends EmbeddedExtensionProvider { @Override - protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) - { + protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map attMap, List content) { return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension) content.get(0)); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java index 931b600d8..955df1022 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/FormNodeProvider.java @@ -33,11 +33,9 @@ import org.jivesoftware.smackx.xdata.packet.DataForm; * * @author Robin Collier */ -public class FormNodeProvider extends EmbeddedExtensionProvider -{ +public class FormNodeProvider extends EmbeddedExtensionProvider { @Override - protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm) content.iterator().next())); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index e40d63374..1f078cef2 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -36,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -public class ItemProvider extends ExtensionElementProvider -{ +public class ItemProvider extends ExtensionElementProvider { @Override public Item parse(XmlPullParser parser, int initialDepth) throws Exception { @@ -46,23 +45,19 @@ public class ItemProvider extends ExtensionElementProvider int tag = parser.next(); - if (tag == XmlPullParser.END_TAG) - { + if (tag == XmlPullParser.END_TAG) { return new Item(id, node); } - else - { + else { String payloadElemName = parser.getName(); String payloadNS = parser.getNamespace(); final ExtensionElementProvider extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); - if (extensionProvider == null) - { + if (extensionProvider == null) { CharSequence payloadText = PacketParserUtils.parseElement(parser, true); return new PayloadItem<>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText)); } - else - { + else { return new PayloadItem<>(id, node, extensionProvider.parse(parser)); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java index d9f2af582..69e7c6fec 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemsProvider.java @@ -30,12 +30,10 @@ import org.jivesoftware.smackx.pubsub.ItemsExtension; * * @author Robin Collier */ -public class ItemsProvider extends EmbeddedExtensionProvider -{ +public class ItemsProvider extends EmbeddedExtensionProvider { @Override - protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java index ef7f62985..f646bec77 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java @@ -31,8 +31,7 @@ import org.xmlpull.v1.XmlPullParser; * * @author Robin Collier */ -public class PubSubProvider extends IQProvider -{ +public class PubSubProvider extends IQProvider { @Override public PubSub parse(XmlPullParser parser, int initialDepth) throws Exception { @@ -40,8 +39,7 @@ public class PubSubProvider extends IQProvider PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSub pubsub = new PubSub(pubSubNamespace); - outerloop: while (true) - { + outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java index 4d00a46a2..d4780af49 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/RetractEventProvider.java @@ -31,11 +31,9 @@ import org.jivesoftware.smackx.pubsub.RetractItem; * * @author Robin Collier */ -public class RetractEventProvider extends EmbeddedExtensionProvider -{ +public class RetractEventProvider extends EmbeddedExtensionProvider { @Override - protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new RetractItem(attributeMap.get("id")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java index aa8db0d9d..719e0720e 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SimpleNodeProvider.java @@ -31,11 +31,9 @@ import org.jivesoftware.smackx.pubsub.PubSubElementType; * * @author Robin Collier */ -public class SimpleNodeProvider extends EmbeddedExtensionProvider -{ +public class SimpleNodeProvider extends EmbeddedExtensionProvider { @Override - protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node")); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java index ac432305b..bb64474fd 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionProvider.java @@ -33,8 +33,7 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Robin Collier */ -public class SubscriptionProvider extends ExtensionElementProvider -{ +public class SubscriptionProvider extends ExtensionElementProvider { @Override public Subscription parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { @@ -46,8 +45,7 @@ public class SubscriptionProvider extends ExtensionElementProvider int tag = parser.next(); - if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options")) - { + if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options")) { tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required")) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java index ab7852ad5..71191adfb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/SubscriptionsProvider.java @@ -31,12 +31,10 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension; * * @author Robin Collier */ -public class SubscriptionsProvider extends EmbeddedExtensionProvider -{ +public class SubscriptionsProvider extends EmbeddedExtensionProvider { @SuppressWarnings("unchecked") @Override - protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) - { + protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map attributeMap, List content) { return new SubscriptionsExtension(attributeMap.get("node"), (List) content); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/util/NodeUtils.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/util/NodeUtils.java index 032e03ae1..d33520677 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/util/NodeUtils.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/util/NodeUtils.java @@ -28,8 +28,7 @@ import org.jivesoftware.smackx.xdata.Form; * * @author Robin Collier */ -public class NodeUtils -{ +public class NodeUtils { /** * Get a {@link ConfigureForm} from a packet. * @@ -37,8 +36,7 @@ public class NodeUtils * @param elem * @return The configuration form */ - public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) - { + public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) { FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java index c7dc3ecc2..9f936771d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceipt.java @@ -31,8 +31,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder; * * @author Georg Lukas */ -public class DeliveryReceipt implements ExtensionElement -{ +public class DeliveryReceipt implements ExtensionElement { public static final String NAMESPACE = "urn:xmpp:receipts"; public static final String ELEMENT = "received"; @@ -41,31 +40,26 @@ public class DeliveryReceipt implements ExtensionElement */ private final String id; - public DeliveryReceipt(String id) - { + public DeliveryReceipt(String id) { this.id = StringUtils.requireNotNullOrEmpty(id, "id must not be null"); } - public String getId() - { + public String getId() { return id; } @Override - public String getElementName() - { + public String getElementName() { return ELEMENT; } @Override - public String getNamespace() - { + public String getNamespace() { return NAMESPACE; } @Override - public XmlStringBuilder toXML() - { + public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("id", id); xml.closeEmptyElement(); @@ -97,13 +91,11 @@ public class DeliveryReceipt implements ExtensionElement /** * This Provider parses and returns DeliveryReceipt packets. */ - public static class Provider extends EmbeddedExtensionProvider - { + public static class Provider extends EmbeddedExtensionProvider { @Override protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace, - Map attributeMap, List content) - { + Map attributeMap, List content) { return new DeliveryReceipt(attributeMap.get("id")); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java index c8f680b1f..eb487ca84 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptRequest.java @@ -33,25 +33,21 @@ import org.xmlpull.v1.XmlPullParserException; * * @author Georg Lukas */ -public class DeliveryReceiptRequest implements ExtensionElement -{ +public class DeliveryReceiptRequest implements ExtensionElement { public static final String ELEMENT = "request"; @Override - public String getElementName() - { + public String getElementName() { return ELEMENT; } @Override - public String getNamespace() - { + public String getNamespace() { return DeliveryReceipt.NAMESPACE; } @Override - public String toXML() - { + public String toXML() { return ""; } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index 5cfe0b302..5c2f6119f 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -44,19 +44,16 @@ import org.junit.Test; * @author Robin Collier * */ -public class ConfigureFormTest extends InitExtensions -{ +public class ConfigureFormTest extends InitExtensions { @Test - public void checkChildrenAssocPolicy() - { + public void checkChildrenAssocPolicy() { ConfigureForm form = new ConfigureForm(DataForm.Type.submit); form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners); assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy()); } @Test - public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException - { + public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException { ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); DiscoverInfo info = new DiscoverInfo(); @@ -75,20 +72,17 @@ public class ConfigureFormTest extends InitExtensions errorIq.setError(error); con.addIQReply(errorIq); - try - { + try { node.getNodeConfiguration(); fail(); } - catch (XMPPErrorException e) - { + catch (XMPPErrorException e) { Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType()); } } @Test(expected = SmackException.class) - public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException - { + public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException { ThreadedDummyConnection con = new ThreadedDummyConnection(); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); DiscoverInfo info = new DiscoverInfo(); diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java index 98e75bd28..97d49b2b8 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ItemValidationTest.java @@ -42,8 +42,7 @@ public class ItemValidationTest extends InitExtensions { private ThreadedDummyConnection connection; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { // Uncomment this to enable debug output // SmackConfiguration.DEBUG = true; @@ -53,15 +52,13 @@ public class ItemValidationTest extends InitExtensions { } @After - public void tearDown() throws Exception - { + public void tearDown() throws Exception { if (connection != null) connection.disconnect(); } @Test - public void verifyBasicItem() throws Exception - { + public void verifyBasicItem() throws Exception { Item simpleItem = new Item(); String simpleCtrl = ""; assertXMLEqual(simpleCtrl, simpleItem.toXML()); @@ -76,8 +73,7 @@ public class ItemValidationTest extends InitExtensions { } @Test - public void verifyPayloadItem() throws Exception - { + public void verifyPayloadItem() throws Exception { SimplePayload payload = new SimplePayload(null, null, "This is the payload"); PayloadItem simpleItem = new PayloadItem<>(payload); @@ -94,8 +90,7 @@ public class ItemValidationTest extends InitExtensions { } @Test - public void parseBasicItem() throws Exception - { + public void parseBasicItem() throws Exception { XmlPullParser parser = PacketParserUtils.getParserFor( "" + "" + @@ -121,8 +116,7 @@ public class ItemValidationTest extends InitExtensions { } @Test - public void parseSimplePayloadItem() throws Exception - { + public void parseSimplePayloadItem() throws Exception { String itemContent = "Some text"; XmlPullParser parser = PacketParserUtils.getParserFor( @@ -154,8 +148,7 @@ public class ItemValidationTest extends InitExtensions { } @Test - public void parseComplexItem() throws Exception - { + public void parseComplexItem() throws Exception { String itemContent = "" + "Soliloquy" + @@ -201,8 +194,7 @@ public class ItemValidationTest extends InitExtensions { } @Test - public void parseEmptyTag() throws Exception - { + public void parseEmptyTag() throws Exception { String itemContent = ""; XmlPullParser parser = PacketParserUtils.getParserFor( diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java index fb1e60f2e..55dafdce6 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java @@ -1015,8 +1015,7 @@ public class AgentSession { * @throws NotConnectedException * @throws InterruptedException */ - public void sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void sendRoomInvitation(RoomInvitation.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason); IQ iq = new RoomInvitation.RoomInvitationIQ(invitation); iq.setType(IQ.Type.set); @@ -1053,8 +1052,7 @@ public class AgentSession { * @throws NotConnectedException * @throws InterruptedException */ - public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException - { + public void sendRoomTransfer(RoomTransfer.Type type, String invitee, String sessionID, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason); IQ iq = new RoomTransfer.RoomTransferIQ(transfer); iq.setType(IQ.Type.set); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java index 1e4524839..2f51b6cea 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java @@ -67,8 +67,7 @@ public class Offer { */ Offer(XMPPConnection conn, AgentSession agentSession, Jid userID, Jid userJID, Jid workgroupName, Date expiresDate, - String sessionID, Map> metaData, OfferContent content) - { + String sessionID, Map> metaData, OfferContent content) { this.connection = conn; this.session = agentSession; this.userID = userID; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java index c40bc4273..f26a0f041 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/AgentStatusRequest.java @@ -129,8 +129,7 @@ public class AgentStatusRequest extends IQ { statusRequest.agents.add(parseAgent(parser)); } else if (eventType == XmlPullParser.END_TAG && - "agent-status-request".equals(parser.getName())) - { + "agent-status-request".equals(parser.getName())) { done = true; } } @@ -149,8 +148,7 @@ public class AgentStatusRequest extends IQ { name = parser.nextText(); } else if (eventType == XmlPullParser.END_TAG && - "agent".equals(parser.getName())) - { + "agent".equals(parser.getName())) { done = true; } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java index 7111db66d..03c66e344 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java @@ -124,8 +124,7 @@ public class OfferRequestProvider extends IQProvider { private final OfferContent content; public OfferRequestPacket(Jid userJID, Jid userID, int timeout, Map> metaData, - String sessionID, OfferContent content) - { + String sessionID, OfferContent content) { super(ELEMENT, NAMESPACE); this.userJID = userJID; this.userID = userID; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java index 1da2ae89d..2486e9043 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java @@ -59,8 +59,7 @@ public class OfferRevokeProvider extends IQProvider { userID = ParserUtils.getJidAttribute(parser, "id"); } else if ((eventType == XmlPullParser.END_TAG) && parser.getName().equals( - "offer-revoke")) - { + "offer-revoke")) { done = true; } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index c840298ea..bae5eb6f5 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -153,8 +153,7 @@ public final class QueueDetails implements ExtensionElement { int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_TAG && - "notify-queue-details".equals(parser.getName())) - { + "notify-queue-details".equals(parser.getName())) { eventType = parser.next(); while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) { String uid; @@ -170,8 +169,7 @@ public final class QueueDetails implements ExtensionElement { eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) - || (!"user".equals(parser.getName()))) - { + || (!"user".equals(parser.getName()))) { if ("position".equals(parser.getName())) { position = Integer.parseInt(parser.nextText()); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java index 92644ecf9..530678c6b 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java @@ -134,8 +134,7 @@ public class QueueOverview implements ExtensionElement { eventType = parser.next(); while ((eventType != XmlPullParser.END_TAG) - || (!ELEMENT_NAME.equals(parser.getName()))) - { + || (!ELEMENT_NAME.equals(parser.getName()))) { if ("count".equals(parser.getName())) { queueOverview.setUserCount(Integer.parseInt(parser.nextText())); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/util/ListenerEventDispatcher.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/util/ListenerEventDispatcher.java index 218ee2573..aa4108572 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/util/ListenerEventDispatcher.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/util/ListenerEventDispatcher.java @@ -68,8 +68,7 @@ public class ListenerEventDispatcher implements Runnable { * @param methodArguments the arguments supplied to the notification method */ public void addListenerTriplet(Object listenerInstance, Method listenerMethod, - Object[] methodArguments) - { + Object[] methodArguments) { if (!this.isRunning) { this.triplets.add(new TripletContainer(listenerInstance, listenerMethod, methodArguments)); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/DefaultMessageEventRequestListener.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/DefaultMessageEventRequestListener.java index 945f96368..7a580ffc4 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/DefaultMessageEventRequestListener.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/DefaultMessageEventRequestListener.java @@ -34,27 +34,23 @@ public class DefaultMessageEventRequestListener implements MessageEventRequestLi @Override public void deliveredNotificationRequested(Jid from, String packetID, - MessageEventManager messageEventManager) throws NotConnectedException, InterruptedException - { + MessageEventManager messageEventManager) throws NotConnectedException, InterruptedException { // Send to the message's sender that the message has been delivered messageEventManager.sendDeliveredNotification(from, packetID); } @Override public void displayedNotificationRequested(Jid from, String packetID, - MessageEventManager messageEventManager) - { + MessageEventManager messageEventManager) { } @Override public void composingNotificationRequested(Jid from, String packetID, - MessageEventManager messageEventManager) - { + MessageEventManager messageEventManager) { } @Override public void offlineNotificationRequested(Jid from, String packetID, - MessageEventManager messageEventManager) - { + MessageEventManager messageEventManager) { } } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java index d049318b6..033a0c869 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/MessageEventManager.java @@ -113,8 +113,7 @@ public final class MessageEventManager extends Manager { * @param composing specifies if the composing event is requested. */ public static void addNotificationsRequests(Message message, boolean offline, - boolean delivered, boolean displayed, boolean composing) - { + boolean delivered, boolean displayed, boolean composing) { // Create a MessageEvent Package and add it to the message MessageEvent messageEvent = new MessageEvent(); messageEvent.setOffline(offline);