1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Fix minor codestyle issues

This commit is contained in:
Paul Schaub 2017-12-13 23:10:11 +01:00 committed by Florian Schmaus
parent 200f90ffdc
commit cb18056613
422 changed files with 1404 additions and 1444 deletions

View file

@ -112,7 +112,7 @@ public class MultipleRecipientManager {
connection.sendStanza(packet);
return;
}
DomainBareJid serviceAddress = getMultipleRecipienServiceAddress(connection);
DomainBareJid serviceAddress = getMultipleRecipientServiceAddress(connection);
if (serviceAddress != null) {
// Send packet to target users using multiple recipient service provided by the server
sendThroughService(connection, packet, to, cc, bcc, replyTo, replyRoom, noReply,
@ -133,8 +133,8 @@ public class MultipleRecipientManager {
/**
* Sends a reply to a previously received stanza(/packet) that was sent to multiple recipients. Before
* attempting to send the reply message some checkings are performed. If any of those checkings
* fail then an XMPPException is going to be thrown with the specific error detail.
* attempting to send the reply message some checks are performed. If any of those checks
* fails, then an XMPPException is going to be thrown with the specific error detail.
*
* @param connection the connection to use to send the reply.
* @param original the previously received stanza(/packet) that was sent to multiple recipients.
@ -201,8 +201,7 @@ public class MultipleRecipientManager {
* if none was found.
*/
public static MultipleRecipientInfo getMultipleRecipientInfo(Stanza packet) {
MultipleAddresses extension = (MultipleAddresses) packet
.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
MultipleAddresses extension = packet.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
return extension == null ? null : new MultipleRecipientInfo(extension);
}
@ -283,7 +282,7 @@ public class MultipleRecipientManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
private static DomainBareJid getMultipleRecipienServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
private static DomainBareJid getMultipleRecipientServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
return sdm.findService(MultipleAddresses.NAMESPACE, true);
}
@ -296,7 +295,7 @@ public class MultipleRecipientManager {
*/
private static class PacketCopy extends Stanza {
private CharSequence text;
private final CharSequence text;
/**
* Create a copy of a stanza(/packet) with the text to send. The passed text must be a valid text to

View file

@ -53,7 +53,7 @@ public class MultipleAddresses implements ExtensionElement {
ofrom,
}
private List<Address> addresses = new ArrayList<Address>();
private final List<Address> addresses = new ArrayList<>();
/**
* Adds a new address to which the stanza(/packet) is going to be sent or was sent.
@ -68,7 +68,7 @@ public class MultipleAddresses implements ExtensionElement {
*/
public void addAddress(Type type, Jid jid, String node, String desc, boolean delivered,
String uri) {
// Create a new address with the specificed configuration
// Create a new address with the specified configuration
Address address = new Address(type);
address.setJid(jid);
address.setNode(node);
@ -83,7 +83,7 @@ public class MultipleAddresses implements ExtensionElement {
* Indicate that the stanza(/packet) being sent should not be replied.
*/
public void setNoReply() {
// Create a new address with the specificed configuration
// Create a new address with the specified configuration
Address address = new Address(Type.noreply);
// Add the new address to the list of multiple recipients
addresses.add(address);
@ -97,7 +97,7 @@ public class MultipleAddresses implements ExtensionElement {
* @return the list of addresses that matches the specified type.
*/
public List<Address> getAddressesOfType(Type type) {
List<Address> answer = new ArrayList<Address>(addresses.size());
List<Address> answer = new ArrayList<>(addresses.size());
for (Address address : addresses) {
if (address.getType().equals(type)) {
answer.add(address);

View file

@ -43,7 +43,7 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
private final Value value;
/**
* Create new amp deliver condition with value setted to one of defined by XEP-0079.
* Create new amp deliver condition with value set to one of defined by XEP-0079.
* See http://xmpp.org/extensions/xep-0079.html#conditions-def-deliver
* @param value AMPDeliveryCondition.Value instance that will be used as value parameter. Can't be null.
*/
@ -67,7 +67,7 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
* Value for amp deliver condition as defined by XEP-0079.
* See http://xmpp.org/extensions/xep-0079.html#conditions-def-deliver
*/
public static enum Value {
public enum Value {
/**
* The message would be immediately delivered to the intended recipient or routed to the next hop.
*/

View file

@ -48,7 +48,7 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
private final String value;
/**
* Create new expire-at amp condition with value setted as XEP-0082 formatted date.
* Create new expire-at amp condition with value set as XEP-0082 formatted date.
* @param utcDateTime Date instance of time
* that will be used as value parameter after formatting to XEP-0082 format. Can't be null.
*/

View file

@ -43,7 +43,7 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
private final Value value;
/**
* Create new amp match-resource condition with value setted to one of defined by XEP-0079.
* Create new amp match-resource condition with value set to one of defined by XEP-0079.
* See http://xmpp.org/extensions/xep-0079.html#conditions-def-match
* @param value AMPDeliveryCondition.Value instance that will be used as value parameter. Can't be null.
*/
@ -67,7 +67,7 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
* match-resource amp condition value as defined by XEP-0079.
* See http://xmpp.org/extensions/xep-0079.html#conditions-def-match
*/
public static enum Value {
public enum Value {
/**
* Destination resource matches any value, effectively ignoring the intended resource.
* Example: "home/laptop" matches "home", "home/desktop" or "work/desktop"

View file

@ -31,7 +31,7 @@ public class AMPExtension implements ExtensionElement {
public static final String NAMESPACE = "http://jabber.org/protocol/amp";
public static final String ELEMENT = "amp";
private CopyOnWriteArrayList<Rule> rules = new CopyOnWriteArrayList<Rule>();
private final CopyOnWriteArrayList<Rule> rules = new CopyOnWriteArrayList<>();
private boolean perHop = false;
private final String from;
@ -225,18 +225,18 @@ public class AMPExtension implements ExtensionElement {
* @see AMPExpireAtCondition
* @see AMPMatchResourceCondition
**/
public static interface Condition {
public interface Condition {
String getName();
String getValue();
static final String ATTRIBUTE_NAME = "condition";
String ATTRIBUTE_NAME = "condition";
}
/**
* amp action attribute.
* See http://xmpp.org/extensions/xep-0079.html#actions-def
**/
public static enum Action {
public enum Action {
/**
* The "alert" action triggers a reply <message/> stanza to the sending entity.
* This <message/> stanza MUST contain the element <amp status='alert'/>,
@ -272,7 +272,7 @@ public class AMPExtension implements ExtensionElement {
/**
* amp notification status as defined by XEP-0079.
*/
public static enum Status {
public enum Status {
alert,
error,
notify

View file

@ -103,7 +103,7 @@ public final class BlockingCommandManager extends Manager {
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iqRequest;
if (blockListCached == null) {
blockListCached = new ArrayList<Jid>();
blockListCached = new ArrayList<>();
}
List<Jid> blockedJids = blockContactIQ.getJids();
@ -125,7 +125,7 @@ public final class BlockingCommandManager extends Manager {
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iqRequest;
if (blockListCached == null) {
blockListCached = new ArrayList<Jid>();
blockListCached = new ArrayList<>();
}
List<Jid> unblockedJids = unblockContactIQ.getJids();

View file

@ -45,7 +45,7 @@ import org.jxmpp.jid.parts.Resourcepart;
* @author Alexander Wenckus
*/
public final class BookmarkManager {
private static final Map<XMPPConnection, BookmarkManager> bookmarkManagerMap = new WeakHashMap<XMPPConnection, BookmarkManager>();
private static final Map<XMPPConnection, BookmarkManager> bookmarkManagerMap = new WeakHashMap<>();
static {
PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks",

View file

@ -21,7 +21,7 @@ import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.parts.Resourcepart;
/**
* Respresents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
* Represents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
*
* @author Derek DeMoro
*/

View file

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.bookmarks;
/**
* Respresents one instance of a URL defined using XEP-0048 Bookmark Storage XEP.
* Represents one instance of a URL defined using XEP-0048 Bookmark Storage XEP.
*
* @author Derek DeMoro
*/
@ -41,9 +41,9 @@ public class BookmarkedURL implements SharedBookmark {
/**
* Returns the name representing the URL (eg. Jive Software). This can be used in as a label, or
* identifer in applications.
* identifier in applications.
*
* @return the name reprenting the URL.
* @return the name representing the URL.
*/
public String getName() {
return name;

View file

@ -68,15 +68,15 @@ public class Bookmarks implements PrivateData {
public static final String NAMESPACE = "storage:bookmarks";
public static final String ELEMENT = "storage";
private List<BookmarkedURL> bookmarkedURLS;
private List<BookmarkedConference> bookmarkedConferences;
private final List<BookmarkedURL> bookmarkedURLS;
private final List<BookmarkedConference> bookmarkedConferences;
/**
* Required Empty Constructor to use Bookmarks.
*/
public Bookmarks() {
bookmarkedURLS = new ArrayList<BookmarkedURL>();
bookmarkedConferences = new ArrayList<BookmarkedConference>();
bookmarkedURLS = new ArrayList<>();
bookmarkedConferences = new ArrayList<>();
}
/**
@ -280,7 +280,7 @@ public class Bookmarks implements PrivateData {
BookmarkedConference conf = new BookmarkedConference(jid);
conf.setName(name);
conf.setAutoJoin(Boolean.valueOf(autojoin).booleanValue());
conf.setAutoJoin(Boolean.valueOf(autojoin));
// Check for nickname
boolean done = false;

View file

@ -29,5 +29,5 @@ public interface SharedBookmark {
*
* @return returns true if this bookmark is shared.
*/
public boolean isShared();
boolean isShared();
}

View file

@ -45,6 +45,6 @@ public interface BytestreamListener {
*
* @param request the incoming bytestream request
*/
public void incomingBytestreamRequest(BytestreamRequest request);
void incomingBytestreamRequest(BytestreamRequest request);
}

View file

@ -41,14 +41,14 @@ public interface BytestreamRequest {
*
* @return the sender of the bytestream open request
*/
public Jid getFrom();
Jid getFrom();
/**
* Returns the session ID of the bytestream open request.
*
* @return the session ID of the bytestream open request
*/
public String getSessionID();
String getSessionID();
/**
* Accepts the bytestream open request and returns the session to send/receive data.
@ -60,13 +60,13 @@ public interface BytestreamRequest {
* @throws NoResponseException
* @throws SmackException
*/
public BytestreamSession accept() throws InterruptedException, NoResponseException, XMPPErrorException, SmackException;
BytestreamSession accept() throws InterruptedException, XMPPErrorException, SmackException;
/**
* Rejects the bytestream request by sending a reject error to the initiator.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void reject() throws NotConnectedException, InterruptedException;
void reject() throws NotConnectedException, InterruptedException;
}

View file

@ -39,7 +39,7 @@ public interface BytestreamSession {
* @return the InputStream associated with this session to send data
* @throws IOException if an error occurs while retrieving the input stream
*/
public InputStream getInputStream() throws IOException;
InputStream getInputStream() throws IOException;
/**
* Returns the OutputStream associated with this session to receive data.
@ -47,7 +47,7 @@ public interface BytestreamSession {
* @return the OutputStream associated with this session to receive data
* @throws IOException if an error occurs while retrieving the output stream
*/
public OutputStream getOutputStream() throws IOException;
OutputStream getOutputStream() throws IOException;
/**
* Closes the bytestream session.
@ -57,7 +57,7 @@ public interface BytestreamSession {
*
* @throws IOException if an error occurs while closing the session
*/
public void close() throws IOException;
void close() throws IOException;
/**
* Returns the timeout for read operations of the input stream associated with this session. 0
@ -66,7 +66,7 @@ public interface BytestreamSession {
* @return the timeout for read operations
* @throws IOException if there is an error in the underlying protocol
*/
public int getReadTimeout() throws IOException;
int getReadTimeout() throws IOException;
/**
* Sets the specified timeout, in milliseconds. With this option set to a non-zero timeout, a
@ -79,6 +79,6 @@ public interface BytestreamSession {
* @param timeout the specified timeout, in milliseconds
* @throws IOException if there is an error in the underlying protocol
*/
public void setReadTimeout(int timeout) throws IOException;
void setReadTimeout(int timeout) throws IOException;
}

View file

@ -181,7 +181,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* list containing session IDs of In-Band Bytestream open packets that should be ignored by the
* InitiationListener
*/
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
/**
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given

View file

@ -532,7 +532,7 @@ public class InBandBytestreamSession implements BytestreamSession {
@Override
public void processStanza(Stanza packet) {
// get data packet extension
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
DataPacketExtension data = packet.getExtension(
DataPacketExtension.ELEMENT,
DataPacketExtension.NAMESPACE);

View file

@ -40,8 +40,7 @@ public class DataPacketProvider {
public Data parse(XmlPullParser parser, int initialDepth)
throws Exception {
DataPacketExtension data = packetExtensionProvider.parse(parser);
Data iq = new Data(data);
return iq;
return new Data(data);
}
}

View file

@ -40,7 +40,7 @@ public class OpenIQProvider extends IQProvider<Open> {
int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));
String stanzaValue = parser.getAttributeValue("", "stanza");
StanzaType stanza = null;
StanzaType stanza;
if (stanzaValue == null) {
stanza = StanzaType.IQ;
}

View file

@ -152,7 +152,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* list containing session IDs of SOCKS5 Bytestream initialization packets that should be
* ignored by the InitiationListener
*/
private List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
private final List<String> ignoredBytestreamRequests = Collections.synchronizedList(new LinkedList<String>());
/**
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
@ -411,13 +411,12 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @return the Socket to send/receive data to/from the user
* @throws IOException if the bytestream could not be established
* @throws InterruptedException if the current thread was interrupted while waiting
* @throws NoResponseException
* @throws SmackException if the target does not support SOCKS5.
* @throws XMPPException
*/
@Override
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
throws IOException, InterruptedException, NoResponseException, SmackException, XMPPException {
throws IOException, InterruptedException, SmackException, XMPPException {
XMPPConnection connection = connection();
XMPPErrorException discoveryException = null;
// check if target supports SOCKS5 Bytestream
@ -589,7 +588,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*/
private List<StreamHost> determineStreamHostInfos(List<Jid> proxies) {
XMPPConnection connection = connection();
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
List<StreamHost> streamHosts = new ArrayList<>();
// add local proxy on first position if exists
List<StreamHost> localProxies = getLocalStreamHost();
@ -601,7 +600,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
for (Jid proxy : proxies) {
Bytestream streamHostRequest = createStreamHostRequest(proxy);
try {
Bytestream response = (Bytestream) connection.createStanzaCollectorAndSend(
Bytestream response = connection.createStanzaCollectorAndSend(
streamHostRequest).nextResultOrThrow();
streamHosts.addAll(response.getStreamHosts());
}
@ -650,7 +649,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
}
final int port = socks5Server.getPort();
List<StreamHost> streamHosts = new ArrayList<StreamHost>();
List<StreamHost> streamHosts = new ArrayList<>();
outerloop: for (String address : addresses) {
// Prevent loopback addresses from appearing as streamhost
final String[] loopbackAddresses = { "127.0.0.1", "0:0:0:0:0:0:0:1", "::1" };

View file

@ -34,9 +34,7 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
/**
@ -74,16 +72,15 @@ class Socks5Client {
* @param timeout timeout to connect to SOCKS5 proxy in milliseconds
* @return socket the initialized socket
* @throws IOException if initializing the socket failed due to a network error
* @throws XMPPErrorException if establishing connection to SOCKS5 proxy failed
* @throws TimeoutException if connecting to SOCKS5 proxy timed out
* @throws InterruptedException if the current thread was interrupted while waiting
* @throws SmackException if the connection to the SOC
* @throws SmackException if the connection to the SOCKS5 proxy failed
* @throws XMPPException
*/
public Socket getSocket(int timeout) throws IOException, XMPPErrorException, InterruptedException,
public Socket getSocket(int timeout) throws IOException, InterruptedException,
TimeoutException, SmackException, XMPPException {
// wrap connecting in future for timeout
FutureTask<Socket> futureTask = new FutureTask<Socket>(new Callable<Socket>() {
FutureTask<Socket> futureTask = new FutureTask<>(new Callable<Socket>() {
@Override
public Socket call() throws IOException, SmackException {
@ -173,7 +170,7 @@ class Socks5Client {
// check if server responded with correct version and no-authentication method
if (response[0] != (byte) 0x05 || response[1] != (byte) 0x00) {
throw new SmackException("Remote SOCKS5 server responsed with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
throw new SmackException("Remote SOCKS5 server responded with unexpected version: " + response[0] + ' ' + response[1] + ". Should be 0x05 0x00.");
}
// request SOCKS5 connection with given address/digest
@ -188,7 +185,7 @@ class Socks5Client {
connectionRequest[1] = (byte) 0x00; // set expected return status to 0
if (!Arrays.equals(connectionRequest, connectionResponse)) {
throw new SmackException(
"Connection request does not equal connection reponse. Response: "
"Connection request does not equal connection response. Response: "
+ Arrays.toString(connectionResponse) + ". Request: "
+ Arrays.toString(connectionRequest));
}

View file

@ -74,7 +74,7 @@ class Socks5ClientForInitiator extends Socks5Client {
@Override
public Socket getSocket(int timeout) throws IOException, InterruptedException,
TimeoutException, XMPPException, SmackException {
Socket socket = null;
Socket socket;
// check if stream host is the local SOCKS5 proxy
if (this.streamHost.getJID().equals(this.connection.get().getUser())) {

View file

@ -93,12 +93,12 @@ public final class Socks5Proxy {
private ServerSocket serverSocket;
/* assigns a connection to a digest */
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<String, Socket>();
private final Map<String, Socket> connectionMap = new ConcurrentHashMap<>();
/* list of digests connections should be stored */
private final List<String> allowedConnections = Collections.synchronizedList(new LinkedList<String>());
private final Set<String> localAddresses = new LinkedHashSet<String>(4);
private final Set<String> localAddresses = new LinkedHashSet<>(4);
/**
* Private constructor.
@ -112,7 +112,7 @@ public final class Socks5Proxy {
} catch (SocketException e) {
throw new IllegalStateException(e);
}
Set<String> localHostAddresses = new HashSet<String>();
Set<String> localHostAddresses = new HashSet<>();
for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) {
// We can't use NetworkInterface.getInterfaceAddresses here, which
// would return a List instead the deprecated Enumeration, because
@ -293,7 +293,7 @@ public final class Socks5Proxy {
*/
public List<String> getLocalAddresses() {
synchronized (localAddresses) {
return new LinkedList<String>(localAddresses);
return new LinkedList<>(localAddresses);
}
}

View file

@ -46,7 +46,7 @@ public class Bytestream extends IQ {
private Mode mode = Mode.tcp;
private final List<StreamHost> streamHosts = new ArrayList<StreamHost>();
private final List<StreamHost> streamHosts = new ArrayList<>();
private StreamHostUsed usedHost;

View file

@ -96,7 +96,7 @@ public final class EntityCapsManager extends Manager {
private static boolean autoEnableEntityCaps = true;
private static Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
private static final Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
private static final StanzaFilter PRESENCES_WITH_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new StanzaExtensionFilter(
ELEMENT, NAMESPACE));
@ -104,7 +104,7 @@ public final class EntityCapsManager extends Manager {
/**
* Map of "node + '#' + hash" to DiscoverInfo data
*/
static final LruCache<String, DiscoverInfo> CAPS_CACHE = new LruCache<String, DiscoverInfo>(1000);
static final LruCache<String, DiscoverInfo> CAPS_CACHE = new LruCache<>(1000);
/**
* Map of Full JID -&gt; DiscoverInfo/null. In case of c2s connection the
@ -417,8 +417,8 @@ public final class EntityCapsManager extends Manager {
}
/**
* Get our own caps version. The version depends on the enabled features. A
* caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='
* Get our own caps version. The version depends on the enabled features.
* A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='
*
* @return our own caps version
*/
@ -497,7 +497,7 @@ public final class EntityCapsManager extends Manager {
if (connection != null)
JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion));
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
final List<Identity> identities = new LinkedList<>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
sdm.setNodeInformationProvider(localNodeVer, new AbstractNodeInformationProvider() {
List<String> features = sdm.getFeatures();
List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
@ -531,7 +531,7 @@ public final class EntityCapsManager extends Manager {
}
/**
* Verify DisoverInfo and Caps Node as defined in XEP-0115 5.4 Processing
* Verify DiscoverInfo and Caps Node as defined in XEP-0115 5.4 Processing
* Method.
*
* @see <a href="http://xmpp.org/extensions/xep-0115.html#ver-proc">XEP-0115
@ -569,7 +569,7 @@ public final class EntityCapsManager extends Manager {
* @return true if the stanza(/packet) extensions is ill-formed
*/
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
List<FormField> foundFormTypes = new LinkedList<FormField>();
List<FormField> foundFormTypes = new LinkedList<>();
for (ExtensionElement pe : info.getExtensions()) {
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
DataForm df = (DataForm) pe;
@ -628,10 +628,9 @@ public final class EntityCapsManager extends Manager {
// [NAME]. Note that each slash is included even if the LANG or
// NAME is not included (in accordance with XEP-0030, the category and
// type MUST be included.
SortedSet<DiscoverInfo.Identity> sortedIdentities = new TreeSet<DiscoverInfo.Identity>();
SortedSet<DiscoverInfo.Identity> sortedIdentities = new TreeSet<>();
for (DiscoverInfo.Identity i : discoverInfo.getIdentities())
sortedIdentities.add(i);
sortedIdentities.addAll(discoverInfo.getIdentities());
// 3. For each identity, append the 'category/type/lang/name' to S,
// followed by the '<' character.
@ -647,7 +646,7 @@ public final class EntityCapsManager extends Manager {
}
// 4. Sort the supported service discovery features.
SortedSet<String> features = new TreeSet<String>();
SortedSet<String> features = new TreeSet<>();
for (Feature f : discoverInfo.getFeatures())
features.add(f.getVar());
@ -666,7 +665,7 @@ public final class EntityCapsManager extends Manager {
// 6. If the service discovery information response includes
// XEP-0128 data forms, sort the forms by the FORM_TYPE (i.e.,
// by the XML character data of the <value/> element).
SortedSet<FormField> fs = new TreeSet<FormField>(new Comparator<FormField>() {
SortedSet<FormField> fs = new TreeSet<>(new Comparator<FormField>() {
@Override
public int compare(FormField f1, FormField f2) {
return f1.getVariable().compareTo(f2.getVariable());
@ -727,10 +726,8 @@ public final class EntityCapsManager extends Manager {
}
private static void formFieldValuesToCaps(List<String> i, StringBuilder sb) {
SortedSet<String> fvs = new TreeSet<String>();
for (String s : i) {
fvs.add(s);
}
SortedSet<String> fvs = new TreeSet<>();
fvs.addAll(i);
for (String fv : fvs) {
sb.append(fv);
sb.append('<');

View file

@ -42,8 +42,8 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
private File cacheDir;
private StringEncoder filenameEncoder;
private final File cacheDir;
private final StringEncoder filenameEncoder;
/**
* Creates a new SimpleDirectoryPersistentCache Object. Make sure that the
@ -108,13 +108,15 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
private File getFileFor(String nodeVer) {
String filename = filenameEncoder.encode(nodeVer);
File nodeFile = new File(cacheDir, filename);
return nodeFile;
return new File(cacheDir, filename);
}
@Override
public void emptyCache() {
File[] files = cacheDir.listFiles();
if (files == null) {
return;
}
for (File f : files) {
f.delete();
}
@ -145,7 +147,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
*/
private static DiscoverInfo restoreInfoFromFile(File file) throws Exception {
DataInputStream dis = new DataInputStream(new FileInputStream(file));
String fileContent = null;
String fileContent;
try {
fileContent = dis.readUTF();
} finally {
@ -154,8 +156,6 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
if (fileContent == null) {
return null;
}
DiscoverInfo info = (DiscoverInfo) PacketParserUtils.parseStanza(fileContent);
return info;
return PacketParserUtils.parseStanza(fileContent);
}
}

View file

@ -32,9 +32,7 @@ public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtensio
@Override
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
SmackException {
String hash = null;
String version = null;
String node = null;
String hash, version, node;
if (parser.getEventType() == XmlPullParser.START_TAG
&& parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
hash = parser.getAttributeValue(null, "hash");

View file

@ -53,8 +53,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
public final class ChatStateManager extends Manager {
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
private static final Map<XMPPConnection, ChatStateManager> INSTANCES =
new WeakHashMap<XMPPConnection, ChatStateManager>();
private static final Map<XMPPConnection, ChatStateManager> INSTANCES = new WeakHashMap<>();
private static final StanzaFilter filter = new NotFilter(new StanzaExtensionFilter(NAMESPACE));

View file

@ -419,7 +419,7 @@ public abstract class AdHocCommand {
complete,
/**
* The action is unknow. This is used when a recieved message has an
* The action is unknown. This is used when a received message has an
* unknown action. It must not be used to send an execution request.
*/
unknown

View file

@ -24,8 +24,8 @@ package org.jivesoftware.smackx.commands;
*/
public class AdHocCommandNote {
private Type type;
private String value;
private final Type type;
private final String value;
/**
* Creates a new adhoc command note with the specified type and value.

View file

@ -42,9 +42,9 @@ import org.jxmpp.jid.Jid;
public abstract class LocalCommand extends AdHocCommand {
/**
* The time stamp of first invokation of the command. Used to implement the session timeout.
* The time stamp of first invocation of the command. Used to implement the session timeout.
*/
private long creationDate;
private final long creationDate;
/**
* The unique ID of the execution of the command.
@ -59,12 +59,12 @@ public abstract class LocalCommand extends AdHocCommand {
/**
* The number of the current stage.
*/
private int currenStage;
private int currentStage;
public LocalCommand() {
super();
this.creationDate = System.currentTimeMillis();
currenStage = -1;
currentStage = -1;
}
/**
@ -139,7 +139,7 @@ public abstract class LocalCommand extends AdHocCommand {
* @return the current stage number.
*/
public int getCurrentStage() {
return currenStage;
return currentStage;
}
@Override
@ -154,7 +154,7 @@ public abstract class LocalCommand extends AdHocCommand {
*
*/
void incrementStage() {
currenStage++;
currentStage++;
}
/**
@ -163,6 +163,6 @@ public abstract class LocalCommand extends AdHocCommand {
*
*/
void decrementStage() {
currenStage--;
currentStage--;
}
}

View file

@ -46,12 +46,12 @@ public class RemoteCommand extends AdHocCommand {
/**
* The connection that is used to execute this command
*/
private XMPPConnection connection;
private final XMPPConnection connection;
/**
* The full JID of the command host
*/
private Jid jid;
private final Jid jid;
/**
* The session ID of this execution.
@ -132,8 +132,8 @@ public class RemoteCommand extends AdHocCommand {
*/
private void executeAction(Action action, Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// TODO: Check that all the required fields of the form were filled, if
// TODO: not throw the corresponding exeption. This will make a faster response,
// TODO: since the request is stoped before it's sent.
// TODO: not throw the corresponding exception. This will make a faster response,
// TODO: since the request is stopped before it's sent.
AdHocCommandData data = new AdHocCommandData();
data.setType(IQ.Type.set);
data.setTo(getOwnerJID());

View file

@ -53,7 +53,7 @@ public class AdHocCommandData extends IQ {
/* Unique ID of the execution */
private String sessionID;
private List<AdHocCommandNote> notes = new ArrayList<AdHocCommandNote>();
private final List<AdHocCommandNote> notes = new ArrayList<>();
private DataForm form;
@ -63,7 +63,7 @@ public class AdHocCommandData extends IQ {
/* Current execution status */
private AdHocCommand.Status status;
private ArrayList<AdHocCommand.Action> actions = new ArrayList<AdHocCommand.Action>();
private final ArrayList<AdHocCommand.Action> actions = new ArrayList<>();
private AdHocCommand.Action executeAction;
@ -164,7 +164,7 @@ public class AdHocCommandData extends IQ {
this.notes.add(note);
}
public void remveNote(AdHocCommandNote note) {
public void removeNote(AdHocCommandNote note) {
this.notes.remove(note);
}

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverItems;
/**
* The NodeInformationProvider is responsible for providing supported indentities, features
* The NodeInformationProvider is responsible for providing supported identities, features
* and hosted items (i.e. DiscoverItems.Item) about a given node. This information will be
* requested each time this XMPPP client receives a disco info or items requests on the
* given node. each time this XMPPP client receives a disco info or items requests on the
@ -56,7 +56,7 @@ public interface NodeInformationProvider {
List<String> getNodeFeatures();
/**
* Returns a list of the indentites defined in the node. For
* Returns a list of the identities defined in the node. For
* example, the x-command protocol must provide an identity of
* category automation and type command-node for each command.
*

View file

@ -78,17 +78,16 @@ public final class ServiceDiscoveryManager extends Manager {
private static DiscoverInfo.Identity defaultIdentity = new Identity(DEFAULT_IDENTITY_CATEGORY,
DEFAULT_IDENTITY_NAME, DEFAULT_IDENTITY_TYPE);
private Set<DiscoverInfo.Identity> identities = new HashSet<DiscoverInfo.Identity>();
private final Set<DiscoverInfo.Identity> identities = new HashSet<>();
private DiscoverInfo.Identity identity = defaultIdentity;
private EntityCapsManager capsManager;
private static Map<XMPPConnection, ServiceDiscoveryManager> instances = new WeakHashMap<>();
private static final Map<XMPPConnection, ServiceDiscoveryManager> instances = new WeakHashMap<>();
private final Set<String> features = new HashSet<String>();
private final Set<String> features = new HashSet<>();
private DataForm extendedInfo = null;
private Map<String, NodeInformationProvider> nodeInformationProviders =
new ConcurrentHashMap<String, NodeInformationProvider>();
private final Map<String, NodeInformationProvider> nodeInformationProviders = new ConcurrentHashMap<>();
// Create a new ServiceDiscoveryManager on every established connection
static {
@ -270,7 +269,7 @@ public final class ServiceDiscoveryManager extends Manager {
* @return all identies as set
*/
public Set<DiscoverInfo.Identity> getIdentities() {
Set<Identity> res = new HashSet<Identity>(identities);
Set<Identity> res = new HashSet<>(identities);
// Add the default identity that must exist
res.add(defaultIdentity);
return Collections.unmodifiableSet(res);
@ -368,7 +367,7 @@ public final class ServiceDiscoveryManager extends Manager {
* @return a List of the supported features by this XMPP entity.
*/
public synchronized List<String> getFeatures() {
return new ArrayList<String>(features);
return new ArrayList<>(features);
}
/**
@ -455,7 +454,7 @@ public final class ServiceDiscoveryManager extends Manager {
public List<ExtensionElement> getExtendedInfoAsList() {
List<ExtensionElement> res = null;
if (extendedInfo != null) {
res = new ArrayList<ExtensionElement>(1);
res = new ArrayList<>(1);
res.add(extendedInfo);
}
return res;
@ -748,7 +747,7 @@ public final class ServiceDiscoveryManager extends Manager {
* Create a cache to hold the 25 most recently lookup services for a given feature for a period
* of 24 hours.
*/
private Cache<String, List<DiscoverInfo>> services = new ExpirationCache<>(25,
private final Cache<String, List<DiscoverInfo>> services = new ExpirationCache<>(25,
24 * 60 * 60 * 1000);
/**
@ -784,7 +783,7 @@ public final class ServiceDiscoveryManager extends Manager {
*/
public List<DiscoverInfo> findServicesDiscoverInfo(String feature, boolean stopOnFirst, boolean useCache, Map<? super Jid, Exception> encounteredExceptions)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<DiscoverInfo> serviceDiscoInfo = null;
List<DiscoverInfo> serviceDiscoInfo;
DomainBareJid serviceName = connection().getXMPPServiceDomain();
if (useCache) {
serviceDiscoInfo = services.lookup(feature);

View file

@ -45,10 +45,10 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
private final List<Feature> features = new LinkedList<Feature>();
private final Set<Feature> featuresSet = new HashSet<Feature>();
private final List<Identity> identities = new LinkedList<Identity>();
private final Set<String> identitiesSet = new HashSet<String>();
private final List<Feature> features = new LinkedList<>();
private final Set<Feature> featuresSet = new HashSet<>();
private final List<Identity> identities = new LinkedList<>();
private final Set<String> identitiesSet = new HashSet<>();
private String node;
private boolean containsDuplicateFeatures;
@ -169,7 +169,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
* @return a list of Identites with the given category and type.
*/
public List<Identity> getIdentities(String category, String type) {
List<Identity> res = new ArrayList<Identity>(identities.size());
List<Identity> res = new ArrayList<>(identities.size());
for (Identity identity : identities) {
if (identity.getCategory().equals(category) && identity.getType().equals(type)) {
res.add(identity);
@ -208,7 +208,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
* Returns true if the specified feature is part of the discovered information.
*
* @param feature the feature to check
* @return true if the requestes feature has been discovered
* @return true if the requests feature has been discovered
*/
public boolean containsFeature(CharSequence feature) {
return features.contains(new Feature(feature));
@ -234,7 +234,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
* @return true if duplicate identities where found, otherwise false
*/
public boolean containsDuplicateIdentities() {
List<Identity> checkedIdentities = new LinkedList<Identity>();
List<Identity> checkedIdentities = new LinkedList<>();
for (Identity i : identities) {
for (Identity i2 : checkedIdentities) {
if (i.equals(i2))
@ -472,7 +472,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
}
/**
* Represents the features offered by the item. This information helps requestors determine
* Represents the features offered by the item. This information helps the requester to determine
* what actions are possible with regard to this item (registration, search, join, etc.)
* as well as specific feature types of interest, if any (e.g., for the purpose of feature
* negotiation).

View file

@ -40,7 +40,7 @@ public class DiscoverItems extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "http://jabber.org/protocol/disco#items";
private final List<Item> items = new LinkedList<Item>();
private final List<Item> items = new LinkedList<>();
private String node;
public DiscoverItems() {

View file

@ -36,7 +36,7 @@ public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
throws Exception {
DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false;
DiscoverInfo.Identity identity = null;
DiscoverInfo.Identity identity;
String category = "";
String identityName = "";
String type = "";

View file

@ -65,11 +65,11 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
@Override
public InputStream createIncomingStream(final StreamInitiation initiation) throws SmackException, XMPPErrorException, InterruptedException {
// This could be either an xep47 ibb 'open' iq or an xep65 streamhost iq
IQ initationSet = initiateIncomingStream(connection(), initiation);
IQ initiationSet = initiateIncomingStream(connection(), initiation);
StreamNegotiator streamNegotiator = determineNegotiator(initationSet);
StreamNegotiator streamNegotiator = determineNegotiator(initiationSet);
return streamNegotiator.negotiateIncomingStream(initationSet);
return streamNegotiator.negotiateIncomingStream(initiationSet);
}
private StreamNegotiator determineNegotiator(Stanza streamInitiation) {

View file

@ -47,7 +47,7 @@ import org.jxmpp.jid.EntityFullJid;
*/
public final class FileTransferManager extends Manager {
private static final Map<XMPPConnection, FileTransferManager> INSTANCES = new WeakHashMap<XMPPConnection, FileTransferManager>();
private static final Map<XMPPConnection, FileTransferManager> INSTANCES = new WeakHashMap<>();
public static synchronized FileTransferManager getInstanceFor(XMPPConnection connection) {
FileTransferManager fileTransferManager = INSTANCES.get(connection);
@ -60,7 +60,7 @@ public final class FileTransferManager extends Manager {
private final FileTransferNegotiator fileTransferNegotiator;
private final List<FileTransferListener> listeners = new CopyOnWriteArrayList<FileTransferListener>();
private final List<FileTransferListener> listeners = new CopyOnWriteArrayList<>();
/**
* Creates a file transfer manager to initiate and receive file transfers.

View file

@ -60,7 +60,7 @@ public final class FileTransferNegotiator extends Manager {
public static final String SI_PROFILE_FILE_TRANSFER_NAMESPACE = "http://jabber.org/protocol/si/profile/file-transfer";
private static final String[] NAMESPACE = { SI_NAMESPACE, SI_PROFILE_FILE_TRANSFER_NAMESPACE };
private static final Map<XMPPConnection, FileTransferNegotiator> INSTANCES = new WeakHashMap<XMPPConnection, FileTransferNegotiator>();
private static final Map<XMPPConnection, FileTransferNegotiator> INSTANCES = new WeakHashMap<>();
private static final String STREAM_INIT_PREFIX = "jsi_";
@ -105,7 +105,7 @@ public final class FileTransferNegotiator extends Manager {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
List<String> namespaces = new ArrayList<>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
@ -132,7 +132,7 @@ public final class FileTransferNegotiator extends Manager {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
List<String> namespaces = new ArrayList<>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
@ -153,7 +153,7 @@ public final class FileTransferNegotiator extends Manager {
* @return Returns a collection of the supported transfer protocols.
*/
public static Collection<String> getSupportedProtocols() {
List<String> protocols = new ArrayList<String>();
List<String> protocols = new ArrayList<>();
protocols.add(DataPacketExtension.NAMESPACE);
if (!IBB_ONLY) {
protocols.add(Bytestream.NAMESPACE);

View file

@ -46,7 +46,7 @@ import org.jxmpp.jid.Jid;
*/
public class IBBTransferNegotiator extends StreamNegotiator {
private InBandBytestreamManager manager;
private final InBandBytestreamManager manager;
/**
* The default constructor for the In-Band Bytestream Negotiator.

View file

@ -22,12 +22,10 @@ import java.io.OutputStream;
import java.io.PushbackInputStream;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
@ -45,7 +43,7 @@ import org.jxmpp.jid.Jid;
*/
public class Socks5TransferNegotiator extends StreamNegotiator {
private Socks5BytestreamManager manager;
private final Socks5BytestreamManager manager;
Socks5TransferNegotiator(XMPPConnection connection) {
super(connection);
@ -53,7 +51,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
}
@Override
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws NoResponseException, SmackException, XMPPException
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws SmackException, XMPPException
{
try {
return this.manager.establishSession(target, streamID).getOutputStream();

View file

@ -137,7 +137,7 @@ public abstract class StreamNegotiator extends Manager {
abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException,
InterruptedException, NoResponseException, SmackException;
InterruptedException, SmackException;
/**
* This method handles the file stream download negotiation process. The
@ -156,7 +156,7 @@ public abstract class StreamNegotiator extends Manager {
* @throws SmackException
*/
public abstract InputStream createIncomingStream(StreamInitiation initiation)
throws XMPPErrorException, InterruptedException, NoResponseException, SmackException;
throws XMPPErrorException, InterruptedException, SmackException;
/**
* This method handles the file upload stream negotiation process. The
@ -169,14 +169,12 @@ public abstract class StreamNegotiator extends Manager {
* @param target The fully-qualified JID of the target or receiver of the file
* transfer.
* @return The negotiated stream ready for data.
* @throws XMPPErrorException If an error occurs during the negotiation process an
* exception will be thrown.
* @throws SmackException
* @throws XMPPException
* @throws InterruptedException
*/
public abstract OutputStream createOutgoingStream(String streamID,
Jid initiator, Jid target) throws XMPPErrorException, NoResponseException, SmackException, XMPPException, InterruptedException;
Jid initiator, Jid target) throws SmackException, XMPPException, InterruptedException;
/**
* Returns the XMPP namespace reserved for this particular type of file

View file

@ -32,7 +32,7 @@ import org.jxmpp.jid.Jid;
public final class GeoLocationManager extends Manager {
private static final Map<XMPPConnection, GeoLocationManager> INSTANCES = new WeakHashMap<XMPPConnection, GeoLocationManager>();
private static final Map<XMPPConnection, GeoLocationManager> INSTANCES = new WeakHashMap<>();
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {

View file

@ -91,7 +91,7 @@ public final class GeoLocation implements Serializable, ExtensionElement {
if (accuracy != null) {
error = null;
LOGGER.log(Level.WARNING,
"Error and accurracy set. Ignoring error as it is deprecated in favor of accuracy");
"Error and accuracy set. Ignoring error as it is deprecated in favor of accuracy");
}
this.error = error;

View file

@ -92,7 +92,7 @@ import org.jxmpp.jid.Jid;
*/
public final class LastActivityManager extends Manager {
private static final Map<XMPPConnection, LastActivityManager> instances = new WeakHashMap<XMPPConnection, LastActivityManager>();
private static final Map<XMPPConnection, LastActivityManager> instances = new WeakHashMap<>();
// private static final PacketFilter IQ_GET_LAST_FILTER = new AndFilter(IQTypeFilter.GET,
// new StanzaTypeFilter(LastActivity.class));

View file

@ -77,7 +77,7 @@ public final class PrivateDataManager extends Manager {
/**
* Map of provider instances.
*/
private static Map<String, PrivateDataProvider> privateDataProviders = new Hashtable<String, PrivateDataProvider>();
private static final Map<String, PrivateDataProvider> privateDataProviders = new Hashtable<>();
/**
* Returns the private data provider registered to the specified XML element name and namespace.

View file

@ -46,8 +46,8 @@ import java.util.Set;
*/
public class DefaultPrivateData implements PrivateData {
private String elementName;
private String namespace;
private final String elementName;
private final String namespace;
private Map<String, String> map;
/**
@ -103,7 +103,7 @@ public class DefaultPrivateData implements PrivateData {
*/
public synchronized Set<String> getNames() {
if (map == null) {
return Collections.<String>emptySet();
return Collections.emptySet();
}
return Collections.unmodifiableSet(map.keySet());
}
@ -129,7 +129,7 @@ public class DefaultPrivateData implements PrivateData {
*/
public synchronized void setValue(String name, String value) {
if (map == null) {
map = new HashMap<String,String>();
map = new HashMap<>();
}
map.put(name, value);
}

View file

@ -31,19 +31,19 @@ public interface PrivateData {
*
* @return the element name.
*/
public String getElementName();
String getElementName();
/**
* Returns the root element XML namespace.
*
* @return the namespace.
*/
public String getNamespace();
String getNamespace();
/**
* Returns the XML reppresentation of the PrivateData.
*
* @return the private data as XML.
*/
public CharSequence toXML();
CharSequence toXML();
}

View file

@ -44,5 +44,5 @@ public interface PrivateDataProvider {
* @param parser an XML parser.
* @return a new PrivateData instance.
*/
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException;
PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException;
}

View file

@ -48,7 +48,7 @@ import org.jxmpp.jid.parts.Localpart;
*/
public final class AccountManager extends Manager {
private static final Map<XMPPConnection, AccountManager> INSTANCES = new WeakHashMap<XMPPConnection, AccountManager>();
private static final Map<XMPPConnection, AccountManager> INSTANCES = new WeakHashMap<>();
/**
* Returns the AccountManager instance associated with a given XMPPConnection.
@ -247,7 +247,7 @@ public final class AccountManager extends Manager {
*/
public void createAccount(Localpart username, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// Create a map for all the required attributes, but give them blank values.
Map<String, String> attributes = new HashMap<String, String>();
Map<String, String> attributes = new HashMap<>();
for (String attributeName : getAccountAttributes()) {
attributes.put(attributeName, "");
}
@ -303,7 +303,7 @@ public final class AccountManager extends Manager {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
throw new IllegalStateException("Changing password over insecure connection.");
}
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("username", connection().getUser().getLocalpart().toString());
map.put("password",newPassword);
Registration reg = new Registration(map);
@ -324,7 +324,7 @@ public final class AccountManager extends Manager {
* @throws InterruptedException
*/
public void deleteAccount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Map<String, String> attributes = new HashMap<String, String>();
Map<String, String> attributes = new HashMap<>();
// To delete an account, we add a single attribute, "remove", that is blank.
attributes.put("remove", "");
Registration reg = new Registration(attributes);
@ -369,7 +369,6 @@ public final class AccountManager extends Manager {
}
private StanzaCollector createStanzaCollectorAndSend(IQ req) throws NotConnectedException, InterruptedException {
StanzaCollector collector = connection().createStanzaCollectorAndSend(new StanzaIdFilter(req.getStanzaId()), req);
return collector;
return connection().createStanzaCollectorAndSend(new StanzaIdFilter(req.getStanzaId()), req);
}
}

View file

@ -36,8 +36,8 @@ public class RegistrationProvider extends IQProvider<Registration> {
public Registration parse(XmlPullParser parser, int initialDepth)
throws Exception {
String instruction = null;
Map<String, String> fields = new HashMap<String, String>();
List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
Map<String, String> fields = new HashMap<>();
List<ExtensionElement> packetExtensions = new LinkedList<>();
outerloop:
while (true) {
int eventType = parser.next();

View file

@ -55,7 +55,7 @@ import org.jxmpp.jid.Jid;
* @author Georg Lukas
*/
public final class VersionManager extends Manager {
private static final Map<XMPPConnection, VersionManager> INSTANCES = new WeakHashMap<XMPPConnection, VersionManager>();
private static final Map<XMPPConnection, VersionManager> INSTANCES = new WeakHashMap<>();
private static Version defaultVersion;

View file

@ -52,7 +52,7 @@ public class JivePropertiesExtension implements ExtensionElement {
private final Map<String, Object> properties;
public JivePropertiesExtension() {
properties = new HashMap<String, Object>();
properties = new HashMap<>();
}
public JivePropertiesExtension(Map<String, Object> properties) {
@ -84,7 +84,7 @@ public class JivePropertiesExtension implements ExtensionElement {
*/
public synchronized void setProperty(String name, Object value) {
if (!(value instanceof Serializable)) {
throw new IllegalArgumentException("Value must be serialiazble");
throw new IllegalArgumentException("Value must be serializable");
}
properties.put(name, value);
}
@ -110,7 +110,7 @@ public class JivePropertiesExtension implements ExtensionElement {
if (properties == null) {
return Collections.emptySet();
}
return Collections.unmodifiableSet(new HashSet<String>(properties.keySet()));
return Collections.unmodifiableSet(new HashSet<>(properties.keySet()));
}
/**
@ -122,7 +122,7 @@ public class JivePropertiesExtension implements ExtensionElement {
if (properties == null) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(new HashMap<String, Object>(properties));
return Collections.unmodifiableMap(new HashMap<>(properties));
}
@Override

View file

@ -55,7 +55,7 @@ public class JivePropertiesExtensionProvider extends ExtensionElementProvider<Ji
public JivePropertiesExtension parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException,
IOException {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<>();
while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("property")) {

View file

@ -73,7 +73,7 @@ public class GroupChatInvitation implements ExtensionElement {
/**
* Creates a new group chat invitation to the specified room address.
* GroupChat room addresses are in the form <tt>room@service</tt>,
* where <tt>service</tt> is the name of groupchat server, such as
* where <tt>service</tt> is the name of group chat server, such as
* <tt>chat.example.com</tt>.
*
* @param roomAddress the address of the group chat room.
@ -85,7 +85,7 @@ public class GroupChatInvitation implements ExtensionElement {
/**
* Returns the address of the group chat room. GroupChat room addresses
* are in the form <tt>room@service</tt>, where <tt>service</tt> is
* the name of groupchat server, such as <tt>chat.example.com</tt>.
* the name of group chat server, such as <tt>chat.example.com</tt>.
*
* @return the address of the group chat room.
*/

View file

@ -35,22 +35,22 @@ public class MUCAdmin extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#admin";
private final List<MUCItem> items = new ArrayList<MUCItem>();
private final List<MUCItem> items = new ArrayList<>();
public MUCAdmin() {
super(ELEMENT, NAMESPACE);
}
/**
* Returns a List of item childs that holds information about roles, affiliation,
* Returns a List of item children that holds information about roles, affiliation,
* jids and nicks.
*
* @return a List of item childs that holds information about roles, affiliation,
* @return a List of item children that holds information about roles, affiliation,
* jids and nicks.
*/
public List<MUCItem> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<MUCItem>(items));
return Collections.unmodifiableList(new ArrayList<>(items));
}
}

View file

@ -177,7 +177,7 @@ public class MUCInitialPresence implements ExtensionElement {
/**
* Deprecated constructor.
* @deprecated use {@link #MUCInitialPresence.History(int, int, int, Date)} instead.
* @deprecated use {@link #History(int, int, int, Date)} instead.
*/
@Deprecated
public History() {
@ -240,7 +240,7 @@ public class MUCInitialPresence implements ExtensionElement {
* Sets the total number of characters to receive in the history.
*
* @param maxChars the total number of characters to receive in the history.
* @deprecated use {@link #MUCInitialPresence.History(int, int, int, Date)} instead.
* @deprecated use {@link #History(int, int, int, Date)} instead.
*/
@Deprecated
public void setMaxChars(int maxChars) {
@ -251,7 +251,7 @@ public class MUCInitialPresence implements ExtensionElement {
* Sets the total number of messages to receive in the history.
*
* @param maxStanzas the total number of messages to receive in the history.
* @deprecated use {@link #MUCInitialPresence.History(int, int, int, Date)} instead.
* @deprecated use {@link #History(int, int, int, Date)} instead.
*/
@Deprecated
public void setMaxStanzas(int maxStanzas) {
@ -265,7 +265,7 @@ public class MUCInitialPresence implements ExtensionElement {
*
* @param seconds the number of seconds to use to filter the messages received during
* that time.
* @deprecated use {@link #MUCInitialPresence.History(int, int, int, Date)} instead.
* @deprecated use {@link #History(int, int, int, Date)} instead.
*/
@Deprecated
public void setSeconds(int seconds) {
@ -278,7 +278,7 @@ public class MUCInitialPresence implements ExtensionElement {
* included in the history.
*
* @param since the since date to use to filter the messages received during that time.
* @deprecated use {@link #MUCInitialPresence.History(int, int, int, Date)} instead.
* @deprecated use {@link #History(int, int, int, Date)} instead.
*/
@Deprecated
public void setSince(Date since) {

View file

@ -34,7 +34,7 @@ public class MUCOwner extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#owner";
private final List<MUCItem> items = new ArrayList<MUCItem>();
private final List<MUCItem> items = new ArrayList<>();
private Destroy destroy;
public MUCOwner() {
@ -42,15 +42,15 @@ public class MUCOwner extends IQ {
}
/**
* Returns a List of item childs that holds information about affiliation,
* Returns a List of item children that holds information about affiliation,
* jids and nicks.
*
* @return a List of item childs that holds information about affiliation,
* @return a List of item children that holds information about affiliation,
* jids and nicks.
*/
public List<MUCItem> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<MUCItem>(items));
return Collections.unmodifiableList(new ArrayList<>(items));
}
}

View file

@ -42,7 +42,7 @@ public class MUCUser implements ExtensionElement {
public static final String ELEMENT = "x";
public static final String NAMESPACE = MUCInitialPresence.NAMESPACE + "#user";
private final Set<Status> statusCodes = new HashSet<Status>(4);
private final Set<Status> statusCodes = new HashSet<>(4);
private Invite invite;
private Decline decline;
@ -87,7 +87,7 @@ public class MUCUser implements ExtensionElement {
/**
* Returns the rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter.
* sent to the room which in turn will forward the refusal to the inviting user.
*
* @return a rejection to an invitation from another user to a room.
*/
@ -160,7 +160,7 @@ public class MUCUser implements ExtensionElement {
/**
* Sets the rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter.
* sent to the room which in turn will forward the refusal to the inviting user.
*
* @param decline the rejection to an invitation from another user to a room.
*/
@ -252,7 +252,7 @@ public class MUCUser implements ExtensionElement {
private final String reason;
/**
* From XEP-0045 § 7.8.2: "… whose value is the bare JID, full JID, or occupant JID of the inviter …"
* From XEP-0045 § 7.8.2: "… whose value is the bare JID, full JID, or occupant JID of the inviting user …"
*/
private final EntityJid from;
@ -273,7 +273,7 @@ public class MUCUser implements ExtensionElement {
}
/**
* Returns the bare JID of the inviter or, optionally, the room JID. (e.g.
* Returns the bare JID of the inviting user or, optionally, the room JID. (e.g.
* 'crone1@shakespeare.lit/desktop').
*
* @return the room's occupant that sent the invitation.
@ -319,7 +319,7 @@ public class MUCUser implements ExtensionElement {
/**
* Represents a rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter.
* sent to the room which in turn will forward the refusal to the inviting user.
*
* @author Gaston Dombiak
*/
@ -360,9 +360,9 @@ public class MUCUser implements ExtensionElement {
}
/**
* Returns the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit')
* Returns the bare JID of the inviting user. (e.g. 'hecate@shakespeare.lit')
*
* @return the bare JID of the inviter.
* @return the bare JID of the inviting user.
*/
public EntityBareJid getTo() {
return to;
@ -394,7 +394,7 @@ public class MUCUser implements ExtensionElement {
public static final class Status implements NamedElement {
public static final String ELEMENT = "status";
private static final Map<Integer, Status> statusMap = new HashMap<Integer, Status>(8);
private static final Map<Integer, Status> statusMap = new HashMap<>(8);
public static final Status PRESENCE_TO_SELF_110 = Status.create(110);
public static final Status ROOM_CREATED_201 = Status.create(201);

View file

@ -123,7 +123,7 @@ public class OfflineMessageManager {
* @throws InterruptedException
*/
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
List<OfflineMessageHeader> answer = new ArrayList<>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
null, namespace);
for (DiscoverItems.Item item : items.getItems()) {
@ -148,7 +148,7 @@ public class OfflineMessageManager {
* @throws InterruptedException
*/
public List<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<Message> messages = new ArrayList<Message>(nodes.size());
List<Message> messages = new ArrayList<>(nodes.size());
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
@ -159,7 +159,7 @@ public class OfflineMessageManager {
StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
@Override
public boolean accept(Stanza packet) {
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
OfflineMessageInfo info = packet.getExtension("offline",
namespace);
return nodes.contains(info.getNode());
}
@ -208,7 +208,7 @@ public class OfflineMessageManager {
StanzaCollector.Configuration messageCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter(PACKET_FILTER).setCollectorToReset(resultCollector);
StanzaCollector messageCollector = connection.createStanzaCollector(messageCollectorConfiguration);
List<Message> messages = null;
List<Message> messages;
try {
resultCollector.nextResultOrThrow();
// Be extra safe, cancel the message collector right here so that it does not collector

View file

@ -48,15 +48,15 @@ public class OfflineMessageRequest extends IQ {
}
/**
* Returns a List of item childs that holds information about offline messages to
* Returns a List of item children that holds information about offline messages to
* view or delete.
*
* @return a List of item childs that holds information about offline messages to
* @return a List of item children that holds information about offline messages to
* view or delete.
*/
public List<Item> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<Item>(items));
return Collections.unmodifiableList(new ArrayList<>(items));
}
}
@ -112,8 +112,7 @@ public class OfflineMessageRequest extends IQ {
buf.rightAngleBracket();
synchronized (items) {
for (int i = 0; i < items.size(); i++) {
Item item = items.get(i);
for (Item item : items) {
buf.append(item.toXML());
}
}

View file

@ -40,6 +40,6 @@ public interface PEPListener {
* @param event the event contained in the message.
* @param message the message stanza containing the PEP event.
*/
public void eventReceived(EntityBareJid from, EventElement event, Message message);
void eventReceived(EntityBareJid from, EventElement event, Message message);
}

View file

@ -50,7 +50,7 @@ import org.jxmpp.jid.EntityBareJid;
/**
*
* Manages Personal Event Publishing (XEP-163). A PEPManager provides a high level access to
* pubsub personal events. It also provides an easy way
* PubSub personal events. It also provides an easy way
* to hook up custom logic when events are received from another XMPP client through PEPListeners.
*
* Use example:

View file

@ -68,7 +68,7 @@ import org.jxmpp.jid.Jid;
public final class PingManager extends Manager {
private static final Logger LOGGER = Logger.getLogger(PingManager.class.getName());
private static final Map<XMPPConnection, PingManager> INSTANCES = new WeakHashMap<XMPPConnection, PingManager>();
private static final Map<XMPPConnection, PingManager> INSTANCES = new WeakHashMap<>();
static {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {

View file

@ -36,13 +36,13 @@ public interface PrivacyListListener {
* @param listName the name of the new or updated privacy list.
* @param listItem the PrivacyItems that rules the list.
*/
public void setPrivacyList(String listName, List<PrivacyItem> listItem);
void setPrivacyList(String listName, List<PrivacyItem> listItem);
/**
* A privacy list has been modified by another. It gets notified.
*
* @param listName the name of the updated privacy list.
*/
public void updatedPrivacyList(String listName);
void updatedPrivacyList(String listName);
}

View file

@ -72,9 +72,9 @@ public final class PrivacyListManager extends Manager {
private static final StanzaFilter PRIVACY_RESULT = new AndFilter(IQTypeFilter.RESULT, PRIVACY_FILTER);
// Keep the list of instances of this class.
private static final Map<XMPPConnection, PrivacyListManager> INSTANCES = new WeakHashMap<XMPPConnection, PrivacyListManager>();
private static final Map<XMPPConnection, PrivacyListManager> INSTANCES = new WeakHashMap<>();
private final Set<PrivacyListListener> listeners = new CopyOnWriteArraySet<PrivacyListListener>();
private final Set<PrivacyListListener> listeners = new CopyOnWriteArraySet<>();
static {
// Create a new PrivacyListManager on every established connection.

View file

@ -55,7 +55,7 @@ public class Privacy extends IQ {
private String defaultName;
/** itemLists holds the set of privacy items classified in lists. It is a map where the
* key is the name of the list and the value a collection with privacy items. **/
private Map<String, List<PrivacyItem>> itemLists = new HashMap<String, List<PrivacyItem>>();
private final Map<String, List<PrivacyItem>> itemLists = new HashMap<>();
public Privacy() {
super(ELEMENT, NAMESPACE);
@ -271,7 +271,7 @@ public class Privacy extends IQ {
public boolean isDeclineActiveList() {
return declineActiveList;
}
// CHECKSYTLE:ON
// CHECKSTYLE:ON
/**
* Sets whether the receiver allows or declines the use of an active list.

View file

@ -328,7 +328,7 @@ public class PrivacyItem {
/**
* Type defines if the rule is based on JIDs, roster groups or presence subscription types.
*/
public static enum Type {
public enum Type {
/**
* JID being analyzed should belong to a roster group of the list's owner.
*/

View file

@ -83,7 +83,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
boolean done = false;
String listName = parser.getAttributeValue("", "name");
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
ArrayList<PrivacyItem> items = new ArrayList<>();
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
@ -128,7 +128,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
allow = false;
break;
default:
throw new SmackException("Unkown action value '" + actionValue + "'");
throw new SmackException("Unknown action value '" + actionValue + "'");
}
PrivacyItem item;

View file

@ -17,8 +17,8 @@
package org.jivesoftware.smackx.pubsub;
/**
* This enumeration represents the access models for the pubsub node
* as defined in the pubsub specification section <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-config">16.4.3</a>.
* This enumeration represents the access models for the PubSub node
* as defined in the PubSub specification section <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-config">16.4.3</a>.
*
* @author Robin Collier
*/

View file

@ -80,8 +80,8 @@ public class Affiliation implements ExtensionElement
this.jid = jid;
this.affiliation = affiliation;
this.node = null;
// This is usually the pubsub#owner namesapce, but see xep60 example 208 where just 'pubsub' is used
// ("notification of affilliation change")
// This is usually the pubsub#owner namespace, but see xep60 example 208 where just 'pubsub' is used
// ("notification of affiliation change")
this.namespace = namespace;
}

View file

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.pubsub;
/**
* This enumeration represents the children association policy for associating leaf nodes
* with collection nodes as defined in the pubsub specification section <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-config">16.4.3</a>.
* with collection nodes as defined in the PubSub specification section <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-config">16.4.3</a>.
*
* @author Robin Collier
*/

View file

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

View file

@ -23,7 +23,7 @@ import java.util.List;
import org.jivesoftware.smack.packet.ExtensionElement;
/**
* Represents the <b>configuration</b> element of a pubsub message event which
* Represents the <b>configuration</b> element of a PubSub message event which
* associates a configuration form to the node which was configured. The form
* contains the current node configuration.
*

View file

@ -163,7 +163,7 @@ public class ConfigureForm extends Form
public void setChildrenAssociationPolicy(ChildrenAssociationPolicy policy)
{
addField(ConfigureNodeFields.children_association_policy, FormField.Type.list_single);
List<String> values = new ArrayList<String>(1);
List<String> values = new ArrayList<>(1);
values.add(policy.toString());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
}
@ -711,7 +711,7 @@ public class ConfigureForm extends Form
private static List<String> getListSingle(String value)
{
List<String> list = new ArrayList<String>(1);
List<String> list = new ArrayList<>(1);
list.add(value);
return list;
}

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
/**
* Represents the top level element of a pubsub event extension. All types of pubsub events are
* Represents the top level element of a PubSub event extension. All types of PubSub events are
* represented by this class. The specific type can be found by {@link #getEventType()}. The
* embedded event information, which is specific to the event type, can be retrieved by the {@link #getEvent()}
* method.
@ -45,8 +45,8 @@ public class EventElement implements EmbeddedPacketExtension
*/
public static final String NAMESPACE = PubSubNamespace.EVENT.getXmlns();
private EventElementType type;
private NodeExtension ext;
private final EventElementType type;
private final NodeExtension ext;
public EventElement(EventElementType eventType, NodeExtension eventExt)
{

View file

@ -17,14 +17,14 @@
package org.jivesoftware.smackx.pubsub;
/**
* This enumeration defines the possible event types that are supported within pubsub
* This enumeration defines the possible event types that are supported within PubSub
* event messages.
*
* @author Robin Collier
*/
public enum EventElementType
{
/** A node has been associated or dissassociated with a collection node. */
/** A node has been associated or disassociated with a collection node. */
collection,
/** A node has had its configuration changed. */

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smackx.xdata.Form;
/**
* Generic stanza(/packet) extension which represents any pubsub form that is
* Generic stanza(/packet) extension which represents any PubSub form that is
* parsed from the incoming stream or being sent out to the server.
*
* Form types are defined in {@link FormNodeType}.
@ -28,7 +28,7 @@ import org.jivesoftware.smackx.xdata.Form;
*/
public class FormNode extends NodeExtension
{
private Form configForm;
private final Form configForm;
/**
* Create a {@link FormNode} which contains the specified form.

View file

@ -21,12 +21,11 @@ import java.util.Locale;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
/**
* The types of forms supported by the pubsub specification.
* The types of forms supported by the PubSub specification.
*
* @author Robin Collier
*/
public enum FormNodeType
{
public enum FormNodeType {
/** Form for configuring an existing node. */
CONFIGURE_OWNER,

View file

@ -22,7 +22,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
/**
* This class represents an item that has been, or will be published to a
* pubsub node. An <tt>Item</tt> has several properties that are dependent
* PubSub node. An <tt>Item</tt> has several properties that are dependent
* on the configuration of the node to which it has been or will be published.
*
* <h3>An Item received from a node (via {@link LeafNode#getItems()} or {@link LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)}</h3>

View file

@ -28,5 +28,5 @@ public enum ItemReply
owner,
/** The item publisher. */
publisher;
publisher
}

View file

@ -51,7 +51,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
private final PubSubElementType elem;
private final String att;
private ItemsElementType(PubSubElementType nodeElement, String attribute)
ItemsElementType(PubSubElementType nodeElement, String attribute)
{
elem = nodeElement;
att = attribute;

View file

@ -30,8 +30,8 @@ import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
/**
* The main class for the majority of pubsub functionality. In general
* almost all pubsub capabilities are related to the concept of a node.
* The main class for the majority of PubSub functionality. In general
* almost all PubSub capabilities are related to the concept of a node.
* All items are published to a node, and typically subscribed to by other
* users. These users then retrieve events based on this subscription.
*
@ -73,7 +73,7 @@ public class LeafNode extends Node
*/
public <T extends Item> List<T> getItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null);
return getItems((List<ExtensionElement>) null, null);
}
/**
@ -112,7 +112,7 @@ public class LeafNode extends Node
*/
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> itemList = new ArrayList<Item>(ids.size());
List<Item> itemList = new ArrayList<>(ids.size());
for (String id : ids)
{
@ -320,7 +320,7 @@ public class LeafNode extends Node
@SuppressWarnings("unchecked")
public <T extends Item> void send(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
Collection<T> items = new ArrayList<T>(1);
Collection<T> items = new ArrayList<>(1);
items.add((item == null ? (T) new Item() : item));
send(items);
}
@ -345,7 +345,7 @@ public class LeafNode extends Node
*/
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
}
@ -378,7 +378,7 @@ public class LeafNode extends Node
*/
public void deleteItem(String itemId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
Collection<String> items = new ArrayList<String>(1);
Collection<String> items = new ArrayList<>(1);
items.add(itemId);
deleteItem(items);
}
@ -394,7 +394,7 @@ public class LeafNode extends Node
*/
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
List<Item> items = new ArrayList<Item>(itemIds.size());
List<Item> items = new ArrayList<>(itemIds.size());
for (String id : itemIds)
{

View file

@ -49,16 +49,16 @@ abstract public class Node
protected final PubSubManager pubSubManager;
protected final String id;
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<>();
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<>();
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<>();
/**
* Construct a node associated to the supplied connection with the specified
* node id.
*
* @param connection The connection the node is associated with
* @param nodeName The node id
* @param pubSubManager The PubSubManager for the connection the node is associated with
* @param nodeId The node id
*/
Node(PubSubManager pubSubManager, String nodeId)
{
@ -220,7 +220,7 @@ abstract public class Node
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
@ -280,7 +280,7 @@ abstract public class Node
/**
* Retrieve the affiliation list for this node as owner.
* <p>
* Note that this is an <b>optional</b> PubSub feature ('pubusb#modify-affiliations').
* Note that this is an <b>optional</b> PubSub feature ('pubsub#modify-affiliations').
* </p>
*
* @param additionalExtensions optional additional extension elements add to the request.
@ -314,7 +314,7 @@ abstract public class Node
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
AffiliationsExtension affilElem = (AffiliationsExtension) reply.getExtension(PubSubElementType.AFFILIATIONS);
AffiliationsExtension affilElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
return affilElem.getAffiliations();
}
@ -322,7 +322,7 @@ abstract public class Node
* Modify the affiliations for this PubSub node as owner. The {@link Affiliation}s given must be created with the
* {@link Affiliation#Affiliation(org.jxmpp.jid.BareJid, Affiliation.Type)} constructor.
* <p>
* Note that this is an <b>optional</b> PubSub feature ('pubusb#modify-affiliations').
* Note that this is an <b>optional</b> PubSub feature ('pubsub#modify-affiliations').
* </p>
*
* @param affiliations
@ -574,12 +574,12 @@ abstract public class Node
private static List<String> getSubscriptionIds(Stanza packet)
{
HeadersExtension headers = (HeadersExtension) packet.getExtension("headers", "http://jabber.org/protocol/shim");
HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null;
if (headers != null)
{
values = new ArrayList<String>(headers.getHeaders().size());
values = new ArrayList<>(headers.getHeaders().size());
for (Header header : headers.getHeaders())
{
@ -598,7 +598,7 @@ abstract public class Node
public class ItemEventTranslator implements StanzaListener
{
@SuppressWarnings("rawtypes")
private ItemEventListener listener;
private final ItemEventListener listener;
public ItemEventTranslator(@SuppressWarnings("rawtypes") ItemEventListener eventListener)
{
@ -609,7 +609,7 @@ abstract public class Node
@SuppressWarnings({ "rawtypes", "unchecked" })
public void processStanza(Stanza packet)
{
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ItemsExtension itemsElem = (ItemsExtension) event.getEvent();
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
listener.handlePublishedItems(eventItems);
@ -624,7 +624,7 @@ abstract public class Node
*/
public class ItemDeleteTranslator implements StanzaListener
{
private ItemDeleteListener listener;
private final ItemDeleteListener listener;
public ItemDeleteTranslator(ItemDeleteListener eventListener)
{
@ -635,7 +635,7 @@ abstract public class Node
public void processStanza(Stanza packet)
{
// CHECKSTYLE:OFF
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions();
@ -648,7 +648,7 @@ abstract public class Node
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
@SuppressWarnings("unchecked")
Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
List<String> items = new ArrayList<String>(pubItems.size());
List<String> items = new ArrayList<>(pubItems.size());
for (RetractItem item : pubItems)
{
@ -670,7 +670,7 @@ abstract public class Node
*/
public static class NodeConfigTranslator implements StanzaListener
{
private NodeConfigListener listener;
private final NodeConfigListener listener;
public NodeConfigTranslator(NodeConfigListener eventListener)
{
@ -680,7 +680,7 @@ abstract public class Node
@Override
public void processStanza(Stanza packet)
{
EventElement event = (EventElement) packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
EventElement event = packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
ConfigurationEvent config = (ConfigurationEvent) event.getEvent();
listener.handleNodeConfiguration(config);
@ -704,9 +704,9 @@ abstract public class Node
this(elementName, null);
}
EventContentFilter(String firstLevelEelement, String secondLevelElement)
EventContentFilter(String firstLevelElement, String secondLevelElement)
{
firstElement = firstLevelEelement;
firstElement = firstLevelElement;
secondElement = secondLevelElement;
allowEmpty = firstElement.equals(EventElementType.items.toString())
&& "item".equals(secondLevelElement);

View file

@ -24,5 +24,5 @@ package org.jivesoftware.smackx.pubsub;
public enum NodeType
{
leaf,
collection;
collection
}

View file

@ -50,7 +50,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
*/
public class PayloadItem<E extends ExtensionElement> extends Item
{
private E payload;
private final E payload;
/**
* Create an <tt>Item</tt> with no id and a payload The id will be set by the server.

View file

@ -54,7 +54,7 @@ public enum PubSubElementType
private final String eName;
private final PubSubNamespace nSpace;
private PubSubElementType(String elemName, PubSubNamespace ns)
PubSubElementType(String elemName, PubSubNamespace ns)
{
eName = elemName;
nSpace = ns;

View file

@ -33,7 +33,7 @@ public enum PubSubFeature implements CharSequence {
access_open(Support.optional),
access_presence(Support.optional),
access_roster(Support.optional),
acccess_whitelist(Support.optional),
access_whitelist(Support.optional),
auto_create(Support.optional),
auto_subscribe(Support.recommended),
collections(Support.optional),
@ -78,7 +78,7 @@ public enum PubSubFeature implements CharSequence {
private final String qualifiedFeature;
private final Feature.Support support;
private PubSubFeature(Feature.Support support) {
PubSubFeature(Feature.Support support) {
this.feature = name().replace('_', '-');
this.qualifiedFeature = PubSub.NAMESPACE + '#' + this.feature;
this.support = support;

View file

@ -80,7 +80,7 @@ public final class PubSubManager extends Manager {
* A map of node IDs to Nodes, used to cache those Nodes. This does only cache the type of Node,
* i.e. {@link CollectionNode} or {@link LeafNode}.
*/
private final Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
private final Map<String, Node> nodeMap = new ConcurrentHashMap<>();
/**
* Get a PubSub manager for the default PubSub service of the connection.
@ -98,7 +98,7 @@ public final class PubSubManager extends Manager {
LOGGER.log(Level.WARNING, "Could not determine PubSub service", e);
}
catch (InterruptedException e) {
LOGGER.log(Level.FINE, "Interupted while trying to determine PubSub service", e);
LOGGER.log(Level.FINE, "Interrupted while trying to determine PubSub service", e);
}
}
if (pubSubService == null) {

View file

@ -37,7 +37,7 @@ public class PublishItem<T extends Item> extends NodeExtension
public PublishItem(String nodeId, T toPublish)
{
super(PubSubElementType.PUBLISH, nodeId);
items = new ArrayList<T>(1);
items = new ArrayList<>(1);
items.add(toPublish);
}

View file

@ -31,5 +31,5 @@ public enum PublishModel
subscribers,
/** Anyone may publish. */
open;
open
}

View file

@ -27,7 +27,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
*/
public class RetractItem implements ExtensionElement
{
private String id;
private final String id;
/**
* Construct a <tt>RetractItem</tt> with the specified id.

View file

@ -181,7 +181,7 @@ public class SubscribeForm extends Form
*/
public List<PresenceState> getShowValues()
{
ArrayList<PresenceState> result = new ArrayList<PresenceState>(5);
ArrayList<PresenceState> result = new ArrayList<>(5);
for (String state : getFieldValues(SubscribeOptionFields.show_values))
{
@ -198,7 +198,7 @@ public class SubscribeForm extends Form
*/
public void setShowValues(Collection<PresenceState> stateValues)
{
ArrayList<String> values = new ArrayList<String>(stateValues.size());
ArrayList<String> values = new ArrayList<>(stateValues.size());
for (PresenceState state : stateValues)
{

View file

@ -24,8 +24,7 @@ import java.util.Locale;
*
* @author Robin Collier
*/
public enum PubSubNamespace
{
public enum PubSubNamespace {
BASIC(null),
ERROR("errors"),
EVENT("event"),
@ -34,13 +33,11 @@ public enum PubSubNamespace
private final String fragment;
private final String fullNamespace;
private PubSubNamespace(String fragment)
{
PubSubNamespace(String fragment) {
this.fragment = fragment;
if (fragment != null) {
fullNamespace = PubSub.NAMESPACE + '#' + fragment;
}
else {
} else {
fullNamespace = PubSub.NAMESPACE;
}
}

View file

@ -28,7 +28,7 @@ import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
/**
* Parses one of several elements used in pubsub that contain a form of some kind as a child element. The
* Parses one of several elements used in PubSub that contain a form of some kind as a child element. The
* elements and namespaces supported is defined in {@link FormNodeType}.
*
* @author Robin Collier

View file

@ -59,11 +59,11 @@ public class ItemProvider extends ExtensionElementProvider<Item>
if (extensionProvider == null)
{
CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
return new PayloadItem<>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
}
else
{
return new PayloadItem<ExtensionElement>(id, node, extensionProvider.parse(parser));
return new PayloadItem<>(id, node, extensionProvider.parse(parser));
}
}
}

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.xmlpull.v1.XmlPullParser;
/**
* Parses the root pubsub stanza(/packet) extensions of the {@link IQ} stanza(/packet) and returns
* Parses the root PubSub stanza(/packet) extensions of the {@link IQ} stanza(/packet) and returns
* a {@link PubSub} instance.
*
* @author Robin Collier

View file

@ -26,8 +26,8 @@ import org.jivesoftware.smackx.pubsub.NodeExtension;
import org.jivesoftware.smackx.pubsub.PubSubElementType;
/**
* Parses simple elements that only contain a <b>node</b> attribute. This is common amongst many of the
* elements defined in the pubsub specification. For this common case a {@link NodeExtension} is returned.
* Parses simple elements that only contain a <b>node</b> attribute. This is common amongst many of the
* elements defined in the PubSub specification. For this common case a {@link NodeExtension} is returned.
*
* @author Robin Collier
*/

Some files were not shown because too many files have changed in this diff Show more