Changeset 34646 in osm for applications/editors


Ignore:
Timestamp:
2018-09-14T21:59:49+02:00 (6 years ago)
Author:
donvip
Message:

spotbugs

Location:
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/actions/OpenLinkAction.java

    r33518 r34646  
    33
    44import java.awt.event.ActionEvent;
     5import java.io.IOException;
    56import java.net.URI;
    67import java.net.URISyntaxException;
     
    4243                    OpenBrowser.displayUrl(uri);
    4344                }
    44             } catch (Exception e2) {
     45            } catch (IOException | URISyntaxException e2) {
    4546                Logging.error(e2);
    4647            }
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/SimpleDataSetHandler.java

    r32545 r34646  
    4040        Tag tag;
    4141        String[] kv = relevantTag.split("=");
    42         if (kv != null && kv.length == 2) {
     42        if (kv.length == 2) {
    4343            tag = new Tag(kv[0], kv[1]);
    4444        } else {
     
    4848    }
    4949
    50     public SimpleDataSetHandler(boolean relevantUnion, String ... relevantTags) {
     50    public SimpleDataSetHandler(boolean relevantUnion, String... relevantTags) {
    5151        addRelevantTag(relevantTags);
    5252        this.relevantUnion = relevantUnion;
    5353    }
    5454
    55     public SimpleDataSetHandler(String ... relevantTags) {
     55    public SimpleDataSetHandler(String... relevantTags) {
    5656        this(false, relevantTags);
    5757    }
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ChooserLauncher.java

    r34452 r34646  
    2121    public void run() {
    2222        Component parent = progressMonitor == null ? MainApplication.getMainFrame() : progressMonitor.getWindowParent();
    23         ProjectionChooser dialog = (ProjectionChooser) new ProjectionChooser(parent).showDialog();
     23        ProjectionChooser dialog = new ProjectionChooser(parent).showDialog();
    2424        if (dialog.getValue() == 1) {
    2525            proj = dialog.getProjection();
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreference.java

    r34452 r34646  
    9898
    9999    private JTextField tfFilter;
    100     private ModuleListPanel pnlModulePreferences;
    101     private ModulePreferencesModel model;
     100    private final ModulePreferencesModel model = new ModulePreferencesModel();
     101    private final ModuleListPanel pnlModulePreferences = new ModuleListPanel(model);
    102102    private JScrollPane spModulePreferences;
    103103
     
    140140        JPanel pnl = new JPanel(new BorderLayout());
    141141        pnl.add(buildSearchFieldPanel(), BorderLayout.NORTH);
    142         model = new ModulePreferencesModel();
    143         spModulePreferences = new JScrollPane(pnlModulePreferences = new ModuleListPanel(model));
     142        spModulePreferences = new JScrollPane(pnlModulePreferences);
    144143        spModulePreferences.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    145144        spModulePreferences.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ProjectionChooser.java

    r33595 r34646  
    158158        }
    159159    }
     160
     161    @Override
     162    public ProjectionChooser showDialog() {
     163        super.showDialog();
     164        return this;
     165    }
    160166}
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java

    r34452 r34646  
    267267            Datum datum1 = ((AbstractSingleCRS) crs1).getDatum();
    268268            Datum datum2 = ((AbstractSingleCRS) crs2).getDatum();
    269             if (!compareDebug("datum", datum1, datum2)) {
     269            if (!compareDebug("datum", datum1, datum2) && datum1 instanceof AbstractIdentifiedObject) {
    270270                AbstractIdentifiedObject adatum1 = (AbstractIdentifiedObject) datum1;
    271271                AbstractIdentifiedObject adatum2 = (AbstractIdentifiedObject) datum2;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlKmzImporter.java

    r32545 r34646  
    1313import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter;
    1414
     15/**
     16 * Keyhole Markup Language (KML/KMZ) importer.
     17 */
    1518public class KmlKmzImporter extends AbstractImporter {
    1619
     
    2730            throws IllegalDataException {
    2831        try {
    29             if (file.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) {
     32            if (file != null && file.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) {
    3033                return KmlReader.parseDataSet(in, instance);
    3134            } else {
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReader.java

    r34153 r34646  
    6060    private File file;
    6161    private InputStream stream;
    62     protected Charset charset;
    63     protected BufferedReader midReader;
     62    private Charset charset;
     63    private BufferedReader midReader;
    6464
    6565    private Character delimiter = '\t';
     
    166166            params += param(Param.lat_0, originLat);
    167167            break;
     168        default:
     169            Logging.trace("originLat not set for " + proj);
    168170        }
    169171
     
    182184            params += param(Param.lat_1, stdP1);
    183185            break;
     186        default:
     187            Logging.trace("stdP1 not set for " + proj);
    184188        }
    185189
     
    193197            params += param(Param.lat_2, stdP2);
    194198            break;
     199        default:
     200            Logging.trace("stdP2 not set for " + proj);
    195201        }
    196202
     
    216222            params += param(Param.k_0, scaleFactor);
    217223            break;
     224        default:
     225            Logging.trace("scaleFactor not set for " + proj);
    218226        }
    219227
     
    249257            params += param(Param.y_0, falseNorthing);
    250258            break;
     259        default:
     260            Logging.trace("falseEasting/falseNorthing not set for " + proj);
    251261        }
    252262
     
    257267            Double.parseDouble(words[8+offset]);
    258268            // TODO: what's proj4 parameter ?
     269        default:
     270            Logging.trace("range not set for " + proj);
    259271        }
    260272
     
    276288            }
    277289            break;
     290        default:
     291            Logging.trace("josmProj not set for " + proj);
    278292        }
    279293
     
    592606    }
    593607
    594     protected void readAttributes(OsmPrimitive p) throws IOException {
     608    private void readAttributes(OsmPrimitive p) throws IOException {
    595609        if (midReader != null) {
    596610            String midLine = midReader.readLine();
     
    613627    }
    614628
    615     protected Node createNode(String x, String y) {
     629    private Node createNode(String x, String y) {
    616630        Node node = new Node(josmProj.eastNorth2latlon(new EastNorth(Double.parseDouble(x), Double.parseDouble(y))));
    617631        ds.addPrimitive(node);
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifTabImporter.java

    r33613 r34646  
    1414import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter;
    1515
     16/**
     17 * MapInfo (MIF/TAB) importer.
     18 */
    1619public class MifTabImporter extends AbstractImporter {
    1720
     
    2831            throws IllegalDataException {
    2932        try {
    30             if (file.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) {
     33            if (file != null && file.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) {
    3134                return MifReader.parseDataSet(in, file, handler, instance);
    3235            } else {
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpImporter.java

    r30723 r34646  
    1414import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter;
    1515
     16/**
     17 * Shapefile (SHP) importer.
     18 */
    1619public class ShpImporter extends AbstractImporter {
    17    
     20
    1821    public static final ExtensionFileFilter SHP_FILE_FILTER = new ExtensionFileFilter(
    1922            OdConstants.SHP_EXT, OdConstants.SHP_EXT, tr("Shapefiles") + " (*."+OdConstants.SHP_EXT+")");
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsDocument.java

    r34452 r34646  
    99import java.util.zip.ZipInputStream;
    1010
     11import javax.xml.parsers.ParserConfigurationException;
     12
    1113import org.jopendocument.io.SaxContentUnmarshaller;
    1214import org.jopendocument.model.OpenDocument;
     
    1416import org.openstreetmap.josm.tools.XmlUtils;
    1517import org.xml.sax.InputSource;
     18import org.xml.sax.SAXException;
    1619import org.xml.sax.XMLReader;
    1720
     
    5154            }
    5255
    53         } catch (Exception e) {
     56        } catch (IOException | SAXException | ParserConfigurationException e) {
    5457            Logging.error(e);
    5558        }
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java

    r34452 r34646  
    175175                Config.getPref().put(togglePreferenceKey, "never");
    176176                break;
     177            default:
     178                Logging.trace(Integer.toString(ret));
    177179            }
    178180        } else {
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleInformation.java

    r34452 r34646  
    139139    }
    140140
     141    @SuppressWarnings("unused")
    141142    private void scanManifest(Manifest manifest) {
    142143        String lang = LanguageInfo.getLanguageCodeManifest();
     
    149150        if (s != null) {
    150151            try {
    151                 @SuppressWarnings("unused")
    152                 URL url = new URL(s);
     152                new URL(s);
    153153            } catch (MalformedURLException e) {
    154154                Logging.error(tr("Invalid URL ''{0}'' in module {1}", s, name));
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleListParser.java

    r34196 r34646  
    101101                url = x[1];
    102102                manifest = new StringBuilder();
    103 
    104103            }
    105104            if (name != null) {
    106105                ModuleInformation info = createInfo(name, url, manifest.toString());
    107                 if (info != null) {
    108                     for (Module module : ModuleHandler.moduleList) {
    109                         if (module.getModuleInformation().name.equals(info.getName())) {
    110                             info.localversion = module.getModuleInformation().localversion;
    111                         }
     106                for (Module module : ModuleHandler.moduleList) {
     107                    if (module.getModuleInformation().name.equals(info.getName())) {
     108                        info.localversion = module.getModuleInformation().localversion;
    112109                    }
    113                     ret.add(info);
    114110                }
     111                ret.add(info);
    115112            }
    116113            return ret;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/NamesFrUtils.java

    r33518 r34646  
    1616import org.openstreetmap.josm.tools.Logging;
    1717
     18/**
     19 * Utilities for French names.
     20 */
    1821public abstract class NamesFrUtils {
    1922
     
    3639                SimpleDataSetHandler.class.getResourceAsStream(OdConstants.DICTIONARY_FR), OdConstants.UTF8))) {
    3740            String line = reader.readLine(); // Skip first line
     41            Logging.trace(line);
    3842            while ((line = reader.readLine()) != null) {
    3943                String[] tab = line.split(";");
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/util/OdUtils.java

    r34452 r34646  
    3434            if (append) {
    3535                int index = result.size()-1;
    36                 if (split[i].endsWith("\"") && StringUtils.countMatches(split[i], "\"") % 2 == 1) {
     36                if (split[i].endsWith("\"") && StringUtils.countMatches(split[i], "\"") % 2 != 0) {
    3737                    append = false;
    3838                }
Note: See TracChangeset for help on using the changeset viewer.