Xlint all the things

and fix all warnings.
This commit is contained in:
Florian Schmaus 2015-03-23 09:27:15 +01:00
parent 7c5428ab0e
commit f546d28ad8
50 changed files with 142 additions and 122 deletions

View File

@ -111,11 +111,14 @@ allprojects {
}
}
compileJava {
tasks.withType(JavaCompile) {
// Some systems may not have set their platform default
// converter to 'utf8', but we use unicode in our source
// files. Therefore ensure that javac uses unicode
options.encoding = "utf8"
options.compilerArgs = [
'-Xlint:all',
]
}
jacoco {

View File

@ -484,8 +484,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return streamId;
}
// TODO remove this suppression once "disable legacy session" code has been removed from Smack
@SuppressWarnings("deprecation")
protected void bindResourceAndEstablishSession(String resource) throws XMPPErrorException,
IOException, SmackException, InterruptedException {
@ -517,7 +515,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
Session.Feature sessionFeature = getFeature(Session.ELEMENT, Session.NAMESPACE);
// Only bind the session if it's announced as stream feature by the server, is not optional and not disabled
// For more information see http://tools.ietf.org/html/draft-cridland-xmpp-session-01
if (sessionFeature != null && !sessionFeature.isOptional() && !getConfiguration().isLegacySessionDisabled()) {
// TODO remove this suppression once "disable legacy session" code has been removed from Smack
@SuppressWarnings("deprecation")
boolean legacySessionDisabled = getConfiguration().isLegacySessionDisabled();
if (sessionFeature != null && !sessionFeature.isOptional() && !legacySessionDisabled) {
Session session = new Session();
packetCollector = createPacketCollectorAndSend(new StanzaIdFilter(session), session);
packetCollector.nextResultOrThrow();
@ -1083,6 +1084,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// desired behavior.
return;
}
break;
default:
break;
}

View File

@ -577,6 +577,7 @@ public class PacketParserUtils {
}
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;

View File

@ -75,7 +75,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
Message message = (Message) PacketParserUtils
Message message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -95,7 +95,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(otherLanguage, message.getBody());
assertTrue(message.getBodyLanguages().isEmpty());
@ -113,7 +113,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
assertTrue(message.getBodyLanguages().isEmpty());
@ -132,7 +132,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
assertTrue(message.getBodyLanguages().isEmpty());
@ -153,7 +153,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getBody());
assertFalse(message.getBodyLanguages().isEmpty());
@ -174,7 +174,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getBody());
assertFalse(message.getBodyLanguages().isEmpty());
@ -195,7 +195,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getBody());
assertFalse(message.getBodyLanguages().isEmpty());
@ -224,7 +224,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
Message message = (Message) PacketParserUtils
Message message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -244,7 +244,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(otherLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
@ -262,7 +262,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
@ -281,7 +281,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
assertTrue(message.getSubjectLanguages().isEmpty());
@ -302,7 +302,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getSubject());
assertFalse(message.getSubjectLanguages().isEmpty());
@ -323,7 +323,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getSubject());
assertFalse(message.getSubjectLanguages().isEmpty());
@ -344,7 +344,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
message = PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertNull(message.getSubject());
assertFalse(message.getSubjectLanguages().isEmpty());
@ -378,7 +378,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -403,7 +403,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage + "2")
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -427,7 +427,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(otherLanguage, message.getBody());
@ -451,7 +451,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage + "2")
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -474,7 +474,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -497,7 +497,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody());
@ -531,7 +531,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -556,7 +556,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage + "2")
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -580,7 +580,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(otherLanguage, message.getSubject());
@ -604,7 +604,7 @@ public class PacketParserUtilsTest {
.t(defaultLanguage + "2")
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -627,7 +627,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -650,7 +650,7 @@ public class PacketParserUtilsTest {
.t(otherLanguage)
.asString(outputProperties);
message = (Message) PacketParserUtils
message = PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject());
@ -682,7 +682,7 @@ public class PacketParserUtilsTest {
.t("Bad Message Body")
.asString(outputProperties);
Message message = (Message) PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
Message message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
fail("Should throw exception. Instead got message: " + message.toXML().toString());
}
@ -854,7 +854,7 @@ public class PacketParserUtilsTest {
XmlUnitUtils.assertSimilar(saslFailureString, saslFailure.toXML());
}
private String determineNonDefaultLanguage() {
private static String determineNonDefaultLanguage() {
String otherLanguage = "jp";
Locale[] availableLocales = Locale.getAvailableLocales();
for (int i = 0; i < availableLocales.length; i++) {

View File

@ -54,7 +54,7 @@ public class CarbonTest extends ExperimentalInitializerTest {
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
cc = (CarbonExtension) new CarbonManagerProvider().parse(parser);
cc = new CarbonManagerProvider().parse(parser);
fwd = cc.getForwarded();
// meta
@ -85,7 +85,7 @@ public class CarbonTest extends ExperimentalInitializerTest {
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
cc = (CarbonExtension) new CarbonManagerProvider().parse(parser);
cc = new CarbonManagerProvider().parse(parser);
assertEquals(CarbonExtension.Direction.received, cc.getDirection());

View File

@ -68,7 +68,7 @@ public class MultipleRecipientInfo {
// TODO should return BareJid
public Jid getReplyRoom() {
List<MultipleAddresses.Address> replyRoom = extension.getAddressesOfType(MultipleAddresses.Type.replyroom);
return replyRoom.isEmpty() ? null : ((MultipleAddresses.Address) replyRoom.get(0)).getJid();
return replyRoom.isEmpty() ? null : replyRoom.get(0).getJid();
}
/**
@ -92,6 +92,6 @@ public class MultipleRecipientInfo {
*/
public MultipleAddresses.Address getReplyAddress() {
List<MultipleAddresses.Address> replyTo = extension.getAddressesOfType(MultipleAddresses.Type.replyto);
return replyTo.isEmpty() ? null : (MultipleAddresses.Address) replyTo.get(0);
return replyTo.isEmpty() ? null : replyTo.get(0);
}
}

View File

@ -98,7 +98,7 @@ public class AMPExtensionProvider extends ExtensionElementProvider<AMPExtension>
return ampExtension;
}
private AMPExtension.Condition createCondition(String name, String value) {
private static AMPExtension.Condition createCondition(String name, String value) {
if (name == null || value == null) {
LOGGER.severe("Can't create rule condition from null name and/or value");
return null;

View File

@ -63,7 +63,7 @@ public class BookmarkManager {
public synchronized static BookmarkManager getBookmarkManager(XMPPConnection connection)
throws XMPPException, SmackException
{
BookmarkManager manager = (BookmarkManager) bookmarkManagerMap.get(connection);
BookmarkManager manager = bookmarkManagerMap.get(connection);
if (manager == null) {
manager = new BookmarkManager(connection);
}

View File

@ -482,7 +482,7 @@ public class InBandBytestreamManager implements BytestreamManager {
*
* @return a new unique session ID
*/
private String getNextSessionID() {
private static String getNextSessionID() {
StringBuilder buffer = new StringBuilder();
buffer.append(SESSION_ID_PREFIX);
buffer.append(Math.abs(randomGenerator.nextLong()));

View File

@ -295,7 +295,7 @@ public class InBandBytestreamSession implements BytestreamSession {
}
// return byte and increment buffer pointer
return ((int) buffer[bufferPointer++]) & 0xff;
return buffer[bufferPointer++] & 0xff;
}
public synchronized int read(byte[] b, int off, int len) throws IOException {

View File

@ -626,7 +626,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param proxy the proxy to query
* @return IQ packet to query a SOCKS5 proxy its network settings
*/
private Bytestream createStreamHostRequest(Jid proxy) {
private static Bytestream createStreamHostRequest(Jid proxy) {
Bytestream request = new Bytestream();
request.setType(IQ.Type.get);
request.setTo(proxy);
@ -681,7 +681,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* @param streamHosts a list of SOCKS5 proxies the target should connect to
* @return a SOCKS5 Bytestream initialization request packet
*/
private Bytestream createBytestreamInitiation(String sessionID, Jid targetJID,
private static Bytestream createBytestreamInitiation(String sessionID, Jid targetJID,
List<StreamHost> streamHosts) {
Bytestream initiation = new Bytestream(sessionID);
@ -738,7 +738,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
*
* @return a new unique session ID
*/
private String getNextSessionID() {
private static String getNextSessionID() {
StringBuilder buffer = new StringBuilder();
buffer.append(SESSION_ID_PREFIX);
buffer.append(Math.abs(randomGenerator.nextLong()));

View File

@ -309,7 +309,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
*
* @param address the address the connection failure counter should be increased
*/
private void incrementConnectionFailures(String address) {
private static void incrementConnectionFailures(String address) {
Integer count = ADDRESS_BLACKLIST.get(address);
ADDRESS_BLACKLIST.put(address, count == null ? 1 : count + 1);
}
@ -320,7 +320,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
* @param address the address
* @return number of connection failures
*/
private int getConnectionFailures(String address) {
private static int getConnectionFailures(String address) {
Integer count = ADDRESS_BLACKLIST.get(address);
return count != null ? count : 0;
}

View File

@ -392,7 +392,7 @@ public class EntityCapsManager extends Manager {
return entityCapsEnabled;
}
public void setEntityNode(String entityNode) throws NotConnectedException {
public void setEntityNode(String entityNode) {
this.entityNode = entityNode;
updateLocalEntityCaps();
}
@ -403,7 +403,7 @@ public class EntityCapsManager extends Manager {
* @param user
* the user (Full JID)
*/
public void removeUserCapsNode(String user) {
public static void removeUserCapsNode(String user) {
JID_TO_NODEVER_CACHE.remove(user);
}

View File

@ -620,7 +620,7 @@ public class AdHocCommandManager extends Manager {
AdHocCommandInfo commandInfo = commands.get(commandNode);
LocalCommand command;
try {
command = (LocalCommand) commandInfo.getCommandInstance();
command = commandInfo.getCommandInstance();
command.setSessionID(sessionID);
command.setName(commandInfo.getName());
command.setNode(commandInfo.getNode());

View File

@ -25,7 +25,6 @@ import org.jivesoftware.smackx.commands.AdHocCommand;
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
import org.jivesoftware.smackx.commands.AdHocCommandNote;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.xmlpull.v1.XmlPullParser;
@ -93,7 +92,7 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
adHocCommandData.addAction(AdHocCommand.Action.prev);
}
else if (elementName.equals("x") && namespace.equals("jabber:x:data")) {
adHocCommandData.setForm((DataForm) dataFormProvider.parse(parser));
adHocCommandData.setForm(dataFormProvider.parse(parser));
}
else if (parser.getName().equals("note")) {
AdHocCommandNote.Type type = AdHocCommandNote.Type.valueOf(

View File

@ -126,7 +126,7 @@ public class FileTransferManager extends Manager {
}
return new OutgoingFileTransfer(connection().getUser(), userID,
fileTransferNegotiator.getNextStreamID(),
FileTransferNegotiator.getNextStreamID(),
fileTransferNegotiator);
}

View File

@ -214,7 +214,7 @@ public class FileTransferNegotiator extends Manager {
return selectedStreamNegotiator;
}
private FormField getStreamMethodField(DataForm form) {
private static FormField getStreamMethodField(DataForm form) {
for (FormField field : form.getFields()) {
if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
return field;
@ -260,7 +260,7 @@ public class FileTransferNegotiator extends Manager {
*
* @return Returns a new, unique, stream ID to identify a file transfer.
*/
public String getNextStreamID() {
public static String getNextStreamID() {
StringBuilder buffer = new StringBuilder();
buffer.append(STREAM_INIT_PREFIX);
buffer.append(Math.abs(randomGenerator.nextLong()));
@ -368,7 +368,7 @@ public class FileTransferNegotiator extends Manager {
}
}
private DataForm createDefaultInitiationForm() {
private static DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(DataForm.Type.form);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.Type.list_single);

View File

@ -64,6 +64,7 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
default:
LOGGER.warning("Unsupported forwarded packet type: " + name);
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;

View File

@ -146,6 +146,7 @@ public class LastActivityManager extends Manager {
// 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
resetIdleTime();
break;
default:
break;
}

View File

@ -99,7 +99,7 @@ public class PrivateDataManager extends Manager {
*/
public static PrivateDataProvider getPrivateDataProvider(String elementName, String namespace) {
String key = getProviderKey(elementName, namespace);
return (PrivateDataProvider)privateDataProviders.get(key);
return privateDataProviders.get(key);
}
/**

View File

@ -115,7 +115,7 @@ public class DefaultPrivateData implements PrivateData {
if (map == null) {
return null;
}
return (String)map.get(name);
return map.get(name);
}
/**

View File

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2014 Florian Schmaus
* Copyright 2003-2007 Jive Software, 2014-2015 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
*/
package org.jivesoftware.smackx.muc.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.muc.MUCAffiliation;
import org.jivesoftware.smackx.muc.MUCRole;
@ -30,7 +30,7 @@ import org.jxmpp.jid.parts.Resourcepart;
* @author Gaston Dombiak
*/
public class MUCItem implements NamedElement {
public static final String ELEMENT = IQ.ITEM;
public static final String ELEMENT = Stanza.ITEM;
private final MUCAffiliation affiliation;
private final MUCRole role;
@ -156,7 +156,7 @@ public class MUCItem implements NamedElement {
if (getActor() != null) {
xml.halfOpenElement("actor").attribute("jid", getActor()).closeEmptyElement();
}
xml.closeElement(IQ.ITEM);
xml.closeElement(Stanza.ITEM);
return xml;
}

View File

@ -51,6 +51,7 @@ public class MUCParserUtils {
reason = parser.nextText();
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;

View File

@ -225,7 +225,7 @@ public class OfflineMessageRequest extends IQ {
return request;
}
private Item parseItem(XmlPullParser parser)
private static Item parseItem(XmlPullParser parser)
throws XmlPullParserException, IOException {
boolean done = false;
Item item = new Item(parser.getAttributeValue("", "node"));

View File

@ -82,7 +82,7 @@ public class Affiliation implements ExtensionElement
return builder.toString();
}
private void appendAttribute(StringBuilder builder, String att, String value)
private static void appendAttribute(StringBuilder builder, String att, String value)
{
builder.append(" ");
builder.append(att);

View File

@ -707,7 +707,7 @@ public class ConfigureForm extends Form
}
}
private List<String> getListSingle(String value)
private static List<String> getListSingle(String value)
{
List<String> list = new ArrayList<String>(1);
list.add(value);

View File

@ -553,7 +553,7 @@ abstract public class Node
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
// CHECKSTYLE:ON
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), (List<Item>)itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet));
listener.handlePublishedItems(eventItems);
}
}

View File

@ -170,7 +170,6 @@ final public class PubSubManager
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("unchecked")
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{
Node node = nodeMap.get(id);
@ -203,7 +202,9 @@ final public class PubSubManager
node.setTo(to);
nodeMap.put(id, node);
}
return (T) node;
@SuppressWarnings("unchecked")
T res = (T) node;
return res;
}
/**

View File

@ -151,7 +151,7 @@ public class Subscription extends NodeExtension
return builder.toString();
}
private void appendAttribute(StringBuilder builder, String att, String value)
private static void appendAttribute(StringBuilder builder, String att, String value)
{
builder.append(" ");
builder.append(att);

View File

@ -52,6 +52,7 @@ public class PubSub extends IQ
*
* @return the XML element name of the packet extension.
*/
@SuppressWarnings("static-method")
public String getElementName() {
return ELEMENT;
}

View File

@ -254,10 +254,12 @@ public class VCardProvider extends IQProvider<VCard> {
default:
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}

View File

@ -91,7 +91,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
return dataForm;
}
private FormField parseField(XmlPullParser parser) throws XmlPullParserException, IOException {
private static FormField parseField(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
final String var = parser.getAttributeValue("", "var");
final FormField.Type type = FormField.Type.fromString(parser.getAttributeValue("", "type"));
@ -131,6 +131,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
}
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
@ -141,7 +142,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
return formField;
}
private DataForm.Item parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
private static DataForm.Item parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
List<FormField> fields = new ArrayList<FormField>();
outerloop: while (true) {
@ -165,7 +166,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
return new DataForm.Item(fields);
}
private DataForm.ReportedData parseReported(XmlPullParser parser) throws XmlPullParserException, IOException {
private static DataForm.ReportedData parseReported(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
List<FormField> fields = new ArrayList<FormField>();
outerloop: while (true) {
@ -189,7 +190,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
return new DataForm.ReportedData(fields);
}
private FormField.Option parseOption(XmlPullParser parser) throws XmlPullParserException, IOException {
private static FormField.Option parseOption(XmlPullParser parser) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
FormField.Option option = null;
String label = parser.getAttributeValue("", "label");

View File

@ -69,7 +69,7 @@ public class DelayInformationTest extends InitExtensions {
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
delayInfo = (DelayInformation) p.parse(parser);
delayInfo = p.parse(parser);
assertEquals("capulet.com", delayInfo.getFrom());
assertEquals(date, delayInfo.getStamp());
@ -85,7 +85,7 @@ public class DelayInformationTest extends InitExtensions {
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
delayInfo = (DelayInformation) p.parse(parser);
delayInfo = p.parse(parser);
assertEquals("capulet.com", delayInfo.getFrom());
assertEquals(date, delayInfo.getStamp());
@ -109,7 +109,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", "2002-09-10T23:08:25.12Z")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
GregorianCalendar cal = (GregorianCalendar) calendar.clone();
cal.add(Calendar.MILLISECOND, 120);
@ -122,7 +122,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", "2002-09-10T23:08:25Z")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
assertEquals(calendar.getTime(), delayInfo.getStamp());
@ -133,7 +133,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", "2002-9-10T23:08:25Z")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
assertEquals(calendar.getTime(), delayInfo.getStamp());
}
@ -152,7 +152,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", "20020910T23:08:25")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
assertEquals(calendar.getTime(), delayInfo.getStamp());
@ -172,7 +172,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", dateFormat.format(dateInPast.getTime()))
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
assertEquals(dateInPast.getTime(), delayInfo.getStamp());
@ -183,7 +183,7 @@ public class DelayInformationTest extends InitExtensions {
.a("stamp", "200868T09:16:20")
.asString(outputProperties);
delayInfo = (DelayInformation) p.parse(PacketParserUtils.getParserFor(control));
delayInfo = p.parse(PacketParserUtils.getParserFor(control));
Date controlDate = XmppDateTime.parseDate("2008-06-08T09:16:20.0Z");
assertEquals(controlDate, delayInfo.getStamp());
@ -209,6 +209,6 @@ public class DelayInformationTest extends InitExtensions {
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
DelayInformation delay = DelayInformationManager.getXep203DelayInformation(presence);
assertNull((Object)delay);
assertNull(delay);
}
}

View File

@ -52,7 +52,7 @@ public class ForwardedTest {
.asString(outputProperties);
parser = PacketParserUtils.getParserFor(control);
fwd = (Forwarded) new ForwardedProvider().parse(parser);
fwd = new ForwardedProvider().parse(parser);
// no delay in packet
assertEquals(null, fwd.getDelayInformation());
@ -79,7 +79,7 @@ public class ForwardedTest {
// @formatter:on
parser = PacketParserUtils.getParserFor(control);
fwd = (Forwarded) new ForwardedProvider().parse(parser);
fwd = new ForwardedProvider().parse(parser);
// assert there is delay information in packet
DelayInformation delay = fwd.getDelayInformation();

View File

@ -90,10 +90,9 @@ public class JMFInit extends Frame implements Runnable {
tempDir = args[0];
message("Setting cache directory to " + tempDir);
Registry r = new Registry();
try {
r.set("secure.cacheDir", tempDir);
r.commit();
Registry.set("secure.cacheDir", tempDir);
Registry.commit();
message("Updated registry");
}
@ -207,6 +206,7 @@ public class JMFInit extends Frame implements Runnable {
PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
plType);
// Move it to the top of the list
@SuppressWarnings("unchecked")
Vector<String> rendList = PlugInManager.getPlugInList(null, null,
plType);
int listSize = rendList.size();
@ -244,6 +244,7 @@ public class JMFInit extends Frame implements Runnable {
if (rend instanceof ExclusiveUse
&& !((ExclusiveUse) rend).isExclusive()) {
// sol8+, DAR supports mixing
@SuppressWarnings("unchecked")
Vector<String> rendList = PlugInManager.getPlugInList(null, null,
plType);
int listSize = rendList.size();
@ -251,7 +252,7 @@ public class JMFInit extends Frame implements Runnable {
String rname = null;
for (int i = 0; i < listSize; i++) {
rname = (String) (rendList.elementAt(i));
rname = rendList.elementAt(i);
if (rname.equals(dar)) { // DAR is in the registry
found = true;
rendList.removeElementAt(i);

View File

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.jingleold.mediaimpl.sshare.api;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Logger;
@ -71,13 +73,13 @@ public class OctTreeQuantizer implements Quantizer {
private int reduceColors;
private int maximumColors;
private int colors = 0;
private Vector<OctTreeNode>[] colorList;
private List<Vector<OctTreeNode>> colorList;
public OctTreeQuantizer() {
setup(256);
colorList = new Vector[MAX_LEVEL+1];
colorList = new ArrayList<>(MAX_LEVEL+1);
for (int i = 0; i < MAX_LEVEL+1; i++)
colorList[i] = new Vector<OctTreeNode>();
colorList.add(i, new Vector<OctTreeNode>());
root = new OctTreeNode();
}
@ -171,7 +173,7 @@ public class OctTreeQuantizer implements Quantizer {
node.leaf[index] = child;
node.isLeaf = false;
nodes++;
colorList[level].addElement(child);
colorList.get(level).addElement(child);
if (level == MAX_LEVEL) {
child.isLeaf = true;
@ -199,7 +201,7 @@ public class OctTreeQuantizer implements Quantizer {
private void reduceTree(int numColors) {
for (int level = MAX_LEVEL-1; level >= 0; level--) {
Vector<OctTreeNode> v = colorList[level];
Vector<OctTreeNode> v = colorList.get(level);
if (v != null && v.size() > 0) {
for (int j = 0; j < v.size(); j++) {
OctTreeNode node = v.elementAt(j);
@ -217,7 +219,7 @@ public class OctTreeQuantizer implements Quantizer {
node.children--;
colors--;
nodes--;
colorList[level+1].removeElement(child);
colorList.get(level+1).removeElement(child);
}
}
node.isLeaf = true;

View File

@ -392,6 +392,7 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("deprecation")
public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
@ -459,6 +460,7 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("deprecation")
public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
@ -495,6 +497,7 @@ public class RTPBridge extends IQ {
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("deprecation")
public static String getPublicIP(XMPPConnection xmppConnection) throws NotConnectedException, InterruptedException {
if (!xmppConnection.isConnected()) {

View File

@ -175,6 +175,7 @@ public class STUN extends SimpleIQ {
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("deprecation")
public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {

View File

@ -133,7 +133,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
*
* @param bestLocalCandidate the acceptedLocalCandidate to set
*/
private void setAcceptedLocalCandidate(TransportCandidate bestLocalCandidate) throws XMPPException {
private void setAcceptedLocalCandidate(TransportCandidate bestLocalCandidate) {
for (int i = 0; i < resolver.getCandidateCount(); i++) {
//TODO FIX The EQUAL Sentence
if (resolver.getCandidate(i).getIp().equals(bestLocalCandidate.getIp())
@ -708,7 +708,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* @param jingleTransport
* @return the iq
*/
private IQ receiveTransportInfoAction(Jingle jingle) throws XMPPException {
private IQ receiveTransportInfoAction(Jingle jingle) {
IQ response = null;
// Parse the Jingle and get any proposed transport candidates
@ -755,7 +755,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
LOGGER.fine("Remote acccepted candidate addr: " + cand.getIp());
}
TransportCandidate cand = (TransportCandidate) accepted.get(0);
TransportCandidate cand = accepted.get(0);
setAcceptedLocalCandidate(cand);
if (isEstablished()) {
@ -770,7 +770,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* @param jingle
* @return the iq
*/
private IQ receiveSessionAcceptAction(Jingle jingle) {
private static IQ receiveSessionAcceptAction(Jingle jingle) {
IQ response = null;
LOGGER.fine("Transport stabilished");
@ -855,7 +855,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
if (!cands.isEmpty()) {
LOGGER.fine("RAW CAND");
return (TransportCandidate) cands.get(0);
return cands.get(0);
} else {
LOGGER.fine("No Remote Candidate");
return null;

View File

@ -310,7 +310,7 @@ public abstract class TransportResolver {
if (cands.size() > 0) {
Collections.sort(cands);
// Return the last candidate
result = (TransportCandidate) cands.get(cands.size() - 1);
result = cands.get(cands.size() - 1);
LOGGER.fine("Result: " + result.getIp());
}
@ -352,7 +352,7 @@ public abstract class TransportResolver {
TransportCandidate cand;
synchronized (candidates) {
cand = (TransportCandidate) candidates.get(i);
cand = candidates.get(i);
}
return cand;
}

View File

@ -125,7 +125,7 @@ public abstract class JingleDescription implements ExtensionElement {
Iterator<PayloadType> jinglePtsIter = getPayloadTypes();
while (jinglePtsIter.hasNext()) {
PayloadType jpt = (PayloadType) jinglePtsIter.next();
PayloadType jpt = jinglePtsIter.next();
if (jpt instanceof PayloadType.Audio) {
PayloadType.Audio jpta = (PayloadType.Audio) jpt;
result.add(jpta);

View File

@ -63,7 +63,7 @@ public class JingleProvider extends IQProvider<Jingle> {
JingleDescriptionProvider jdpAudio = new JingleDescriptionProvider.Audio();
JingleTransportProvider jtpRawUdp = new JingleTransportProvider.RawUdp();
JingleTransportProvider jtpIce = new JingleTransportProvider.Ice();
ExtensionElementProvider jmipAudio = new JingleContentInfoProvider.Audio();
ExtensionElementProvider<?> jmipAudio = new JingleContentInfoProvider.Audio();
int eventType;
String elementName;
@ -93,19 +93,19 @@ public class JingleProvider extends IQProvider<Jingle> {
if (elementName.equals(JingleContent.NODENAME)) {
// Add a new <content> element to the jingle
currentContent = (JingleContent) jcp.parse(parser);
currentContent = jcp.parse(parser);
jingle.addContent(currentContent);
} else if (elementName.equals(JingleDescription.NODENAME) && namespace.equals(JingleDescription.Audio.NAMESPACE)) {
// Set the <description> element of the <content>
currentContent.setDescription((JingleDescription) jdpAudio.parse(parser));
currentContent.setDescription(jdpAudio.parse(parser));
} else if (elementName.equals(JingleTransport.NODENAME)) {
// Add all of the <transport> elements to the <content> of the jingle
// Parse the possible transport namespaces
if (namespace.equals(JingleTransport.RawUdp.NAMESPACE)) {
currentContent.addJingleTransport((JingleTransport) jtpRawUdp.parse(parser));
currentContent.addJingleTransport(jtpRawUdp.parse(parser));
} else if (namespace.equals(JingleTransport.Ice.NAMESPACE)) {
currentContent.addJingleTransport((JingleTransport) jtpIce.parse(parser));
currentContent.addJingleTransport(jtpIce.parse(parser));
} else {
throw new SmackException("Unknown transport namespace \"" + namespace + "\" in Jingle packet.");
}

View File

@ -217,7 +217,7 @@ public class AgentRoster {
Presence presence = null;
while (it.hasNext()) {
p = (Presence)userPresences.get(it.next());
p = userPresences.get(it.next());
if (presence == null){
presence = p;
}
@ -346,7 +346,7 @@ public class AgentRoster {
// Fire an event.
synchronized (entries) {
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
String entry = (String)i.next();
String entry = i.next();
if (entry.equals(key.asBareJidIfPossible())) {
fireEvent(EVENT_PRESENCE_CHANGED, packet);
}

View File

@ -51,7 +51,7 @@ public class MacroGroup {
Collection<Macro> col = Collections.unmodifiableList(macros);
Iterator<Macro> iter = col.iterator();
while (iter.hasNext()) {
Macro macro = (Macro)iter.next();
Macro macro = iter.next();
if (macro.getTitle().equalsIgnoreCase(title)) {
return macro;
}
@ -68,14 +68,14 @@ public class MacroGroup {
}
public Macro getMacro(int location) {
return (Macro)macros.get(location);
return macros.get(location);
}
public MacroGroup getMacroGroupByTitle(String title) {
Collection<MacroGroup> col = Collections.unmodifiableList(macroGroups);
Iterator<MacroGroup> iter = col.iterator();
while (iter.hasNext()) {
MacroGroup group = (MacroGroup)iter.next();
MacroGroup group = iter.next();
if (group.getTitle().equalsIgnoreCase(title)) {
return group;
}
@ -84,7 +84,7 @@ public class MacroGroup {
}
public MacroGroup getMacroGroup(int location) {
return (MacroGroup)macroGroups.get(location);
return macroGroups.get(location);
}

View File

@ -102,7 +102,7 @@ public class AgentStatus implements ExtensionElement {
if (!currentChats.isEmpty()) {
buf.append("<current-chats xmlns= \"http://jivesoftware.com/protocol/workgroup\">");
for (Iterator<ChatInfo> it = currentChats.iterator(); it.hasNext();) {
buf.append(((ChatInfo)it.next()).toXML());
buf.append(it.next().toXML());
}
buf.append("</current-chats>");
}
@ -251,7 +251,7 @@ public class AgentStatus implements ExtensionElement {
return agentStatus;
}
private ChatInfo parseChatInfo(XmlPullParser parser) {
private static ChatInfo parseChatInfo(XmlPullParser parser) {
String sessionID = parser.getAttributeValue("", "sessionID");
String userID = parser.getAttributeValue("", "userID");

View File

@ -75,7 +75,7 @@ public class AgentStatusRequest extends IQ {
buf.rightAngleBracket();
synchronized (agents) {
for (Iterator<Item> i=agents.iterator(); i.hasNext(); ) {
Item item = (Item) i.next();
Item item = i.next();
buf.append("<agent jid=\"").append(item.getJID()).append("\">");
if (item.getName() != null) {
buf.append("<name xmlns=\""+ AgentInfo.NAMESPACE + "\">");

View File

@ -112,7 +112,7 @@ public class QueueDetails implements ExtensionElement {
synchronized (users) {
for (Iterator<QueueUser> i=users.iterator(); i.hasNext(); ) {
QueueUser user = (QueueUser)i.next();
QueueUser user = i.next();
int position = user.getQueuePosition();
int timeRemaining = user.getEstimatedRemainingTime();
Date timestamp = user.getQueueJoinTimestamp();

View File

@ -101,7 +101,7 @@ public class ChatSettings extends IQ {
public ChatSetting getFirstEntry() {
if (settings.size() > 0) {
return (ChatSetting)settings.get(0);
return settings.get(0);
}
return null;
}
@ -146,7 +146,7 @@ public class ChatSettings extends IQ {
return chatSettings;
}
private ChatSetting parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
private static ChatSetting parseChatSetting(XmlPullParser parser) throws XmlPullParserException, IOException {
boolean done = false;
String key = null;

View File

@ -174,7 +174,7 @@ public class MessageEventManager extends Manager {
Method method =
MessageEventRequestListener.class.getDeclaredMethod(
methodName,
new Class[] { String.class, String.class, MessageEventManager.class });
new Class<?>[] { String.class, String.class, MessageEventManager.class });
for (MessageEventRequestListener listener : messageEventRequestListeners) {
method.invoke(listener, new Object[] { from, packetID, this });
}
@ -194,7 +194,7 @@ public class MessageEventManager extends Manager {
Method method =
MessageEventNotificationListener.class.getDeclaredMethod(
methodName,
new Class[] { String.class, String.class });
new Class<?>[] { String.class, String.class });
for (MessageEventNotificationListener listener : messageEventNotificationListeners) {
method.invoke(listener, new Object[] { from, packetID });
}

View File

@ -70,7 +70,7 @@ public class RosterExchangeProvider extends ExtensionElementProvider<RosterExcha
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("item")) {
// Create packet.
remoteRosterEntry = new RemoteRosterEntry(jid, name, (String[]) groupsName.toArray(new String[groupsName.size()]));
remoteRosterEntry = new RemoteRosterEntry(jid, name, groupsName.toArray(new String[groupsName.size()]));
rosterExchange.addRosterEntry(remoteRosterEntry);
}
if (parser.getName().equals("x")) {