diff --git a/src/main/java/org/harctoolbox/guicomponents/AckWithMemoryDialog.java b/src/main/java/org/harctoolbox/guicomponents/AckWithMemoryDialog.java index c94f109d..4e4aebec 100644 --- a/src/main/java/org/harctoolbox/guicomponents/AckWithMemoryDialog.java +++ b/src/main/java/org/harctoolbox/guicomponents/AckWithMemoryDialog.java @@ -28,6 +28,7 @@ public final class AckWithMemoryDialog extends javax.swing.JDialog { private final String message; private final String uSureMessage; + @SuppressWarnings("PublicInnerClass") public interface PropertyFlip { public boolean getProperty(); public void setProperty(boolean value); @@ -41,6 +42,7 @@ private AckWithMemoryDialog(String message, String uSure, PropertyFlip propertyF initComponents(); } + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public static boolean ackWithMemoryDialog(String message, String uSure, PropertyFlip propertyFlip, Frame parent) { if (propertyFlip.getProperty()) return true; diff --git a/src/main/java/org/harctoolbox/guicomponents/Console.java b/src/main/java/org/harctoolbox/guicomponents/Console.java index 38cdb7b0..b2285d87 100644 --- a/src/main/java/org/harctoolbox/guicomponents/Console.java +++ b/src/main/java/org/harctoolbox/guicomponents/Console.java @@ -309,6 +309,7 @@ public void toClipboard(String str) { // return (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this).getTransferData(DataFlavor.stringFlavor); //} } + @SuppressWarnings("PublicInnerClass") public interface IErrorFunction { void err(Exception ex, String str); diff --git a/src/main/java/org/harctoolbox/guicomponents/CopyClipboardText.java b/src/main/java/org/harctoolbox/guicomponents/CopyClipboardText.java index 42bc04a9..36ccccfc 100644 --- a/src/main/java/org/harctoolbox/guicomponents/CopyClipboardText.java +++ b/src/main/java/org/harctoolbox/guicomponents/CopyClipboardText.java @@ -25,6 +25,7 @@ import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; +@SuppressWarnings("UseOfSystemOutOrSystemErr") public class CopyClipboardText implements ClipboardOwner { public static String getSelection() { diff --git a/src/main/java/org/harctoolbox/guicomponents/GirsClientBean.java b/src/main/java/org/harctoolbox/guicomponents/GirsClientBean.java index 7ca63cde..b64906c1 100644 --- a/src/main/java/org/harctoolbox/guicomponents/GirsClientBean.java +++ b/src/main/java/org/harctoolbox/guicomponents/GirsClientBean.java @@ -59,6 +59,7 @@ public GirsClientBean(GuiUtils guiUtils, boolean verbose) { this(guiUtils, verbose, DEFAULT_TIMEOUT, DEFAULT_PORTNAME, DEFAULT_BAUD, DEFAULT_IPNAME, DEFAULT_PORT, DEFAULT_TYPE); } + @SuppressWarnings("AssignmentToMethodParameter") public GirsClientBean(GuiUtils guiUtils, boolean verbose, int timeout, String initialPort, int baud, String ipName, int portNumber, Type type) { super(guiUtils, verbose, timeout); @@ -337,6 +338,7 @@ private void enableStuff(boolean isOpen) { displayVersion(); } + @SuppressWarnings("PublicInnerClass") public static enum Type { SERIAL, TCP, diff --git a/src/main/java/org/harctoolbox/guicomponents/GuiUtils.java b/src/main/java/org/harctoolbox/guicomponents/GuiUtils.java index 002c57cb..53e0513b 100644 --- a/src/main/java/org/harctoolbox/guicomponents/GuiUtils.java +++ b/src/main/java/org/harctoolbox/guicomponents/GuiUtils.java @@ -25,7 +25,6 @@ import java.io.InputStreamReader; import java.io.Serializable; import java.net.MalformedURLException; -import java.net.Proxy; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -234,7 +233,7 @@ public String getInput(String message, String title, String defaultAnswer) { public Integer getIntegerInput(String message, int oldValue) { String s = getInput(message, "Parameter input", Integer.toString(oldValue)); - return s != null ? Integer.parseInt(s) : null; + return s != null ? Integer.valueOf(s) : null; } public Long getLongInput(String message, long oldValue) { @@ -246,7 +245,7 @@ public Long getLongInput(String message, long oldValue) { public Double getDoubleInput(String message, double oldValue) { String s = getInput(message, "Parameter input", Double.toString(oldValue)); - return s != null ? Double.parseDouble(s) : null; + return s != null ? Double.valueOf(s) : null; } public boolean confirm(String message) { @@ -297,6 +296,7 @@ else if (Desktop.isDesktopSupported()) * ... not omnipresent, use only this function. * * @param file file or directory to be opened/edited. + * @throws java.io.IOException */ public void open(File file) throws IOException { if (useXdbOpen) @@ -375,6 +375,7 @@ public boolean checkUpToDate(String currentVersionUrl, String versionString) { return current != null && current.equals(versionString); } + @SuppressWarnings("PublicInnerClass") public interface EmergencyFixer { public void fix(); diff --git a/src/main/java/org/harctoolbox/guicomponents/HardwareBean.java b/src/main/java/org/harctoolbox/guicomponents/HardwareBean.java index db237e01..0efc8729 100644 --- a/src/main/java/org/harctoolbox/guicomponents/HardwareBean.java +++ b/src/main/java/org/harctoolbox/guicomponents/HardwareBean.java @@ -33,6 +33,7 @@ /** * This is a superclass of all the hardware managing beans. */ +@SuppressWarnings("serial") public abstract class HardwareBean extends JPanel implements Closeable { public static final String PROP_VERSION = "PROP_VERSION"; @@ -103,6 +104,7 @@ protected void openClose(boolean opening) throws IOException, HarcHardwareExcept /** * Returns a somewhat friendly name of the class. + * @return name */ @Override public String getName() { @@ -158,6 +160,10 @@ public boolean canSend() { /** * Default implementation, override whenever the subclass can capture. * @return ModulatedSequence captured, or null. + * @throws org.harctoolbox.guicomponents.HardwareBean.CannotCaptureException + * @throws HarcHardwareException + * @throws InvalidArgumentException + * @throws IOException */ public ModulatedIrSequence capture() throws CannotCaptureException, HarcHardwareException, InvalidArgumentException, IOException { throw new CannotCaptureException(getName()); @@ -165,19 +171,29 @@ public ModulatedIrSequence capture() throws CannotCaptureException, HarcHardware /** * Default implementation, override whenever the subclass can send. - * @return success of operation + * + * @param irSignal + * @param count + * @return success of operation + * @throws NoSuchTransmitterException + * @throws IOException + * @throws HardwareUnavailableException + * @throws HarcHardwareException + * @throws InvalidArgumentException */ public boolean sendIr(IrSignal irSignal, int count) throws NoSuchTransmitterException, IOException, HardwareUnavailableException, HarcHardwareException, InvalidArgumentException { throw new CannotSendException(getName()); } - public static class CannotCaptureException extends HarcHardwareException { + @SuppressWarnings("PublicInnerClass") + public static class CannotCaptureException extends HarcHardwareException { private CannotCaptureException(String name) { super("Selected hardware " + name + " cannot capture."); } } + @SuppressWarnings("PublicInnerClass") public static class CannotSendException extends HarcHardwareException { public CannotSendException(String name) { diff --git a/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java b/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java index d808cb33..40938f97 100644 --- a/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java +++ b/src/main/java/org/harctoolbox/guicomponents/IrPlotter.java @@ -100,6 +100,7 @@ public IrPlotter() { this(true); } + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public IrPlotter(IrPlotter irPlotter, boolean zoomSupport) { this(zoomSupport); this.noIntroBursts = irPlotter.noIntroBursts; @@ -319,6 +320,7 @@ private void drawPlot(Graphics graphics) { } } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private int[] getTickValues(int xmin, int xmax, int pixelWidth) { if (xmin == xmax) return new int[0]; diff --git a/src/main/java/org/harctoolbox/guicomponents/IrpRenderBean.java b/src/main/java/org/harctoolbox/guicomponents/IrpRenderBean.java index b92aa4f5..1e841fb0 100644 --- a/src/main/java/org/harctoolbox/guicomponents/IrpRenderBean.java +++ b/src/main/java/org/harctoolbox/guicomponents/IrpRenderBean.java @@ -242,8 +242,7 @@ public InputVariableSetValues getIntervalParameters() throws UnknownProtocolExce public IrSignal render() throws IrpException, IrCoreException, ParseException { Map parameters = getParameters(); - IrSignal irSignal = protocol.toIrSignal(parameters); - return irSignal; + return protocol.toIrSignal(parameters); } public Map getCommands() throws IrCoreException, IrpException, ParseException, GirrException { diff --git a/src/main/java/org/harctoolbox/guicomponents/LookAndFeelManager.java b/src/main/java/org/harctoolbox/guicomponents/LookAndFeelManager.java index 472de9c0..663a85c6 100644 --- a/src/main/java/org/harctoolbox/guicomponents/LookAndFeelManager.java +++ b/src/main/java/org/harctoolbox/guicomponents/LookAndFeelManager.java @@ -122,6 +122,7 @@ public String getCurrentLAFClassName() { /** * Allows for error reporting function and a set-property function of the caller. */ + @SuppressWarnings("PublicInnerClass") public interface ILookAndFeelManagerCaller { /** * Used for error reporting through the caller. diff --git a/src/main/java/org/harctoolbox/guicomponents/MetaDataDialog.java b/src/main/java/org/harctoolbox/guicomponents/MetaDataDialog.java index d624bc0f..616ef684 100644 --- a/src/main/java/org/harctoolbox/guicomponents/MetaDataDialog.java +++ b/src/main/java/org/harctoolbox/guicomponents/MetaDataDialog.java @@ -43,6 +43,7 @@ private MetaDataDialog(Remote.MetaData metaData, Frame parent) { nameTextField.setText(DEFAULT_REMOTENAME); } + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public static Remote.MetaData inquireMetaData(Remote.MetaData initData, Frame parent) { MetaDataDialog dialog = new MetaDataDialog(initData, parent); Rectangle parentCoords = parent.getBounds(); diff --git a/src/main/java/org/harctoolbox/guicomponents/SerialHardwareBean.java b/src/main/java/org/harctoolbox/guicomponents/SerialHardwareBean.java index 279901c2..2e5e70a2 100644 --- a/src/main/java/org/harctoolbox/guicomponents/SerialHardwareBean.java +++ b/src/main/java/org/harctoolbox/guicomponents/SerialHardwareBean.java @@ -29,6 +29,7 @@ * * */ +@SuppressWarnings("serial") public abstract class SerialHardwareBean extends HardwareBean { protected static DefaultComboBoxModel createModel(boolean useCached) { @@ -40,8 +41,7 @@ protected static DefaultComboBoxModel createModel(boolean useCached) { portNames.add(""); } //portNames.add(0, ""); - DefaultComboBoxModel model = new DefaultComboBoxModel<>(portNames.toArray(new String[portNames.size()])); - return model; + return new DefaultComboBoxModel<>(portNames.toArray(new String[portNames.size()])); } protected String portName; diff --git a/src/main/java/org/harctoolbox/guicomponents/StandalonePopupAnnoyer.java b/src/main/java/org/harctoolbox/guicomponents/StandalonePopupAnnoyer.java index 24e53715..5af4eda1 100644 --- a/src/main/java/org/harctoolbox/guicomponents/StandalonePopupAnnoyer.java +++ b/src/main/java/org/harctoolbox/guicomponents/StandalonePopupAnnoyer.java @@ -38,6 +38,7 @@ private static boolean errorContinue(String message) { return ans == 0; } + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { try { boolean result = errorContinue(args[0]); diff --git a/src/main/java/org/harctoolbox/guicomponents/UndoableJTextArea.java b/src/main/java/org/harctoolbox/guicomponents/UndoableJTextArea.java index 85115805..e1ee385f 100644 --- a/src/main/java/org/harctoolbox/guicomponents/UndoableJTextArea.java +++ b/src/main/java/org/harctoolbox/guicomponents/UndoableJTextArea.java @@ -155,6 +155,7 @@ private String last() { } } + @SuppressWarnings({"PublicInnerClass", "serial"}) public static class UndoHistoryEmptyException extends Exception { public UndoHistoryEmptyException() { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java index 0b6df470..04d26fae 100755 --- a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java @@ -46,7 +46,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; import java.util.function.Function; import javax.comm.DriverGenUnix; import javax.swing.DefaultComboBoxModel; @@ -1337,12 +1336,12 @@ private File saveCommands(Map commands, String title, Exporter guiUtils.error("No exporter"); return null; } - + if (commands.isEmpty()) { guiUtils.error("Nothing to export"); return null; } - + File savedFile; if (commands.size() == 1) { savedFile = saveSignalWrite(commands.values().iterator().next(), title, exporter); @@ -1353,7 +1352,7 @@ private File saveCommands(Map commands, String title, Exporter } savedFile = saveCommandsWrite(commands, title, (RemoteSetExporter) exporter); } - + if (savedFile != null) { guiUtils.message("File " + savedFile + " was successfully written with " + commands.size() + (commands.size() == 1 ? " command." : " commands.")); if (properties.getAutoOpenExports()) @@ -1409,15 +1408,6 @@ private File saveSignalWrite(Command command, String title, Exporter exporter) t new File(properties.getExportDir()), properties.getExportCharsetName()); } - private double getFrequency() { - try { - return Double.parseDouble(frequencyLabel.getText()); - } catch (NumberFormatException | NullPointerException ex) { - } - double f = properties.getFallbackFrequency(); - return f > 0 ? f : ModulatedIrSequence.DEFAULT_FREQUENCY; - } - private void reAnalyze() { try { IrSignal irSignal = getCapturedIrSignal(); @@ -7414,8 +7404,8 @@ private void editingTextFieldActionPerformed(java.awt.event.ActionEvent evt) {// Class clazz = tableModel.getColumnClass(column); String str = editingTextField.getText(); Object thing = str.trim().isEmpty() ? null - : clazz == Integer.class ? Integer.parseInt(str) - : clazz == Boolean.class ? Boolean.parseBoolean(str) + : clazz == Integer.class ? Integer.valueOf(str) + : clazz == Boolean.class ? Boolean.valueOf(str) : str; Object oldValue = tableModel.getValueAt(r, c); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/IrScrutinizer.java b/src/main/java/org/harctoolbox/irscrutinizer/IrScrutinizer.java index 51e9fb89..b5adafaa 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/IrScrutinizer.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/IrScrutinizer.java @@ -70,6 +70,7 @@ private static void doExit(int exitcode) { /** * @param args the command line arguments. */ + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public static void main(String[] args) { argumentParser = new JCommander(commandLineArgs); argumentParser.setProgramName(Version.appName); @@ -116,6 +117,7 @@ public static void setupRadixPrefixes() { IrCoreUtils.setRadixPrefixes(map); } + @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") private static String nukeProperties(boolean verbose) { Props properties = new Props(commandLineArgs.propertiesFilename, commandLineArgs.applicationHome); String filename = properties.getFilename(); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/NamedIrSignal.java b/src/main/java/org/harctoolbox/irscrutinizer/NamedIrSignal.java index 22352089..bca5ce3c 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/NamedIrSignal.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/NamedIrSignal.java @@ -42,6 +42,7 @@ * * */ +@SuppressWarnings({"PackageVisibleInnerClass", "serial", "UseOfSystemOutOrSystemErr"}) abstract class NamedIrSignal { private static int count = 0; @@ -225,6 +226,7 @@ public void removeColumns(Collection list) { public abstract static class LearnedIrSignalTableModel extends DefaultTableModel { private final AbstractColumnFunction columnsFunc; private boolean scrollRequest = false; + @SuppressWarnings("PackageVisibleField") protected boolean unsavedChanges; protected LearnedIrSignalTableModel(AbstractColumnFunction columnFunc) { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/ParametrizedIrSignal.java b/src/main/java/org/harctoolbox/irscrutinizer/ParametrizedIrSignal.java index 6bfcd421..b1153b67 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/ParametrizedIrSignal.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/ParametrizedIrSignal.java @@ -34,6 +34,7 @@ * * */ +@SuppressWarnings({"PackageVisibleInnerClass", "serial", "AccessingNonPublicFieldOfAnotherObject"}) class ParametrizedIrSignal extends NamedIrSignal { private static Decoder decoder = null; private static Decoder.DecoderParameters decoderParameters = null; diff --git a/src/main/java/org/harctoolbox/irscrutinizer/RawIrSignal.java b/src/main/java/org/harctoolbox/irscrutinizer/RawIrSignal.java index 862f626e..4df114c9 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/RawIrSignal.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/RawIrSignal.java @@ -41,6 +41,7 @@ * Note: Editing of the sequences is not implemented (yet). * */ +@SuppressWarnings({"UseOfSystemOutOrSystemErr", "PackageVisibleInnerClass"}) class RawIrSignal extends NamedIrSignal { private static Decoder decoder = null; @@ -186,8 +187,7 @@ private void setIrSignal(ModulatedIrSequence irSequence) { } public Command toCommand() { - Command command = new Command(getName(), getComment(), irSignal); - return command; + return new Command(getName(), getComment(), irSignal); } public IrSignal getIrSignal() { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormat.java b/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormat.java index 829d9404..eb04019b 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormat.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormat.java @@ -100,8 +100,7 @@ private static Map parseExportFormatsFile(GuiUtils gui static DocumentFragment extractDocumentation(Element el) { NodeList nodeList = el.getElementsByTagNameNS(EXPORTFORMAT_NAMESPACE, "documentation"); - DocumentFragment doc = nodeList.getLength() > 0 ? nodeListToDocumentFragment(nodeList, true) : null; - return doc; + return nodeList.getLength() > 0 ? nodeListToDocumentFragment(nodeList, true) : null; } private static DocumentFragment nodeToDocumentFragment(Node node, boolean preserve) { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormatMain.java b/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormatMain.java index 0a1d0fa7..d248a1a9 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormatMain.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/exporter/DynamicRemoteSetExportFormatMain.java @@ -64,7 +64,7 @@ private static void doExit(int exitcode) { System.exit(exitcode); } - @SuppressWarnings("UseOfSystemOutOrSystemErr") + @SuppressWarnings({"UseOfSystemOutOrSystemErr", "AccessingNonPublicFieldOfAnotherObject"}) public static void main(String[] args) { argumentParser = new JCommander(commandLineArgs); argumentParser.setProgramName("DynamicRemoteSetExportFormatVersion"); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/exporter/ExportFormatManager.java b/src/main/java/org/harctoolbox/irscrutinizer/exporter/ExportFormatManager.java index 7ea0a75b..63ad2157 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/exporter/ExportFormatManager.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/exporter/ExportFormatManager.java @@ -140,6 +140,7 @@ public String[] toArray() { return list.toArray(new String[list.size()]); } + @SuppressWarnings("PublicInnerClass") public interface IExportFormatSelector { public void select(String name); } diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CcfImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CcfImporter.java index 9f46559d..778dfb61 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CcfImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CcfImporter.java @@ -98,13 +98,12 @@ private Remote loadDevice(CCFDevice dev) { Map notes = new HashMap<>(1); notes.put("note", "Imported by IrScrutinizer"); - Remote remote = new Remote(new Remote.MetaData(deviceName), + return new Remote(new Remote.MetaData(deviceName), origin, //java.lang.String comment, notes,//"Imported by IrScrutinizer", //java.lang.String notes, commands, null //java.util.HashMap> applicationParameters) ); - return remote; } @SuppressWarnings("UseOfSystemOutOrSystemErr") diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CmlImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CmlImporter.java index c2c61a7e..9a7f4400 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CmlImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CmlImporter.java @@ -125,6 +125,7 @@ private int searchToken(InputStream inputStream) throws IOException { } } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private Remote parseRemote(InputStream inputStream) throws IOException, InvalidArgumentException { long status = inputStream.skip(12); if (status != 12) @@ -151,6 +152,7 @@ private Remote parseRemote(InputStream inputStream) throws IOException, InvalidA return new Remote(metaData, null, null, commands, null); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private Command parseCommand(InputStream inputStream, String remoteName) throws IOException, InvalidArgumentException { byte[] x = getBytes(inputStream, 23); int wav = byte2unsigned(x[9]) + 256 * byte2unsigned(x[10]); @@ -187,8 +189,7 @@ private Command parseCommand(InputStream inputStream, String remoteName) throws return null; } IrSignal irSignal = new IrSignal(timingsMicroseconds, introLength, repeatLength, frequency); - Command command = new Command(commandName, null, irSignal); - return command; + return new Command(commandName, null, irSignal); } diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CommandFusionImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CommandFusionImporter.java index 7d751d0e..d1544e59 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CommandFusionImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CommandFusionImporter.java @@ -92,10 +92,9 @@ Remote parseRemote(JsonObject jsonObject) { Map notes = new HashMap<>(1); notes.put("Description", remoteInfo.getString("Description", null)); - Remote remote = new Remote(new Remote.MetaData(name, null, manufacturer, model, deviceClass, remoteName), + return new Remote(new Remote.MetaData(name, null, manufacturer, model, deviceClass, remoteName), null /* String comment */, notes, commands, null /* HashMap> applicationParameters*/); - return remote; } diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/ControlTowerIrDatabase.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/ControlTowerIrDatabase.java index 9183c259..a5c34058 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/ControlTowerIrDatabase.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/ControlTowerIrDatabase.java @@ -139,8 +139,7 @@ private InputStreamReader getReader(String str) throws IOException { System.err.println("Opening " + url); URLConnection urlConnection = url.openConnection(); InputStream is = urlConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is, Charset.forName("US-ASCII")); - return isr; + return new InputStreamReader(is, Charset.forName("US-ASCII")); } private JsonValue readFrom(String str) throws IOException { @@ -150,8 +149,7 @@ private JsonValue readFrom(String str) throws IOException { private JsonValue readFrom(Reader reader) throws IOException { JsonParser parser = Json.createParser(reader); JsonParser.Event x = parser.next(); - JsonValue obj = parser.getValue(); - return obj; + return parser.getValue(); } @SuppressWarnings("UseOfSystemOutOrSystemErr") @@ -388,11 +386,13 @@ public Remote.MetaData getMetaData() { throw new ThisCannotHappenException(); } + @SuppressWarnings("PublicInnerClass") public static class LoginException extends Exception { public LoginException(String message) { super(message); } } + @SuppressWarnings("PublicInnerClass") public static class Model { private final String brand; private final String type; diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvImporter.java index 1610879c..cace4592 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvImporter.java @@ -85,7 +85,7 @@ protected static String[] gobbleString(String[] chunks, int column, boolean name chunk = chunk.substring(2); if (rejectNumbers && chunk.length() > 1) { try { - Integer.parseInt(chunk, basis); + Integer.valueOf(chunk, basis); break; } catch (NumberFormatException ex) { } diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvParametrizedImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvParametrizedImporter.java index 04492732..35cb2e95 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvParametrizedImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvParametrizedImporter.java @@ -56,6 +56,7 @@ public static Collection process(Reader reader, return csvImportParametrized.getCommands(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { try { Reader r = new InputStreamReader(new FileInputStream(args[0]), Charset.forName("US-ASCII")); @@ -136,6 +137,7 @@ public void load(File file, String origin, String charsetName) throws FileNotFou } @Override + @SuppressWarnings("UseOfSystemOutOrSystemErr") public void load(Reader reader, String origin) throws IOException { prepareLoad(origin); boolean rejectNumbers = nameColumn < protocolColumn || nameColumn < dColumn @@ -197,6 +199,7 @@ private NameEngine gobbleNameEngine(String[] chunks, int column, int offset) { return null; } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private long gobbleLong(String[] chunks, int column, String name, int offset) { if (column == 0) return IrCoreUtils.INVALID; diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvRawImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvRawImporter.java index 2bb13bd0..ff8295cd 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvRawImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/CsvRawImporter.java @@ -43,6 +43,7 @@ * * Columns are numbered starting with 1. */ +@SuppressWarnings("serial") public class CsvRawImporter extends CsvImporter { public static Collection process(File file, String separator, int nameColumn, boolean nameMultiColumn, int codeColumn, boolean includeTail, @@ -52,6 +53,7 @@ public static Collection process(File file, String separator, int nameC return csvImportRaw.getCommands(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { try { Collection signals = process(new File(args[0]), " ", 3, false, 6, true, true, true, true, "WINDOWS-1252"); @@ -150,6 +152,7 @@ public void load(Reader reader, String origin) throws IOException { setupRemoteSet(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private Command scrutinizeRaw(String[] chunks, boolean rejectNumbers) { String[] nameArray = gobbleString(chunks, nameColumn, nameMultiColumn, 16, "-", rejectNumbers); String name = join(nameArray); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/FileImporterBean.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/FileImporterBean.java index 0ac64ff1..a2ce73aa 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/FileImporterBean.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/FileImporterBean.java @@ -98,6 +98,7 @@ public FileImporterBean() { initComponents(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private boolean isSane() { if (guiUtils == null) { System.err.println("guiUtils is not setup in FileImporterBean"); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java index f42459d8..534c1c4e 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java @@ -90,8 +90,7 @@ private InputStreamReader getReader(String str) throws IOException { if (verbose) System.err.println("Opening " + url.toString()); URLConnection urlConnection = url.openConnection(); - InputStreamReader reader = new InputStreamReader(urlConnection.getInputStream(), Charset.forName("US-ASCII")); - return reader; + return new InputStreamReader(urlConnection.getInputStream(), Charset.forName("US-ASCII")); } private JsonValue readFrom(String str) throws IOException { @@ -101,8 +100,7 @@ private JsonValue readFrom(String str) throws IOException { private JsonValue readFrom(Reader reader) throws IOException { JsonParser parser = Json.createParser(reader); JsonParser.Event x = parser.next(); - JsonValue obj = parser.getValue(); - return obj; + return parser.getValue(); } private Map getMap(String urlFragment, String keyName, String valueName) throws IOException { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/IctImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/IctImporter.java index 9ed54e1e..90d7eeeb 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/IctImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/IctImporter.java @@ -69,6 +69,7 @@ public static Collection importer(BufferedReader reader, String orig) t return imp.getCommands(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { if (args.length == 0) process(System.in, System.out); @@ -147,10 +148,10 @@ public void load(Reader reader, String origin) throws IOException, InvalidArgume else if (chunks[0].equals("sample_count")) sampleCount = Integer.parseInt(chunks[1]); else if (chunks[0].startsWith("+")) { - data.add(Integer.parseInt(chunks[0].substring(1))); + data.add(Integer.valueOf(chunks[0].substring(1))); noSamples++; } else if (chunks[0].equals("pulse")) { - data.add(Integer.parseInt(chunks[1])); + data.add(Integer.valueOf(chunks[1])); noSamples++; } else if (chunks[0].equals(IRSCOPE_ENDING_STRING)) { data.add(IRSCOPE_ENDING_GAP); @@ -172,13 +173,13 @@ else if (chunks[0].startsWith("+")) { } else if (chunks[0].equals("irscope")) ; else if (chunks[0].startsWith("-")) { - data.add(Integer.parseInt(chunks[0].substring(1))); + data.add(Integer.valueOf(chunks[0].substring(1))); noSamples++; } else if (chunks[0].equals("space")) if (data.isEmpty()) ; // Ignore leading gaps else { - data.add(Integer.parseInt(chunks[1])); + data.add(Integer.valueOf(chunks[1])); noSamples++; } else if (chunks[0].startsWith("#")) diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/IrTransImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/IrTransImporter.java index f57f00ba..a320e382 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/IrTransImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/IrTransImporter.java @@ -51,6 +51,7 @@ public class IrTransImporter extends RemoteSetImporter implements IReaderImporte public static final String defaultCharsetName = "windows-1252"; private static final int dummyEndingGap = 50000; + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { IrTransImporter importer = new IrTransImporter(); try { @@ -66,6 +67,7 @@ public IrTransImporter() { super(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private Remote parseRemote(LineNumberReader reader) throws IOException, ParseException { String name = parseName(reader); if (name == null) @@ -99,6 +101,7 @@ private String parseName(LineNumberReader reader) throws IOException, ParseExcep return arr[1]; } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private Map parseCommands(LineNumberReader reader, List timings) throws IOException, ParseException { gobbleTo(reader, "[COMMANDS]", true); Map commands = new LinkedHashMap<>(32); @@ -203,7 +206,7 @@ private boolean gobbleTo(LineNumberReader reader, String target, boolean throwEx return true; } - @SuppressWarnings("ValueOfIncrementOrDecrementUsed") + @SuppressWarnings({"ValueOfIncrementOrDecrementUsed", "UseOfSystemOutOrSystemErr"}) private List parseTimings(LineNumberReader reader) throws IOException, ParseException { List timings = new ArrayList<>(16); boolean hasTiming = gobbleTo(reader, "[TIMING]", false); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/RawLineImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/RawLineImporter.java index 9a35303f..9b59a42c 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/RawLineImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/RawLineImporter.java @@ -37,6 +37,7 @@ */ public class RawLineImporter extends RemoteSetImporter implements IReaderImporter { + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { RawLineImporter rli = new RawLineImporter(); try { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/RemoteSetImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/RemoteSetImporter.java index feffd352..e55b707f 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/RemoteSetImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/RemoteSetImporter.java @@ -60,12 +60,11 @@ protected Remote setupRemote() { Map> appParams = new HashMap<>(8); appParams.put(getClass().getSimpleName(), null); Remote.MetaData metaData =new Remote.MetaData(IrCoreUtils.basename(origin)); - Remote remote = new Remote(metaData, + return new Remote(metaData, null, //String comment, null, getCommandIndex(), appParams); - return remote; } protected void setupRemoteSet(Remote remote) { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/TreeImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/TreeImporter.java index 600c3190..087d4337 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/TreeImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/TreeImporter.java @@ -278,8 +278,7 @@ private Command getSingleCommand() { guiUtils.error("A command (not remote) has to be selected for this command."); return null; } - Command command = (Command) thing; - return command; + return (Command) thing; } private void checkGuiMain() { diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/WaveImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/WaveImporter.java index e4e3af16..9e94b327 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/WaveImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/WaveImporter.java @@ -46,6 +46,7 @@ public void setDivideCarrier(boolean divideCarrier) { } @Override + @SuppressWarnings("UseOfSystemOutOrSystemErr") public void load(File file, String origin, String charsetName /* ignored */) throws IOException { try { Wave wave = new Wave(file); diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/XcfImporter.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/XcfImporter.java index 261e3792..9c69f50b 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/XcfImporter.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/importer/XcfImporter.java @@ -85,6 +85,7 @@ public static RemoteSet importXcf(String filename) throws IOException, SAXExcept return importer.getRemoteSet(); } + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String args[]) { try { RemoteSet buttons = importXcf(args[0]); @@ -228,13 +229,12 @@ private Remote loadModule(Element module) { NodeList nextpages = page.getElementsByTagName("Next"); page = nextpages.getLength() > 0 ? pageIndex.get(((Element) nextpages.item(0)).getAttribute("id")) : null; } - Remote remote = new Remote(new Remote.MetaData(name), + return new Remote(new Remote.MetaData(name), null, //java.lang.String comment, null, //java.lang.String notes, cmds, null //java.util.HashMap> applicationParameters) ); - return remote; } private Map loadPage(Element page) { @@ -280,8 +280,7 @@ private String actionCodeCcf(Element action) { if (nl.getLength() == 0) return null; - String ccf = nl.item(0).getTextContent(); - return ccf; + return nl.item(0).getTextContent(); } private String actionCodeName(Element action) { @@ -309,6 +308,7 @@ private void setupNamesIndex(Element element) { } } + @SuppressWarnings("UseOfSystemOutOrSystemErr") private void setupActionIndex(Element element) { actionIndex = mkIndex(element, "ACTION"); for (Element action : actionIndex.values()) { diff --git a/src/main/java/org/harctoolbox/valuesets/InputVariableSetValues.java b/src/main/java/org/harctoolbox/valuesets/InputVariableSetValues.java index 0a6202c5..9cac02ee 100644 --- a/src/main/java/org/harctoolbox/valuesets/InputVariableSetValues.java +++ b/src/main/java/org/harctoolbox/valuesets/InputVariableSetValues.java @@ -47,6 +47,7 @@ public class InputVariableSetValues implements Iterable { /** For testing purposes only * @param args */ + @SuppressWarnings("UseOfSystemOutOrSystemErr") public static void main(String[] args) { int seed = (int) IrCoreUtils.INVALID; int arg_i = 0; @@ -98,7 +99,7 @@ public Iterator iterator() { @Override public boolean hasNext() { - return valueSets.size() > 0 + return !valueSets.isEmpty() && (currentSetIndex == IrCoreUtils.INVALID || setIterator.hasNext() || currentSetIndex < valueSets.size() - 1); @@ -119,8 +120,7 @@ public Long next() { if (setIterator == null) setIterator = valueSets.get(currentSetIndex).iterator(); - Long l = setIterator.next(); - return l; + return setIterator.next(); } @Override