Changeset 6806 in josm


Ignore:
Timestamp:
2014-02-03T19:26:05+01:00 (10 years ago)
Author:
Don-vip
Message:

fix some Sonar issues introduced recently

Location:
trunk/src/org/openstreetmap/josm
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r6783 r6806  
    211211    private static final Collection<MapFrameListener> mapFrameListeners = new ArrayList<MapFrameListener>();
    212212
    213     protected static final Map<String, Throwable> networkErrors = new HashMap<String, Throwable>();
     213    protected static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<String, Throwable>();
    214214
    215215    /**
     
    14491449    public static Throwable addNetworkError(String url, Throwable t) {
    14501450        if (url != null && t != null) {
    1451             return networkErrors.put(url, t);
     1451            return NETWORK_ERRORS.put(url, t);
    14521452        }
    14531453        return null;
     
    14601460     */
    14611461    public static Map<String, Throwable> getNetworkErrors() {
    1462         return new HashMap<String, Throwable>(networkErrors);
     1462        return new HashMap<String, Throwable>(NETWORK_ERRORS);
    14631463    }
    14641464}
  • trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java

    r6734 r6806  
    6969    public void actionPerformed(ActionEvent e) {
    7070        if (!isEnabled() || relations.isEmpty()) return;
    71         if (relations.size() > Main.pref.getInteger("warn.open.maxrelations", 5)) {
     71        if (relations.size() > Main.pref.getInteger("warn.open.maxrelations", 5) &&
    7272            /* I18N english text for value 1 makes no real sense, never called for values <= maxrel (usually 5) */
    73             if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(Main.parent,
     73            JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(Main.parent,
    7474                    "<html>"+trn("You are about to open <b>{0}</b> different relation editor simultaneously.<br/>Do you want to continue?",
    7575                            "You are about to open <b>{0}</b> different relation editors simultaneously.<br/>Do you want to continue?",
    7676                            relations.size(), relations.size())+"</html>",
    7777                    tr("Confirmation"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE)) {
    78                 return;
    79             }
     78            return;
    8079        }
    8180        for (Relation r : relations) {
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r6797 r6806  
    524524
    525525        private boolean handleNetworkErrors() {
    526             boolean condition = !networkErrors.isEmpty();
     526            boolean condition = !NETWORK_ERRORS.isEmpty();
    527527            if (condition) {
    528528                Set<String> errors = new TreeSet<String>();
    529                 for (Throwable t : networkErrors.values()) {
     529                for (Throwable t : NETWORK_ERRORS.values()) {
    530530                    errors.add(t.toString());
    531531                }
     
    537537                                "It may result of a missing proxy configuration.<br>" +
    538538                                "Would you like to change your proxy settings now?",
    539                                 Utils.joinAsHtmlUnorderedList(networkErrors.keySet()),
     539                                Utils.joinAsHtmlUnorderedList(NETWORK_ERRORS.keySet()),
    540540                                Utils.joinAsHtmlUnorderedList(errors)
    541541                        ));
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java

    r6802 r6806  
    266266            } else {
    267267                // Do not suggest to keep all values in order to reduce the wrong usage of semicolon values, see #9104!
    268                 //decision.keepAll();
    269268            }
    270269        }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r6743 r6806  
    185185        @Override
    186186        protected String createInfoUrl(Object infoObject) {
    187             HistoryOsmPrimitive primitive = (HistoryOsmPrimitive) infoObject;
    188             return primitive.getUser() == null ? null : getBaseBrowseUrl() + "/user/" + primitive.getUser().getName();
     187            HistoryOsmPrimitive hp = (HistoryOsmPrimitive) infoObject;
     188            return hp.getUser() == null ? null : getBaseBrowseUrl() + "/user/" + hp.getUser().getName();
    189189        }
    190190
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r6805 r6806  
    538538                return s == null ? null : URLEncoder.encode(s, "UTF-8");
    539539            } catch (UnsupportedEncodingException ex) {
    540                 throw new RuntimeException();
     540                throw new RuntimeException(ex);
    541541            }
    542542        }
  • trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreference.java

    r6670 r6806  
    124124         * The unique instance.
    125125         */
    126         public final static RulePrefHelper INSTANCE = new RulePrefHelper();
     126        public static final RulePrefHelper INSTANCE = new RulePrefHelper();
    127127
    128128        /**
  • trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java

    r6756 r6806  
    7171        return result;
    7272    }
     73   
     74    private static class GeometryPrimitiveVisitor implements PrimitiveVisitor {
     75       
     76        private final JsonObjectBuilder geomObj;
     77       
     78        public GeometryPrimitiveVisitor(JsonObjectBuilder geomObj) {
     79            this.geomObj = geomObj;
     80        }
     81
     82        @Override
     83        public void visit(INode n) {
     84            geomObj.add("type", "Point");
     85            LatLon ll = n.getCoor();
     86            if (ll != null) {
     87                geomObj.add("coordinates", getCoorArray(n.getCoor()));
     88            }
     89        }
     90
     91        @Override
     92        public void visit(IWay w) {
     93            geomObj.add("type", "LineString");
     94            if (w instanceof Way) {
     95                JsonArrayBuilder array = Json.createArrayBuilder();
     96                for (Node n : ((Way)w).getNodes()) {
     97                    LatLon ll = n.getCoor();
     98                    if (ll != null) {
     99                        array.add(getCoorArray(ll));
     100                    }
     101                }
     102                geomObj.add("coordinates", array);
     103            }
     104        }
     105
     106        @Override
     107        public void visit(IRelation r) {
     108        }
     109
     110        private JsonArrayBuilder getCoorArray(LatLon c) {
     111            return Json.createArrayBuilder().add(c.lon()).add(c.lat());
     112        }
     113    }
    73114
    74115    protected static void appendPrimitive(OsmPrimitive p, JsonArrayBuilder array) {
     
    87128        // Geometry
    88129        final JsonObjectBuilder geomObj = Json.createObjectBuilder();
    89         p.accept(new PrimitiveVisitor() {
    90             @Override
    91             public void visit(INode n) {
    92                 geomObj.add("type", "Point");
    93                 LatLon ll = n.getCoor();
    94                 if (ll != null) {
    95                     geomObj.add("coordinates", getCoorArray(n.getCoor()));
    96                 }
    97             }
    98 
    99             @Override
    100             public void visit(IWay w) {
    101                 geomObj.add("type", "LineString");
    102                 if (w instanceof Way) {
    103                     JsonArrayBuilder array = Json.createArrayBuilder();
    104                     for (Node n : ((Way)w).getNodes()) {
    105                         LatLon ll = n.getCoor();
    106                         if (ll != null) {
    107                             array.add(getCoorArray(ll));
    108                         }
    109                     }
    110                     geomObj.add("coordinates", array);
    111                 }
    112             }
    113 
    114             @Override
    115             public void visit(IRelation r) {
    116             }
    117 
    118             private JsonArrayBuilder getCoorArray(LatLon c) {
    119                 return Json.createArrayBuilder().add(c.lon()).add(c.lat());
    120             }
    121         });
     130        p.accept(new GeometryPrimitiveVisitor(geomObj));
    122131
    123132        // Build primitive JSON object
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6798 r6806  
    6565    public static final Charset UTF_8 = Charset.forName("UTF-8");
    6666
     67    private static final int MILLIS_OF_SECOND = 1000;
     68    private static final int MILLIS_OF_MINUTE = 60000;
     69    private static final int MILLIS_OF_HOUR = 3600000;
     70    private static final int MILLIS_OF_DAY = 86400000;
     71
    6772    /**
    6873     * Tests whether {@code predicate} applies to at least one elements from {@code collection}.
     
    830835     */
    831836    public static String getDurationString(long elapsedTime) throws IllegalArgumentException {
    832         final int MILLIS_OF_SECOND = 1000;
    833         final int MILLIS_OF_MINUTE = 60000;
    834         final int MILLIS_OF_HOUR = 3600000;
    835         final int MILLIS_OF_DAY = 86400000;
    836837        if (elapsedTime < 0) {
    837838            throw new IllegalArgumentException("elapsedTime must be > 0");
Note: See TracChangeset for help on using the changeset viewer.