1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 13:07:59 +01:00

Code cleanup: unused imports, values, blocks, etc.

This commit is contained in:
Florian Schmaus 2014-02-16 11:01:51 +01:00
parent 6dd64da930
commit 2e11470aee
26 changed files with 47 additions and 45 deletions

View file

@ -2,10 +2,6 @@ package org.jivesoftware.smack.initializer;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View file

@ -21,9 +21,12 @@ import java.io.IOException;
* *
* @author Atul Aggarwal * @author Atul Aggarwal
*/ */
public class ProxyException public class ProxyException extends IOException {
extends IOException /**
{ *
*/
private static final long serialVersionUID = 1L;
public ProxyException(ProxyInfo.ProxyType type, String ex, Throwable cause) public ProxyException(ProxyInfo.ProxyType type, String ex, Throwable cause)
{ {
super("Proxy Exception " + type.toString() + " : "+ex+", "+cause); super("Proxy Exception " + type.toString() + " : "+ex+", "+cause);

View file

@ -74,7 +74,6 @@ public class Socks4ProxySocketFactory
String proxy_host = proxy.getProxyAddress(); String proxy_host = proxy.getProxyAddress();
int proxy_port = proxy.getProxyPort(); int proxy_port = proxy.getProxyPort();
String user = proxy.getProxyUsername(); String user = proxy.getProxyUsername();
String passwd = proxy.getProxyPassword();
try try
{ {

View file

@ -461,7 +461,6 @@ public class Base64
// Isolate options // Isolate options
int gzip = (options & GZIP); int gzip = (options & GZIP);
int dontBreakLines = (options & DONT_BREAK_LINES);
try try
{ {
@ -1220,9 +1219,8 @@ public class Base64
private int numSigBytes; // Number of meaningful bytes in the buffer private int numSigBytes; // Number of meaningful bytes in the buffer
private int lineLength; private int lineLength;
private boolean breakLines; // Break lines at less than 80 characters private boolean breakLines; // Break lines at less than 80 characters
private int options; // Record options used to create the stream. private int options; // Record options used to create the stream.
private byte[] alphabet; // Local copies to avoid extra method calls private byte[] decodabet; // Local copies to avoid extra method calls
private byte[] decodabet; // Local copies to avoid extra method calls
/** /**
@ -1267,9 +1265,8 @@ public class Base64
this.buffer = new byte[ bufferLength ]; this.buffer = new byte[ bufferLength ];
this.position = -1; this.position = -1;
this.lineLength = 0; this.lineLength = 0;
this.options = options; // Record for later, mostly to determine which alphabet to use this.options = options; // Record for later, mostly to determine which alphabet to use
this.alphabet = getAlphabet(options); this.decodabet = getDecodabet(options);
this.decodabet = getDecodabet(options);
} // end constructor } // end constructor
/** /**
@ -1457,9 +1454,8 @@ public class Base64
private boolean breakLines; private boolean breakLines;
private byte[] b4; // Scratch used in a few places private byte[] b4; // Scratch used in a few places
private boolean suspendEncoding; private boolean suspendEncoding;
private int options; // Record for later private int options; // Record for later
private byte[] alphabet; // Local copies to avoid extra method calls private byte[] decodabet; // Local copies to avoid extra method calls
private byte[] decodabet; // Local copies to avoid extra method calls
/** /**
* Constructs a {@link Base64.OutputStream} in ENCODE mode. * Constructs a {@link Base64.OutputStream} in ENCODE mode.
@ -1504,9 +1500,8 @@ public class Base64
this.lineLength = 0; this.lineLength = 0;
this.suspendEncoding = false; this.suspendEncoding = false;
this.b4 = new byte[4]; this.b4 = new byte[4];
this.options = options; this.options = options;
this.alphabet = getAlphabet(options); this.decodabet = getDecodabet(options);
this.decodabet = getDecodabet(options);
} // end constructor } // end constructor

View file

@ -253,6 +253,7 @@ public class Cache<K, V> implements Map<K, V> {
return map.containsKey(key); return map.containsKey(key);
} }
@SuppressWarnings("unchecked")
public void putAll(Map<? extends K, ? extends V> map) { public void putAll(Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) { for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
V value = entry.getValue(); V value = entry.getValue();
@ -273,6 +274,7 @@ public class Cache<K, V> implements Map<K, V> {
deleteExpiredEntries(); deleteExpiredEntries();
//noinspection unchecked //noinspection unchecked
@SuppressWarnings("unchecked")
CacheObject<V> cacheObject = new CacheObject<V>((V) value); CacheObject<V> cacheObject = new CacheObject<V>((V) value);
return map.containsValue(cacheObject); return map.containsValue(cacheObject);
@ -454,6 +456,7 @@ public class Cache<K, V> implements Map<K, V> {
/** /**
* A count of the number of times the object has been read from cache. * A count of the number of times the object has been read from cache.
*/ */
@SuppressWarnings("unused")
public int readCount = 0; public int readCount = 0;
/** /**
@ -509,6 +512,7 @@ public class Cache<K, V> implements Map<K, V> {
* *
* @return the first element of the list. * @return the first element of the list.
*/ */
@SuppressWarnings("unused")
public LinkedListNode getFirst() { public LinkedListNode getFirst() {
LinkedListNode node = head.next; LinkedListNode node = head.next;
if (node == head) { if (node == head) {
@ -565,6 +569,7 @@ public class Cache<K, V> implements Map<K, V> {
* @param object the object to add to the end of the list. * @param object the object to add to the end of the list.
* @return the node created to wrap the object. * @return the node created to wrap the object.
*/ */
@SuppressWarnings("unused")
public LinkedListNode addLast(Object object) { public LinkedListNode addLast(Object object) {
LinkedListNode node = new LinkedListNode(object, head, head.previous); LinkedListNode node = new LinkedListNode(object, head, head.previous);
node.previous.next = node; node.previous.next = node;

View file

@ -43,7 +43,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
/** /**
* An AdHocCommandManager is responsible for keeping the list of available * An AdHocCommandManager is responsible for keeping the list of available

View file

@ -33,7 +33,6 @@ public class DiscoverInfoProvider implements IQProvider {
public IQ parseIQ(XmlPullParser parser) throws Exception { public IQ parseIQ(XmlPullParser parser) throws Exception {
DiscoverInfo discoverInfo = new DiscoverInfo(); DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false; boolean done = false;
DiscoverInfo.Feature feature = null;
DiscoverInfo.Identity identity = null; DiscoverInfo.Identity identity = null;
String category = ""; String category = "";
String name = ""; String name = "";

View file

@ -23,7 +23,6 @@ import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.PacketInterceptor; import org.jivesoftware.smack.PacketInterceptor;
import org.jivesoftware.smack.PacketListener; import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration; import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet; import org.jivesoftware.smack.packet.Packet;
@ -56,7 +55,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.WeakHashMap; import java.util.WeakHashMap;

View file

@ -17,7 +17,12 @@
package org.jivesoftware.smackx.iqlast; package org.jivesoftware.smackx.iqlast;
import org.jivesoftware.smack.*; import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter; import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.filter.PacketIDFilter;
@ -113,6 +118,8 @@ public class LastActivityManager {
// We assume that only a switch to available and chat indicates user activity // We assume that only a switch to available and chat indicates user activity
// since other mode changes could be also a result of some sort of automatism // since other mode changes could be also a result of some sort of automatism
resetIdleTime(); resetIdleTime();
default:
break;
} }
} }
}, new PacketTypeFilter(Presence.class)); }, new PacketTypeFilter(Presence.class));

View file

@ -32,13 +32,6 @@ import org.jivesoftware.smack.packet.Packet;
* @author Larry Kirschner * @author Larry Kirschner
*/ */
class ConnectionDetachedPacketCollector { class ConnectionDetachedPacketCollector {
/**
* Max number of packets that any one collector can hold. After the max is
* reached, older packets will be automatically dropped from the queue as
* new packets are added.
*/
private int maxPackets = SmackConfiguration.getPacketCollectorSize();
private ArrayBlockingQueue<Packet> resultQueue; private ArrayBlockingQueue<Packet> resultQueue;
/** /**

View file

@ -21,8 +21,6 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.xdata.Form; import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.FormField;
import java.util.Iterator;
/** /**
* Represents the room information that was discovered using Service Discovery. It's possible to * Represents the room information that was discovered using Service Discovery. It's possible to
* obtain information about a room before joining the room but only for rooms that are public (i.e. * obtain information about a room before joining the room but only for rooms that are public (i.e.

View file

@ -24,7 +24,7 @@ import java.util.List;
*/ */
public class AffiliationsExtension extends NodeExtension public class AffiliationsExtension extends NodeExtension
{ {
protected List<Affiliation> items = Collections.EMPTY_LIST; protected List<Affiliation> items = Collections.emptyList();
public AffiliationsExtension() public AffiliationsExtension()
{ {

View file

@ -49,7 +49,7 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
public List<PacketExtension> getExtensions() public List<PacketExtension> getExtensions()
{ {
if (getConfiguration() == null) if (getConfiguration() == null)
return Collections.EMPTY_LIST; return Collections.emptyList();
else else
return Arrays.asList(((PacketExtension)getConfiguration().getDataFormToSend())); return Arrays.asList(((PacketExtension)getConfiguration().getDataFormToSend()));
} }

View file

@ -23,7 +23,7 @@ import java.util.List;
*/ */
public class ItemDeleteEvent extends SubscriptionEvent public class ItemDeleteEvent extends SubscriptionEvent
{ {
private List<String> itemIds = Collections.EMPTY_LIST; private List<String> itemIds = Collections.emptyList();
/** /**
* Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied * Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied

View file

@ -124,6 +124,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
return type; return type;
} }
@SuppressWarnings("unchecked")
public List<PacketExtension> getExtensions() public List<PacketExtension> getExtensions()
{ {
return (List<PacketExtension>)getItems(); return (List<PacketExtension>)getItems();

View file

@ -63,6 +63,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems() public <T extends Item> List<T> getItems()
throws XMPPException throws XMPPException
{ {
@ -84,6 +85,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(String subscriptionId) public <T extends Item> List<T> getItems(String subscriptionId)
throws XMPPException throws XMPPException
{ {
@ -107,6 +109,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(Collection<String> ids) public <T extends Item> List<T> getItems(Collection<String> ids)
throws XMPPException throws XMPPException
{ {
@ -132,6 +135,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems) public <T extends Item> List<T> getItems(int maxItems)
throws XMPPException throws XMPPException
{ {
@ -154,6 +158,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) public <T extends Item> List<T> getItems(int maxItems, String subscriptionId)
throws XMPPException throws XMPPException
{ {
@ -198,6 +203,7 @@ public class LeafNode extends Node
* *
* @param item - The item being sent * @param item - The item being sent
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> void publish(T item) public <T extends Item> void publish(T item)
{ {
Collection<T> items = new ArrayList<T>(1); Collection<T> items = new ArrayList<T>(1);
@ -268,6 +274,7 @@ public class LeafNode extends Node
* *
* @throws XMPPException * @throws XMPPException
*/ */
@SuppressWarnings("unchecked")
public <T extends Item> void send(T item) public <T extends Item> void send(T item)
throws XMPPException throws XMPPException
{ {

View file

@ -149,6 +149,7 @@ final public class PubSubManager
* @return the node * @return the node
* @throws XMPPException The node does not exist * @throws XMPPException The node does not exist
*/ */
@SuppressWarnings("unchecked")
public <T extends Node> T getNode(String id) public <T extends Node> T getNode(String id)
throws XMPPException throws XMPPException
{ {

View file

@ -14,7 +14,6 @@
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;

View file

@ -23,7 +23,7 @@ import java.util.List;
*/ */
abstract public class SubscriptionEvent extends NodeEvent abstract public class SubscriptionEvent extends NodeEvent
{ {
private List<String> subIds = Collections.EMPTY_LIST; private List<String> subIds = Collections.emptyList();
/** /**
* Construct an event with no subscription id's. This can * Construct an event with no subscription id's. This can

View file

@ -23,7 +23,7 @@ import java.util.List;
*/ */
public class SubscriptionsExtension extends NodeExtension public class SubscriptionsExtension extends NodeExtension
{ {
protected List<Subscription> items = Collections.EMPTY_LIST; protected List<Subscription> items = Collections.emptyList();
/** /**
* Subscriptions to the root node * Subscriptions to the root node

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smackx.pubsub.AffiliationsExtension;
* @author Robin Collier * @author Robin Collier
*/public class AffiliationsProvider extends EmbeddedExtensionProvider */public class AffiliationsProvider extends EmbeddedExtensionProvider
{ {
@SuppressWarnings("unchecked")
@Override @Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content) protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{ {

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smackx.pubsub.SubscriptionsExtension;
*/ */
public class SubscriptionsProvider extends EmbeddedExtensionProvider public class SubscriptionsProvider extends EmbeddedExtensionProvider
{ {
@SuppressWarnings("unchecked")
@Override @Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content) protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{ {

View file

@ -30,7 +30,7 @@ public class HeadersExtension implements PacketExtension
{ {
public static final String NAMESPACE = "http://jabber.org/protocol/shim"; public static final String NAMESPACE = "http://jabber.org/protocol/shim";
private Collection<Header> headers = Collections.EMPTY_LIST; private Collection<Header> headers = Collections.emptyList();
public HeadersExtension(Collection<Header> headerList) public HeadersExtension(Collection<Header> headerList)
{ {

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smackx.shim.packet.HeadersExtension;
*/ */
public class HeadersProvider extends EmbeddedExtensionProvider public class HeadersProvider extends EmbeddedExtensionProvider
{ {
@SuppressWarnings("unchecked")
@Override @Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content) protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{ {

View file

@ -98,7 +98,7 @@ public class StreamInitiationProvider implements IQProvider {
Date fileDate = new Date(); Date fileDate = new Date();
if (date != null) { if (date != null) {
try { try {
fileDate = StringUtils.parseXEP0082Date(date); fileDate = StringUtils.parseDate(date);
} catch (ParseException e) { } catch (ParseException e) {
// couldn't parse date, use current date-time // couldn't parse date, use current date-time
} }

View file

@ -42,7 +42,6 @@ public class DataFormProvider implements PacketExtensionProvider {
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
boolean done = false; boolean done = false;
StringBuilder buffer = null;
DataForm dataForm = new DataForm(parser.getAttributeValue("", "type")); DataForm dataForm = new DataForm(parser.getAttributeValue("", "type"));
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();