used findbugs
This commit is contained in:
@@ -18,10 +18,8 @@
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.lang.SupportedLocales;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -72,9 +72,7 @@ public class Pair<K, V> implements Map.Entry<K, V> {
|
||||
final Pair<?, ?> other = (Pair<?, ?>) obj;
|
||||
if (!Objects.equals(this.key, other.key))
|
||||
return false;
|
||||
if (!Objects.equals(this.value, other.value))
|
||||
return false;
|
||||
return true;
|
||||
return Objects.equals(this.value, other.value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ public class Base64 {
|
||||
val |= (0xFF & (int) data[i + 2]);
|
||||
quad = true;
|
||||
}
|
||||
out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
|
||||
out[index + 3] = ALPHABET[(quad ? (val & 0x3F) : 64)];
|
||||
val >>= 6;
|
||||
out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
|
||||
out[index + 2] = ALPHABET[(trip ? (val & 0x3F) : 64)];
|
||||
val >>= 6;
|
||||
out[index + 1] = alphabet[val & 0x3F];
|
||||
out[index + 1] = ALPHABET[val & 0x3F];
|
||||
val >>= 6;
|
||||
out[index + 0] = alphabet[val & 0x3F];
|
||||
out[index + 0] = ALPHABET[val & 0x3F];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class Base64 {
|
||||
int accum = 0;
|
||||
int index = 0;
|
||||
for (int ix = 0; ix < data.length; ix++) {
|
||||
int value = codes[data[ix] & 0xFF];
|
||||
int value = CODES[data[ix] & 0xFF];
|
||||
if (value >= 0) {
|
||||
accum <<= 6;
|
||||
shift += 6;
|
||||
@@ -86,20 +86,20 @@ public class Base64 {
|
||||
throw new Error("miscalculated data length!");
|
||||
return out;
|
||||
}
|
||||
private static final char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
private static final char[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
.toCharArray();
|
||||
private static final byte[] codes = new byte[256];
|
||||
private static final byte[] CODES = new byte[256];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 256; i++)
|
||||
codes[i] = -1;
|
||||
CODES[i] = -1;
|
||||
for (int i = 'A'; i <= 'Z'; i++)
|
||||
codes[i] = (byte) (i - 'A');
|
||||
CODES[i] = (byte) (i - 'A');
|
||||
for (int i = 'a'; i <= 'z'; i++)
|
||||
codes[i] = (byte) (26 + i - 'a');
|
||||
CODES[i] = (byte) (26 + i - 'a');
|
||||
for (int i = '0'; i <= '9'; i++)
|
||||
codes[i] = (byte) (52 + i - '0');
|
||||
codes['+'] = 62;
|
||||
codes['/'] = 63;
|
||||
CODES[i] = (byte) (52 + i - '0');
|
||||
CODES['+'] = 62;
|
||||
CODES['/'] = 63;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,34 +25,34 @@ import org.jackhuang.hellominecraft.util.logging.logger.Logger;
|
||||
*/
|
||||
public class HMCLog {
|
||||
|
||||
private static final Logger logger = new Logger("Hello Minecraft!");
|
||||
private static final Logger LOGGER = new Logger("Hello Minecraft!");
|
||||
|
||||
public static void log(String message) {
|
||||
logger.info(message);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
logger.warn(message);
|
||||
LOGGER.warn(message);
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
logger.debug(message);
|
||||
LOGGER.debug(message);
|
||||
}
|
||||
|
||||
public static void warn(String msg, Throwable t) {
|
||||
logger.warn(msg, t);
|
||||
LOGGER.warn(msg, t);
|
||||
}
|
||||
|
||||
public static void debug(String msg, Throwable t) {
|
||||
logger.debug(msg, t);
|
||||
LOGGER.debug(msg, t);
|
||||
}
|
||||
|
||||
public static void err(String msg) {
|
||||
logger.error(msg);
|
||||
LOGGER.error(msg);
|
||||
}
|
||||
|
||||
public static void err(String msg, Throwable t) {
|
||||
logger.error(msg, t);
|
||||
LOGGER.error(msg, t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,18 +60,29 @@ public enum Level {
|
||||
if (m.find()) {
|
||||
// New style logs from log4j
|
||||
String levelStr = m.group("level");
|
||||
if ("INFO".equals(levelStr))
|
||||
level = INFO;
|
||||
else if ("WARN".equals(levelStr))
|
||||
level = WARN;
|
||||
else if ("ERROR".equals(levelStr))
|
||||
level = ERROR;
|
||||
else if ("FATAL".equals(levelStr))
|
||||
level = FATAL;
|
||||
else if ("TRACE".equals(levelStr))
|
||||
level = TRACE;
|
||||
else if ("DEBUG".equals(levelStr))
|
||||
level = DEBUG;
|
||||
if (null != levelStr)
|
||||
switch (levelStr) {
|
||||
case "INFO":
|
||||
level = INFO;
|
||||
break;
|
||||
case "WARN":
|
||||
level = WARN;
|
||||
break;
|
||||
case "ERROR":
|
||||
level = ERROR;
|
||||
break;
|
||||
case "FATAL":
|
||||
level = FATAL;
|
||||
break;
|
||||
case "TRACE":
|
||||
level = TRACE;
|
||||
break;
|
||||
case "DEBUG":
|
||||
level = DEBUG;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]")
|
||||
|| line.contains("[FINER]") || line.contains("[FINEST]"))
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Logger extends AbstractLogger {
|
||||
this.config = new PrivateConfig(this.config, level);
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
public synchronized Level getLevel() {
|
||||
return this.config.level;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.io.InputStreamReader;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.StringTokenizer;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
@@ -85,7 +84,7 @@ public enum OS {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(file)));
|
||||
long[] result = new long[4];
|
||||
String str = null;
|
||||
String str;
|
||||
StringTokenizer token;
|
||||
while ((str = br.readLine()) != null) {
|
||||
token = new StringTokenizer(str);
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.io.OutputStream;
|
||||
import java.util.Timer;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.util.logging.Level;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -21,9 +21,7 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
|
||||
public class CheckBoxTreeLabel extends JLabel {
|
||||
|
||||
@@ -198,23 +198,20 @@ public class NavButtonManager implements ActionListener {
|
||||
final boolean enableNext = nextStep != null && canContinue && problem == null && !isDeferredResult;
|
||||
final boolean enablePrevious = wizard.getPreviousStep() != null && !isDeferredResult;
|
||||
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
next.setEnabled(enableNext);
|
||||
prev.setEnabled(enablePrevious);
|
||||
finish.setEnabled(enableFinish);
|
||||
JRootPane root = next.getRootPane();
|
||||
if (root != null)
|
||||
if (next.isEnabled())
|
||||
root.setDefaultButton(next);
|
||||
else if (finish.isEnabled())
|
||||
root.setDefaultButton(finish);
|
||||
else if (prev.isEnabled())
|
||||
root.setDefaultButton(prev);
|
||||
else
|
||||
root.setDefaultButton(null);
|
||||
}
|
||||
final Runnable runnable = () -> {
|
||||
next.setEnabled(enableNext);
|
||||
prev.setEnabled(enablePrevious);
|
||||
finish.setEnabled(enableFinish);
|
||||
JRootPane root = next.getRootPane();
|
||||
if (root != null)
|
||||
if (next.isEnabled())
|
||||
root.setDefaultButton(next);
|
||||
else if (finish.isEnabled())
|
||||
root.setDefaultButton(finish);
|
||||
else if (prev.isEnabled())
|
||||
root.setDefaultButton(prev);
|
||||
else
|
||||
root.setDefaultButton(null);
|
||||
};
|
||||
|
||||
if (EventQueue.isDispatchThread())
|
||||
@@ -265,21 +262,18 @@ public class NavButtonManager implements ActionListener {
|
||||
}
|
||||
|
||||
void deferredResultFailed(final boolean canGoBack) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!canGoBack)
|
||||
getCancel().setText(getCloseString());
|
||||
getPrev().setEnabled(true);
|
||||
getNext().setEnabled(false);
|
||||
getCancel().setEnabled(true);
|
||||
getFinish().setEnabled(false);
|
||||
final Runnable runnable = () -> {
|
||||
if (!canGoBack)
|
||||
getCancel().setText(getCloseString());
|
||||
getPrev().setEnabled(true);
|
||||
getNext().setEnabled(false);
|
||||
getCancel().setEnabled(true);
|
||||
getFinish().setEnabled(false);
|
||||
|
||||
if (NAME_CLOSE.equals(deferredStatus)) {
|
||||
// no action
|
||||
} else
|
||||
deferredStatus = DEFERRED_FAILED + deferredStatus;
|
||||
}
|
||||
if (NAME_CLOSE.equals(deferredStatus)) {
|
||||
// no action
|
||||
} else
|
||||
deferredStatus = DEFERRED_FAILED + deferredStatus;
|
||||
};
|
||||
if (EventQueue.isDispatchThread())
|
||||
runnable.run();
|
||||
@@ -601,25 +595,22 @@ public class NavButtonManager implements ActionListener {
|
||||
}
|
||||
|
||||
public void navigabilityChanged(final Wizard wizard) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (wizard.isBusy()) {
|
||||
next.setEnabled(false);
|
||||
prev.setEnabled(false);
|
||||
finish.setEnabled(false);
|
||||
cancel.setEnabled(false);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
wasBusy = true;
|
||||
return;
|
||||
} else if (wasBusy) {
|
||||
cancel.setEnabled(true);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
configureNavigationButtons(wizard, prev, next, finish);
|
||||
|
||||
parent.updateProblem();
|
||||
final Runnable runnable = () -> {
|
||||
if (wizard.isBusy()) {
|
||||
next.setEnabled(false);
|
||||
prev.setEnabled(false);
|
||||
finish.setEnabled(false);
|
||||
cancel.setEnabled(false);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
wasBusy = true;
|
||||
return;
|
||||
} else if (wasBusy) {
|
||||
cancel.setEnabled(true);
|
||||
parent.getOuterPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
configureNavigationButtons(wizard, prev, next, finish);
|
||||
|
||||
parent.updateProblem();
|
||||
};
|
||||
if (EventQueue.isDispatchThread())
|
||||
runnable.run();
|
||||
|
||||
@@ -150,14 +150,10 @@ final class Util {
|
||||
try {
|
||||
m.setAccessible(true);
|
||||
result = (String) m.invoke(null, (Object[]) null);
|
||||
} catch (InvocationTargetException ite) {
|
||||
} catch (InvocationTargetException | IllegalAccessException ite) {
|
||||
throw new IllegalArgumentException("Could not invoke "
|
||||
+ "public static String " + clazz.getName()
|
||||
+ ".getDescription() - make sure it exists.");
|
||||
} catch (IllegalAccessException iae) {
|
||||
throw new IllegalArgumentException("Could not invoke "
|
||||
+ "public static String " + clazz.getName()
|
||||
+ ".getDescription() - make sure it exists.");
|
||||
+ ".getDescription() - make sure it exists.", ite);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,7 @@ public abstract class WizardPanelNavResult extends DeferredWizardResult {
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof WPNRimmediate && ((WPNRimmediate) o).value == value)
|
||||
return true;
|
||||
return false;
|
||||
return o instanceof WPNRimmediate && ((WPNRimmediate) o).value == value;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
Reference in New Issue
Block a user