Commit bb51c61c authored by Christian Schudt's avatar Christian Schudt

Java Generics: Fix various "unchecked" compiler warnings.

parent 9d3b8cfa
...@@ -54,7 +54,7 @@ public class Channel<T extends Packet> { ...@@ -54,7 +54,7 @@ public class Channel<T extends Packet> {
private static final Logger Log = LoggerFactory.getLogger(Channel.class); private static final Logger Log = LoggerFactory.getLogger(Channel.class);
private String name; private String name;
private ChannelHandler channelHandler; private ChannelHandler<T> channelHandler;
ThreadPoolExecutor executor; ThreadPoolExecutor executor;
...@@ -68,7 +68,7 @@ public class Channel<T extends Packet> { ...@@ -68,7 +68,7 @@ public class Channel<T extends Packet> {
this.name = name; this.name = name;
this.channelHandler = channelHandler; this.channelHandler = channelHandler;
executor = new ThreadPoolExecutor(1, 8, 15, TimeUnit.SECONDS, new LinkedBlockingQueue()); executor = new ThreadPoolExecutor(1, 8, 15, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
} }
/** /**
......
...@@ -81,7 +81,7 @@ public class MulticastRouter extends BasicModule implements ServerFeaturesProvid ...@@ -81,7 +81,7 @@ public class MulticastRouter extends BasicModule implements ServerFeaturesProvid
* Cache for a day discovered information of remote servers. The local server will try * Cache for a day discovered information of remote servers. The local server will try
* to discover if remote servers support multicast service. * to discover if remote servers support multicast service.
*/ */
private Cache cache; private Cache<String, String> cache;
/** /**
* Packets that include recipients that belong to remote servers are not processed by * Packets that include recipients that belong to remote servers are not processed by
* the main thread since extra work is required. This variable holds the list of packets * the main thread since extra work is required. This variable holds the list of packets
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
package org.jivesoftware.openfire; package org.jivesoftware.openfire;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
/** /**
* *
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public interface RoutableChannelHandler extends ChannelHandler { public interface RoutableChannelHandler extends ChannelHandler<Packet> {
/** /**
* Returns the XMPP address. The address is used by services like the core * Returns the XMPP address. The address is used by services like the core
......
...@@ -33,13 +33,13 @@ import org.jivesoftware.openfire.component.InternalComponentManager; ...@@ -33,13 +33,13 @@ import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.container.AdminConsolePlugin; import org.jivesoftware.openfire.container.AdminConsolePlugin;
import org.jivesoftware.openfire.container.Module; import org.jivesoftware.openfire.container.Module;
import org.jivesoftware.openfire.container.PluginManager; import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.disco.*; import org.jivesoftware.openfire.disco.*;
import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager; import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferManager; import org.jivesoftware.openfire.filetransfer.FileTransferManager;
import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy; import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy;
import org.jivesoftware.openfire.handler.*; import org.jivesoftware.openfire.handler.*;
import org.jivesoftware.openfire.keystore.IdentityStoreConfig; import org.jivesoftware.openfire.keystore.IdentityStoreConfig;
import org.jivesoftware.openfire.keystore.Purpose; import org.jivesoftware.openfire.keystore.Purpose;
import org.jivesoftware.openfire.lockout.LockOutManager; import org.jivesoftware.openfire.lockout.LockOutManager;
import org.jivesoftware.openfire.mediaproxy.MediaProxyService; import org.jivesoftware.openfire.mediaproxy.MediaProxyService;
import org.jivesoftware.openfire.muc.MultiUserChatManager; import org.jivesoftware.openfire.muc.MultiUserChatManager;
...@@ -54,22 +54,22 @@ import org.jivesoftware.openfire.transport.TransportHandler; ...@@ -54,22 +54,22 @@ import org.jivesoftware.openfire.transport.TransportHandler;
import org.jivesoftware.openfire.update.UpdateManager; import org.jivesoftware.openfire.update.UpdateManager;
import org.jivesoftware.openfire.user.UserManager; import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.vcard.VCardManager; import org.jivesoftware.openfire.vcard.VCardManager;
import org.jivesoftware.util.*; import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.io.*; import java.io.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* The main XMPP server that will load, initialize and start all the server's * The main XMPP server that will load, initialize and start all the server's
* modules. The server is unique in the JVM and could be obtained by using the * modules. The server is unique in the JVM and could be obtained by using the
...@@ -376,8 +376,8 @@ public class XMPPServer { ...@@ -376,8 +376,8 @@ public class XMPPServer {
// Update certificates (if required) // Update certificates (if required)
try { try {
// Check if keystore already has certificates for current domain // Check if keystore already has certificates for current domain
final IdentityStoreConfig storeConfig = (IdentityStoreConfig) SSLConfig.getInstance().getStoreConfig( Purpose.SOCKETBASED_IDENTITYSTORE ); final IdentityStoreConfig storeConfig = (IdentityStoreConfig) SSLConfig.getInstance().getStoreConfig( Purpose.SOCKETBASED_IDENTITYSTORE );
storeConfig.ensureDomainCertificates( "DSA", "RSA" ); storeConfig.ensureDomainCertificates( "DSA", "RSA" );
} catch (Exception e) { } catch (Exception e) {
logger.error("Error generating self-signed certificates", e); logger.error("Error generating self-signed certificates", e);
} }
...@@ -512,7 +512,7 @@ public class XMPPServer { ...@@ -512,7 +512,7 @@ public class XMPPServer {
/** /**
* Loads a module. * Loads a module.
* *
* @param moduleName the name of the class that implements the Module interface. * @param moduleName the name of the class that implements the Module interface.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void loadModule(String moduleName, String moduleImpl) { private void loadModule(String moduleName, String moduleImpl) {
...@@ -575,7 +575,7 @@ public class XMPPServer { ...@@ -575,7 +575,7 @@ public class XMPPServer {
public void restart() { public void restart() {
if (isStandAlone() && isRestartable()) { if (isStandAlone() && isRestartable()) {
try { try {
Class wrapperClass = Class.forName(WRAPPER_CLASSNAME); Class<?> wrapperClass = Class.forName(WRAPPER_CLASSNAME);
Method restartMethod = wrapperClass.getMethod("restart", (Class []) null); Method restartMethod = wrapperClass.getMethod("restart", (Class []) null);
restartMethod.invoke(null, (Object []) null); restartMethod.invoke(null, (Object []) null);
} }
...@@ -626,7 +626,7 @@ public class XMPPServer { ...@@ -626,7 +626,7 @@ public class XMPPServer {
// if we're in a wrapper, we have to tell the wrapper to shut us down // if we're in a wrapper, we have to tell the wrapper to shut us down
if (isRestartable()) { if (isRestartable()) {
try { try {
Class wrapperClass = Class.forName(WRAPPER_CLASSNAME); Class<?> wrapperClass = Class.forName(WRAPPER_CLASSNAME);
Method stopMethod = wrapperClass.getMethod("stop", Integer.TYPE); Method stopMethod = wrapperClass.getMethod("stop", Integer.TYPE);
stopMethod.invoke(null, 0); stopMethod.invoke(null, 0);
} }
......
...@@ -44,7 +44,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager { ...@@ -44,7 +44,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
private boolean auditPresence; private boolean auditPresence;
private boolean auditIQ; private boolean auditIQ;
private boolean auditXPath; private boolean auditXPath;
private List xpath = new LinkedList(); private List<String> xpath = new LinkedList<>();
private AuditorImpl auditor = null; private AuditorImpl auditor = null;
/** /**
* Max size in bytes that all audit log files may have. When the limit is reached * Max size in bytes that all audit log files may have. When the limit is reached
...@@ -63,7 +63,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager { ...@@ -63,7 +63,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
private int maxDays; private int maxDays;
private int logTimeout; private int logTimeout;
private String logDir; private String logDir;
private Collection<String> ignoreList = new ArrayList<String>(); private Collection<String> ignoreList = new ArrayList<>();
private static final int MAX_TOTAL_SIZE = 1000; private static final int MAX_TOTAL_SIZE = 1000;
private static final int MAX_FILE_SIZE = 10; private static final int MAX_FILE_SIZE = 10;
private static final int MAX_DAYS = -1; private static final int MAX_DAYS = -1;
......
...@@ -75,7 +75,7 @@ public class POP3AuthProvider implements AuthProvider { ...@@ -75,7 +75,7 @@ public class POP3AuthProvider implements AuthProvider {
private static final Logger Log = LoggerFactory.getLogger(POP3AuthProvider.class); private static final Logger Log = LoggerFactory.getLogger(POP3AuthProvider.class);
private Cache authCache = null; private Cache<String, String> authCache = null;
private String host = null; private String host = null;
private String domain = null; private String domain = null;
private int port = -1; private int port = -1;
......
...@@ -1022,7 +1022,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -1022,7 +1022,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
//Tries to create an instance with the message //Tries to create an instance with the message
Exception exception; Exception exception;
try { try {
Class exceptionClass = Class.forName(className); Class<?> exceptionClass = Class.forName(className);
if (message == null) { if (message == null) {
exception = (Exception) exceptionClass.newInstance(); exception = (Exception) exceptionClass.newInstance();
} else { } else {
......
...@@ -41,6 +41,7 @@ import org.jivesoftware.openfire.stats.i18nStatistic; ...@@ -41,6 +41,7 @@ import org.jivesoftware.openfire.stats.i18nStatistic;
import org.jivesoftware.util.ClassUtils; import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -60,7 +61,7 @@ public class ProxyConnectionManager { ...@@ -60,7 +61,7 @@ public class ProxyConnectionManager {
private static final String proxyTransferRate = "proxyTransferRate"; private static final String proxyTransferRate = "proxyTransferRate";
private Map<String, ProxyTransfer> connectionMap; private Cache<String, ProxyTransfer> connectionMap;
private final Object connectionLock = new Object(); private final Object connectionLock = new Object();
......
...@@ -57,10 +57,10 @@ public class XDataFormImpl { ...@@ -57,10 +57,10 @@ public class XDataFormImpl {
private String type; private String type;
private String title; private String title;
private List instructions = new ArrayList(); private List<String> instructions = new ArrayList<>();
private List fields = new ArrayList(); private List<FormField> fields = new ArrayList<>();
private List reportedFields = new ArrayList(); private List<FormField> reportedFields = new ArrayList<>();
private List reportedItems = new ArrayList(); private List<List<FormField>> reportedItems = new ArrayList<>();
public XDataFormImpl() { public XDataFormImpl() {
super(); super();
...@@ -74,7 +74,7 @@ public class XDataFormImpl { ...@@ -74,7 +74,7 @@ public class XDataFormImpl {
this.title = title; this.title = title;
} }
public void setInstructions(List instructions) { public void setInstructions(List<String> instructions) {
this.instructions = instructions; this.instructions = instructions;
} }
...@@ -88,7 +88,7 @@ public class XDataFormImpl { ...@@ -88,7 +88,7 @@ public class XDataFormImpl {
public Iterator getInstructions() { public Iterator getInstructions() {
synchronized (instructions) { synchronized (instructions) {
return Collections.unmodifiableList(new ArrayList(instructions)).iterator(); return Collections.unmodifiableList(new ArrayList<>(instructions)).iterator();
} }
} }
...@@ -109,7 +109,7 @@ public class XDataFormImpl { ...@@ -109,7 +109,7 @@ public class XDataFormImpl {
public Iterator getFields() { public Iterator getFields() {
synchronized (fields) { synchronized (fields) {
return Collections.unmodifiableList(new ArrayList(fields)).iterator(); return Collections.unmodifiableList(new ArrayList<>(fields)).iterator();
} }
} }
...@@ -135,7 +135,7 @@ public class XDataFormImpl { ...@@ -135,7 +135,7 @@ public class XDataFormImpl {
} }
} }
public void addItemFields(ArrayList itemFields) { public void addItemFields(List<FormField> itemFields) {
synchronized (reportedItems) { synchronized (reportedItems) {
// We are nesting a List (of fields) inside of the List of items // We are nesting a List (of fields) inside of the List of items
reportedItems.add(itemFields); reportedItems.add(itemFields);
...@@ -245,7 +245,7 @@ public class XDataFormImpl { ...@@ -245,7 +245,7 @@ public class XDataFormImpl {
while (itemElements.hasNext()) { while (itemElements.hasNext()) {
Element itemElement = (Element)itemElements.next(); Element itemElement = (Element)itemElements.next();
Iterator itemFieldElements = itemElement.elementIterator("field"); Iterator itemFieldElements = itemElement.elementIterator("field");
ArrayList itemFields = new ArrayList(); ArrayList<FormField> itemFields = new ArrayList<>();
while (itemFieldElements.hasNext()) { while (itemFieldElements.hasNext()) {
XFormFieldImpl field = new XFormFieldImpl(); XFormFieldImpl field = new XFormFieldImpl();
field.parse((Element)itemFieldElements.next()); field.parse((Element)itemFieldElements.next());
......
...@@ -31,7 +31,7 @@ import java.util.Collection; ...@@ -31,7 +31,7 @@ import java.util.Collection;
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class GroupCollection extends AbstractCollection { public class GroupCollection extends AbstractCollection<Group> {
private String[] elements; private String[] elements;
...@@ -50,7 +50,7 @@ public class GroupCollection extends AbstractCollection { ...@@ -50,7 +50,7 @@ public class GroupCollection extends AbstractCollection {
} }
@Override @Override
public Iterator iterator() { public Iterator<Group> iterator() {
return new GroupIterator(); return new GroupIterator();
} }
...@@ -59,10 +59,10 @@ public class GroupCollection extends AbstractCollection { ...@@ -59,10 +59,10 @@ public class GroupCollection extends AbstractCollection {
return elements.length; return elements.length;
} }
private class GroupIterator implements Iterator { private class GroupIterator implements Iterator<Group> {
private int currentIndex = -1; private int currentIndex = -1;
private Object nextElement = null; private Group nextElement = null;
public boolean hasNext() { public boolean hasNext() {
// If we are at the end of the list, there can't be any more elements // If we are at the end of the list, there can't be any more elements
...@@ -81,8 +81,8 @@ public class GroupCollection extends AbstractCollection { ...@@ -81,8 +81,8 @@ public class GroupCollection extends AbstractCollection {
return true; return true;
} }
public Object next() throws java.util.NoSuchElementException { public Group next() throws java.util.NoSuchElementException {
Object element; Group element;
if (nextElement != null) { if (nextElement != null) {
element = nextElement; element = nextElement;
nextElement = null; nextElement = null;
...@@ -105,10 +105,10 @@ public class GroupCollection extends AbstractCollection { ...@@ -105,10 +105,10 @@ public class GroupCollection extends AbstractCollection {
* *
* @return the next available element. * @return the next available element.
*/ */
private Object getNextElement() { private Group getNextElement() {
while (currentIndex + 1 < elements.length) { while (currentIndex + 1 < elements.length) {
currentIndex++; currentIndex++;
Object element = null; Group element = null;
try { try {
element = GroupManager.getInstance().getGroup(elements[currentIndex]); element = GroupManager.getInstance().getGroup(elements[currentIndex]);
} }
......
...@@ -98,17 +98,17 @@ public class BrowserLauncher { ...@@ -98,17 +98,17 @@ public class BrowserLauncher {
/** /**
* The com.apple.mrj.MRJFileUtils class * The com.apple.mrj.MRJFileUtils class
*/ */
private static Class mrjFileUtilsClass; private static Class<?> mrjFileUtilsClass;
/** /**
* The com.apple.mrj.MRJOSType class * The com.apple.mrj.MRJOSType class
*/ */
private static Class mrjOSTypeClass; private static Class<?> mrjOSTypeClass;
/** /**
* The com.apple.MacOS.AEDesc class * The com.apple.MacOS.AEDesc class
*/ */
private static Class aeDescClass; private static Class<?> aeDescClass;
/** /**
* The <init>(int) method of com.apple.MacOS.AETarget * The <init>(int) method of com.apple.MacOS.AETarget
...@@ -345,19 +345,19 @@ public class BrowserLauncher { ...@@ -345,19 +345,19 @@ public class BrowserLauncher {
switch (jvm) { switch (jvm) {
case MRJ_2_0: case MRJ_2_0:
try { try {
Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class<?> aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class<?> osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class<?> appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
Class aeClass = Class.forName("com.apple.MacOS.ae"); Class<?> aeClass = Class.forName("com.apple.MacOS.ae");
aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[]{int.class}); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(int.class);
appleEventConstructor = appleEventClass.getDeclaredConstructor(new Class[]{int.class, int.class, aeTargetClass, int.class, int.class}); appleEventConstructor = appleEventClass.getDeclaredConstructor(int.class, int.class, aeTargetClass, int.class, int.class);
aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[]{String.class}); aeDescConstructor = aeDescClass.getDeclaredConstructor(String.class);
makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[]{String.class}); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", String.class);
putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[]{int.class, aeDescClass}); putParameter = appleEventClass.getDeclaredMethod("putParameter", int.class, aeDescClass);
sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[]{}); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply");
Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject");
keyDirectObject = (Integer)keyDirectObjectField.get(null); keyDirectObject = (Integer)keyDirectObjectField.get(null);
...@@ -389,9 +389,9 @@ public class BrowserLauncher { ...@@ -389,9 +389,9 @@ public class BrowserLauncher {
mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
kSystemFolderType = systemFolderField.get(null); kSystemFolderType = systemFolderField.get(null);
findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[]{mrjOSTypeClass}); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", mrjOSTypeClass);
getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[]{File.class}); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", File.class);
getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[]{File.class}); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", File.class);
} }
catch (ClassNotFoundException cnfe) { catch (ClassNotFoundException cnfe) {
errorMessage = cnfe.getMessage(); errorMessage = cnfe.getMessage();
...@@ -416,9 +416,9 @@ public class BrowserLauncher { ...@@ -416,9 +416,9 @@ public class BrowserLauncher {
break; break;
case MRJ_3_0: case MRJ_3_0:
try { try {
Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Class<?> linker = Class.forName("com.apple.mrj.jdirect.Linker");
Constructor constructor = linker.getConstructor(new Class[]{Class.class}); Constructor constructor = linker.getConstructor(Class.class);
linkage = constructor.newInstance(new Object[]{BrowserLauncher.class}); linkage = constructor.newInstance(BrowserLauncher.class);
} }
catch (ClassNotFoundException cnfe) { catch (ClassNotFoundException cnfe) {
errorMessage = cnfe.getMessage(); errorMessage = cnfe.getMessage();
...@@ -444,7 +444,7 @@ public class BrowserLauncher { ...@@ -444,7 +444,7 @@ public class BrowserLauncher {
case MRJ_3_1: case MRJ_3_1:
try { try {
mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[]{String.class}); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", String.class);
} }
catch (ClassNotFoundException cnfe) { catch (ClassNotFoundException cnfe) {
errorMessage = cnfe.getMessage(); errorMessage = cnfe.getMessage();
......
...@@ -39,7 +39,7 @@ public final class GraphicUtils { ...@@ -39,7 +39,7 @@ public final class GraphicUtils {
}; };
protected final static MediaTracker tracker = new MediaTracker(component); protected final static MediaTracker tracker = new MediaTracker(component);
private static Hashtable imageCache = new Hashtable(); private static Hashtable<String, Image> imageCache = new Hashtable<>();
private GraphicUtils() { private GraphicUtils() {
} }
......
...@@ -104,8 +104,8 @@ public class XMPPServerInfoImpl implements XMPPServerInfo { ...@@ -104,8 +104,8 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
if (connectionManager == null) { if (connectionManager == null) {
connectionManager = XMPPServer.getInstance().getConnectionManager(); connectionManager = XMPPServer.getInstance().getConnectionManager();
} }
return (Collection<ServerPort>) (connectionManager == null ? return connectionManager == null ?
Collections.emptyList() : Collections.<ServerPort>emptyList() :
connectionManager.getPorts()); connectionManager.getPorts();
} }
} }
\ No newline at end of file
...@@ -46,7 +46,7 @@ public class TransportHandler extends BasicModule implements ChannelHandler { ...@@ -46,7 +46,7 @@ public class TransportHandler extends BasicModule implements ChannelHandler {
private static final Logger Log = LoggerFactory.getLogger(TransportHandler.class); private static final Logger Log = LoggerFactory.getLogger(TransportHandler.class);
private Map<String, Channel> transports = new ConcurrentHashMap<String, Channel>(); private Map<String, Channel<Packet>> transports = new ConcurrentHashMap<>();
private PacketDeliverer deliverer; private PacketDeliverer deliverer;
...@@ -54,14 +54,14 @@ public class TransportHandler extends BasicModule implements ChannelHandler { ...@@ -54,14 +54,14 @@ public class TransportHandler extends BasicModule implements ChannelHandler {
super("Transport handler"); super("Transport handler");
} }
public void addTransport(Channel transport) { public void addTransport(Channel<Packet> transport) {
transports.put(transport.getName(), transport); transports.put(transport.getName(), transport);
} }
public void process(Packet packet) throws UnauthorizedException, PacketException { public void process(Packet packet) throws UnauthorizedException, PacketException {
boolean handled = false; boolean handled = false;
String host = packet.getTo().getDomain(); String host = packet.getTo().getDomain();
for (Channel channel : transports.values()) { for (Channel<Packet> channel : transports.values()) {
if (channel.getName().equalsIgnoreCase(host)) { if (channel.getName().equalsIgnoreCase(host)) {
channel.add(packet); channel.add(packet);
handled = true; handled = true;
......
...@@ -471,26 +471,26 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -471,26 +471,26 @@ public class User implements Cacheable, Externalizable, Result {
/** /**
* Map implementation that updates the database when properties are modified. * Map implementation that updates the database when properties are modified.
*/ */
private class PropertiesMap extends AbstractMap { private class PropertiesMap extends AbstractMap<String, String> {
@Override @Override
public Object put(Object key, Object value) { public String put(String key, String value) {
Map<String,Object> eventParams = new HashMap<String,Object>(); Map<String,Object> eventParams = new HashMap<>();
Object answer; String answer;
String keyString = (String) key; String keyString = key;
synchronized (getName() + keyString.intern()) { synchronized (getName() + keyString.intern()) {
if (properties.containsKey(keyString)) { if (properties.containsKey(keyString)) {
String originalValue = properties.get(keyString); String originalValue = properties.get(keyString);
answer = properties.put(keyString, (String)value); answer = properties.put(keyString, value);
updateProperty(keyString, (String)value); updateProperty(keyString, value);
// Configure event. // Configure event.
eventParams.put("type", "propertyModified"); eventParams.put("type", "propertyModified");
eventParams.put("propertyKey", key); eventParams.put("propertyKey", key);
eventParams.put("originalValue", originalValue); eventParams.put("originalValue", originalValue);
} }
else { else {
answer = properties.put(keyString, (String)value); answer = properties.put(keyString, value);
insertProperty(keyString, (String)value); insertProperty(keyString, value);
// Configure event. // Configure event.
eventParams.put("type", "propertyAdded"); eventParams.put("type", "propertyAdded");
eventParams.put("propertyKey", key); eventParams.put("propertyKey", key);
...@@ -503,7 +503,7 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -503,7 +503,7 @@ public class User implements Cacheable, Externalizable, Result {
} }
@Override @Override
public Set<Entry> entrySet() { public Set<Entry<String, String>> entrySet() {
return new PropertiesEntrySet(); return new PropertiesEntrySet();
} }
} }
...@@ -511,26 +511,26 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -511,26 +511,26 @@ public class User implements Cacheable, Externalizable, Result {
/** /**
* Set implementation that updates the database when properties are deleted. * Set implementation that updates the database when properties are deleted.
*/ */
private class PropertiesEntrySet extends AbstractSet { private class PropertiesEntrySet extends AbstractSet<Map.Entry<String, String>> {
@Override @Override
public int size() { public int size() {
return properties.entrySet().size(); return properties.entrySet().size();
} }
@Override @Override
public Iterator iterator() { public Iterator<Map.Entry<String, String>> iterator() {
return new Iterator() { return new Iterator<Map.Entry<String, String>>() {
Iterator iter = properties.entrySet().iterator(); Iterator<Map.Entry<String, String>> iter = properties.entrySet().iterator();
Map.Entry current = null; Map.Entry<String,String> current = null;
public boolean hasNext() { public boolean hasNext() {
return iter.hasNext(); return iter.hasNext();
} }
public Object next() { public Map.Entry<String, String> next() {
current = (Map.Entry)iter.next(); current = iter.next();
return current; return current;
} }
...@@ -538,11 +538,11 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -538,11 +538,11 @@ public class User implements Cacheable, Externalizable, Result {
if (current == null) { if (current == null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
String key = (String)current.getKey(); String key = current.getKey();
deleteProperty(key); deleteProperty(key);
iter.remove(); iter.remove();
// Fire event. // Fire event.
Map<String,Object> params = new HashMap<String,Object>(); Map<String,Object> params = new HashMap<>();
params.put("type", "propertyDeleted"); params.put("type", "propertyDeleted");
params.put("propertyKey", key); params.put("propertyKey", key);
UserEventDispatcher.dispatchEvent(User.this, UserEventDispatcher.dispatchEvent(User.this,
......
...@@ -30,7 +30,7 @@ import java.util.AbstractCollection; ...@@ -30,7 +30,7 @@ import java.util.AbstractCollection;
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class UserCollection extends AbstractCollection { public class UserCollection extends AbstractCollection<User> {
private String[] elements; private String[] elements;
...@@ -42,7 +42,7 @@ public class UserCollection extends AbstractCollection { ...@@ -42,7 +42,7 @@ public class UserCollection extends AbstractCollection {
} }
@Override @Override
public Iterator iterator() { public Iterator<User> iterator() {
return new UserIterator(); return new UserIterator();
} }
...@@ -51,10 +51,10 @@ public class UserCollection extends AbstractCollection { ...@@ -51,10 +51,10 @@ public class UserCollection extends AbstractCollection {
return elements.length; return elements.length;
} }
private class UserIterator implements Iterator { private class UserIterator implements Iterator<User> {
private int currentIndex = -1; private int currentIndex = -1;
private Object nextElement = null; private User nextElement = null;
public boolean hasNext() { public boolean hasNext() {
// If we are at the end of the list, there can't be any more elements // If we are at the end of the list, there can't be any more elements
...@@ -73,8 +73,8 @@ public class UserCollection extends AbstractCollection { ...@@ -73,8 +73,8 @@ public class UserCollection extends AbstractCollection {
return true; return true;
} }
public Object next() throws java.util.NoSuchElementException { public User next() throws java.util.NoSuchElementException {
Object element; User element;
if (nextElement != null) { if (nextElement != null) {
element = nextElement; element = nextElement;
nextElement = null; nextElement = null;
...@@ -97,10 +97,10 @@ public class UserCollection extends AbstractCollection { ...@@ -97,10 +97,10 @@ public class UserCollection extends AbstractCollection {
* *
* @return the next available element. * @return the next available element.
*/ */
private Object getNextElement() { private User getNextElement() {
while (currentIndex + 1 < elements.length) { while (currentIndex + 1 < elements.length) {
currentIndex++; currentIndex++;
Object element = null; User element = null;
try { try {
element = UserManager.getInstance().getUser(elements[currentIndex]); element = UserManager.getInstance().getUser(elements[currentIndex]);
} }
......
...@@ -176,13 +176,13 @@ public class ElementUtil { ...@@ -176,13 +176,13 @@ public class ElementUtil {
} }
// We found matching property, return names of children. // We found matching property, return names of children.
Iterator iter = element.elementIterator(propName[propName.length - 1]); Iterator iter = element.elementIterator(propName[propName.length - 1]);
ArrayList props = new ArrayList(); ArrayList<String> props = new ArrayList<>();
while (iter.hasNext()) { while (iter.hasNext()) {
Element e = (Element) iter.next(); Element e = (Element) iter.next();
props.add(e.getName()); props.add(e.getName());
} }
String[] childrenNames = new String[props.size()]; String[] childrenNames = new String[props.size()];
return (String[]) props.toArray(childrenNames); return props.toArray(childrenNames);
} }
/** /**
...@@ -280,13 +280,13 @@ public class ElementUtil { ...@@ -280,13 +280,13 @@ public class ElementUtil {
return properties; return properties;
} }
else { else {
List list = new ArrayList(15); List<String> list = new ArrayList<>(15);
for (int i = 0; i < properties.length; i++) { for (int i = 0; i < properties.length; i++) {
String propName = parent + "." + properties[i]; String propName = parent + "." + properties[i];
list.add(propName); list.add(propName);
list.addAll(Arrays.asList(getRecursiveChildrenProperties(element, propName))); list.addAll(Arrays.asList(getRecursiveChildrenProperties(element, propName)));
} }
return (String[]) list.toArray(new String[]{}); return list.toArray(new String[]{});
} }
} }
...@@ -370,13 +370,13 @@ public class ElementUtil { ...@@ -370,13 +370,13 @@ public class ElementUtil {
* @return an array representation of the given Jive property. * @return an array representation of the given Jive property.
*/ */
private static String[] parsePropertyName(String name) { private static String[] parsePropertyName(String name) {
List propName = new ArrayList(5); List<String> propName = new ArrayList<>(5);
// Use a StringTokenizer to tokenize the property name. // Use a StringTokenizer to tokenize the property name.
StringTokenizer tokenizer = new StringTokenizer(name, "."); StringTokenizer tokenizer = new StringTokenizer(name, ".");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
propName.add(tokenizer.nextToken()); propName.add(tokenizer.nextToken());
} }
return (String[]) propName.toArray(new String[propName.size()]); return propName.toArray(new String[propName.size()]);
} }
......
...@@ -87,12 +87,12 @@ public class FastDateFormat { ...@@ -87,12 +87,12 @@ public class FastDateFormat {
private static String cDefaultPattern; private static String cDefaultPattern;
private static TimeZone cDefaultTimeZone = TimeZone.getDefault(); private static TimeZone cDefaultTimeZone = TimeZone.getDefault();
private static Map cTimeZoneDisplayCache = new HashMap(); private static Map<Object, String> cTimeZoneDisplayCache = new HashMap<>();
private static Map cInstanceCache = new HashMap(7); private static Map<Object, FastDateFormat> cInstanceCache = new HashMap<>(7);
private static Map cDateInstanceCache = new HashMap(7); private static Map<Object, FastDateFormat> cDateInstanceCache = new HashMap<>(7);
private static Map cTimeInstanceCache = new HashMap(7); private static Map<Object, FastDateFormat> cTimeInstanceCache = new HashMap<>(7);
private static Map cDateTimeInstanceCache = new HashMap(7); private static Map<Object, FastDateFormat> cDateTimeInstanceCache = new HashMap<>(7);
public static FastDateFormat getInstance() { public static FastDateFormat getInstance() {
return getInstance(getDefaultPattern(), null, null, null); return getInstance(getDefaultPattern(), null, null, null);
...@@ -178,7 +178,7 @@ public class FastDateFormat { ...@@ -178,7 +178,7 @@ public class FastDateFormat {
key = new Pair(key, symbols); key = new Pair(key, symbols);
} }
FastDateFormat format = (FastDateFormat)cInstanceCache.get(key); FastDateFormat format = cInstanceCache.get(key);
if (format == null) { if (format == null) {
if (locale == null) { if (locale == null) {
locale = Locale.getDefault(); locale = Locale.getDefault();
...@@ -260,7 +260,7 @@ public class FastDateFormat { ...@@ -260,7 +260,7 @@ public class FastDateFormat {
key = new Pair(key, locale); key = new Pair(key, locale);
} }
FastDateFormat format = (FastDateFormat)cTimeInstanceCache.get(key); FastDateFormat format = cTimeInstanceCache.get(key);
if (format == null) { if (format == null) {
int ts; int ts;
...@@ -310,8 +310,7 @@ public class FastDateFormat { ...@@ -310,8 +310,7 @@ public class FastDateFormat {
key = new Pair(key, locale); key = new Pair(key, locale);
} }
FastDateFormat format = FastDateFormat format = cDateTimeInstanceCache.get(key);
(FastDateFormat)cDateTimeInstanceCache.get(key);
if (format == null) { if (format == null) {
int ds; int ds;
...@@ -355,7 +354,7 @@ public class FastDateFormat { ...@@ -355,7 +354,7 @@ public class FastDateFormat {
int style, int style,
Locale locale) { Locale locale) {
Object key = new TimeZoneDisplayKey(tz, daylight, style, locale); Object key = new TimeZoneDisplayKey(tz, daylight, style, locale);
String value = (String)cTimeZoneDisplayCache.get(key); String value = cTimeZoneDisplayCache.get(key);
if (value == null) { if (value == null) {
// This is a very slow call, so cache the results. // This is a very slow call, so cache the results.
value = tz.getDisplayName(daylight, style, locale); value = tz.getDisplayName(daylight, style, locale);
...@@ -376,7 +375,7 @@ public class FastDateFormat { ...@@ -376,7 +375,7 @@ public class FastDateFormat {
*/ */
private static List parse(String pattern, TimeZone timeZone, Locale locale, private static List parse(String pattern, TimeZone timeZone, Locale locale,
DateFormatSymbols symbols) { DateFormatSymbols symbols) {
List rules = new ArrayList(); List<Rule> rules = new ArrayList<>();
String[] ERAs = symbols.getEras(); String[] ERAs = symbols.getEras();
String[] months = symbols.getMonths(); String[] months = symbols.getMonths();
......
...@@ -37,7 +37,7 @@ import java.util.*; ...@@ -37,7 +37,7 @@ import java.util.*;
public class IntEnum extends Enum { public class IntEnum extends Enum {
private int value; private int value;
protected static Hashtable enumTypes = new Hashtable(); protected static Hashtable<Class<?>, Map<Integer, IntEnum>> enumTypes = new Hashtable<>();
protected IntEnum(String name, int val) { protected IntEnum(String name, int val) {
super(name); super(name);
...@@ -72,9 +72,9 @@ public class IntEnum extends Enum { ...@@ -72,9 +72,9 @@ public class IntEnum extends Enum {
* @param enumeration The enum to be registered * @param enumeration The enum to be registered
*/ */
protected static void register(IntEnum enumeration) { protected static void register(IntEnum enumeration) {
Map enums = (Map)enumTypes.get(enumeration.getClass()); Map<Integer, IntEnum> enums = enumTypes.get(enumeration.getClass());
if (enums == null) { if (enums == null) {
enums = new HashMap<Integer,Object>(); enums = new HashMap<>();
enumTypes.put(enumeration.getClass(), enums); enumTypes.put(enumeration.getClass(), enums);
} }
enums.put(enumeration.getValue(), enumeration); enums.put(enumeration.getValue(), enumeration);
......
...@@ -407,7 +407,7 @@ public class LocaleUtils { ...@@ -407,7 +407,7 @@ public class LocaleUtils {
* inserted into the pattern at the appropriate places. * inserted into the pattern at the appropriate places.
* @return the localized string. * @return the localized string.
*/ */
public static String getLocalizedString(String key, List arguments) { public static String getLocalizedString(String key, List<?> arguments) {
Locale locale = JiveGlobals.getLocale(); Locale locale = JiveGlobals.getLocale();
ResourceBundle bundle = ResourceBundle.getBundle(resourceBaseName, locale); ResourceBundle bundle = ResourceBundle.getBundle(resourceBaseName, locale);
...@@ -470,7 +470,7 @@ public class LocaleUtils { ...@@ -470,7 +470,7 @@ public class LocaleUtils {
* used if the requested locale is not available) * used if the requested locale is not available)
* @return the localized string. * @return the localized string.
*/ */
public static String getLocalizedString(String key, String pluginName, List arguments, Locale locale, boolean fallback) { public static String getLocalizedString(String key, String pluginName, List<?> arguments, Locale locale, boolean fallback) {
if (pluginName == null) { if (pluginName == null) {
return getLocalizedString(key, arguments); return getLocalizedString(key, arguments);
} }
......
...@@ -83,13 +83,13 @@ public class ParamUtils { ...@@ -83,13 +83,13 @@ public class ParamUtils {
return new String[0]; return new String[0];
} }
else { else {
java.util.List values = new java.util.ArrayList(paramValues.length); java.util.List<String> values = new java.util.ArrayList<>(paramValues.length);
for (int i = 0; i < paramValues.length; i++) { for (int i = 0; i < paramValues.length; i++) {
if (paramValues[i] != null && !"".equals(paramValues[i])) { if (paramValues[i] != null && !"".equals(paramValues[i])) {
values.add(paramValues[i]); values.add(paramValues[i]);
} }
} }
return (String[])values.toArray(new String[]{}); return values.toArray(new String[]{});
} }
} }
......
...@@ -70,7 +70,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler { ...@@ -70,7 +70,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler {
private boolean inDTD; private boolean inDTD;
/** The namespaces used for the current element when consuming SAX events */ /** The namespaces used for the current element when consuming SAX events */
private Map namespacesMap; private Map<String, String> namespacesMap;
/** /**
* what is the maximum allowed character code * what is the maximum allowed character code
...@@ -493,7 +493,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler { ...@@ -493,7 +493,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler {
@Override @Override
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) throws SAXException {
if ( namespacesMap == null ) { if ( namespacesMap == null ) {
namespacesMap = new HashMap(); namespacesMap = new HashMap<>();
} }
namespacesMap.put(prefix, uri); namespacesMap.put(prefix, uri);
super.startPrefixMapping(prefix, uri); super.startPrefixMapping(prefix, uri);
......
...@@ -121,7 +121,7 @@ public class CacheSizes { ...@@ -121,7 +121,7 @@ public class CacheSizes {
* @param map the Map object to determine the size of. * @param map the Map object to determine the size of.
* @return the size of the Map object. * @return the size of the Map object.
*/ */
public static int sizeOfMap(Map map) public static int sizeOfMap(Map<?,?> map)
throws CannotCalculateSizeException { throws CannotCalculateSizeException {
if (map == null) { if (map == null) {
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment