Enable LeftCurly checkstyle check

This commit is contained in:
Florian Schmaus 2018-04-06 10:21:46 +02:00
parent 5a841ff0a8
commit 9b5dafe541
93 changed files with 549 additions and 1087 deletions

View File

@ -80,6 +80,7 @@
<module name="GenericWhitespace"/> <module name="GenericWhitespace"/>
<module name="EmptyStatement"/> <module name="EmptyStatement"/>
<module name="PackageDeclaration"/> <module name="PackageDeclaration"/>
<module name="LeftCurly"/>
<module name="RegexpSinglelineJava"> <module name="RegexpSinglelineJava">
<property name="format" value="printStackTrace"/> <property name="format" value="printStackTrace"/>
<property name="message" value="Usage of printStackTrace"/> <property name="message" value="Usage of printStackTrace"/>

View File

@ -193,8 +193,7 @@ public final class ProviderManager {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void addIQProvider(String elementName, String namespace, public static void addIQProvider(String elementName, String namespace,
Object provider) Object provider) {
{
validate(elementName, namespace); validate(elementName, namespace);
// First remove existing providers // First remove existing providers
String key = removeIQProvider(elementName, namespace); String key = removeIQProvider(elementName, namespace);
@ -255,8 +254,7 @@ public final class ProviderManager {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void addExtensionProvider(String elementName, String namespace, public static void addExtensionProvider(String elementName, String namespace,
Object provider) Object provider) {
{
validate(elementName, namespace); validate(elementName, namespace);
// First remove existing providers // First remove existing providers
String key = removeExtensionProvider(elementName, namespace); String key = removeExtensionProvider(elementName, namespace);

View File

@ -37,8 +37,7 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
private final ProxyInfo proxy; private final ProxyInfo proxy;
HTTPProxySocketConnection(ProxyInfo proxy) HTTPProxySocketConnection(ProxyInfo proxy) {
{
this.proxy = proxy; this.proxy = proxy;
} }
@ -51,12 +50,10 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
String hostport = "CONNECT " + host + ":" + port; String hostport = "CONNECT " + host + ":" + port;
String proxyLine; String proxyLine;
String username = proxy.getProxyUsername(); String username = proxy.getProxyUsername();
if (username == null) if (username == null) {
{
proxyLine = ""; proxyLine = "";
} }
else else {
{
String password = proxy.getProxyPassword(); String password = proxy.getProxyPassword();
proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password); proxyLine = "\r\nProxy-Authorization: Basic " + Base64.encode(username + ":" + password);
} }
@ -67,41 +64,33 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
StringBuilder got = new StringBuilder(100); StringBuilder got = new StringBuilder(100);
int nlchars = 0; int nlchars = 0;
while (true) while (true) {
{
int inByte = in.read(); int inByte = in.read();
if (inByte == -1) if (inByte == -1) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP); throw new ProxyException(ProxyInfo.ProxyType.HTTP);
} }
char c = (char) inByte; char c = (char) inByte;
got.append(c); got.append(c);
if (got.length() > 1024) if (got.length() > 1024) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Received " + throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Received " +
"header of >1024 characters from " "header of >1024 characters from "
+ proxyhost + ", cancelling connection"); + proxyhost + ", cancelling connection");
} }
if ((nlchars == 0 || nlchars == 2) && c == '\r') if ((nlchars == 0 || nlchars == 2) && c == '\r') {
{
nlchars++; nlchars++;
} }
else if ((nlchars == 1 || nlchars == 3) && c == '\n') else if ((nlchars == 1 || nlchars == 3) && c == '\n') {
{
nlchars++; nlchars++;
} }
else else {
{
nlchars = 0; nlchars = 0;
} }
if (nlchars == 4) if (nlchars == 4) {
{
break; break;
} }
} }
if (nlchars != 4) if (nlchars != 4) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Never " + throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Never " +
"received blank line from " "received blank line from "
+ proxyhost + ", cancelling connection"); + proxyhost + ", cancelling connection");
@ -112,23 +101,20 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
BufferedReader br = new BufferedReader(new StringReader(gotstr)); BufferedReader br = new BufferedReader(new StringReader(gotstr));
String response = br.readLine(); String response = br.readLine();
if (response == null) if (response == null) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Empty proxy " + throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Empty proxy " +
"response from " + proxyhost + ", cancelling"); "response from " + proxyhost + ", cancelling");
} }
Matcher m = RESPONSE_PATTERN.matcher(response); Matcher m = RESPONSE_PATTERN.matcher(response);
if (!m.matches()) if (!m.matches()) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP , "Unexpected " + throw new ProxyException(ProxyInfo.ProxyType.HTTP , "Unexpected " +
"proxy response from " + proxyhost + ": " + response); "proxy response from " + proxyhost + ": " + response);
} }
int code = Integer.parseInt(m.group(1)); int code = Integer.parseInt(m.group(1));
if (code != HttpURLConnection.HTTP_OK) if (code != HttpURLConnection.HTTP_OK) {
{
throw new ProxyException(ProxyInfo.ProxyType.HTTP); throw new ProxyException(ProxyInfo.ProxyType.HTTP);
} }
} }

View File

@ -29,13 +29,11 @@ public class ProxyException extends IOException {
*/ */
private static final long serialVersionUID = 1L; 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); super("Proxy Exception " + type.toString() + " : " + ex);
} }
public ProxyException(ProxyInfo.ProxyType type) public ProxyException(ProxyInfo.ProxyType type) {
{
super("Proxy Exception " + type.toString() + " : " + "Unknown Error"); super("Proxy Exception " + type.toString() + " : " + "Unknown Error");
} }
} }

View File

@ -23,10 +23,8 @@ package org.jivesoftware.smack.proxy;
* @author Atul Aggarwal * @author Atul Aggarwal
*/ */
public class ProxyInfo public class ProxyInfo {
{ public enum ProxyType {
public enum ProxyType
{
HTTP, HTTP,
SOCKS4, SOCKS4,
SOCKS5 SOCKS5
@ -40,8 +38,7 @@ public class ProxyInfo
private final ProxySocketConnection proxySocketConnection; private final ProxySocketConnection proxySocketConnection;
public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser, public ProxyInfo(ProxyType pType, String pHost, int pPort, String pUser,
String pPass) String pPass) {
{
this.proxyType = pType; this.proxyType = pType;
this.proxyAddress = pHost; this.proxyAddress = pHost;
this.proxyPort = pPort; this.proxyPort = pPort;
@ -63,45 +60,37 @@ public class ProxyInfo
} }
public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser, public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser,
String pPass) String pPass) {
{
return new ProxyInfo(ProxyType.HTTP, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.HTTP, pHost, pPort, pUser, pPass);
} }
public static ProxyInfo forSocks4Proxy(String pHost, int pPort, String pUser, public static ProxyInfo forSocks4Proxy(String pHost, int pPort, String pUser,
String pPass) String pPass) {
{
return new ProxyInfo(ProxyType.SOCKS4, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.SOCKS4, pHost, pPort, pUser, pPass);
} }
public static ProxyInfo forSocks5Proxy(String pHost, int pPort, String pUser, public static ProxyInfo forSocks5Proxy(String pHost, int pPort, String pUser,
String pPass) String pPass) {
{
return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass);
} }
public ProxyType getProxyType() public ProxyType getProxyType() {
{
return proxyType; return proxyType;
} }
public String getProxyAddress() public String getProxyAddress() {
{
return proxyAddress; return proxyAddress;
} }
public int getProxyPort() public int getProxyPort() {
{
return proxyPort; return proxyPort;
} }
public String getProxyUsername() public String getProxyUsername() {
{
return proxyUsername; return proxyUsername;
} }
public String getProxyPassword() public String getProxyPassword() {
{
return proxyPassword; return proxyPassword;
} }

View File

@ -33,8 +33,7 @@ import org.jivesoftware.smack.util.StringUtils;
public class Socks4ProxySocketConnection implements ProxySocketConnection { public class Socks4ProxySocketConnection implements ProxySocketConnection {
private final ProxyInfo proxy; private final ProxyInfo proxy;
Socks4ProxySocketConnection(ProxyInfo proxy) Socks4ProxySocketConnection(ProxyInfo proxy) {
{
this.proxy = proxy; this.proxy = proxy;
} }
@ -47,8 +46,7 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection {
int proxy_port = proxy.getProxyPort(); int proxy_port = proxy.getProxyPort();
String user = proxy.getProxyUsername(); String user = proxy.getProxyUsername();
try try {
{
socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout); socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout);
in = socket.getInputStream(); in = socket.getInputStream();
out = socket.getOutputStream(); out = socket.getOutputStream();
@ -84,13 +82,11 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection {
InetAddress inetAddress = InetAddress.getByName(proxy_host); InetAddress inetAddress = InetAddress.getByName(proxy_host);
byte[] byteAddress = inetAddress.getAddress(); byte[] byteAddress = inetAddress.getAddress();
for (int i = 0; i < byteAddress.length; i++) for (int i = 0; i < byteAddress.length; i++) {
{
buf[index++] = byteAddress[i]; buf[index++] = byteAddress[i];
} }
if (user != null) if (user != null) {
{
byte[] userBytes = user.getBytes(StringUtils.UTF8); byte[] userBytes = user.getBytes(StringUtils.UTF8);
System.arraycopy(userBytes, 0, buf, index, user.length()); System.arraycopy(userBytes, 0, buf, index, user.length());
index += user.length(); index += user.length();
@ -127,29 +123,23 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection {
int len = 6; int len = 6;
int s = 0; int s = 0;
while (s < len) while (s < len) {
{
int i = in.read(buf, s, len - s); int i = in.read(buf, s, len - s);
if (i <= 0) if (i <= 0) {
{
throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, throw new ProxyException(ProxyInfo.ProxyType.SOCKS4,
"stream is closed"); "stream is closed");
} }
s += i; s += i;
} }
if (buf[0] != 0) if (buf[0] != 0) {
{
throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, throw new ProxyException(ProxyInfo.ProxyType.SOCKS4,
"server returns VN " + buf[0]); "server returns VN " + buf[0]);
} }
if (buf[1] != 90) if (buf[1] != 90) {
{ try {
try
{
socket.close(); socket.close();
} }
catch (Exception eee) catch (Exception eee) {
{
} }
String message = "ProxySOCKS4: server returns CD " + buf[1]; String message = "ProxySOCKS4: server returns CD " + buf[1];
throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, message); throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, message);
@ -157,18 +147,14 @@ public class Socks4ProxySocketConnection implements ProxySocketConnection {
byte[] temp = new byte[2]; byte[] temp = new byte[2];
in.read(temp, 0, 2); in.read(temp, 0, 2);
} }
catch (RuntimeException e) catch (RuntimeException e) {
{
throw e; throw e;
} }
catch (Exception e) catch (Exception e) {
{ try {
try
{
socket.close(); socket.close();
} }
catch (Exception eee) catch (Exception eee) {
{
} }
throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, e.toString()); throw new ProxyException(ProxyInfo.ProxyType.SOCKS4, e.toString());
} }

View File

@ -32,8 +32,7 @@ import org.jivesoftware.smack.util.StringUtils;
public class Socks5ProxySocketConnection implements ProxySocketConnection { public class Socks5ProxySocketConnection implements ProxySocketConnection {
private final ProxyInfo proxy; private final ProxyInfo proxy;
Socks5ProxySocketConnection(ProxyInfo proxy) Socks5ProxySocketConnection(ProxyInfo proxy) {
{
this.proxy = proxy; this.proxy = proxy;
} }
@ -47,8 +46,7 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
String user = proxy.getProxyUsername(); String user = proxy.getProxyUsername();
String passwd = proxy.getProxyPassword(); String passwd = proxy.getProxyPassword();
try try {
{
socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout); socket.connect(new InetSocketAddress(proxy_host, proxy_port), timeout);
in = socket.getInputStream(); in = socket.getInputStream();
out = socket.getOutputStream(); out = socket.getOutputStream();
@ -100,14 +98,12 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
fill(in, buf, 2); fill(in, buf, 2);
boolean check = false; boolean check = false;
switch ((buf[1]) & 0xff) switch ((buf[1]) & 0xff) {
{
case 0: // NO AUTHENTICATION REQUIRED case 0: // NO AUTHENTICATION REQUIRED
check = true; check = true;
break; break;
case 2: // USERNAME/PASSWORD case 2: // USERNAME/PASSWORD
if (user == null || passwd == null) if (user == null || passwd == null) {
{
break; break;
} }
@ -160,22 +156,18 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
connection. connection.
*/ */
fill(in, buf, 2); fill(in, buf, 2);
if (buf[1] == 0) if (buf[1] == 0) {
{
check = true; check = true;
} }
break; break;
default: default:
} }
if (!check) if (!check) {
{ try {
try
{
socket.close(); socket.close();
} }
catch (Exception eee) catch (Exception eee) {
{
} }
throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, throw new ProxyException(ProxyInfo.ProxyType.SOCKS5,
"fail in SOCKS5 proxy"); "fail in SOCKS5 proxy");
@ -260,21 +252,17 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
fill(in, buf, 4); fill(in, buf, 4);
if (buf[1] != 0) if (buf[1] != 0) {
{ try {
try
{
socket.close(); socket.close();
} }
catch (Exception eee) catch (Exception eee) {
{
} }
throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, throw new ProxyException(ProxyInfo.ProxyType.SOCKS5,
"server returns " + buf[1]); "server returns " + buf[1]);
} }
switch (buf[3] & 0xff) switch (buf[3] & 0xff) {
{
case 1: case 1:
fill(in, buf, 6); fill(in, buf, 6);
break; break;
@ -288,18 +276,14 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
default: default:
} }
} }
catch (RuntimeException e) catch (RuntimeException e) {
{
throw e; throw e;
} }
catch (Exception e) catch (Exception e) {
{ try {
try
{
socket.close(); socket.close();
} }
catch (Exception eee) catch (Exception eee) {
{
} }
// TODO convert to IOException(e) when minimum Android API level is 9 or higher // TODO convert to IOException(e) when minimum Android API level is 9 or higher
throw new IOException(e.getLocalizedMessage()); throw new IOException(e.getLocalizedMessage());
@ -307,14 +291,11 @@ public class Socks5ProxySocketConnection implements ProxySocketConnection {
} }
private static void fill(InputStream in, byte[] buf, int len) private static void fill(InputStream in, byte[] buf, int len)
throws IOException throws IOException {
{
int s = 0; int s = 0;
while (s < len) while (s < len) {
{
int i = in.read(buf, s, len - s); int i = in.read(buf, s, len - s);
if (i <= 0) if (i <= 0) {
{
throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, "stream " + throw new ProxyException(ProxyInfo.ProxyType.SOCKS5, "stream " +
"is closed"); "is closed");
} }

View File

@ -24,16 +24,13 @@ import org.jivesoftware.smack.packet.Stanza;
import org.junit.Test; import org.junit.Test;
public class StanzaCollectorTest public class StanzaCollectorTest {
{
@Test @Test
public void verifyRollover() throws InterruptedException public void verifyRollover() throws InterruptedException {
{
TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), 5); 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); Stanza testPacket = new TestPacket(i);
collector.processStanza(testPacket); collector.processStanza(testPacket);
} }
@ -46,8 +43,7 @@ public class StanzaCollectorTest
assertEquals("5", collector.pollResult().getStanzaId()); assertEquals("5", collector.pollResult().getStanzaId());
assertNull(collector.pollResult()); assertNull(collector.pollResult());
for (int i = 10; i < 15; i++) for (int i = 10; i < 15; i++) {
{
Stanza testPacket = new TestPacket(i); Stanza testPacket = new TestPacket(i);
collector.processStanza(testPacket); collector.processStanza(testPacket);
} }
@ -67,26 +63,18 @@ public class StanzaCollectorTest
* catch problems. * catch problems.
*/ */
@Test @Test
public void verifyThreadSafety() public void verifyThreadSafety() {
{
int insertCount = 500; int insertCount = 500;
final TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), insertCount); final TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), insertCount);
Thread consumer1 = new Thread(new Runnable() Thread consumer1 = new Thread(new Runnable() {
{
@Override @Override
public void run() public void run() {
{ try {
try while (true) {
{ try {
while (true)
{
try
{
Thread.sleep(3); Thread.sleep(3);
} } catch (InterruptedException e) {
catch (InterruptedException e)
{
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
Stanza packet = collector.nextResultBlockForever(); Stanza packet = collector.nextResultBlockForever();
@ -100,55 +88,41 @@ public class StanzaCollectorTest
}); });
consumer1.setName("consumer 1"); consumer1.setName("consumer 1");
Thread consumer2 = new Thread(new Runnable() Thread consumer2 = new Thread(new Runnable() {
{
@Override @Override
public void run() public void run() {
{
Stanza p; Stanza p;
do do {
{ try {
try
{
Thread.sleep(3); Thread.sleep(3);
} } catch (InterruptedException e) {
catch (InterruptedException e)
{
} }
try { try {
p = collector.nextResult(1); p = collector.nextResult(1);
} } catch (InterruptedException e) {
catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// System.out.println(Thread.currentThread().getName() + " packet: " + p); // System.out.println(Thread.currentThread().getName() + " packet: " + p);
} }
while (p != null); while (p != null);
} }
}); });
consumer2.setName("consumer 2"); consumer2.setName("consumer 2");
Thread consumer3 = new Thread(new Runnable() Thread consumer3 = new Thread(new Runnable() {
{
@Override @Override
public void run() public void run() {
{
Stanza p; Stanza p;
do do {
{ try {
try
{
Thread.sleep(3); Thread.sleep(3);
} } catch (InterruptedException e) {
catch (InterruptedException e)
{
} }
p = collector.pollResult(); p = collector.pollResult();
// System.out.println(Thread.currentThread().getName() + " packet: " + p); // System.out.println(Thread.currentThread().getName() + " packet: " + p);
} } while (p != null);
while (p != null);
} }
}); });
consumer3.setName("consumer 3"); consumer3.setName("consumer 3");
@ -157,54 +131,43 @@ public class StanzaCollectorTest
consumer2.start(); consumer2.start();
consumer3.start(); consumer3.start();
for (int i = 0; i < insertCount; i++) for (int i = 0; i < insertCount; i++) {
{
collector.processStanza(new TestPacket(i)); collector.processStanza(new TestPacket(i));
} }
try try {
{
Thread.sleep(5000); Thread.sleep(5000);
consumer3.join(); consumer3.join();
consumer2.join(); consumer2.join();
consumer1.interrupt(); 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 // 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. // and main, but the probability is extremely remote.
assertNull(collector.pollResult()); assertNull(collector.pollResult());
} }
static class OKEverything implements StanzaFilter static class OKEverything implements StanzaFilter {
{
@Override @Override
public boolean accept(Stanza packet) public boolean accept(Stanza packet) {
{
return true; return true;
} }
} }
static class TestStanzaCollector extends StanzaCollector static class TestStanzaCollector extends StanzaCollector {
{ protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) {
protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)
{
super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size)); super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
} }
} }
static class TestPacket extends Stanza static class TestPacket extends Stanza {
{ TestPacket(int i) {
TestPacket(int i)
{
setStanzaId(String.valueOf(i)); setStanzaId(String.valueOf(i));
} }
@Override @Override
public String toXML() public String toXML() {
{
return "<packetId>" + getStanzaId() + "</packetId>"; return "<packetId>" + getStanzaId() + "</packetId>";
} }

View File

@ -45,8 +45,7 @@ public class FromMatchesFilterTest {
private static final Jid SERVICE_JID2 = JidTestUtil.PUBSUB_EXAMPLE_ORG; private static final Jid SERVICE_JID2 = JidTestUtil.PUBSUB_EXAMPLE_ORG;
@Test @Test
public void autoCompareMatchingEntityFullJid() public void autoCompareMatchingEntityFullJid() {
{
FromMatchesFilter filter = FromMatchesFilter.create(FULL_JID1_R1); FromMatchesFilter filter = FromMatchesFilter.create(FULL_JID1_R1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -70,8 +69,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void autoCompareMatchingBaseJid() public void autoCompareMatchingBaseJid() {
{
FromMatchesFilter filter = FromMatchesFilter.create(BASE_JID1); FromMatchesFilter filter = FromMatchesFilter.create(BASE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -95,8 +93,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void autoCompareMatchingServiceJid() public void autoCompareMatchingServiceJid() {
{
FromMatchesFilter filter = FromMatchesFilter.create(SERVICE_JID1); FromMatchesFilter filter = FromMatchesFilter.create(SERVICE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -117,8 +114,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void bareCompareMatchingEntityFullJid() public void bareCompareMatchingEntityFullJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1); FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -142,8 +138,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void bareCompareMatchingBaseJid() public void bareCompareMatchingBaseJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1); FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -167,8 +162,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void bareCompareMatchingServiceJid() public void bareCompareMatchingServiceJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1); FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -189,8 +183,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void fullCompareMatchingEntityFullJid() public void fullCompareMatchingEntityFullJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createFull(FULL_JID1_R1); FromMatchesFilter filter = FromMatchesFilter.createFull(FULL_JID1_R1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -214,8 +207,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void fullCompareMatchingBaseJid() public void fullCompareMatchingBaseJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createFull(BASE_JID1); FromMatchesFilter filter = FromMatchesFilter.createFull(BASE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();
@ -239,8 +231,7 @@ public class FromMatchesFilterTest {
} }
@Test @Test
public void fullCompareMatchingServiceJid() public void fullCompareMatchingServiceJid() {
{
FromMatchesFilter filter = FromMatchesFilter.createFull(SERVICE_JID1); FromMatchesFilter filter = FromMatchesFilter.createFull(SERVICE_JID1);
Stanza packet = new Message(); Stanza packet = new Message();

View File

@ -434,8 +434,7 @@ public class EnhancedDebugger extends SmackDebugger {
int index = str.lastIndexOf(">"); int index = str.lastIndexOf(">");
if (index != -1) { if (index != -1) {
if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
{
try { try {
receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0)); receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
} }

View File

@ -71,8 +71,9 @@ public class MultipleRecipientManager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public static void send(XMPPConnection connection, Stanza packet, Collection<? extends Jid> to, Collection<? extends Jid> cc, Collection<? extends Jid> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException, InterruptedException public static void send(XMPPConnection connection, Stanza packet, Collection<? extends Jid> to,
{ Collection<? extends Jid> cc, Collection<? extends Jid> bcc) throws NoResponseException, XMPPErrorException,
FeatureNotSupportedException, NotConnectedException, InterruptedException {
send(connection, packet, to, cc, bcc, null, null, false); send(connection, packet, to, cc, bcc, null, null, false);
} }
@ -143,8 +144,8 @@ public class MultipleRecipientManager {
* @throws XMPPErrorException * @throws XMPPErrorException
* @throws InterruptedException * @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); MultipleRecipientInfo info = getMultipleRecipientInfo(original);
if (info == null) { if (info == null) {
throw new SmackException("Original message does not contain multiple recipient info"); throw new SmackException("Original message does not contain multiple recipient info");

View File

@ -60,8 +60,7 @@ public final class BookmarkManager {
* exist it is created. * exist it is created.
* @throws IllegalArgumentException when the connection is null. * @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); BookmarkManager manager = bookmarkManagerMap.get(connection);
if (manager == null) { if (manager == null) {
manager = new BookmarkManager(connection); manager = new BookmarkManager(connection);
@ -114,8 +113,7 @@ public final class BookmarkManager {
* @throws InterruptedException * @throws InterruptedException
*/ */
public void addBookmarkedConference(String name, EntityBareJid jid, boolean isAutoJoin, 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(); retrieveBookmarks();
BookmarkedConference bookmark BookmarkedConference bookmark
= new BookmarkedConference(name, jid, isAutoJoin, nickname, password); = new BookmarkedConference(name, jid, isAutoJoin, nickname, password);

View File

@ -40,8 +40,7 @@ public class BookmarkedConference implements SharedBookmark {
} }
protected BookmarkedConference(String name, EntityBareJid jid, boolean autoJoin, Resourcepart nickname, protected BookmarkedConference(String name, EntityBareJid jid, boolean autoJoin, Resourcepart nickname,
String password) String password) {
{
this.name = name; this.name = name;
this.jid = jid; this.jid = jid;
this.autoJoin = autoJoin; this.autoJoin = autoJoin;

View File

@ -232,13 +232,11 @@ public class Bookmarks implements PrivateData {
} }
} }
else if (eventType == XmlPullParser.START_TAG && else if (eventType == XmlPullParser.START_TAG &&
"conference".equals(parser.getName())) "conference".equals(parser.getName())) {
{
final BookmarkedConference conference = getConferenceStorage(parser); final BookmarkedConference conference = getConferenceStorage(parser);
storage.addBookmarkedConference(conference); 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; done = true;
} }
} }

View File

@ -606,8 +606,7 @@ public final class AdHocCommandManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
private static IQ respondError(AdHocCommandData response, XMPPError.Condition condition, 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)); XMPPError.Builder error = XMPPError.getBuilder(condition).addExtension(new AdHocCommandData.SpecificError(specificCondition));
return respondError(response, error); return respondError(response, error);
} }
@ -672,8 +671,7 @@ public final class AdHocCommandManager extends Manager {
private LocalCommandFactory factory; private LocalCommandFactory factory;
private AdHocCommandInfo(String node, String name, Jid ownerJID, private AdHocCommandInfo(String node, String name, Jid ownerJID,
LocalCommandFactory factory) LocalCommandFactory factory) {
{
this.node = node; this.node = node;
this.name = name; this.name = name;
this.ownerJID = ownerJID; this.ownerJID = ownerJID;
@ -681,8 +679,7 @@ public final class AdHocCommandManager extends Manager {
} }
public LocalCommand getCommandInstance() throws InstantiationException, public LocalCommand getCommandInstance() throws InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
{
return factory.getInstance(); return factory.getInstance();
} }

View File

@ -654,8 +654,7 @@ public final class ServiceDiscoveryManager extends Manager {
*/ */
@Deprecated @Deprecated
// TODO: Remove in Smack 4.4 // 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.setType(IQ.Type.set);
discoverItems.setTo(entityID); discoverItems.setTo(entityID);
discoverItems.setNode(node); discoverItems.setNode(node);

View File

@ -204,8 +204,7 @@ public abstract class FileTransfer {
} }
protected void writeToStream(final InputStream in, final OutputStream out) protected void writeToStream(final InputStream in, final OutputStream out)
throws IOException throws IOException {
{
final byte[] b = new byte[BUFFER_SIZE]; final byte[] b = new byte[BUFFER_SIZE];
int count = 0; int count = 0;
amountWritten = 0; amountWritten = 0;

View File

@ -161,8 +161,7 @@ public class OutgoingFileTransfer extends FileTransfer {
*/ */
public synchronized void sendFile(final String fileName, public synchronized void sendFile(final String fileName,
final long fileSize, final String description, final long fileSize, final String description,
final NegotiationProgress progress) final NegotiationProgress progress) {
{
if (progress == null) { if (progress == null) {
throw new IllegalArgumentException("Callback progress cannot be null."); throw new IllegalArgumentException("Callback progress cannot be null.");
} }

View File

@ -51,8 +51,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
} }
@Override @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 { try {
return this.manager.establishSession(target, streamID).getOutputStream(); return this.manager.establishSession(target, streamID).getOutputStream();
} }

View File

@ -73,8 +73,7 @@ public abstract class StreamNegotiator extends Manager {
* @return The response to be forwarded to the initiator. * @return The response to be forwarded to the initiator.
*/ */
protected static StreamInitiation createInitiationAccept( protected static StreamInitiation createInitiationAccept(
StreamInitiation streamInitiationOffer, String[] namespaces) StreamInitiation streamInitiationOffer, String[] namespaces) {
{
StreamInitiation response = new StreamInitiation(); StreamInitiation response = new StreamInitiation();
response.setTo(streamInitiationOffer.getFrom()); response.setTo(streamInitiationOffer.getFrom());
response.setFrom(streamInitiationOffer.getTo()); response.setFrom(streamInitiationOffer.getTo());

View File

@ -115,8 +115,7 @@ public final class PrivateDataManager extends Manager {
* @param provider the private data provider. * @param provider the private data provider.
*/ */
public static void addPrivateDataProvider(String elementName, String namespace, public static void addPrivateDataProvider(String elementName, String namespace,
PrivateDataProvider provider) PrivateDataProvider provider) {
{
String key = XmppStringUtils.generateKey(elementName, namespace); String key = XmppStringUtils.generateKey(elementName, namespace);
privateDataProviders.put(key, provider); privateDataProviders.put(key, provider);
} }
@ -159,8 +158,7 @@ public final class PrivateDataManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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. // Create an IQ packet to get the private data.
IQ privateDataGet = new PrivateDataIQ(elementName, namespace); IQ privateDataGet = new PrivateDataIQ(elementName, namespace);

View File

@ -1583,8 +1583,7 @@ public class MultiUserChat {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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(); MUCAdmin iq = new MUCAdmin();
iq.setTo(room); iq.setTo(room);
iq.setType(IQ.Type.set); iq.setType(IQ.Type.set);

View File

@ -22,8 +22,8 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum AccessModel public enum AccessModel {
{
/** Anyone may subscribe and retrieve items. */ /** Anyone may subscribe and retrieve items. */
open, open,

View File

@ -35,8 +35,7 @@ import org.jxmpp.jid.BareJid;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class Affiliation implements ExtensionElement public class Affiliation implements ExtensionElement {
{
public static final String ELEMENT = "affiliation"; public static final String ELEMENT = "affiliation";
private final BareJid jid; private final BareJid jid;
@ -44,8 +43,7 @@ public class Affiliation implements ExtensionElement
private final Type affiliation; private final Type affiliation;
private final PubSubNamespace namespace; private final PubSubNamespace namespace;
public enum Type public enum Type {
{
member, none, outcast, owner, publisher member, none, outcast, owner, publisher
} }

View File

@ -28,8 +28,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class AffiliationsExtension extends NodeExtension public class AffiliationsExtension extends NodeExtension {
{
protected List<Affiliation> items = Collections.emptyList(); protected List<Affiliation> items = Collections.emptyList();
private final String node; private final String node;
@ -47,20 +46,16 @@ public class AffiliationsExtension extends NodeExtension
this.node = node; this.node = node;
} }
public List<Affiliation> getAffiliations() public List<Affiliation> getAffiliations() {
{
return items; return items;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{ if ((items == null) || (items.size() == 0)) {
if ((items == null) || (items.size() == 0))
{
return super.toXML(); return super.toXML();
} }
else else {
{
// Can't use XmlStringBuilder(this), because we don't want the namespace to be included // Can't use XmlStringBuilder(this), because we don't want the namespace to be included
XmlStringBuilder xml = new XmlStringBuilder(); XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(getElementName()); xml.halfOpenElement(getElementName());

View File

@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum ChildrenAssociationPolicy public enum ChildrenAssociationPolicy {
{
/** Anyone may associate leaf nodes with the collection. */ /** Anyone may associate leaf nodes with the collection. */
all, all,

View File

@ -18,8 +18,7 @@ package org.jivesoftware.smackx.pubsub;
public class CollectionNode extends Node { public class CollectionNode extends Node {
CollectionNode(PubSubManager pubSubManager, String nodeId) CollectionNode(PubSubManager pubSubManager, String nodeId) {
{
super(pubSubManager, nodeId); super(pubSubManager, nodeId);
} }

View File

@ -29,29 +29,24 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension {
{
private ConfigureForm form; private ConfigureForm form;
public ConfigurationEvent(String nodeId) public ConfigurationEvent(String nodeId) {
{
super(PubSubElementType.CONFIGURATION, nodeId); super(PubSubElementType.CONFIGURATION, nodeId);
} }
public ConfigurationEvent(String nodeId, ConfigureForm configForm) public ConfigurationEvent(String nodeId, ConfigureForm configForm) {
{
super(PubSubElementType.CONFIGURATION, nodeId); super(PubSubElementType.CONFIGURATION, nodeId);
form = configForm; form = configForm;
} }
public ConfigureForm getConfiguration() public ConfigureForm getConfiguration() {
{
return form; return form;
} }
@Override @Override
public List<ExtensionElement> getExtensions() public List<ExtensionElement> getExtensions() {
{
if (getConfiguration() == null) if (getConfiguration() == null)
return Collections.emptyList(); return Collections.emptyList();
else else

View File

@ -33,16 +33,14 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ConfigureForm extends Form public class ConfigureForm extends Form {
{
/** /**
* Create a decorator from an existing {@link DataForm} that has been * Create a decorator from an existing {@link DataForm} that has been
* retrieved from parsing a node configuration request. * retrieved from parsing a node configuration request.
* *
* @param configDataForm * @param configDataForm
*/ */
public ConfigureForm(DataForm configDataForm) public ConfigureForm(DataForm configDataForm) {
{
super(configDataForm); super(configDataForm);
} }
@ -53,8 +51,7 @@ public class ConfigureForm extends Form
* *
* @param nodeConfigForm * @param nodeConfigForm
*/ */
public ConfigureForm(Form nodeConfigForm) public ConfigureForm(Form nodeConfigForm) {
{
super(nodeConfigForm.getDataFormToSend()); 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)}. * using the resulting form to create a answer form. See {@link #ConfigureForm(Form)}.
* @param formType * @param formType
*/ */
public ConfigureForm(DataForm.Type formType) public ConfigureForm(DataForm.Type formType) {
{
super(formType); super(formType);
} }
@ -75,8 +71,7 @@ public class ConfigureForm extends Form
* *
* @return The current {@link AccessModel} * @return The current {@link AccessModel}
*/ */
public AccessModel getAccessModel() public AccessModel getAccessModel() {
{
String value = getFieldValue(ConfigureNodeFields.access_model); String value = getFieldValue(ConfigureNodeFields.access_model);
if (value == null) if (value == null)
@ -90,8 +85,7 @@ public class ConfigureForm extends Form
* *
* @param accessModel * @param accessModel
*/ */
public void setAccessModel(AccessModel accessModel) public void setAccessModel(AccessModel accessModel) {
{
addField(ConfigureNodeFields.access_model, FormField.Type.list_single); addField(ConfigureNodeFields.access_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.access_model.getFieldName(), getListSingle(accessModel.toString())); setAnswer(ConfigureNodeFields.access_model.getFieldName(), getListSingle(accessModel.toString()));
} }
@ -102,8 +96,7 @@ public class ConfigureForm extends Form
* *
* @return URL to an XSL * @return URL to an XSL
*/ */
public String getBodyXSLT() public String getBodyXSLT() {
{
return getFieldValue(ConfigureNodeFields.body_xslt); return getFieldValue(ConfigureNodeFields.body_xslt);
} }
@ -113,8 +106,7 @@ public class ConfigureForm extends Form
* *
* @param bodyXslt The URL of an XSL * @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); addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt); setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt);
} }
@ -124,8 +116,7 @@ public class ConfigureForm extends Form
* *
* @return list of child nodes. * @return list of child nodes.
*/ */
public List<String> getChildren() public List<String> getChildren() {
{
return getFieldValues(ConfigureNodeFields.children); return getFieldValues(ConfigureNodeFields.children);
} }
@ -134,8 +125,7 @@ public class ConfigureForm extends Form
* *
* @param children * @param children
*/ */
public void setChildren(List<String> children) public void setChildren(List<String> children) {
{
addField(ConfigureNodeFields.children, FormField.Type.text_multi); addField(ConfigureNodeFields.children, FormField.Type.text_multi);
setAnswer(ConfigureNodeFields.children.getFieldName(), children); setAnswer(ConfigureNodeFields.children.getFieldName(), children);
} }
@ -145,8 +135,7 @@ public class ConfigureForm extends Form
* *
* @return The current policy * @return The current policy
*/ */
public ChildrenAssociationPolicy getChildrenAssociationPolicy() public ChildrenAssociationPolicy getChildrenAssociationPolicy() {
{
String value = getFieldValue(ConfigureNodeFields.children_association_policy); String value = getFieldValue(ConfigureNodeFields.children_association_policy);
if (value == null) if (value == null)
@ -160,8 +149,7 @@ public class ConfigureForm extends Form
* *
* @param policy The policy being set * @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); addField(ConfigureNodeFields.children_association_policy, FormField.Type.list_single);
List<String> values = new ArrayList<>(1); List<String> values = new ArrayList<>(1);
values.add(policy.toString()); values.add(policy.toString());
@ -175,8 +163,7 @@ public class ConfigureForm extends Form
* *
* @return List of the whitelist * @return List of the whitelist
*/ */
public List<String> getChildrenAssociationWhitelist() public List<String> getChildrenAssociationWhitelist() {
{
return getFieldValues(ConfigureNodeFields.children_association_whitelist); return getFieldValues(ConfigureNodeFields.children_association_whitelist);
} }
@ -187,8 +174,7 @@ public class ConfigureForm extends Form
* *
* @param whitelist The list of JID's * @param whitelist The list of JID's
*/ */
public void setChildrenAssociationWhitelist(List<String> whitelist) public void setChildrenAssociationWhitelist(List<String> whitelist) {
{
addField(ConfigureNodeFields.children_association_whitelist, FormField.Type.jid_multi); addField(ConfigureNodeFields.children_association_whitelist, FormField.Type.jid_multi);
setAnswer(ConfigureNodeFields.children_association_whitelist.getFieldName(), whitelist); setAnswer(ConfigureNodeFields.children_association_whitelist.getFieldName(), whitelist);
} }
@ -198,8 +184,7 @@ public class ConfigureForm extends Form
* *
* @return The maximum number of child nodes * @return The maximum number of child nodes
*/ */
public int getChildrenMax() public int getChildrenMax() {
{
return Integer.parseInt(getFieldValue(ConfigureNodeFields.children_max)); return Integer.parseInt(getFieldValue(ConfigureNodeFields.children_max));
} }
@ -208,8 +193,7 @@ public class ConfigureForm extends Form
* *
* @param max The maximum number of child nodes. * @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); addField(ConfigureNodeFields.children_max, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.children_max.getFieldName(), max); setAnswer(ConfigureNodeFields.children_max.getFieldName(), max);
} }
@ -219,8 +203,7 @@ public class ConfigureForm extends Form
* *
* @return The collection node id * @return The collection node id
*/ */
public String getCollection() public String getCollection() {
{
return getFieldValue(ConfigureNodeFields.collection); return getFieldValue(ConfigureNodeFields.collection);
} }
@ -229,8 +212,7 @@ public class ConfigureForm extends Form
* *
* @param collection The node id of the collection node * @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); addField(ConfigureNodeFields.collection, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.collection.getFieldName(), collection); setAnswer(ConfigureNodeFields.collection.getFieldName(), collection);
} }
@ -242,8 +224,7 @@ public class ConfigureForm extends Form
* *
* @return The URL of an XSL transformation * @return The URL of an XSL transformation
*/ */
public String getDataformXSLT() public String getDataformXSLT() {
{
return getFieldValue(ConfigureNodeFields.dataform_xslt); return getFieldValue(ConfigureNodeFields.dataform_xslt);
} }
@ -254,8 +235,7 @@ public class ConfigureForm extends Form
* *
* @param url The URL of an XSL transformation * @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); addField(ConfigureNodeFields.dataform_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.dataform_xslt.getFieldName(), url); setAnswer(ConfigureNodeFields.dataform_xslt.getFieldName(), url);
} }
@ -265,8 +245,7 @@ public class ConfigureForm extends Form
* *
* @return true if it does, false otherwise * @return true if it does, false otherwise
*/ */
public boolean isDeliverPayloads() public boolean isDeliverPayloads() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads)); 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 * @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); addField(ConfigureNodeFields.deliver_payloads, FormField.Type.bool);
setAnswer(ConfigureNodeFields.deliver_payloads.getFieldName(), deliver); setAnswer(ConfigureNodeFields.deliver_payloads.getFieldName(), deliver);
} }
@ -286,8 +264,7 @@ public class ConfigureForm extends Form
* *
* @return Who should get the reply * @return Who should get the reply
*/ */
public ItemReply getItemReply() public ItemReply getItemReply() {
{
String value = getFieldValue(ConfigureNodeFields.itemreply); String value = getFieldValue(ConfigureNodeFields.itemreply);
if (value == null) if (value == null)
@ -301,8 +278,7 @@ public class ConfigureForm extends Form
* *
* @param reply Defines who should get the reply * @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); addField(ConfigureNodeFields.itemreply, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.itemreply.getFieldName(), getListSingle(reply.toString())); setAnswer(ConfigureNodeFields.itemreply.getFieldName(), getListSingle(reply.toString()));
} }
@ -313,8 +289,7 @@ public class ConfigureForm extends Form
* *
* @return The maximum number of items to persist * @return The maximum number of items to persist
*/ */
public int getMaxItems() public int getMaxItems() {
{
return Integer.parseInt(getFieldValue(ConfigureNodeFields.max_items)); 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 * @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); addField(ConfigureNodeFields.max_items, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_items.getFieldName(), max); setAnswer(ConfigureNodeFields.max_items.getFieldName(), max);
} }
@ -335,8 +309,7 @@ public class ConfigureForm extends Form
* *
* @return The maximum payload size * @return The maximum payload size
*/ */
public int getMaxPayloadSize() public int getMaxPayloadSize() {
{
return Integer.parseInt(getFieldValue(ConfigureNodeFields.max_payload_size)); return Integer.parseInt(getFieldValue(ConfigureNodeFields.max_payload_size));
} }
@ -345,8 +318,7 @@ public class ConfigureForm extends Form
* *
* @param max The maximum payload size * @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); addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max); setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max);
} }
@ -356,8 +328,7 @@ public class ConfigureForm extends Form
* *
* @return The node type * @return The node type
*/ */
public NodeType getNodeType() public NodeType getNodeType() {
{
String value = getFieldValue(ConfigureNodeFields.node_type); String value = getFieldValue(ConfigureNodeFields.node_type);
if (value == null) if (value == null)
@ -371,8 +342,7 @@ public class ConfigureForm extends Form
* *
* @param type The node type * @param type The node type
*/ */
public void setNodeType(NodeType type) public void setNodeType(NodeType type) {
{
addField(ConfigureNodeFields.node_type, FormField.Type.list_single); addField(ConfigureNodeFields.node_type, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.node_type.getFieldName(), getListSingle(type.toString())); 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 * @return true if they should be notified, false otherwise
*/ */
public boolean isNotifyConfig() public boolean isNotifyConfig() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config)); 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 * @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); addField(ConfigureNodeFields.notify_config, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_config.getFieldName(), notify); setAnswer(ConfigureNodeFields.notify_config.getFieldName(), notify);
} }
@ -403,8 +371,7 @@ public class ConfigureForm extends Form
* *
* @return true if subscribers should be notified, false otherwise * @return true if subscribers should be notified, false otherwise
*/ */
public boolean isNotifyDelete() public boolean isNotifyDelete() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete)); 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 * @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); addField(ConfigureNodeFields.notify_delete, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_delete.getFieldName(), notify); setAnswer(ConfigureNodeFields.notify_delete.getFieldName(), notify);
} }
@ -425,8 +391,7 @@ public class ConfigureForm extends Form
* *
* @return true if subscribers should be notified, false otherwise * @return true if subscribers should be notified, false otherwise
*/ */
public boolean isNotifyRetract() public boolean isNotifyRetract() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract)); 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 * @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); addField(ConfigureNodeFields.notify_retract, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify); setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
} }
@ -447,8 +411,7 @@ public class ConfigureForm extends Form
* *
* @return true if items are persisted * @return true if items are persisted
*/ */
public boolean isPersistItems() public boolean isPersistItems() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items)); 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 * @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); addField(ConfigureNodeFields.persist_items, FormField.Type.bool);
setAnswer(ConfigureNodeFields.persist_items.getFieldName(), persist); setAnswer(ConfigureNodeFields.persist_items.getFieldName(), persist);
} }
@ -468,8 +430,7 @@ public class ConfigureForm extends Form
* *
* @return true if users must be available * @return true if users must be available
*/ */
public boolean isPresenceBasedDelivery() public boolean isPresenceBasedDelivery() {
{
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery)); 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 * @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); addField(ConfigureNodeFields.presence_based_delivery, FormField.Type.bool);
setAnswer(ConfigureNodeFields.presence_based_delivery.getFieldName(), presenceBased); setAnswer(ConfigureNodeFields.presence_based_delivery.getFieldName(), presenceBased);
} }
@ -489,8 +449,7 @@ public class ConfigureForm extends Form
* *
* @return The publishing model * @return The publishing model
*/ */
public PublishModel getPublishModel() public PublishModel getPublishModel() {
{
String value = getFieldValue(ConfigureNodeFields.publish_model); String value = getFieldValue(ConfigureNodeFields.publish_model);
if (value == null) if (value == null)
@ -504,8 +463,7 @@ public class ConfigureForm extends Form
* *
* @param publish The enum representing the possible options for the publishing model * @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); addField(ConfigureNodeFields.publish_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString())); setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString()));
} }
@ -515,8 +473,7 @@ public class ConfigureForm extends Form
* *
* @return The reply room JID's * @return The reply room JID's
*/ */
public List<String> getReplyRoom() public List<String> getReplyRoom() {
{
return getFieldValues(ConfigureNodeFields.replyroom); 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 * @param replyRooms The multi user chat room to use as reply rooms
*/ */
public void setReplyRoom(List<String> replyRooms) public void setReplyRoom(List<String> replyRooms) {
{
addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi); addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms); setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms);
} }
@ -536,8 +492,7 @@ public class ConfigureForm extends Form
* *
* @return The JID's * @return The JID's
*/ */
public List<String> getReplyTo() public List<String> getReplyTo() {
{
return getFieldValues(ConfigureNodeFields.replyto); return getFieldValues(ConfigureNodeFields.replyto);
} }
@ -546,8 +501,7 @@ public class ConfigureForm extends Form
* *
* @param replyTos The JID's to reply to * @param replyTos The JID's to reply to
*/ */
public void setReplyTo(List<String> replyTos) public void setReplyTo(List<String> replyTos) {
{
addField(ConfigureNodeFields.replyto, FormField.Type.list_multi); addField(ConfigureNodeFields.replyto, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos); setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos);
} }
@ -557,8 +511,7 @@ public class ConfigureForm extends Form
* *
* @return The roster groups * @return The roster groups
*/ */
public List<String> getRosterGroupsAllowed() public List<String> getRosterGroupsAllowed() {
{
return getFieldValues(ConfigureNodeFields.roster_groups_allowed); return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
} }
@ -567,8 +520,7 @@ public class ConfigureForm extends Form
* *
* @param groups The roster groups * @param groups The roster groups
*/ */
public void setRosterGroupsAllowed(List<String> groups) public void setRosterGroupsAllowed(List<String> groups) {
{
addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi); addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups); setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups);
} }
@ -580,8 +532,7 @@ public class ConfigureForm extends Form
* @deprecated use {@link #isSubscribe()} instead * @deprecated use {@link #isSubscribe()} instead
*/ */
@Deprecated @Deprecated
public boolean isSubscibe() public boolean isSubscibe() {
{
return isSubscribe(); return isSubscribe();
} }
@ -599,8 +550,7 @@ public class ConfigureForm extends Form
* *
* @param subscribe true if they are, false otherwise * @param subscribe true if they are, false otherwise
*/ */
public void setSubscribe(boolean subscribe) public void setSubscribe(boolean subscribe) {
{
addField(ConfigureNodeFields.subscribe, FormField.Type.bool); addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe); setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
} }
@ -611,8 +561,7 @@ public class ConfigureForm extends Form
* @return The node title * @return The node title
*/ */
@Override @Override
public String getTitle() public String getTitle() {
{
return getFieldValue(ConfigureNodeFields.title); return getFieldValue(ConfigureNodeFields.title);
} }
@ -622,8 +571,7 @@ public class ConfigureForm extends Form
* @param title The node title * @param title The node title
*/ */
@Override @Override
public void setTitle(String title) public void setTitle(String title) {
{
addField(ConfigureNodeFields.title, FormField.Type.text_single); addField(ConfigureNodeFields.title, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.title.getFieldName(), title); setAnswer(ConfigureNodeFields.title.getFieldName(), title);
} }
@ -633,8 +581,7 @@ public class ConfigureForm extends Form
* *
* @return The type of node data * @return The type of node data
*/ */
public String getDataType() public String getDataType() {
{
return getFieldValue(ConfigureNodeFields.type); return getFieldValue(ConfigureNodeFields.type);
} }
@ -643,27 +590,23 @@ public class ConfigureForm extends Form
* *
* @param type The type of node data * @param type The type of node data
*/ */
public void setDataType(String type) public void setDataType(String type) {
{
addField(ConfigureNodeFields.type, FormField.Type.text_single); addField(ConfigureNodeFields.type, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.type.getFieldName(), type); setAnswer(ConfigureNodeFields.type.getFieldName(), type);
} }
@Override @Override
public String toString() public String toString() {
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content ["); StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields()) for (FormField formField : getFields()) {
{
result.append('('); result.append('(');
result.append(formField.getVariable()); result.append(formField.getVariable());
result.append(':'); result.append(':');
StringBuilder valuesBuilder = new StringBuilder(); StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues()) for (String value : formField.getValues()) {
{
if (valuesBuilder.length() > 0) if (valuesBuilder.length() > 0)
result.append(','); result.append(',');
valuesBuilder.append(value); valuesBuilder.append(value);
@ -678,39 +621,33 @@ public class ConfigureForm extends Form
return result.toString(); return result.toString();
} }
private static boolean parseBoolean(String fieldValue) private static boolean parseBoolean(String fieldValue) {
{
return ("1".equals(fieldValue) || "true".equals(fieldValue)); return ("1".equals(fieldValue) || "true".equals(fieldValue));
} }
private String getFieldValue(ConfigureNodeFields field) private String getFieldValue(ConfigureNodeFields field) {
{
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0); return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
} }
private List<String> getFieldValues(ConfigureNodeFields field) private List<String> getFieldValues(ConfigureNodeFields field) {
{
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return formField.getValues(); return formField.getValues();
} }
private void addField(ConfigureNodeFields nodeField, FormField.Type type) private void addField(ConfigureNodeFields nodeField, FormField.Type type) {
{
String fieldName = nodeField.getFieldName(); String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null) if (getField(fieldName) == null) {
{
FormField field = new FormField(fieldName); FormField field = new FormField(fieldName);
field.setType(type); field.setType(type);
addField(field); addField(field);
} }
} }
private static List<String> getListSingle(String value) private static List<String> getListSingle(String value) {
{
List<String> list = new ArrayList<>(1); List<String> list = new ArrayList<>(1);
list.add(value); list.add(value);
return list; return list;

View File

@ -27,8 +27,7 @@ import org.jivesoftware.smackx.xdata.Form;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum ConfigureNodeFields public enum ConfigureNodeFields {
{
/** /**
* Determines who may subscribe and retrieve items. * Determines who may subscribe and retrieve items.
* *
@ -214,8 +213,7 @@ public enum ConfigureNodeFields
*/ */
type; type;
public String getFieldName() public String getFieldName() {
{
return "pubsub#" + toString(); return "pubsub#" + toString();
} }
} }

View File

@ -37,8 +37,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public interface EmbeddedPacketExtension extends ExtensionElement public interface EmbeddedPacketExtension extends ExtensionElement {
{
/** /**
* Get the list of embedded {@link ExtensionElement} objects. * Get the list of embedded {@link ExtensionElement} objects.
* *

View File

@ -33,8 +33,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class EventElement implements EmbeddedPacketExtension public class EventElement implements EmbeddedPacketExtension {
{
/** /**
* The constant String "event". * The constant String "event".
*/ */
@ -48,37 +47,31 @@ public class EventElement implements EmbeddedPacketExtension
private final EventElementType type; private final EventElementType type;
private final NodeExtension ext; private final NodeExtension ext;
public EventElement(EventElementType eventType, NodeExtension eventExt) public EventElement(EventElementType eventType, NodeExtension eventExt) {
{
type = eventType; type = eventType;
ext = eventExt; ext = eventExt;
} }
public EventElementType getEventType() public EventElementType getEventType() {
{
return type; return type;
} }
@Override @Override
public List<ExtensionElement> getExtensions() public List<ExtensionElement> getExtensions() {
{
return Arrays.asList(new ExtensionElement[] {getEvent()}); return Arrays.asList(new ExtensionElement[] {getEvent()});
} }
public NodeExtension getEvent() public NodeExtension getEvent() {
{
return ext; return ext;
} }
@Override @Override
public String getElementName() public String getElementName() {
{
return "event"; return "event";
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return PubSubNamespace.EVENT.getXmlns(); return PubSubNamespace.EVENT.getXmlns();
} }

View File

@ -22,8 +22,8 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum EventElementType public enum EventElementType {
{
/** A node has been associated or disassociated with a collection node. */ /** A node has been associated or disassociated with a collection node. */
collection, collection,

View File

@ -26,8 +26,7 @@ import org.jivesoftware.smackx.xdata.Form;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class FormNode extends NodeExtension public class FormNode extends NodeExtension {
{
private final Form configForm; private final Form configForm;
/** /**
@ -36,8 +35,7 @@ public class FormNode extends NodeExtension
* @param formType The type of form being sent * @param formType The type of form being sent
* @param submitForm The form * @param submitForm The form
*/ */
public FormNode(FormNodeType formType, Form submitForm) public FormNode(FormNodeType formType, Form submitForm) {
{
super(formType.getNodeElement()); super(formType.getNodeElement());
if (submitForm == null) if (submitForm == null)
@ -53,8 +51,7 @@ public class FormNode extends NodeExtension
* @param nodeId The node the form is associated with * @param nodeId The node the form is associated with
* @param submitForm The form * @param submitForm The form
*/ */
public FormNode(FormNodeType formType, String nodeId, Form submitForm) public FormNode(FormNodeType formType, String nodeId, Form submitForm) {
{
super(formType.getNodeElement(), nodeId); super(formType.getNodeElement(), nodeId);
if (submitForm == null) if (submitForm == null)
@ -67,25 +64,20 @@ public class FormNode extends NodeExtension
* *
* @return The form * @return The form
*/ */
public Form getForm() public Form getForm() {
{
return configForm; return configForm;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{ if (configForm == null) {
if (configForm == null)
{
return super.toXML(); return super.toXML();
} }
else else {
{
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
if (getNode() != null) if (getNode() != null) {
{
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
builder.append("'>"); builder.append("'>");

View File

@ -38,15 +38,12 @@ public enum FormNodeType {
/** Form which represents the default node configuration options. */ /** Form which represents the default node configuration options. */
DEFAULT; DEFAULT;
public PubSubElementType getNodeElement() public PubSubElementType getNodeElement() {
{
return PubSubElementType.valueOf(toString()); return PubSubElementType.valueOf(toString());
} }
public static FormNodeType valueOfFromElementName(String elem, String configNamespace) public static FormNodeType valueOfFromElementName(String elem, String configNamespace) {
{ if ("configure".equals(elem) && PubSubNamespace.OWNER.getXmlns().equals(configNamespace)) {
if ("configure".equals(elem) && PubSubNamespace.OWNER.getXmlns().equals(configNamespace))
{
return CONFIGURE_OWNER; return CONFIGURE_OWNER;
} }
return valueOf(elem.toUpperCase(Locale.US)); return valueOf(elem.toUpperCase(Locale.US));

View File

@ -23,40 +23,33 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class GetItemsRequest extends NodeExtension public class GetItemsRequest extends NodeExtension {
{
protected final String subId; protected final String subId;
protected final int maxItems; protected final int maxItems;
public GetItemsRequest(String nodeId) public GetItemsRequest(String nodeId) {
{
this(nodeId, null, -1); this(nodeId, null, -1);
} }
public GetItemsRequest(String nodeId, String subscriptionId) public GetItemsRequest(String nodeId, String subscriptionId) {
{
this(nodeId, subscriptionId, -1); this(nodeId, subscriptionId, -1);
} }
public GetItemsRequest(String nodeId, int maxItemsToReturn) public GetItemsRequest(String nodeId, int maxItemsToReturn) {
{
this(nodeId, null, 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); super(PubSubElementType.ITEMS, nodeId);
maxItems = maxItemsToReturn; maxItems = maxItemsToReturn;
subId = subscriptionId; subId = subscriptionId;
} }
public String getSubscriptionId() public String getSubscriptionId() {
{
return subId; return subId;
} }
public int getMaxItems() public int getMaxItems() {
{
return maxItems; return maxItems;
} }

View File

@ -49,8 +49,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class Item extends NodeExtension public class Item extends NodeExtension {
{
private String id; private String id;
/** /**
@ -60,8 +59,7 @@ public class Item extends NodeExtension
* set to false, no <tt>Item</tt> is sent to the node, you have to use the {@link LeafNode#publish()} * set to false, no <tt>Item</tt> is sent to the node, you have to use the {@link LeafNode#publish()}
* method in this case. * method in this case.
*/ */
public Item() public Item() {
{
super(PubSubElementType.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. * @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()}. * 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 // The element type is actually irrelevant since we override getNamespace() to return null
super(PubSubElementType.ITEM); super(PubSubElementType.ITEM);
id = itemId; id = itemId;
@ -90,8 +87,7 @@ public class Item extends NodeExtension
* @param itemId The id of the item. * @param itemId The id of the item.
* @param nodeId The id of the node which the item was published to. * @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); super(PubSubElementType.ITEM_EVENT, nodeId);
id = itemId; id = itemId;
} }
@ -101,24 +97,20 @@ public class Item extends NodeExtension
* *
* @return The id * @return The id
*/ */
public String getId() public String getId() {
{
return id; return id;
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return null; return null;
} }
@Override @Override
public String toXML() public String toXML() {
{
StringBuilder builder = new StringBuilder("<item"); StringBuilder builder = new StringBuilder("<item");
if (id != null) if (id != null) {
{
builder.append(" id='"); builder.append(" id='");
builder.append(id); builder.append(id);
builder.append('\''); builder.append('\'');
@ -135,8 +127,7 @@ public class Item extends NodeExtension
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + " | Content [" + toXML() + "]"; return getClass().getName() + " | Content [" + toXML() + "]";
} }
} }

View File

@ -24,8 +24,7 @@ import java.util.List;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemDeleteEvent extends SubscriptionEvent public class ItemDeleteEvent extends SubscriptionEvent {
{
private List<String> itemIds = Collections.emptyList(); private List<String> itemIds = Collections.emptyList();
/** /**
@ -38,8 +37,7 @@ public class ItemDeleteEvent extends SubscriptionEvent
* @param deletedItemIds The item ids of the items that were deleted. * @param deletedItemIds The item ids of the items that were deleted.
* @param subscriptionIds The subscriptions that match the event. * @param subscriptionIds The subscriptions that match the event.
*/ */
public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds) public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds) {
{
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
if (deletedItemIds == null) if (deletedItemIds == null)
@ -52,14 +50,12 @@ public class ItemDeleteEvent extends SubscriptionEvent
* *
* @return List of item id's * @return List of item id's
*/ */
public List<String> getItemIds() public List<String> getItemIds() {
{
return Collections.unmodifiableList(itemIds); return Collections.unmodifiableList(itemIds);
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']'; return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']';
} }
} }

View File

@ -25,8 +25,7 @@ import java.util.List;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemPublishEvent<T extends Item> extends SubscriptionEvent public class ItemPublishEvent<T extends Item> extends SubscriptionEvent {
{
private List<T> items; private List<T> items;
private Date originalDate; private Date originalDate;
@ -37,8 +36,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* @param nodeId The id of the node the event came from * @param nodeId The id of the node the event came from
* @param eventItems The list of {@link Item} that were published * @param eventItems The list of {@link Item} that were published
*/ */
public ItemPublishEvent(String nodeId, List<T> eventItems) public ItemPublishEvent(String nodeId, List<T> eventItems) {
{
super(nodeId); super(nodeId);
items = eventItems; items = eventItems;
} }
@ -53,8 +51,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* @param eventItems The list of {@link Item} that were published * @param eventItems The list of {@link Item} that were published
* @param subscriptionIds The list of subscriptionIds * @param subscriptionIds The list of subscriptionIds
*/ */
public ItemPublishEvent(String nodeId, List<T> eventItems, List<String> subscriptionIds) public ItemPublishEvent(String nodeId, List<T> eventItems, List<String> subscriptionIds) {
{
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
items = eventItems; items = eventItems;
} }
@ -71,8 +68,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* @param subscriptionIds The list of subscriptionIds * @param subscriptionIds The list of subscriptionIds
* @param publishedDate date of publication. * @param publishedDate date of publication.
*/ */
public ItemPublishEvent(String nodeId, List<T> eventItems, List<String> subscriptionIds, Date publishedDate) public ItemPublishEvent(String nodeId, List<T> eventItems, List<String> subscriptionIds, Date publishedDate) {
{
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
items = eventItems; items = eventItems;
@ -85,8 +81,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* *
* @return The list of published {@link Item} * @return The list of published {@link Item}
*/ */
public List<T> getItems() public List<T> getItems() {
{
return Collections.unmodifiableList(items); return Collections.unmodifiableList(items);
} }
@ -100,8 +95,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* *
* @return true if the items are delayed, false otherwise. * @return true if the items are delayed, false otherwise.
*/ */
public boolean isDelayed() public boolean isDelayed() {
{
return (originalDate != null); return (originalDate != null);
} }
@ -111,14 +105,12 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
* *
* @return date of publication. * @return date of publication.
*/ */
public Date getPublishedDate() public Date getPublishedDate() {
{
return originalDate; return originalDate;
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " + return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " +
(isDelayed() ? originalDate.toString() : "false") + ']'; (isDelayed() ? originalDate.toString() : "false") + ']';
} }

View File

@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum ItemReply public enum ItemReply {
{
/** The node owner. */ /** The node owner. */
owner, owner,

View File

@ -34,14 +34,12 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemsExtension extends NodeExtension implements EmbeddedPacketExtension public class ItemsExtension extends NodeExtension implements EmbeddedPacketExtension {
{
protected ItemsElementType type; protected ItemsElementType type;
protected Boolean notify; protected Boolean notify;
protected List<? extends ExtensionElement> items; protected List<? extends ExtensionElement> items;
public enum ItemsElementType public enum ItemsElementType {
{
/** An items element, which has an optional <b>max_items</b> attribute when requesting items. */ /** An items element, which has an optional <b>max_items</b> attribute when requesting items. */
items(PubSubElementType.ITEMS, "max_items"), items(PubSubElementType.ITEMS, "max_items"),
@ -51,19 +49,16 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
private final PubSubElementType elem; private final PubSubElementType elem;
private final String att; private final String att;
ItemsElementType(PubSubElementType nodeElement, String attribute) ItemsElementType(PubSubElementType nodeElement, String attribute) {
{
elem = nodeElement; elem = nodeElement;
att = attribute; att = attribute;
} }
public PubSubElementType getNodeElement() public PubSubElementType getNodeElement() {
{
return elem; return elem;
} }
public String getElementAttribute() public String getElementAttribute() {
{
return att; 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 nodeId The node to which the items are being sent or deleted
* @param items The list of {@link Item} or {@link RetractItem} * @param items The list of {@link Item} or {@link RetractItem}
*/ */
public ItemsExtension(ItemsElementType itemsType, String nodeId, List<? extends ExtensionElement> items) public ItemsExtension(ItemsElementType itemsType, String nodeId, List<? extends ExtensionElement> items) {
{
super(itemsType.getNodeElement(), nodeId); super(itemsType.getNodeElement(), nodeId);
type = itemsType; type = itemsType;
this.items = items; 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 items The list of {@link Item} or {@link RetractItem}
* @param notify * @param notify
*/ */
public ItemsExtension(String nodeId, List<? extends ExtensionElement> items, boolean notify) public ItemsExtension(String nodeId, List<? extends ExtensionElement> items, boolean notify) {
{
super(ItemsElementType.retract.getNodeElement(), nodeId); super(ItemsElementType.retract.getNodeElement(), nodeId);
type = ItemsElementType.retract; type = ItemsElementType.retract;
this.items = items; this.items = items;
@ -126,15 +119,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
* *
* @return The element type * @return The element type
*/ */
public ItemsElementType getItemsElementType() public ItemsElementType getItemsElementType() {
{
return type; return type;
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions() public List<ExtensionElement> getExtensions() {
{
return (List<ExtensionElement>) getItems(); return (List<ExtensionElement>) getItems();
} }
@ -143,8 +134,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
* *
* @return List of {@link Item}, {@link RetractItem}, or null * @return List of {@link Item}, {@link RetractItem}, or null
*/ */
public List<? extends ExtensionElement> getItems() public List<? extends ExtensionElement> getItems() {
{
return items; return items;
} }
@ -153,38 +143,31 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
* *
* @return The attribute value * @return The attribute value
*/ */
public boolean getNotify() public boolean getNotify() {
{
return notify; return notify;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{ if ((items == null) || (items.size() == 0)) {
if ((items == null) || (items.size() == 0))
{
return super.toXML(); return super.toXML();
} }
else else {
{
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
if (notify != null) if (notify != null) {
{
builder.append("' "); builder.append("' ");
builder.append(type.getElementAttribute()); builder.append(type.getElementAttribute());
builder.append("='"); builder.append("='");
builder.append(notify.equals(Boolean.TRUE) ? 1 : 0); builder.append(notify.equals(Boolean.TRUE) ? 1 : 0);
builder.append("'>"); builder.append("'>");
} }
else else {
{
builder.append("'>"); builder.append("'>");
for (ExtensionElement item : items) for (ExtensionElement item : items) {
{
builder.append(item.toXML()); builder.append(item.toXML());
} }
} }
@ -197,8 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + "Content [" + toXML() + "]"; return getClass().getName() + "Content [" + toXML() + "]";
} }

View File

@ -37,10 +37,8 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class LeafNode extends Node public class LeafNode extends Node {
{ LeafNode(PubSubManager pubSubManager, String nodeId) {
LeafNode(PubSubManager pubSubManager, String nodeId)
{
super(pubSubManager, nodeId); super(pubSubManager, nodeId);
} }
@ -54,8 +52,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public DiscoverItems discoverItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
DiscoverItems items = new DiscoverItems(); DiscoverItems items = new DiscoverItems();
items.setTo(pubSubManager.getServiceJid()); items.setTo(pubSubManager.getServiceJid());
items.setNode(getId()); items.setNode(getId());
@ -72,8 +69,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
return getItems((List<ExtensionElement>) null, null); return getItems((List<ExtensionElement>) null, null);
} }
@ -92,8 +88,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId)); PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId));
return getItems(request); return getItems(request);
} }
@ -114,12 +109,10 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
List<Item> itemList = new ArrayList<>(ids.size()); List<Item> itemList = new ArrayList<>(ids.size());
for (String id : ids) for (String id : ids) {
{
itemList.add(new Item(id)); itemList.add(new Item(id));
} }
PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList)); PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
@ -138,8 +131,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems)); PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
return getItems(request); return getItems(request);
} }
@ -160,8 +152,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems)); PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems));
return getItems(request); return getItems(request);
} }
@ -224,8 +215,7 @@ public class LeafNode extends Node
* @deprecated use {@link #publish()} instead. * @deprecated use {@link #publish()} instead.
*/ */
@Deprecated @Deprecated
public void send() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException public void send() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
{
publish(); publish();
} }
@ -248,8 +238,7 @@ public class LeafNode extends Node
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Deprecated @Deprecated
public <T extends Item> void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException public <T extends Item> void send(T item) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
{
publish(item); publish(item);
} }
@ -269,8 +258,7 @@ public class LeafNode extends Node
* @deprecated use {@link #publish(Collection)} instead. * @deprecated use {@link #publish(Collection)} instead.
*/ */
@Deprecated @Deprecated
public <T extends Item> void send(Collection<T> items) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException public <T extends Item> void send(Collection<T> items) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
{
publish(items); publish(items);
} }
@ -287,8 +275,7 @@ public class LeafNode extends Node
* @throws InterruptedException * @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())); PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
@ -316,8 +303,7 @@ public class LeafNode extends Node
* *
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Item> void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
Collection<T> items = new ArrayList<>(1); Collection<T> items = new ArrayList<>(1);
items.add((item == null ? (T) new Item() : item)); items.add((item == null ? (T) new Item() : item));
publish(items); publish(items);
@ -338,8 +324,7 @@ public class LeafNode extends Node
* @throws InterruptedException * @throws InterruptedException
* *
*/ */
public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items)); PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
@ -355,8 +340,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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()); PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
@ -371,8 +355,7 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
Collection<String> items = new ArrayList<>(1); Collection<String> items = new ArrayList<>(1);
items.add(itemId); items.add(itemId);
deleteItem(items); deleteItem(items);
@ -387,13 +370,11 @@ public class LeafNode extends Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
List<Item> items = new ArrayList<>(itemIds.size()); List<Item> items = new ArrayList<>(itemIds.size());
for (String id : itemIds) for (String id : itemIds) {
{ items.add(new Item(id));
items.add(new Item(id));
} }
PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items)); PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();

View File

@ -44,8 +44,7 @@ import org.jivesoftware.smackx.shim.packet.Header;
import org.jivesoftware.smackx.shim.packet.HeadersExtension; import org.jivesoftware.smackx.shim.packet.HeadersExtension;
import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.Form;
public abstract class Node public abstract class Node {
{
protected final PubSubManager pubSubManager; protected final PubSubManager pubSubManager;
protected final String id; 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 pubSubManager The PubSubManager for the connection the node is associated with
* @param nodeId The node id * @param nodeId The node id
*/ */
Node(PubSubManager pubSubManager, String nodeId) Node(PubSubManager pubSubManager, String nodeId) {
{
this.pubSubManager = pubSubManager; this.pubSubManager = pubSubManager;
id = nodeId; id = nodeId;
} }
@ -71,8 +69,7 @@ public abstract class Node
* *
* @return the node id * @return the node id
*/ */
public String getId() public String getId() {
{
return id; return id;
} }
/** /**
@ -85,8 +82,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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( PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(
PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER); PubSubElementType.CONFIGURE_OWNER, getId()), PubSubNamespace.OWNER);
Stanza reply = sendPubsubPacket(pubSub); Stanza reply = sendPubsubPacket(pubSub);
@ -102,8 +98,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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, PubSub packet = createPubsubPacket(Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
getId(), submitForm), PubSubNamespace.OWNER); getId(), submitForm), PubSubNamespace.OWNER);
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
@ -118,8 +113,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public DiscoverInfo discoverInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();
info.setTo(pubSubManager.getServiceJid()); info.setTo(pubSubManager.getServiceJid());
info.setNode(getId()); info.setNode(getId());
@ -136,8 +130,7 @@ public abstract class Node
* @throws InterruptedException * @throws InterruptedException
* *
*/ */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
return getSubscriptions(null, null); return getSubscriptions(null, null);
} }
@ -365,8 +358,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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 pubSub = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
PubSub reply = sendPubsubPacket(pubSub); PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION); return reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -394,8 +386,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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())); PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm)); request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
PubSub reply = sendPubsubPacket(request); PubSub reply = sendPubsubPacket(request);
@ -414,8 +405,7 @@ public abstract class Node
* @throws InterruptedException * @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); unsubscribe(jid, null);
} }
@ -429,8 +419,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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))); sendPubsubPacket(createPubsubPacket(Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId)));
} }
@ -446,8 +435,7 @@ public abstract class Node
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); return getSubscriptionOptions(jid, null);
} }
@ -465,8 +453,7 @@ public abstract class Node
* @throws InterruptedException * @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))); PubSub packet = sendPubsubPacket(createPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
FormNode ext = packet.getExtension(PubSubElementType.OPTIONS); FormNode ext = packet.getExtension(PubSubElementType.OPTIONS);
return new SubscribeForm(ext.getForm()); return new SubscribeForm(ext.getForm());
@ -480,8 +467,7 @@ public abstract class Node
* @param listener The handler for the event * @param listener The handler for the event
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) public void addItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) {
{
StanzaListener conListener = new ItemEventTranslator(listener); StanzaListener conListener = new ItemEventTranslator(listener);
itemEventToListenerMap.put(listener, conListener); itemEventToListenerMap.put(listener, conListener);
pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item")); pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.items.toString(), "item"));
@ -492,8 +478,7 @@ public abstract class Node
* *
* @param listener The handler to unregister * @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); StanzaListener conListener = itemEventToListenerMap.remove(listener);
if (conListener != null) if (conListener != null)
@ -506,8 +491,7 @@ public abstract class Node
* *
* @param listener The handler for the event * @param listener The handler for the event
*/ */
public void addConfigurationListener(NodeConfigListener listener) public void addConfigurationListener(NodeConfigListener listener) {
{
StanzaListener conListener = new NodeConfigTranslator(listener); StanzaListener conListener = new NodeConfigTranslator(listener);
configEventToListenerMap.put(listener, conListener); configEventToListenerMap.put(listener, conListener);
pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.configuration.toString())); pubSubManager.getConnection().addSyncStanzaListener(conListener, new EventContentFilter(EventElementType.configuration.toString()));
@ -518,8 +502,7 @@ public abstract class Node
* *
* @param listener The handler to unregister * @param listener The handler to unregister
*/ */
public void removeConfigurationListener(NodeConfigListener listener) public void removeConfigurationListener(NodeConfigListener listener) {
{
StanzaListener conListener = configEventToListenerMap .remove(listener); StanzaListener conListener = configEventToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
@ -532,8 +515,7 @@ public abstract class Node
* *
* @param listener The handler for the event * @param listener The handler for the event
*/ */
public void addItemDeleteListener(ItemDeleteListener listener) public void addItemDeleteListener(ItemDeleteListener listener) {
{
StanzaListener delListener = new ItemDeleteTranslator(listener); StanzaListener delListener = new ItemDeleteTranslator(listener);
itemDeleteToListenerMap.put(listener, delListener); itemDeleteToListenerMap.put(listener, delListener);
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract"); EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
@ -547,8 +529,7 @@ public abstract class Node
* *
* @param listener The handler to unregister * @param listener The handler to unregister
*/ */
public void removeItemDeleteListener(ItemDeleteListener listener) public void removeItemDeleteListener(ItemDeleteListener listener) {
{
StanzaListener conListener = itemDeleteToListenerMap .remove(listener); StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
@ -556,38 +537,31 @@ public abstract class Node
} }
@Override @Override
public String toString() public String toString() {
{
return super.toString() + " " + getClass().getName() + " id: " + id; 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); 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); 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); return pubSubManager.sendPubsubPacket(packet);
} }
private static List<String> getSubscriptionIds(Stanza packet) private static List<String> getSubscriptionIds(Stanza packet) {
{
HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim"); HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null; List<String> values = null;
if (headers != null) if (headers != null) {
{
values = new ArrayList<>(headers.getHeaders().size()); values = new ArrayList<>(headers.getHeaders().size());
for (Header header : headers.getHeaders()) for (Header header : headers.getHeaders()) {
{
values.add(header.getValue()); values.add(header.getValue());
} }
} }
@ -600,20 +574,17 @@ public abstract class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public static class ItemEventTranslator implements StanzaListener public static class ItemEventTranslator implements StanzaListener {
{
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private final ItemEventListener listener; private final ItemEventListener listener;
public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener) public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener) {
{
listener = eventListener; listener = eventListener;
} }
@Override @Override
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public void processStanza(Stanza packet) public void processStanza(Stanza packet) {
{
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ItemsExtension itemsElem = (ItemsExtension) event.getEvent(); ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet)); ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
@ -627,36 +598,30 @@ public abstract class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public static class ItemDeleteTranslator implements StanzaListener public static class ItemDeleteTranslator implements StanzaListener {
{
private final ItemDeleteListener listener; private final ItemDeleteListener listener;
public ItemDeleteTranslator(ItemDeleteListener eventListener) public ItemDeleteTranslator(ItemDeleteListener eventListener) {
{
listener = eventListener; listener = eventListener;
} }
@Override @Override
public void processStanza(Stanza packet) public void processStanza(Stanza packet) {
{
// CHECKSTYLE:OFF // CHECKSTYLE:OFF
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions(); List<ExtensionElement> 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(); listener.handlePurge();
} }
else else {
{
ItemsExtension itemsElem = (ItemsExtension)event.getEvent(); ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems(); Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
List<String> items = new ArrayList<>(pubItems.size()); List<String> items = new ArrayList<>(pubItems.size());
for (RetractItem item : pubItems) for (RetractItem item : pubItems) {
{
items.add(item.getId()); items.add(item.getId());
} }
@ -673,18 +638,15 @@ public abstract class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
public static class NodeConfigTranslator implements StanzaListener public static class NodeConfigTranslator implements StanzaListener {
{
private final NodeConfigListener listener; private final NodeConfigListener listener;
public NodeConfigTranslator(NodeConfigListener eventListener) public NodeConfigTranslator(NodeConfigListener eventListener) {
{
listener = eventListener; listener = eventListener;
} }
@Override @Override
public void processStanza(Stanza packet) public void processStanza(Stanza packet) {
{
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ConfigurationEvent config = (ConfigurationEvent) event.getEvent(); ConfigurationEvent config = (ConfigurationEvent) event.getEvent();
@ -698,19 +660,16 @@ public abstract class Node
* *
* @author Robin Collier * @author Robin Collier
*/ */
class EventContentFilter extends FlexibleStanzaTypeFilter<Message> class EventContentFilter extends FlexibleStanzaTypeFilter<Message> {
{
private final String firstElement; private final String firstElement;
private final String secondElement; private final String secondElement;
private final boolean allowEmpty; private final boolean allowEmpty;
EventContentFilter(String elementName) EventContentFilter(String elementName) {
{
this(elementName, null); this(elementName, null);
} }
EventContentFilter(String firstLevelElement, String secondLevelElement) EventContentFilter(String firstLevelElement, String secondLevelElement) {
{
firstElement = firstLevelElement; firstElement = firstLevelElement;
secondElement = secondLevelElement; secondElement = secondLevelElement;
allowEmpty = firstElement.equals(EventElementType.items.toString()) allowEmpty = firstElement.equals(EventElementType.items.toString())
@ -729,16 +688,14 @@ public abstract class Node
if (embedEvent == null) if (embedEvent == null)
return false; return false;
if (embedEvent.getElementName().equals(firstElement)) if (embedEvent.getElementName().equals(firstElement)) {
{
if (!embedEvent.getNode().equals(getId())) if (!embedEvent.getNode().equals(getId()))
return false; return false;
if (secondElement == null) if (secondElement == null)
return true; return true;
if (embedEvent instanceof EmbeddedPacketExtension) if (embedEvent instanceof EmbeddedPacketExtension) {
{
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension) embedEvent).getExtensions(); List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension) embedEvent).getExtensions();
// XEP-0060 allows no elements on second level for notifications. See schema or // XEP-0060 allows no elements on second level for notifications. See schema or

View File

@ -16,17 +16,14 @@
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
public abstract class NodeEvent public abstract class NodeEvent {
{
private String nodeId; private String nodeId;
protected NodeEvent(String id) protected NodeEvent(String id) {
{
nodeId = id; nodeId = id;
} }
public String getNodeId() public String getNodeId() {
{
return nodeId; return nodeId;
} }
} }

View File

@ -26,8 +26,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class NodeExtension implements ExtensionElement public class NodeExtension implements ExtensionElement {
{
private final PubSubElementType element; private final PubSubElementType element;
private final String node; private final String node;
@ -38,8 +37,7 @@ public class NodeExtension implements ExtensionElement
* @param elem Defines the element name and namespace * @param elem Defines the element name and namespace
* @param nodeId Specifies the id of the node * @param nodeId Specifies the id of the node
*/ */
public NodeExtension(PubSubElementType elem, String nodeId) public NodeExtension(PubSubElementType elem, String nodeId) {
{
element = elem; element = elem;
this.node = nodeId; this.node = nodeId;
} }
@ -50,8 +48,7 @@ public class NodeExtension implements ExtensionElement
* *
* @param elem Defines the element name and namespace * @param elem Defines the element name and namespace
*/ */
public NodeExtension(PubSubElementType elem) public NodeExtension(PubSubElementType elem) {
{
this(elem, null); this(elem, null);
} }
@ -60,32 +57,27 @@ public class NodeExtension implements ExtensionElement
* *
* @return The node id * @return The node id
*/ */
public String getNode() public String getNode() {
{
return node; return node;
} }
@Override @Override
public String getElementName() public String getElementName() {
{
return element.getElementName(); return element.getElementName();
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return element.getNamespace().getXmlns(); return element.getNamespace().getXmlns();
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{
return '<' + getElementName() + (node == null ? "" : " node='" + node + '\'') + "/>"; return '<' + getElementName() + (node == null ? "" : " node='" + node + '\'') + "/>";
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + " - content [" + toXML() + "]"; return getClass().getName() + " - content [" + toXML() + "]";
} }
} }

View File

@ -21,8 +21,7 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum NodeType public enum NodeType {
{
leaf, leaf,
collection collection
} }

View File

@ -23,35 +23,29 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class OptionsExtension extends NodeExtension public class OptionsExtension extends NodeExtension {
{
protected String jid; protected String jid;
protected String id; protected String id;
public OptionsExtension(String subscriptionJid) public OptionsExtension(String subscriptionJid) {
{
this(subscriptionJid, null, null); this(subscriptionJid, null, null);
} }
public OptionsExtension(String subscriptionJid, String nodeId) public OptionsExtension(String subscriptionJid, String nodeId) {
{
this(subscriptionJid, nodeId, null); this(subscriptionJid, nodeId, null);
} }
public OptionsExtension(String jid, String nodeId, String subscriptionId) public OptionsExtension(String jid, String nodeId, String subscriptionId) {
{
super(PubSubElementType.OPTIONS, nodeId); super(PubSubElementType.OPTIONS, nodeId);
this.jid = jid; this.jid = jid;
id = subscriptionId; id = subscriptionId;
} }
public String getJid() public String getJid() {
{
return jid; return jid;
} }
public String getId() public String getId() {
{
return id; return id;
} }

View File

@ -48,8 +48,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class PayloadItem<E extends ExtensionElement> extends Item public class PayloadItem<E extends ExtensionElement> extends Item {
{
private final E payload; private final E payload;
/** /**
@ -57,8 +56,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
* *
* @param payloadExt A {@link ExtensionElement} which represents the payload data. * @param payloadExt A {@link ExtensionElement} which represents the payload data.
*/ */
public PayloadItem(E payloadExt) public PayloadItem(E payloadExt) {
{
super(); super();
if (payloadExt == null) if (payloadExt == null)
@ -72,8 +70,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
* @param itemId The id of this item. It can be null if we want the server to set the id. * @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. * @param payloadExt A {@link ExtensionElement} which represents the payload data.
*/ */
public PayloadItem(String itemId, E payloadExt) public PayloadItem(String itemId, E payloadExt) {
{
super(itemId); super(itemId);
if (payloadExt == null) if (payloadExt == null)
@ -95,8 +92,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
* @param nodeId The id of the node the item was published to. * @param nodeId The id of the node the item was published to.
* @param payloadExt A {@link ExtensionElement} which represents the payload data. * @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); super(itemId, nodeId);
if (payloadExt == null) if (payloadExt == null)
@ -110,18 +106,15 @@ public class PayloadItem<E extends ExtensionElement> extends Item
* *
* @return The payload as a {@link ExtensionElement}. * @return The payload as a {@link ExtensionElement}.
*/ */
public E getPayload() public E getPayload() {
{
return payload; return payload;
} }
@Override @Override
public String toXML() public String toXML() {
{
StringBuilder builder = new StringBuilder("<item"); StringBuilder builder = new StringBuilder("<item");
if (getId() != null) if (getId() != null) {
{
builder.append(" id='"); builder.append(" id='");
builder.append(getId()); builder.append(getId());
builder.append('\''); builder.append('\'');
@ -140,8 +133,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + " | Content [" + toXML() + "]"; return getClass().getName() + " | Content [" + toXML() + "]";
} }
} }

View File

@ -22,7 +22,6 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum PresenceState public enum PresenceState {
{
chat, online, away, xa, dnd chat, online, away, xa, dnd
} }

View File

@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum PubSubElementType public enum PubSubElementType {
{
CREATE("create", PubSubNamespace.BASIC), CREATE("create", PubSubNamespace.BASIC),
DELETE("delete", PubSubNamespace.OWNER), DELETE("delete", PubSubNamespace.OWNER),
DELETE_EVENT("delete", PubSubNamespace.EVENT), DELETE_EVENT("delete", PubSubNamespace.EVENT),
@ -54,29 +53,24 @@ public enum PubSubElementType
private final String eName; private final String eName;
private final PubSubNamespace nSpace; private final PubSubNamespace nSpace;
PubSubElementType(String elemName, PubSubNamespace ns) PubSubElementType(String elemName, PubSubNamespace ns) {
{
eName = elemName; eName = elemName;
nSpace = ns; nSpace = ns;
} }
public PubSubNamespace getNamespace() public PubSubNamespace getNamespace() {
{
return nSpace; return nSpace;
} }
public String getElementName() public String getElementName() {
{
return eName; return eName;
} }
public static PubSubElementType valueOfFromElemName(String elemName, String namespace) public static PubSubElementType valueOfFromElemName(String elemName, String namespace) {
{
int index = namespace.lastIndexOf('#'); int index = namespace.lastIndexOf('#');
String fragment = (index == -1 ? null : namespace.substring(index + 1)); 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 + '_' + fragment).toUpperCase(Locale.US));
} }
return valueOf(elemName.toUpperCase(Locale.US).replace('-', '_')); return valueOf(elemName.toUpperCase(Locale.US).replace('-', '_'));

View File

@ -141,8 +141,7 @@ public final class PubSubManager extends Manager {
* @param connection The XMPP connection * @param connection The XMPP connection
* @param toAddress The pubsub specific to address (required for some servers) * @param toAddress The pubsub specific to address (required for some servers)
*/ */
PubSubManager(XMPPConnection connection, BareJid toAddress) PubSubManager(XMPPConnection connection, BareJid toAddress) {
{
super(connection); super(connection);
pubSubService = toAddress; pubSubService = toAddress;
} }
@ -156,8 +155,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns()); NodeExtension elem = reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
@ -178,8 +176,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); return (LeafNode) createNode(nodeId, null);
} }
@ -197,13 +194,11 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId), null);
boolean isLeafNode = true; boolean isLeafNode = true;
if (config != null) if (config != null) {
{
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config)); request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName()); FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
@ -234,12 +229,10 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException * @throws InterruptedException
* @throws NotAPubSubNodeException * @throws NotAPubSubNodeException
*/ */
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException {
{
Node node = nodeMap.get(id); Node node = nodeMap.get(id);
if (node == null) if (node == null) {
{
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();
info.setTo(pubSubService); info.setTo(pubSubService);
info.setNode(id); info.setNode(id);
@ -429,8 +422,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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(); DiscoverItems items = new DiscoverItems();
if (nodeId != null) if (nodeId != null)
@ -449,8 +441,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null); Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions(); return subElem.getSubscriptions();
@ -466,8 +457,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException * @throws InterruptedException
* *
*/ */
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null); PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS); AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations(); return listElem.getAffiliations();
@ -482,8 +472,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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()); sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
nodeMap.remove(nodeId); nodeMap.remove(nodeId);
} }
@ -497,8 +486,7 @@ public final class PubSubManager extends Manager {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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 // Errors will cause exceptions in getReply, so it only returns
// on success. // on success.
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace()); 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 NotConnectedException
* @throws InterruptedException * @throws InterruptedException
*/ */
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
{
ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(connection()); ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(connection());
return mgr.discoverInfo(pubSubService); return mgr.discoverInfo(pubSubService);
} }

View File

@ -24,8 +24,7 @@ import java.util.Collection;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class PublishItem<T extends Item> extends NodeExtension public class PublishItem<T extends Item> extends NodeExtension {
{
protected Collection<T> items; protected Collection<T> items;
/** /**
@ -34,8 +33,7 @@ public class PublishItem<T extends Item> extends NodeExtension
* @param nodeId The node to publish to * @param nodeId The node to publish to
* @param toPublish The {@link Item} to publish * @param toPublish The {@link Item} to publish
*/ */
public PublishItem(String nodeId, T toPublish) public PublishItem(String nodeId, T toPublish) {
{
super(PubSubElementType.PUBLISH, nodeId); super(PubSubElementType.PUBLISH, nodeId);
items = new ArrayList<>(1); items = new ArrayList<>(1);
items.add(toPublish); items.add(toPublish);
@ -47,23 +45,20 @@ public class PublishItem<T extends Item> extends NodeExtension
* @param nodeId The node to publish to * @param nodeId The node to publish to
* @param toPublish The list of {@link Item} to publish * @param toPublish The list of {@link Item} to publish
*/ */
public PublishItem(String nodeId, Collection<T> toPublish) public PublishItem(String nodeId, Collection<T> toPublish) {
{
super(PubSubElementType.PUBLISH, nodeId); super(PubSubElementType.PUBLISH, nodeId);
items = toPublish; items = toPublish;
} }
@Override @Override
public String toXML() public String toXML() {
{
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
builder.append("'>"); builder.append("'>");
for (Item item : items) for (Item item : items) {
{
builder.append(item.toXML()); builder.append(item.toXML());
} }
builder.append("</publish>"); builder.append("</publish>");

View File

@ -22,8 +22,7 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum PublishModel public enum PublishModel {
{
/** Only publishers may publish. */ /** Only publishers may publish. */
publishers, publishers,

View File

@ -25,8 +25,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class RetractItem implements ExtensionElement public class RetractItem implements ExtensionElement {
{
private final String id; private final String id;
/** /**
@ -34,33 +33,28 @@ public class RetractItem implements ExtensionElement
* *
* @param itemId The id if the item deleted * @param itemId The id if the item deleted
*/ */
public RetractItem(String itemId) public RetractItem(String itemId) {
{
if (itemId == null) if (itemId == null)
throw new IllegalArgumentException("itemId must not be 'null'"); throw new IllegalArgumentException("itemId must not be 'null'");
id = itemId; id = itemId;
} }
public String getId() public String getId() {
{
return id; return id;
} }
@Override @Override
public String getElementName() public String getElementName() {
{
return "retract"; return "retract";
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return PubSubNamespace.EVENT.getXmlns(); return PubSubNamespace.EVENT.getXmlns();
} }
@Override @Override
public String toXML() public String toXML() {
{
return "<retract id='" + id + "'/>"; return "<retract id='" + id + "'/>";
} }
} }

View File

@ -24,8 +24,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SimplePayload implements ExtensionElement public class SimplePayload implements ExtensionElement {
{
private final String elemName; private final String elemName;
private final String ns; private final String ns;
private final CharSequence payload; 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 namespace The namespace of the payload, null if there is none
* @param xmlPayload The payload data * @param xmlPayload The payload data
*/ */
public SimplePayload(String elementName, String namespace, CharSequence xmlPayload) public SimplePayload(String elementName, String namespace, CharSequence xmlPayload) {
{
elemName = elementName; elemName = elementName;
payload = xmlPayload; payload = xmlPayload;
ns = namespace; ns = namespace;
} }
@Override @Override
public String getElementName() public String getElementName() {
{
return elemName; return elemName;
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return ns; return ns;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{
return payload; return payload;
} }
@Override @Override
public String toString() public String toString() {
{
return getClass().getName() + "payload [" + toXML() + "]"; return getClass().getName() + "payload [" + toXML() + "]";
} }
} }

View File

@ -21,35 +21,29 @@ package org.jivesoftware.smackx.pubsub;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SubscribeExtension extends NodeExtension public class SubscribeExtension extends NodeExtension {
{
protected String jid; protected String jid;
public SubscribeExtension(String subscribeJid) public SubscribeExtension(String subscribeJid) {
{
super(PubSubElementType.SUBSCRIBE); super(PubSubElementType.SUBSCRIBE);
jid = subscribeJid; jid = subscribeJid;
} }
public SubscribeExtension(String subscribeJid, String nodeId) public SubscribeExtension(String subscribeJid, String nodeId) {
{
super(PubSubElementType.SUBSCRIBE, nodeId); super(PubSubElementType.SUBSCRIBE, nodeId);
jid = subscribeJid; jid = subscribeJid;
} }
public String getJid() public String getJid() {
{
return jid; return jid;
} }
@Override @Override
public String toXML() public String toXML() {
{
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
if (getNode() != null) if (getNode() != null) {
{
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
builder.append('\''); builder.append('\'');

View File

@ -39,20 +39,16 @@ import org.jxmpp.util.XmppDateTime;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SubscribeForm extends Form public class SubscribeForm extends Form {
{ public SubscribeForm(DataForm configDataForm) {
public SubscribeForm(DataForm configDataForm)
{
super(configDataForm); super(configDataForm);
} }
public SubscribeForm(Form subscribeOptionsForm) public SubscribeForm(Form subscribeOptionsForm) {
{
super(subscribeOptionsForm.getDataFormToSend()); super(subscribeOptionsForm.getDataFormToSend());
} }
public SubscribeForm(DataForm.Type formType) public SubscribeForm(DataForm.Type formType) {
{
super(formType); super(formType);
} }
@ -61,8 +57,7 @@ public class SubscribeForm extends Form
* *
* @return true if want to receive, false otherwise * @return true if want to receive, false otherwise
*/ */
public boolean isDeliverOn() public boolean isDeliverOn() {
{
return parseBoolean(getFieldValue(SubscribeOptionFields.deliver)); return parseBoolean(getFieldValue(SubscribeOptionFields.deliver));
} }
@ -71,8 +66,7 @@ public class SubscribeForm extends Form
* *
* @param deliverNotifications * @param deliverNotifications
*/ */
public void setDeliverOn(boolean deliverNotifications) public void setDeliverOn(boolean deliverNotifications) {
{
addField(SubscribeOptionFields.deliver, FormField.Type.bool); addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), deliverNotifications); setAnswer(SubscribeOptionFields.deliver.getFieldName(), deliverNotifications);
} }
@ -82,8 +76,7 @@ public class SubscribeForm extends Form
* *
* @return true to aggregate, false otherwise * @return true to aggregate, false otherwise
*/ */
public boolean isDigestOn() public boolean isDigestOn() {
{
return parseBoolean(getFieldValue(SubscribeOptionFields.digest)); return parseBoolean(getFieldValue(SubscribeOptionFields.digest));
} }
@ -92,8 +85,7 @@ public class SubscribeForm extends Form
* *
* @param digestOn true to aggregate, false otherwise * @param digestOn true to aggregate, false otherwise
*/ */
public void setDigestOn(boolean digestOn) public void setDigestOn(boolean digestOn) {
{
addField(SubscribeOptionFields.deliver, FormField.Type.bool); addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), digestOn); setAnswer(SubscribeOptionFields.deliver.getFieldName(), digestOn);
} }
@ -103,8 +95,7 @@ public class SubscribeForm extends Form
* *
* @return The frequency in milliseconds * @return The frequency in milliseconds
*/ */
public int getDigestFrequency() public int getDigestFrequency() {
{
return Integer.parseInt(getFieldValue(SubscribeOptionFields.digest_frequency)); return Integer.parseInt(getFieldValue(SubscribeOptionFields.digest_frequency));
} }
@ -113,8 +104,7 @@ public class SubscribeForm extends Form
* *
* @param frequency The frequency in milliseconds * @param frequency The frequency in milliseconds
*/ */
public void setDigestFrequency(int frequency) public void setDigestFrequency(int frequency) {
{
addField(SubscribeOptionFields.digest_frequency, FormField.Type.text_single); addField(SubscribeOptionFields.digest_frequency, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.digest_frequency.getFieldName(), frequency); setAnswer(SubscribeOptionFields.digest_frequency.getFieldName(), frequency);
} }
@ -124,15 +114,12 @@ public class SubscribeForm extends Form
* *
* @return The expiry date * @return The expiry date
*/ */
public Date getExpiry() public Date getExpiry() {
{
String dateTime = getFieldValue(SubscribeOptionFields.expire); String dateTime = getFieldValue(SubscribeOptionFields.expire);
try try {
{
return XmppDateTime.parseDate(dateTime); return XmppDateTime.parseDate(dateTime);
} }
catch (ParseException e) catch (ParseException e) {
{
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime); UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e); exc.initCause(e);
throw exc; throw exc;
@ -144,8 +131,7 @@ public class SubscribeForm extends Form
* *
* @param expire The expiry date * @param expire The expiry date
*/ */
public void setExpiry(Date expire) public void setExpiry(Date expire) {
{
addField(SubscribeOptionFields.expire, FormField.Type.text_single); addField(SubscribeOptionFields.expire, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire)); 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 * @return true to receive the message body, false otherwise
*/ */
public boolean isIncludeBody() public boolean isIncludeBody() {
{
return parseBoolean(getFieldValue(SubscribeOptionFields.include_body)); 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 * @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); addField(SubscribeOptionFields.include_body, FormField.Type.bool);
setAnswer(SubscribeOptionFields.include_body.getFieldName(), include); setAnswer(SubscribeOptionFields.include_body.getFieldName(), include);
} }
@ -179,12 +163,10 @@ public class SubscribeForm extends Form
* *
* @return the list of states * @return the list of states
*/ */
public List<PresenceState> getShowValues() public List<PresenceState> getShowValues() {
{
ArrayList<PresenceState> result = new ArrayList<>(5); ArrayList<PresenceState> result = new ArrayList<>(5);
for (String state : getFieldValues(SubscribeOptionFields.show_values)) for (String state : getFieldValues(SubscribeOptionFields.show_values)) {
{
result.add(PresenceState.valueOf(state)); result.add(PresenceState.valueOf(state));
} }
return result; return result;
@ -196,12 +178,10 @@ public class SubscribeForm extends Form
* *
* @param stateValues The list of states * @param stateValues The list of states
*/ */
public void setShowValues(Collection<PresenceState> stateValues) public void setShowValues(Collection<PresenceState> stateValues) {
{
ArrayList<String> values = new ArrayList<>(stateValues.size()); ArrayList<String> values = new ArrayList<>(stateValues.size());
for (PresenceState state : stateValues) for (PresenceState state : stateValues) {
{
values.add(state.toString()); values.add(state.toString());
} }
addField(SubscribeOptionFields.show_values, FormField.Type.list_multi); 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)); return ("1".equals(fieldValue) || "true".equals(fieldValue));
} }
private String getFieldValue(SubscribeOptionFields field) private String getFieldValue(SubscribeOptionFields field) {
{
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return formField.getValues().get(0); return formField.getValues().get(0);
} }
private List<String> getFieldValues(SubscribeOptionFields field) private List<String> getFieldValues(SubscribeOptionFields field) {
{
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return formField.getValues(); return formField.getValues();
} }
private void addField(SubscribeOptionFields nodeField, FormField.Type type) private void addField(SubscribeOptionFields nodeField, FormField.Type type) {
{
String fieldName = nodeField.getFieldName(); String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null) if (getField(fieldName) == null) {
{
FormField field = new FormField(fieldName); FormField field = new FormField(fieldName);
field.setType(type); field.setType(type);
addField(field); addField(field);

View File

@ -24,8 +24,7 @@ import java.util.Calendar;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public enum SubscribeOptionFields public enum SubscribeOptionFields {
{
/** /**
* Whether an entity wants to receive or disable notifications. * Whether an entity wants to receive or disable notifications.
* *
@ -83,15 +82,13 @@ public enum SubscribeOptionFields
*/ */
subscription_depth; subscription_depth;
public String getFieldName() public String getFieldName() {
{
if (this == show_values) if (this == show_values)
return "pubsub#" + toString().replace('_', '-'); return "pubsub#" + toString().replace('_', '-');
return "pubsub#" + toString(); return "pubsub#" + toString();
} }
public static SubscribeOptionFields valueOfFromElement(String elementName) public static SubscribeOptionFields valueOfFromElement(String elementName) {
{
String portion = elementName.substring(elementName.lastIndexOf('#' + 1)); String portion = elementName.substring(elementName.lastIndexOf('#' + 1));
if ("show-values".equals(portion)) if ("show-values".equals(portion))

View File

@ -25,15 +25,13 @@ import org.jxmpp.jid.Jid;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class Subscription extends NodeExtension public class Subscription extends NodeExtension {
{
protected Jid jid; protected Jid jid;
protected String id; protected String id;
protected State state; protected State state;
protected boolean configRequired = false; protected boolean configRequired = false;
public enum State public enum State {
{
subscribed, unconfigured, pending, none subscribed, unconfigured, pending, none
} }
@ -43,8 +41,7 @@ public class Subscription extends NodeExtension
* *
* @param subscriptionJid The subscriber JID * @param subscriptionJid The subscriber JID
*/ */
public Subscription(Jid subscriptionJid) public Subscription(Jid subscriptionJid) {
{
this(subscriptionJid, null, null, null); this(subscriptionJid, null, null, null);
} }
@ -55,8 +52,7 @@ public class Subscription extends NodeExtension
* @param subscriptionJid The subscriber JID * @param subscriptionJid The subscriber JID
* @param nodeId The node id * @param nodeId The node id
*/ */
public Subscription(Jid subscriptionJid, String nodeId) public Subscription(Jid subscriptionJid, String nodeId) {
{
this(subscriptionJid, nodeId, null, null); this(subscriptionJid, nodeId, null, null);
} }
@ -69,8 +65,7 @@ public class Subscription extends NodeExtension
* @param subscriptionId The id of this subscription * @param subscriptionId The id of this subscription
* @param state The current state of the 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); super(PubSubElementType.SUBSCRIPTION, nodeId);
this.jid = jid; this.jid = jid;
id = subscriptionId; id = subscriptionId;
@ -88,8 +83,7 @@ public class Subscription extends NodeExtension
* @param state The current state of the subscription * @param state The current state of the subscription
* @param configRequired Is configuration required to complete 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); super(PubSubElementType.SUBSCRIPTION, nodeId);
this.jid = jid; this.jid = jid;
id = subscriptionId; id = subscriptionId;
@ -102,8 +96,7 @@ public class Subscription extends NodeExtension
* *
* @return The JID * @return The JID
*/ */
public Jid getJid() public Jid getJid() {
{
return jid; return jid;
} }
@ -112,8 +105,7 @@ public class Subscription extends NodeExtension
* *
* @return The subscription id * @return The subscription id
*/ */
public String getId() public String getId() {
{
return id; return id;
} }
@ -122,8 +114,7 @@ public class Subscription extends NodeExtension
* *
* @return Current subscription state * @return Current subscription state
*/ */
public State getState() public State getState() {
{
return state; return state;
} }
@ -132,14 +123,12 @@ public class Subscription extends NodeExtension
* *
* @return true if configuration is required, false otherwise * @return true if configuration is required, false otherwise
*/ */
public boolean isConfigRequired() public boolean isConfigRequired() {
{
return configRequired; return configRequired;
} }
@Override @Override
public XmlStringBuilder toXML() public XmlStringBuilder toXML() {
{
XmlStringBuilder builder = new XmlStringBuilder(this); XmlStringBuilder builder = new XmlStringBuilder(this);
builder.attribute("jid", jid); builder.attribute("jid", jid);
@ -151,8 +140,7 @@ public class Subscription extends NodeExtension
return builder; 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(' ');
builder.append(att); builder.append(att);
builder.append("='"); builder.append("='");

View File

@ -24,8 +24,7 @@ import java.util.List;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public abstract class SubscriptionEvent extends NodeEvent public abstract class SubscriptionEvent extends NodeEvent {
{
private List<String> subIds = Collections.emptyList(); private List<String> subIds = Collections.emptyList();
/** /**
@ -36,8 +35,7 @@ public abstract class SubscriptionEvent extends NodeEvent
* *
* @param nodeId The id of the node the event came from * @param nodeId The id of the node the event came from
*/ */
protected SubscriptionEvent(String nodeId) protected SubscriptionEvent(String nodeId) {
{
super(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 nodeId The id of the node the event came from
* @param subscriptionIds The list of subscription id's * @param subscriptionIds The list of subscription id's
*/ */
protected SubscriptionEvent(String nodeId, List<String> subscriptionIds) protected SubscriptionEvent(String nodeId, List<String> subscriptionIds) {
{
super(nodeId); super(nodeId);
if (subscriptionIds != null) if (subscriptionIds != null)
@ -60,8 +57,7 @@ public abstract class SubscriptionEvent extends NodeEvent
* *
* @return List of subscription id's * @return List of subscription id's
*/ */
public List<String> getSubscriptions() public List<String> getSubscriptions() {
{
return Collections.unmodifiableList(subIds); return Collections.unmodifiableList(subIds);
} }
@ -70,8 +66,7 @@ public abstract class SubscriptionEvent extends NodeEvent
* *
* @param subscriptionIds The list of subscription id's * @param subscriptionIds The list of subscription id's
*/ */
protected void setSubscriptions(List<String> subscriptionIds) protected void setSubscriptions(List<String> subscriptionIds) {
{
if (subscriptionIds != null) if (subscriptionIds != null)
subIds = subscriptionIds; subIds = subscriptionIds;
} }

View File

@ -24,8 +24,7 @@ import java.util.List;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SubscriptionsExtension extends NodeExtension public class SubscriptionsExtension extends NodeExtension {
{
protected List<Subscription> items = Collections.emptyList(); protected List<Subscription> items = Collections.emptyList();
/** /**
@ -33,8 +32,7 @@ public class SubscriptionsExtension extends NodeExtension
* *
* @param subList The list of subscriptions * @param subList The list of subscriptions
*/ */
public SubscriptionsExtension(List<Subscription> subList) public SubscriptionsExtension(List<Subscription> subList) {
{
super(PubSubElementType.SUBSCRIPTIONS); super(PubSubElementType.SUBSCRIPTIONS);
if (subList != null) if (subList != null)
@ -47,8 +45,7 @@ public class SubscriptionsExtension extends NodeExtension
* @param nodeId The node subscribed to * @param nodeId The node subscribed to
* @param subList The list of subscriptions * @param subList The list of subscriptions
*/ */
public SubscriptionsExtension(String nodeId, List<Subscription> subList) public SubscriptionsExtension(String nodeId, List<Subscription> subList) {
{
super(PubSubElementType.SUBSCRIPTIONS, nodeId); super(PubSubElementType.SUBSCRIPTIONS, nodeId);
if (subList != null) if (subList != null)
@ -60,33 +57,27 @@ public class SubscriptionsExtension extends NodeExtension
* *
* @return List of subscriptions * @return List of subscriptions
*/ */
public List<Subscription> getSubscriptions() public List<Subscription> getSubscriptions() {
{
return items; return items;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML() {
{ if ((items == null) || (items.size() == 0)) {
if ((items == null) || (items.size() == 0))
{
return super.toXML(); return super.toXML();
} }
else else {
{
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
if (getNode() != null) if (getNode() != null) {
{
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
builder.append('\''); builder.append('\'');
} }
builder.append('>'); builder.append('>');
for (Subscription item : items) for (Subscription item : items) {
{
builder.append(item.toXML()); builder.append(item.toXML());
} }

View File

@ -24,35 +24,29 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class UnsubscribeExtension extends NodeExtension public class UnsubscribeExtension extends NodeExtension {
{
protected String jid; protected String jid;
protected String id; protected String id;
public UnsubscribeExtension(String subscriptionJid) public UnsubscribeExtension(String subscriptionJid) {
{
this(subscriptionJid, null, null); this(subscriptionJid, null, null);
} }
public UnsubscribeExtension(String subscriptionJid, String nodeId) public UnsubscribeExtension(String subscriptionJid, String nodeId) {
{
this(subscriptionJid, nodeId, null); this(subscriptionJid, nodeId, null);
} }
public UnsubscribeExtension(String jid, String nodeId, String subscriptionId) public UnsubscribeExtension(String jid, String nodeId, String subscriptionId) {
{
super(PubSubElementType.UNSUBSCRIBE, nodeId); super(PubSubElementType.UNSUBSCRIBE, nodeId);
this.jid = jid; this.jid = jid;
id = subscriptionId; id = subscriptionId;
} }
public String getJid() public String getJid() {
{
return jid; return jid;
} }
public String getId() public String getId() {
{
return id; return id;
} }

View File

@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public interface ItemDeleteListener public interface ItemDeleteListener {
{
/** /**
* Called when items are deleted from a node the listener is * Called when items are deleted from a node the listener is
* registered with. * registered with.

View File

@ -27,8 +27,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public interface ItemEventListener<T extends Item> public interface ItemEventListener<T extends Item> {
{
/** /**
* Called whenever an item is published to the node the listener * Called whenever an item is published to the node the listener
* is registered with. * is registered with.

View File

@ -26,8 +26,7 @@ import org.jivesoftware.smackx.pubsub.LeafNode;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public interface NodeConfigListener public interface NodeConfigListener {
{
/** /**
* Called whenever the node the listener * Called whenever the node the listener
* is registered with is configured. * is registered with is configured.

View File

@ -30,8 +30,7 @@ import org.jxmpp.jid.Jid;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class PubSub extends IQ public class PubSub extends IQ {
{
public static final String ELEMENT = "pubsub"; public static final String ELEMENT = "pubsub";
public static final String NAMESPACE = "http://jabber.org/protocol/pubsub"; public static final String NAMESPACE = "http://jabber.org/protocol/pubsub";
@ -50,8 +49,7 @@ public class PubSub extends IQ
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem) public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem) {
{
return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); return (PE) getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
} }

View File

@ -42,22 +42,18 @@ public enum PubSubNamespace {
} }
} }
public String getXmlns() public String getXmlns() {
{
return fullNamespace; return fullNamespace;
} }
public String getFragment() public String getFragment() {
{
return fragment; return fragment;
} }
public static PubSubNamespace valueOfFromXmlns(String ns) public static PubSubNamespace valueOfFromXmlns(String ns) {
{
int index = ns.lastIndexOf('#'); int index = ns.lastIndexOf('#');
if (index != -1) if (index != -1) {
{
String suffix = ns.substring(ns.lastIndexOf('#') + 1); String suffix = ns.substring(ns.lastIndexOf('#') + 1);
return valueOf(suffix.toUpperCase(Locale.US)); return valueOf(suffix.toUpperCase(Locale.US));
} }

View File

@ -30,12 +30,10 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension;
* as specified in the <a href="http://xmpp.org/extensions/xep-0060.html#schemas-pubsub">affiliation schema</a>. * as specified in the <a href="http://xmpp.org/extensions/xep-0060.html#schemas-pubsub">affiliation schema</a>.
* *
* @author Robin Collier * @author Robin Collier
*/public class AffiliationsProvider extends EmbeddedExtensionProvider<AffiliationsExtension> */public class AffiliationsProvider extends EmbeddedExtensionProvider<AffiliationsExtension> {
{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected AffiliationsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new AffiliationsExtension((List<Affiliation>) content); return new AffiliationsExtension((List<Affiliation>) content);
} }

View File

@ -32,11 +32,9 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ConfigEventProvider extends EmbeddedExtensionProvider<ConfigurationEvent> public class ConfigEventProvider extends EmbeddedExtensionProvider<ConfigurationEvent> {
{
@Override @Override
protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) protected ConfigurationEvent createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) {
{
if (content.size() == 0) if (content.size() == 0)
return new ConfigurationEvent(attMap.get("node")); return new ConfigurationEvent(attMap.get("node"));
else else

View File

@ -32,11 +32,9 @@ import org.jivesoftware.smackx.pubsub.NodeExtension;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class EventProvider extends EmbeddedExtensionProvider<EventElement> public class EventProvider extends EmbeddedExtensionProvider<EventElement> {
{
@Override @Override
protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) protected EventElement createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attMap, List<? extends ExtensionElement> content) {
{
return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension) content.get(0)); return new EventElement(EventElementType.valueOf(content.get(0).getElementName()), (NodeExtension) content.get(0));
} }
} }

View File

@ -33,11 +33,9 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> {
{
@Override @Override
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm) content.iterator().next())); return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm) content.iterator().next()));
} }
} }

View File

@ -36,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemProvider extends ExtensionElementProvider<Item> public class ItemProvider extends ExtensionElementProvider<Item> {
{
@Override @Override
public Item parse(XmlPullParser parser, int initialDepth) public Item parse(XmlPullParser parser, int initialDepth)
throws Exception { throws Exception {
@ -46,23 +45,19 @@ public class ItemProvider extends ExtensionElementProvider<Item>
int tag = parser.next(); int tag = parser.next();
if (tag == XmlPullParser.END_TAG) if (tag == XmlPullParser.END_TAG) {
{
return new Item(id, node); return new Item(id, node);
} }
else else {
{
String payloadElemName = parser.getName(); String payloadElemName = parser.getName();
String payloadNS = parser.getNamespace(); String payloadNS = parser.getNamespace();
final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
if (extensionProvider == null) if (extensionProvider == null) {
{
CharSequence payloadText = PacketParserUtils.parseElement(parser, true); CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText)); return new PayloadItem<>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
} }
else else {
{
return new PayloadItem<>(id, node, extensionProvider.parse(parser)); return new PayloadItem<>(id, node, extensionProvider.parse(parser));
} }
} }

View File

@ -30,12 +30,10 @@ import org.jivesoftware.smackx.pubsub.ItemsExtension;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class ItemsProvider extends EmbeddedExtensionProvider<ItemsExtension> public class ItemsProvider extends EmbeddedExtensionProvider<ItemsExtension> {
{
@Override @Override
protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected ItemsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content); return new ItemsExtension(ItemsExtension.ItemsElementType.items, attributeMap.get("node"), content);
} }

View File

@ -31,8 +31,7 @@ import org.xmlpull.v1.XmlPullParser;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class PubSubProvider extends IQProvider<PubSub> public class PubSubProvider extends IQProvider<PubSub> {
{
@Override @Override
public PubSub parse(XmlPullParser parser, int initialDepth) public PubSub parse(XmlPullParser parser, int initialDepth)
throws Exception { throws Exception {
@ -40,8 +39,7 @@ public class PubSubProvider extends IQProvider<PubSub>
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
PubSub pubsub = new PubSub(pubSubNamespace); PubSub pubsub = new PubSub(pubSubNamespace);
outerloop: while (true) outerloop: while (true) {
{
int eventType = parser.next(); int eventType = parser.next();
switch (eventType) { switch (eventType) {
case XmlPullParser.START_TAG: case XmlPullParser.START_TAG:

View File

@ -31,11 +31,9 @@ import org.jivesoftware.smackx.pubsub.RetractItem;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class RetractEventProvider extends EmbeddedExtensionProvider<RetractItem> public class RetractEventProvider extends EmbeddedExtensionProvider<RetractItem> {
{
@Override @Override
protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected RetractItem createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new RetractItem(attributeMap.get("id")); return new RetractItem(attributeMap.get("id"));
} }

View File

@ -31,11 +31,9 @@ import org.jivesoftware.smackx.pubsub.PubSubElementType;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SimpleNodeProvider extends EmbeddedExtensionProvider<NodeExtension> public class SimpleNodeProvider extends EmbeddedExtensionProvider<NodeExtension> {
{
@Override @Override
protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected NodeExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node")); return new NodeExtension(PubSubElementType.valueOfFromElemName(currentElement, currentNamespace), attributeMap.get("node"));
} }
} }

View File

@ -33,8 +33,7 @@ import org.xmlpull.v1.XmlPullParserException;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SubscriptionProvider extends ExtensionElementProvider<Subscription> public class SubscriptionProvider extends ExtensionElementProvider<Subscription> {
{
@Override @Override
public Subscription parse(XmlPullParser parser, int initialDepth) public Subscription parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
@ -46,8 +45,7 @@ public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
int tag = parser.next(); 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(); tag = parser.next();
if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required")) if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required"))

View File

@ -31,12 +31,10 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class SubscriptionsProvider extends EmbeddedExtensionProvider<SubscriptionsExtension> public class SubscriptionsProvider extends EmbeddedExtensionProvider<SubscriptionsExtension> {
{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>) content); return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>) content);
} }

View File

@ -28,8 +28,7 @@ import org.jivesoftware.smackx.xdata.Form;
* *
* @author Robin Collier * @author Robin Collier
*/ */
public class NodeUtils public class NodeUtils {
{
/** /**
* Get a {@link ConfigureForm} from a packet. * Get a {@link ConfigureForm} from a packet.
* *
@ -37,8 +36,7 @@ public class NodeUtils
* @param elem * @param elem
* @return The configuration form * @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()); FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns());
Form formReply = config.getForm(); Form formReply = config.getForm();
return new ConfigureForm(formReply); return new ConfigureForm(formReply);

View File

@ -31,8 +31,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* *
* @author Georg Lukas * @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 NAMESPACE = "urn:xmpp:receipts";
public static final String ELEMENT = "received"; public static final String ELEMENT = "received";
@ -41,31 +40,26 @@ public class DeliveryReceipt implements ExtensionElement
*/ */
private final String id; private final String id;
public DeliveryReceipt(String id) public DeliveryReceipt(String id) {
{
this.id = StringUtils.requireNotNullOrEmpty(id, "id must not be null"); this.id = StringUtils.requireNotNullOrEmpty(id, "id must not be null");
} }
public String getId() public String getId() {
{
return id; return id;
} }
@Override @Override
public String getElementName() public String getElementName() {
{
return ELEMENT; return ELEMENT;
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return NAMESPACE; return NAMESPACE;
} }
@Override @Override
public XmlStringBuilder toXML() public XmlStringBuilder toXML() {
{
XmlStringBuilder xml = new XmlStringBuilder(this); XmlStringBuilder xml = new XmlStringBuilder(this);
xml.attribute("id", id); xml.attribute("id", id);
xml.closeEmptyElement(); xml.closeEmptyElement();
@ -97,13 +91,11 @@ public class DeliveryReceipt implements ExtensionElement
/** /**
* This Provider parses and returns DeliveryReceipt packets. * This Provider parses and returns DeliveryReceipt packets.
*/ */
public static class Provider extends EmbeddedExtensionProvider<DeliveryReceipt> public static class Provider extends EmbeddedExtensionProvider<DeliveryReceipt> {
{
@Override @Override
protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace, protected DeliveryReceipt createReturnExtension(String currentElement, String currentNamespace,
Map<String, String> attributeMap, List<? extends ExtensionElement> content) Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
{
return new DeliveryReceipt(attributeMap.get("id")); return new DeliveryReceipt(attributeMap.get("id"));
} }

View File

@ -33,25 +33,21 @@ import org.xmlpull.v1.XmlPullParserException;
* *
* @author Georg Lukas * @author Georg Lukas
*/ */
public class DeliveryReceiptRequest implements ExtensionElement public class DeliveryReceiptRequest implements ExtensionElement {
{
public static final String ELEMENT = "request"; public static final String ELEMENT = "request";
@Override @Override
public String getElementName() public String getElementName() {
{
return ELEMENT; return ELEMENT;
} }
@Override @Override
public String getNamespace() public String getNamespace() {
{
return DeliveryReceipt.NAMESPACE; return DeliveryReceipt.NAMESPACE;
} }
@Override @Override
public String toXML() public String toXML() {
{
return "<request xmlns='" + DeliveryReceipt.NAMESPACE + "'/>"; return "<request xmlns='" + DeliveryReceipt.NAMESPACE + "'/>";
} }

View File

@ -44,19 +44,16 @@ import org.junit.Test;
* @author Robin Collier * @author Robin Collier
* *
*/ */
public class ConfigureFormTest extends InitExtensions public class ConfigureFormTest extends InitExtensions {
{
@Test @Test
public void checkChildrenAssocPolicy() public void checkChildrenAssocPolicy() {
{
ConfigureForm form = new ConfigureForm(DataForm.Type.submit); ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners); form.setChildrenAssociationPolicy(ChildrenAssociationPolicy.owners);
assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy()); assertEquals(ChildrenAssociationPolicy.owners, form.getChildrenAssociationPolicy());
} }
@Test @Test
public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException {
{
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();
@ -75,20 +72,17 @@ public class ConfigureFormTest extends InitExtensions
errorIq.setError(error); errorIq.setError(error);
con.addIQReply(errorIq); con.addIQReply(errorIq);
try try {
{
node.getNodeConfiguration(); node.getNodeConfiguration();
fail(); fail();
} }
catch (XMPPErrorException e) catch (XMPPErrorException e) {
{
Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType()); Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
} }
} }
@Test(expected = SmackException.class) @Test(expected = SmackException.class)
public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException {
{
ThreadedDummyConnection con = new ThreadedDummyConnection(); ThreadedDummyConnection con = new ThreadedDummyConnection();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo(); DiscoverInfo info = new DiscoverInfo();

View File

@ -42,8 +42,7 @@ public class ItemValidationTest extends InitExtensions {
private ThreadedDummyConnection connection; private ThreadedDummyConnection connection;
@Before @Before
public void setUp() throws Exception public void setUp() throws Exception {
{
// Uncomment this to enable debug output // Uncomment this to enable debug output
// SmackConfiguration.DEBUG = true; // SmackConfiguration.DEBUG = true;
@ -53,15 +52,13 @@ public class ItemValidationTest extends InitExtensions {
} }
@After @After
public void tearDown() throws Exception public void tearDown() throws Exception {
{
if (connection != null) if (connection != null)
connection.disconnect(); connection.disconnect();
} }
@Test @Test
public void verifyBasicItem() throws Exception public void verifyBasicItem() throws Exception {
{
Item simpleItem = new Item(); Item simpleItem = new Item();
String simpleCtrl = "<item />"; String simpleCtrl = "<item />";
assertXMLEqual(simpleCtrl, simpleItem.toXML()); assertXMLEqual(simpleCtrl, simpleItem.toXML());
@ -76,8 +73,7 @@ public class ItemValidationTest extends InitExtensions {
} }
@Test @Test
public void verifyPayloadItem() throws Exception public void verifyPayloadItem() throws Exception {
{
SimplePayload payload = new SimplePayload(null, null, "<data>This is the payload</data>"); SimplePayload payload = new SimplePayload(null, null, "<data>This is the payload</data>");
PayloadItem<SimplePayload> simpleItem = new PayloadItem<>(payload); PayloadItem<SimplePayload> simpleItem = new PayloadItem<>(payload);
@ -94,8 +90,7 @@ public class ItemValidationTest extends InitExtensions {
} }
@Test @Test
public void parseBasicItem() throws Exception public void parseBasicItem() throws Exception {
{
XmlPullParser parser = PacketParserUtils.getParserFor( XmlPullParser parser = PacketParserUtils.getParserFor(
"<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" + "<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
"<event xmlns='http://jabber.org/protocol/pubsub#event'>" + "<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
@ -121,8 +116,7 @@ public class ItemValidationTest extends InitExtensions {
} }
@Test @Test
public void parseSimplePayloadItem() throws Exception public void parseSimplePayloadItem() throws Exception {
{
String itemContent = "<foo xmlns='smack:test'>Some text</foo>"; String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
XmlPullParser parser = PacketParserUtils.getParserFor( XmlPullParser parser = PacketParserUtils.getParserFor(
@ -154,8 +148,7 @@ public class ItemValidationTest extends InitExtensions {
} }
@Test @Test
public void parseComplexItem() throws Exception public void parseComplexItem() throws Exception {
{
String itemContent = String itemContent =
"<entry xmlns='http://www.w3.org/2005/Atom'>" + "<entry xmlns='http://www.w3.org/2005/Atom'>" +
"<title>Soliloquy</title>" + "<title>Soliloquy</title>" +
@ -201,8 +194,7 @@ public class ItemValidationTest extends InitExtensions {
} }
@Test @Test
public void parseEmptyTag() throws Exception public void parseEmptyTag() throws Exception {
{
String itemContent = "<foo xmlns='smack:test'><bar/></foo>"; String itemContent = "<foo xmlns='smack:test'><bar/></foo>";
XmlPullParser parser = PacketParserUtils.getParserFor( XmlPullParser parser = PacketParserUtils.getParserFor(

View File

@ -1015,8 +1015,7 @@ public class AgentSession {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); final RoomInvitation invitation = new RoomInvitation(type, invitee, sessionID, reason);
IQ iq = new RoomInvitation.RoomInvitationIQ(invitation); IQ iq = new RoomInvitation.RoomInvitationIQ(invitation);
iq.setType(IQ.Type.set); iq.setType(IQ.Type.set);
@ -1053,8 +1052,7 @@ public class AgentSession {
* @throws NotConnectedException * @throws NotConnectedException
* @throws InterruptedException * @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); final RoomTransfer transfer = new RoomTransfer(type, invitee, sessionID, reason);
IQ iq = new RoomTransfer.RoomTransferIQ(transfer); IQ iq = new RoomTransfer.RoomTransferIQ(transfer);
iq.setType(IQ.Type.set); iq.setType(IQ.Type.set);

View File

@ -67,8 +67,7 @@ public class Offer {
*/ */
Offer(XMPPConnection conn, AgentSession agentSession, Jid userID, Offer(XMPPConnection conn, AgentSession agentSession, Jid userID,
Jid userJID, Jid workgroupName, Date expiresDate, Jid userJID, Jid workgroupName, Date expiresDate,
String sessionID, Map<String, List<String>> metaData, OfferContent content) String sessionID, Map<String, List<String>> metaData, OfferContent content) {
{
this.connection = conn; this.connection = conn;
this.session = agentSession; this.session = agentSession;
this.userID = userID; this.userID = userID;

View File

@ -129,8 +129,7 @@ public class AgentStatusRequest extends IQ {
statusRequest.agents.add(parseAgent(parser)); statusRequest.agents.add(parseAgent(parser));
} }
else if (eventType == XmlPullParser.END_TAG && else if (eventType == XmlPullParser.END_TAG &&
"agent-status-request".equals(parser.getName())) "agent-status-request".equals(parser.getName())) {
{
done = true; done = true;
} }
} }
@ -149,8 +148,7 @@ public class AgentStatusRequest extends IQ {
name = parser.nextText(); name = parser.nextText();
} }
else if (eventType == XmlPullParser.END_TAG && else if (eventType == XmlPullParser.END_TAG &&
"agent".equals(parser.getName())) "agent".equals(parser.getName())) {
{
done = true; done = true;
} }
} }

View File

@ -124,8 +124,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
private final OfferContent content; private final OfferContent content;
public OfferRequestPacket(Jid userJID, Jid userID, int timeout, Map<String, List<String>> metaData, public OfferRequestPacket(Jid userJID, Jid userID, int timeout, Map<String, List<String>> metaData,
String sessionID, OfferContent content) String sessionID, OfferContent content) {
{
super(ELEMENT, NAMESPACE); super(ELEMENT, NAMESPACE);
this.userJID = userJID; this.userJID = userJID;
this.userID = userID; this.userID = userID;

View File

@ -59,8 +59,7 @@ public class OfferRevokeProvider extends IQProvider<IQ> {
userID = ParserUtils.getJidAttribute(parser, "id"); userID = ParserUtils.getJidAttribute(parser, "id");
} }
else if ((eventType == XmlPullParser.END_TAG) && parser.getName().equals( else if ((eventType == XmlPullParser.END_TAG) && parser.getName().equals(
"offer-revoke")) "offer-revoke")) {
{
done = true; done = true;
} }
} }

View File

@ -153,8 +153,7 @@ public final class QueueDetails implements ExtensionElement {
int eventType = parser.getEventType(); int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_TAG && while (eventType != XmlPullParser.END_TAG &&
"notify-queue-details".equals(parser.getName())) "notify-queue-details".equals(parser.getName())) {
{
eventType = parser.next(); eventType = parser.next();
while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) { while ((eventType == XmlPullParser.START_TAG) && "user".equals(parser.getName())) {
String uid; String uid;
@ -170,8 +169,7 @@ public final class QueueDetails implements ExtensionElement {
eventType = parser.next(); eventType = parser.next();
while ((eventType != XmlPullParser.END_TAG) while ((eventType != XmlPullParser.END_TAG)
|| (!"user".equals(parser.getName()))) || (!"user".equals(parser.getName()))) {
{
if ("position".equals(parser.getName())) { if ("position".equals(parser.getName())) {
position = Integer.parseInt(parser.nextText()); position = Integer.parseInt(parser.nextText());
} }

View File

@ -134,8 +134,7 @@ public class QueueOverview implements ExtensionElement {
eventType = parser.next(); eventType = parser.next();
while ((eventType != XmlPullParser.END_TAG) while ((eventType != XmlPullParser.END_TAG)
|| (!ELEMENT_NAME.equals(parser.getName()))) || (!ELEMENT_NAME.equals(parser.getName()))) {
{
if ("count".equals(parser.getName())) { if ("count".equals(parser.getName())) {
queueOverview.setUserCount(Integer.parseInt(parser.nextText())); queueOverview.setUserCount(Integer.parseInt(parser.nextText()));
} }

View File

@ -68,8 +68,7 @@ public class ListenerEventDispatcher implements Runnable {
* @param methodArguments the arguments supplied to the notification method * @param methodArguments the arguments supplied to the notification method
*/ */
public void addListenerTriplet(Object listenerInstance, Method listenerMethod, public void addListenerTriplet(Object listenerInstance, Method listenerMethod,
Object[] methodArguments) Object[] methodArguments) {
{
if (!this.isRunning) { if (!this.isRunning) {
this.triplets.add(new TripletContainer(listenerInstance, listenerMethod, this.triplets.add(new TripletContainer(listenerInstance, listenerMethod,
methodArguments)); methodArguments));

View File

@ -34,27 +34,23 @@ public class DefaultMessageEventRequestListener implements MessageEventRequestLi
@Override @Override
public void deliveredNotificationRequested(Jid from, String packetID, 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 // Send to the message's sender that the message has been delivered
messageEventManager.sendDeliveredNotification(from, packetID); messageEventManager.sendDeliveredNotification(from, packetID);
} }
@Override @Override
public void displayedNotificationRequested(Jid from, String packetID, public void displayedNotificationRequested(Jid from, String packetID,
MessageEventManager messageEventManager) MessageEventManager messageEventManager) {
{
} }
@Override @Override
public void composingNotificationRequested(Jid from, String packetID, public void composingNotificationRequested(Jid from, String packetID,
MessageEventManager messageEventManager) MessageEventManager messageEventManager) {
{
} }
@Override @Override
public void offlineNotificationRequested(Jid from, String packetID, public void offlineNotificationRequested(Jid from, String packetID,
MessageEventManager messageEventManager) MessageEventManager messageEventManager) {
{
} }
} }

View File

@ -113,8 +113,7 @@ public final class MessageEventManager extends Manager {
* @param composing specifies if the composing event is requested. * @param composing specifies if the composing event is requested.
*/ */
public static void addNotificationsRequests(Message message, boolean offline, 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 // Create a MessageEvent Package and add it to the message
MessageEvent messageEvent = new MessageEvent(); MessageEvent messageEvent = new MessageEvent();
messageEvent.setOffline(offline); messageEvent.setOffline(offline);