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

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

@ -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,8 +170,7 @@ final public class PubSubManager
* @throws NotConnectedException
* @throws InterruptedException
*/
@SuppressWarnings("unchecked")
public <T extends Node> T getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
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();