1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

SMACK-363 Applied code cleanup patches for many generics related issues.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13325 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
rcollier 2012-10-26 10:47:55 +00:00
parent 6dc64671e2
commit e08c8afe44
109 changed files with 577 additions and 605 deletions

View file

@ -63,7 +63,7 @@ import java.util.*;
*/
public class SASLAuthentication implements UserAuthentication {
private static Map<String, Class> implementedMechanisms = new HashMap<String, Class>();
private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
private static List<String> mechanismsPreferences = new ArrayList<String>();
private Connection connection;
@ -109,7 +109,7 @@ public class SASLAuthentication implements UserAuthentication {
* @param name common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or KERBEROS_V4.
* @param mClass a SASLMechanism subclass.
*/
public static void registerSASLMechanism(String name, Class mClass) {
public static void registerSASLMechanism(String name, Class<? extends SASLMechanism> mClass) {
implementedMechanisms.put(name, mClass);
}
@ -167,8 +167,8 @@ public class SASLAuthentication implements UserAuthentication {
*
* @return the registerd SASLMechanism classes sorted by the level of preference.
*/
public static List<Class> getRegisterSASLMechanisms() {
List<Class> answer = new ArrayList<Class>();
public static List<Class<? extends SASLMechanism>> getRegisterSASLMechanisms() {
List<Class<? extends SASLMechanism>> answer = new ArrayList<Class<? extends SASLMechanism>>();
for (String mechanismsPreference : mechanismsPreferences) {
answer.add(implementedMechanisms.get(mechanismsPreference));
}
@ -228,9 +228,9 @@ public class SASLAuthentication implements UserAuthentication {
// A SASL mechanism was found. Authenticate using the selected mechanism and then
// proceed to bind a resource
try {
Class mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = (SASLMechanism) constructor.newInstance(this);
Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = constructor.newInstance(this);
// Trigger SASL authentication with the selected mechanism. We use
// connection.getHost() since GSAPI requires the FQDN of the server, which
// may not match the XMPP domain.
@ -310,9 +310,9 @@ public class SASLAuthentication implements UserAuthentication {
// A SASL mechanism was found. Authenticate using the selected mechanism and then
// proceed to bind a resource
try {
Class mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = (SASLMechanism) constructor.newInstance(this);
Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
currentMechanism = constructor.newInstance(this);
// Trigger SASL authentication with the selected mechanism. We use
// connection.getHost() since GSAPI requires the FQDN of the server, which
// may not match the XMPP domain.

View file

@ -69,9 +69,9 @@ public final class SmackConfiguration {
// Get an array of class loaders to try loading the providers files from.
ClassLoader[] classLoaders = getClassLoaders();
for (ClassLoader classLoader : classLoaders) {
Enumeration configEnum = classLoader.getResources("META-INF/smack-config.xml");
Enumeration<URL> configEnum = classLoader.getResources("META-INF/smack-config.xml");
while (configEnum.hasMoreElements()) {
URL url = (URL) configEnum.nextElement();
URL url = configEnum.nextElement();
InputStream systemStream = null;
try {
systemStream = url.openStream();

View file

@ -743,7 +743,7 @@ public class XMPPConnection extends Connection {
}
else if(config.getKeystoreType().equals("PKCS11")) {
try {
Constructor c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
Constructor<?> c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
String pkcs11Config = "name = SmartCard\nlibrary = "+config.getPKCS11Library();
ByteArrayInputStream config = new ByteArrayInputStream(pkcs11Config.getBytes());
Provider p = (Provider)c.newInstance(config);

View file

@ -35,7 +35,7 @@ import org.jivesoftware.smack.packet.Packet;
*/
public class PacketTypeFilter implements PacketFilter {
Class packetType;
Class<? extends Packet> packetType;
/**
* Creates a new packet type filter that will filter for packets that are the
@ -43,7 +43,7 @@ public class PacketTypeFilter implements PacketFilter {
*
* @param packetType the Class type.
*/
public PacketTypeFilter(Class packetType) {
public PacketTypeFilter(Class<? extends Packet> packetType) {
// Ensure the packet type is a sub-class of Packet.
if (!Packet.class.isAssignableFrom(packetType)) {
throw new IllegalArgumentException("Packet type must be a sub-class of Packet.");

View file

@ -58,7 +58,7 @@ public class Privacy extends IQ {
* @param listItem the {@link PrivacyItem} that rules the list.
* @return the privacy List.
*/
public List setPrivacyList(String listName, List<PrivacyItem> listItem) {
public List<PrivacyItem> setPrivacyList(String listName, List<PrivacyItem> listItem) {
// Add new list to the itemLists
this.getItemLists().put(listName, listItem);
return listItem;

View file

@ -157,10 +157,10 @@ public class ProviderManager {
// Get an array of class loaders to try loading the providers files from.
ClassLoader[] classLoaders = getClassLoaders();
for (ClassLoader classLoader : classLoaders) {
Enumeration providerEnum = classLoader.getResources(
Enumeration<URL> providerEnum = classLoader.getResources(
"META-INF/smack.providers");
while (providerEnum.hasMoreElements()) {
URL url = (URL) providerEnum.nextElement();
URL url = providerEnum.nextElement();
InputStream providerStream = null;
try {
providerStream = url.openStream();
@ -190,7 +190,7 @@ public class ProviderManager {
// reflection later to create instances of the class.
try {
// Add the provider to the map.
Class provider = Class.forName(className);
Class<?> provider = Class.forName(className);
if (IQProvider.class.isAssignableFrom(provider)) {
iqProviders.put(key, provider.newInstance());
}
@ -224,7 +224,7 @@ public class ProviderManager {
// of the class.
try {
// Add the provider to the map.
Class provider = Class.forName(className);
Class<?> provider = Class.forName(className);
if (PacketExtensionProvider.class.isAssignableFrom(
provider)) {
extensionProviders.put(key, provider.newInstance());
@ -309,7 +309,7 @@ public class ProviderManager {
Object provider)
{
if (!(provider instanceof IQProvider || (provider instanceof Class &&
IQ.class.isAssignableFrom((Class)provider))))
IQ.class.isAssignableFrom((Class<?>)provider))))
{
throw new IllegalArgumentException("Provider must be an IQProvider " +
"or a Class instance.");

View file

@ -26,7 +26,6 @@ import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
import javax.security.auth.callback.CallbackHandler;
/**
@ -61,7 +60,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
*/
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException {
String[] mechanisms = { getName() };
Map props = new HashMap();
Map<String,String> props = new HashMap<String,String>();
props.put(Sasl.SERVER_AUTH,"TRUE");
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
authenticate();
@ -80,7 +79,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
*/
public void authenticate(String username, String host, String password) throws IOException, XMPPException {
String[] mechanisms = { getName() };
Map props = new HashMap();
Map<String,String> props = new HashMap<String, String>();
props.put(Sasl.SERVER_AUTH,"TRUE");
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
authenticate();

View file

@ -477,7 +477,7 @@ public class Cache<K, V> implements Map<K, V> {
return false;
}
final CacheObject cacheObject = (CacheObject) o;
final CacheObject<?> cacheObject = (CacheObject<?>) o;
return object.equals(cacheObject.object);

View file

@ -28,6 +28,7 @@ import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
/**
* Utilty class to perform DNS lookups for XMPP services.
*
@ -39,13 +40,13 @@ public class DNSUtil {
* Create a cache to hold the 100 most recently accessed DNS lookups for a period of
* 10 minutes.
*/
private static Map cache = new Cache(100, 1000*60*10);
private static Map<String, HostAddress> cache = new Cache<String, HostAddress>(100, 1000*60*10);
private static DirContext context;
static {
try {
Hashtable env = new Hashtable();
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
context = new InitialDirContext(env);
}
@ -97,9 +98,9 @@ public class DNSUtil {
try {
Attributes dnsLookup = context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"});
Attribute srvAttribute = dnsLookup.get("SRV");
NamingEnumeration srvRecords = srvAttribute.getAll();
NamingEnumeration<String> srvRecords = (NamingEnumeration<String>) srvAttribute.getAll();
while(srvRecords.hasMore()) {
String srvRecord = (String) srvRecords.next();
String srvRecord = srvRecords.next();
String [] srvRecordEntries = srvRecord.split(" ");
int priority = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 4]);
int port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);

View file

@ -32,7 +32,7 @@ import java.util.*;
public class ObservableReader extends Reader {
Reader wrappedReader = null;
List listeners = new ArrayList();
List<ReaderListener> listeners = new ArrayList<ReaderListener>();
public ObservableReader(Reader wrappedReader) {
this.wrappedReader = wrappedReader;

View file

@ -32,7 +32,7 @@ import java.util.*;
public class ObservableWriter extends Writer {
Writer wrappedWriter = null;
List listeners = new ArrayList();
List<WriterListener> listeners = new ArrayList<WriterListener>();
public ObservableWriter(Writer wrappedWriter) {
this.wrappedWriter = wrappedWriter;

View file

@ -307,7 +307,7 @@ public class PacketParserUtils {
}
else if (provider instanceof Class) {
iqPacket = (IQ)PacketParserUtils.parseWithIntrospection(elementName,
(Class)provider, parser);
(Class<?>)provider, parser);
}
}
}
@ -769,7 +769,7 @@ public class PacketParserUtils {
}
else if (provider instanceof Class) {
return (PacketExtension)parseWithIntrospection(
elementName, (Class)provider, parser);
elementName, (Class<?>)provider, parser);
}
}
// No providers registered, so use a default extension.
@ -814,7 +814,7 @@ public class PacketParserUtils {
}
public static Object parseWithIntrospection(String elementName,
Class objectClass, XmlPullParser parser) throws Exception
Class<?> objectClass, XmlPullParser parser) throws Exception
{
boolean done = false;
Object object = objectClass.newInstance();
@ -825,7 +825,7 @@ public class PacketParserUtils {
String stringValue = parser.nextText();
PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
// Load the class type of the property.
Class propertyType = descriptor.getPropertyType();
Class<?> propertyType = descriptor.getPropertyType();
// Get the value of the property by converting it from a
// String to the correct object type.
Object value = decode(propertyType, stringValue);
@ -850,7 +850,7 @@ public class PacketParserUtils {
* @return the String value decoded into the specified type.
* @throws Exception If decoding failed due to an error.
*/
private static Object decode(Class type, String value) throws Exception {
private static Object decode(Class<?> type, String value) throws Exception {
if (type.getName().equals("java.lang.String")) {
return value;
}