Changeset 8394 in josm for trunk/src


Ignore:
Timestamp:
2015-05-18T23:34:11+02:00 (9 years ago)
Author:
Don-vip
Message:
  • global use of String.isEmpty()
  • Correctness - Method throws alternative exception from catch block without history
Location:
trunk/src/org/openstreetmap/josm
Files:
38 edited

Legend:

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

    r8390 r8394  
    137137            if (dataset != null) {
    138138                String result = DatasetConsistencyTest.runTests(dataset);
    139                 if (result.length() == 0) {
     139                if (result.isEmpty()) {
    140140                    text.append("Dataset consistency test: No problems found\n");
    141141                } else {
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r8379 r8394  
    625625
    626626        public static SearchSetting readFromString(String s) {
    627             if (s.length() == 0)
     627            if (s.isEmpty())
    628628                return null;
    629629
     
    664664
    665665        public String writeToString() {
    666             if (text == null || text.length() == 0)
     666            if (text == null || text.isEmpty())
    667667                return "";
    668668
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r8250 r8394  
    619619                    keyPattern = Pattern.compile(key, regexFlags(false));
    620620                } catch (PatternSyntaxException e) {
    621                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()));
     621                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    622622                } catch (Exception e) {
    623                     throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()));
     623                    throw new ParseError(tr(rxErrorMsgNoPos, key, e.getMessage()), e);
    624624                }
    625625            } else {
     
    630630                    valuePattern = Pattern.compile(this.value, regexFlags(false));
    631631                } catch (PatternSyntaxException e) {
    632                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()));
     632                    throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
    633633                } catch (Exception e) {
    634                     throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()));
     634                    throw new ParseError(tr(rxErrorMsgNoPos, value, e.getMessage()), e);
    635635                }
    636636            } else {
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r8390 r8394  
    604604                return; // some basic protection
    605605            }
    606             if (address == null || path == null || address.length() == 0 || path.length() == 0) {
     606            if (address == null || path == null || address.isEmpty() || path.isEmpty()) {
    607607                log("Error: Please specify url=\"where to get file\" and path=\"where to place it\"");
    608608                return;
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r8390 r8394  
    769769     */
    770770    public boolean put(final String key, String value) {
    771         if(value != null && value.length() == 0) {
     771        if(value != null && value.isEmpty()) {
    772772            value = null;
    773773        }
  • trunk/src/org/openstreetmap/josm/data/imagery/Shape.java

    r8291 r8394  
    7272                throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", lat));
    7373        } catch (NumberFormatException e) {
    74             throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", sLat));
     74            throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", sLat), e);
    7575        }
    7676
     
    8080                throw new IllegalArgumentException(tr("Illegal longitude value ''{0}''", lon));
    8181        } catch (NumberFormatException e) {
    82             throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", sLon));
     82            throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", sLon), e);
    8383        }
    8484
  • trunk/src/org/openstreetmap/josm/data/validation/routines/RegexValidator.java

    r8390 r8394  
    109109        int flags = caseSensitive ? 0: Pattern.CASE_INSENSITIVE;
    110110        for (int i = 0; i < regexs.length; i++) {
    111             if (regexs[i] == null || regexs[i].length() == 0) {
     111            if (regexs[i] == null || regexs[i].isEmpty()) {
    112112                throw new IllegalArgumentException("Regular expression[" + i + "] is missing");
    113113            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r8378 r8394  
    354354                withErrors.put(p, "LK");
    355355            }
    356             if (checkValues && (value==null || value.trim().length() == 0) && !withErrors.contains(p, "EV")) {
     356            if (checkValues && (value==null || value.trim().isEmpty()) && !withErrors.contains(p, "EV")) {
    357357                errors.add( new TestError(this, Severity.WARNING, tr("Tags with empty values"),
    358358                        tr(s, key), MessageFormat.format(s, key), EMPTY_VALUES, p) );
     
    563563                String key = prop.getKey();
    564564                String value = prop.getValue();
    565                 if (value == null || value.trim().length() == 0) {
     565                if (value == null || value.trim().isEmpty()) {
    566566                    commands.add(new ChangePropertyCommand(p, key, null));
    567567                } else if (value.startsWith(" ") || value.endsWith(" ")) {
     
    679679            try {
    680680                description = m.group(1);
    681                 if (description != null && description.length() == 0) {
     681                if (description != null && description.isEmpty()) {
    682682                    description = null;
    683683                }
  • trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    r8390 r8394  
    274274                }
    275275                if(n == null && way.get("building") != null) n = tr("building");
    276                 if(n == null || n.length() == 0) {
     276                if(n == null || n.isEmpty()) {
    277277                    n = String.valueOf(way.getId());
    278278                }
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r8380 r8394  
    10131013            }
    10141014            currentSearchText = searchTerm;
    1015             if (searchTerm.length() == 0) {
     1015            if (searchTerm.isEmpty()) {
    10161016                // No text to search
    10171017                hideMenu();
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

    r8376 r8394  
    111111    @Override
    112112    public void setCustomText(String text) {
    113         if(text == null || text.trim().length() == 0) {
     113        if(text == null || text.trim().isEmpty()) {
    114114            customText.setVisible(false);
    115115            adjustLayout();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/AdvancedChangesetQueryPanel.java

    r8308 r8394  
    984984        public void validate() {
    985985            String value  = getComponent().getText();
    986             if (value == null || value.trim().length() == 0) {
     986            if (value == null || value.trim().isEmpty()) {
    987987                feedbackInvalid("");
    988988                return;
     
    10031003        public int getUid() {
    10041004            String value  = getComponent().getText();
    1005             if (value == null || value.trim().length() == 0) return 0;
     1005            if (value == null || value.trim().isEmpty()) return 0;
    10061006            try {
    10071007                int uid = Integer.parseInt(value.trim());
     
    10311031        public void validate() {
    10321032            String value  = getComponent().getText();
    1033             if (value.trim().length() == 0) {
     1033            if (value.trim().isEmpty()) {
    10341034                feedbackInvalid(tr("<html>The  current value is not a valid user name.<br>Please enter an non-empty user name.</html>"));
    10351035                return;
     
    11201120        @Override
    11211121        public boolean isValid() {
    1122             if (getComponent().getText().trim().length() == 0) return true;
     1122            if (getComponent().getText().trim().isEmpty()) return true;
    11231123            return getDate() != null;
    11241124        }
     
    11571157
    11581158        public Date getDate() {
    1159             if (getComponent().getText().trim().length() == 0)
     1159            if (getComponent().getText().trim().isEmpty())
    11601160                return null;
    11611161
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r8390 r8394  
    296296        @Override
    297297        public void actionPerformed(ActionEvent e) {
    298             if (!isEnabled() || cbSearchExpression.getText().trim().length() == 0)
     298            if (!isEnabled() || cbSearchExpression.getText().trim().isEmpty())
    299299                return;
    300300            cbSearchExpression.addCurrentItemToHistory();
  • trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java

    r7862 r8394  
    144144    public static String buildAbsoluteHelpTopic(String topic, LocaleType type) {
    145145        String prefix = getHelpTopicPrefix(type);
    146         if (prefix == null || topic == null || topic.trim().length() == 0 || "/".equals(topic.trim()))
     146        if (prefix == null || topic == null || topic.trim().isEmpty() || "/".equals(topic.trim()))
    147147            return prefix;
    148148        prefix += "/" + topic;
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java

    r7937 r8394  
    5454
    5555    private static class DownloadException extends Exception {
    56         public DownloadException(String msg) {
    57             super(msg);
     56        /**
     57         * Constructs a new {@code DownloadException}.
     58         * @param message the detail message. The detail message is saved for
     59         *          later retrieval by the {@link #getMessage()} method.
     60         * @param  cause the cause (which is saved for later retrieval by the
     61         *         {@link #getCause()} method).  (A <tt>null</tt> value is
     62         *         permitted, and indicates that the cause is nonexistent or unknown.)
     63         */
     64        public DownloadException(String message, Throwable cause) {
     65            super(message, cause);
    5866        }
    5967    }
     
    133141            String msg = tr("Cannot download file ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", file.getName(), address);
    134142            Main.warn(msg);
    135             throw new DownloadException(msg);
     143            throw new DownloadException(msg, e);
    136144        } catch (IOException e) {
    137145            if (canceled)
    138146                return;
    139             throw new DownloadException(e.getMessage());
     147            throw new DownloadException(e.getMessage(), e);
    140148        } finally {
    141149            closeConnectionIfNeeded();
  • trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java

    r8390 r8394  
    120120                    sb.append("<hr/>");
    121121                    String userName = XmlWriter.encode(comment.getUser().getName());
    122                     if (userName == null || userName.trim().length() == 0) {
     122                    if (userName == null || userName.trim().isEmpty()) {
    123123                        userName = "&lt;Anonymous&gt;";
    124124                    }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r8378 r8394  
    811811        public void actionPerformed(ActionEvent e) {
    812812            String result = DatasetConsistencyTest.runTests(data);
    813             if (result.length() == 0) {
     813            if (result.isEmpty()) {
    814814                JOptionPane.showMessageDialog(Main.parent, tr("No problems found"));
    815815            } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r8393 r8394  
    317317            String tzId = Main.pref.get("geoimage.timezoneid", "");
    318318            TimeZone defaultTz;
    319             if (tzId.length() == 0) {
     319            if (tzId.isEmpty()) {
    320320                defaultTz = TimeZone.getDefault();
    321321            } else {
     
    13081308    private double parseTimezone(String timezone) throws ParseException {
    13091309
     1310        if (timezone.isEmpty())
     1311            return 0;
     1312
    13101313        String error = tr("Error while parsing timezone.\nExpected format: {0}", "+H:MM");
    1311 
    1312         if (timezone.length() == 0)
    1313             return 0;
    13141314
    13151315        char sgnTimezone = '+';
     
    13221322            case ' ' :
    13231323                if (state != 2 || hTimezone.length() != 0)
    1324                     throw new ParseException(error,0);
     1324                    throw new ParseException(error, i);
    13251325                break;
    13261326            case '+' :
     
    13301330                    state = 2;
    13311331                } else
    1332                     throw new ParseException(error,0);
     1332                    throw new ParseException(error, i);
    13331333                break;
    13341334            case ':' :
     
    13371337                    state = 3;
    13381338                } else
    1339                     throw new ParseException(error,0);
     1339                    throw new ParseException(error, i);
    13401340                break;
    13411341            case '0' : case '1' : case '2' : case '3' : case '4' :
     
    13511351                    break;
    13521352                default :
    1353                     throw new ParseException(error,0);
     1353                    throw new ParseException(error, i);
    13541354                }
    13551355                break;
    13561356            default :
    1357                 throw new ParseException(error,0);
     1357                throw new ParseException(error, i);
    13581358            }
    13591359        }
     
    13681368        } catch (NumberFormatException nfe) {
    13691369            // Invalid timezone
    1370             throw new ParseException(error,0);
    1371         }
    1372 
    1373         if (h > 12 || m > 59 )
    1374             throw new ParseException(error,0);
     1370            throw new ParseException(error, 0);
     1371        }
     1372
     1373        if (h > 12 || m > 59)
     1374            throw new ParseException(error, 0);
    13751375        else
    13761376            return (h + m / 60.0) * (sgnTimezone == '-' ? -1 : 1);
     
    13801380        String error = tr("Error while parsing offset.\nExpected format: {0}", "number");
    13811381
    1382         if (offset.length() > 0) {
     1382        if (!offset.isEmpty()) {
    13831383            try {
    13841384                if(offset.startsWith("+")) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r8097 r8394  
    224224
    225225            /* non-prefixed path is generic path, always take it */
    226             if(a[0].length() == 0 || source.getPrefName().equals(a[0])) {
     226            if(a[0].isEmpty() || source.getPrefName().equals(a[0])) {
    227227                dirs.add(a[1]);
    228228            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r8390 r8394  
    703703
    704704    private static void prepareFileChooser(String url, AbstractFileChooser fc) {
    705         if (url == null || url.trim().length() == 0) return;
     705        if (url == null || url.trim().isEmpty()) return;
    706706        URL sourceUrl = null;
    707707        try {
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r8390 r8394  
    780780                LAST_VALUES.put(key, v);
    781781            }
    782             if (v.equals(originalValue) || (originalValue == null && v.length() == 0))
     782            if (v.equals(originalValue) || (originalValue == null && v.isEmpty()))
    783783                return;
    784784
     
    11561156            // no change if same as before
    11571157            if (originalValue == null) {
    1158                 if (value.length() == 0)
     1158                if (value.isEmpty())
    11591159                    return;
    11601160            } else if (value.equals(originalValue.toString()))
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java

    r8308 r8394  
    8181                try {
    8282                    Long.parseLong(str);
    83                     if (currentText.length() == 0) {
     83                    if (currentText.isEmpty()) {
    8484                        // we don't autocomplete on numbers
    8585                        super.insertString(offs, str, a);
  • trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java

    r8378 r8394  
    3939     */
    4040    public static RotationAngle buildStaticRotation(final String string) {
    41         final double value;
    4241        try {
    43             value = parseCardinalRotation(string);
    44         } catch (IllegalArgumentException ignore) {
    45             throw new IllegalArgumentException("Invalid string: " + string);
     42            return buildStaticRotation(parseCardinalRotation(string));
     43        } catch (IllegalArgumentException e) {
     44            throw new IllegalArgumentException("Invalid string: " + string, e);
    4645        }
    47         return buildStaticRotation(value);
    4846    }
    4947
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r8390 r8394  
    315315
    316316        /**
     317         * Constructs a new {@code ChangesetQueryUrlException} with the specified cause and detail message.
     318         *
     319         * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
     320         * @param  cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
     321         *         (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.)
     322         */
     323        public ChangesetQueryUrlException(String message, Throwable cause) {
     324            super(message, cause);
     325        }
     326
     327        /**
    317328         * Constructs a new {@code ChangesetQueryUrlException} with the specified cause and a detail message of
    318329         * <tt>(cause==null ? null : cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>).
     
    329340        protected int parseUid(String value) throws ChangesetQueryUrlException {
    330341            if (value == null || value.trim().isEmpty())
    331                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
     342                throw new ChangesetQueryUrlException(
     343                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
    332344            int id;
    333345            try {
    334346                id = Integer.parseInt(value);
    335347                if (id <= 0)
    336                     throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
     348                    throw new ChangesetQueryUrlException(
     349                            tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
    337350            } catch(NumberFormatException e) {
    338                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value));
     351                throw new ChangesetQueryUrlException(
     352                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "uid", value), e);
    339353            }
    340354            return id;
     
    343357        protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException {
    344358            if (value == null || value.trim().isEmpty())
    345                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
     359                throw new ChangesetQueryUrlException(
     360                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
    346361            switch (value) {
    347362            case "true":
     
    350365                return false;
    351366            default:
    352                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
     367                throw new ChangesetQueryUrlException(
     368                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
    353369            }
    354370        }
     
    356372        protected Date parseDate(String value, String parameter) throws ChangesetQueryUrlException {
    357373            if (value == null || value.trim().isEmpty())
    358                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
     374                throw new ChangesetQueryUrlException(
     375                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
    359376            DateFormat formatter = DateUtils.newIsoDateTimeFormat();
    360377            try {
    361378                return formatter.parse(value);
    362379            } catch(ParseException e) {
    363                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value));
     380                throw new ChangesetQueryUrlException(
     381                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter, value), e);
    364382            }
    365383        }
     
    368386            String[] dates = value.split(",");
    369387            if (dates == null || dates.length == 0 || dates.length > 2)
    370                 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "time", value));
     388                throw new ChangesetQueryUrlException(
     389                        tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "time", value));
    371390            if (dates.length == 1)
    372391                return new Date[]{parseDate(dates[0], "time")};
     
    395414                case "uid":
    396415                    if (queryParams.containsKey("display_name"))
    397                         throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
     416                        throw new ChangesetQueryUrlException(
     417                                tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
    398418                    csQuery.forUser(parseUid(queryParams.get("uid")));
    399419                    break;
    400420                case "display_name":
    401421                    if (queryParams.containsKey("uid"))
    402                         throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
     422                        throw new ChangesetQueryUrlException(
     423                                tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
    403424                    csQuery.forUser(queryParams.get("display_name"));
    404425                    break;
     
    435456                    break;
    436457                default:
    437                     throw new ChangesetQueryUrlException(tr("Unsupported parameter ''{0}'' in changeset query string", k));
     458                    throw new ChangesetQueryUrlException(
     459                            tr("Unsupported parameter ''{0}'' in changeset query string", k));
    438460                }
    439461            }
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r7187 r8394  
    111111    public final void initFromPreferences() {
    112112        String value = Main.pref.get(ProxyPreferencesPanel.PROXY_POLICY);
    113         if (value.length() == 0) {
     113        if (value.isEmpty()) {
    114114            proxyPolicy = ProxyPolicy.NO_PROXY;
    115115        } else {
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r8390 r8394  
    361361            osm.setChangesetId(getChangeset().getId());
    362362        } catch(NumberFormatException e){
    363             throw new OsmTransferException(tr("Unexpected format of ID replied by the server. Got ''{0}''.", ret));
     363            throw new OsmTransferException(tr("Unexpected format of ID replied by the server. Got ''{0}''.", ret), e);
    364364        }
    365365    }
     
    384384        } catch(NumberFormatException e) {
    385385            throw new OsmTransferException(tr("Unexpected format of new version of modified primitive ''{0}''. Got ''{1}''.",
    386                     osm.getId(), ret));
     386                    osm.getId(), ret), e);
    387387        }
    388388    }
     
    427427                changeset.setOpen(true);
    428428            } catch(NumberFormatException e){
    429                 throw new OsmTransferException(tr("Unexpected format of ID replied by the server. Got ''{0}''.", ret));
     429                throw new OsmTransferException(tr("Unexpected format of ID replied by the server. Got ''{0}''.", ret), e);
    430430            }
    431431            progressMonitor.setCustomText(tr("Successfully opened changeset {0}",changeset.getId()));
  • trunk/src/org/openstreetmap/josm/io/OsmChangeImporter.java

    r6716 r8394  
    3535    }
    3636
    37     @Override public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
     37    @Override
     38    public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
    3839        try {
    3940            importData(Compression.getUncompressedFileInputStream(file), file, progressMonitor);
    4041        } catch (FileNotFoundException e) {
    4142            Main.error(e);
    42             throw new IOException(tr("File ''{0}'' does not exist.", file.getName()));
     43            throw new IOException(tr("File ''{0}'' does not exist.", file.getName()), e);
    4344        }
    4445    }
  • trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java

    r7509 r8394  
    5252                userInfo.setId(Integer.parseInt(v));
    5353            } catch(NumberFormatException e) {
    54                 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "id", "user", v));
     54                throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "id", "user", v), e);
    5555            }
    5656            // -- display name
     
    7777                    lat = Double.parseDouble(v);
    7878                } catch(NumberFormatException e) {
    79                     throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lat", "home", v));
     79                    throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.",
     80                            "lat", "home", v), e);
    8081                }
    8182
     
    8788                    lon = Double.parseDouble(v);
    8889                } catch(NumberFormatException e) {
    89                     throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lon", "home", v));
     90                    throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.",
     91                            "lon", "home", v), e);
    9092                }
    9193
     
    9799                    zoom = Integer.parseInt(v);
    98100                } catch(NumberFormatException e) {
    99                     throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "zoom", "home", v));
     101                    throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.",
     102                            "zoom", "home", v), e);
    100103                }
    101104                userInfo.setHome(new LatLon(lat,lon));
  • trunk/src/org/openstreetmap/josm/io/ProgressInputStream.java

    r6380 r8394  
    3838            progressMonitor.finishTask();
    3939            if (con.getHeaderField("Error") != null)
    40                 throw new OsmTransferException(tr(con.getHeaderField("Error")));
     40                throw new OsmTransferException(tr(con.getHeaderField("Error")), e);
    4141            throw new OsmTransferException(e);
    4242        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/DNSName.java

    r8291 r8394  
    7171     */
    7272    public DNSName(String name) throws IOException {
    73         if (name == null || name.length() == 0)
     73        if (name == null || name.isEmpty())
    7474            throw new IOException("DNS name must not be null");
    7575        if (name.indexOf(' ') != -1)
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java

    r7937 r8394  
    3030    private double lat;
    3131    private double lon;
    32    
     32
    3333    private Node node;
    3434
     
    4747        return new String[] { "lat", "lon" };
    4848    }
    49    
     49
    5050    @Override
    5151    public String[] getOptionalParams()
     
    6363        return new String[] {
    6464            "/add_node?lat=11&lon=22",
    65             "/add_node?lon=13.3&lat=53.2&addtags=natural=tree|name=%20%20%20==Great%20Oak==" 
     65            "/add_node?lon=13.3&lat=53.2&addtags=natural=tree|name=%20%20%20==Great%20Oak=="
    6666        };
    6767    }
    68    
     68
    6969    @Override
    7070    public String getPermissionMessage() {
     
    122122            lon = Double.parseDouble(args.get("lon"));
    123123        } catch (NumberFormatException e) {
    124             throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")");
     124            throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")", e);
    125125        }
    126126        if (!Main.main.hasEditLayer()) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java

    r8332 r8394  
    104104                allCoordinates.add(new LatLon(lat, lon));
    105105            } catch (NumberFormatException e) {
    106                 throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")");
     106                throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")", e);
    107107            }
    108108        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r8318 r8394  
    272272            maxlon = LatLon.roundToOsmPrecision(Double.parseDouble(args.get("right")));
    273273        } catch (NumberFormatException e) {
    274             throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")");
     274            throw new RequestHandlerBadRequestException("NumberFormatException ("+e.getMessage()+")", e);
    275275        }
    276276
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r8338 r8394  
    223223        if(mandatory != null) for (String key : mandatory) {
    224224            String value = args.get(key);
    225             if ((value == null) || (value.length() == 0)) {
     225            if (value == null || value.isEmpty()) {
    226226                error = true;
    227227                Main.warn("'" + myCommand + "' remote control request must have '" + key + "' parameter");
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r8390 r8394  
    179179                    return new BufferedInputStream(new FileInputStream(file));
    180180                } catch (FileNotFoundException e) {
    181                     throw new IOException(tr("File ''{0}'' does not exist.", file.getPath()));
     181                    throw new IOException(tr("File ''{0}'' does not exist.", file.getPath()), e);
    182182                }
    183183            } else if (inZipPath != null) {
  • trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java

    r8291 r8394  
    137137            }
    138138        } catch (MalformedURLException e) {
    139             String msg = tr("Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.", pi.name, pi.downloadlink);
     139            String msg = tr("Cannot download plugin ''{0}''. Its download link ''{1}'' is not a valid URL. Skipping download.",
     140                    pi.name, pi.downloadlink);
    140141            Main.warn(msg);
    141             throw new PluginDownloadException(msg);
     142            throw new PluginDownloadException(msg, e);
    142143        } catch (IOException e) {
    143144            if (canceled)
  • trunk/src/org/openstreetmap/josm/tools/CopyList.java

    r8285 r8394  
    178178            } catch (IndexOutOfBoundsException e) {
    179179                checkForComodification();
    180                 throw new NoSuchElementException();
     180                throw new NoSuchElementException(e.getMessage());
    181181            }
    182182        }
     
    196196                expectedModCount = modCount;
    197197            } catch (IndexOutOfBoundsException e) {
    198                 throw new ConcurrentModificationException();
     198                throw new ConcurrentModificationException(e);
    199199            }
    200200        }
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r8390 r8394  
    153153            Matcher m = p.matcher(preferenceValue);
    154154            if (!m.find())
    155                 throw new WindowGeometryException(tr("Preference with key ''{0}'' does not include ''{1}''. Cannot restore window geometry from preferences.", preferenceKey, field));
     155                throw new WindowGeometryException(
     156                        tr("Preference with key ''{0}'' does not include ''{1}''. Cannot restore window geometry from preferences.",
     157                                preferenceKey, field));
    156158            v = m.group(1);
    157159            return Integer.parseInt(v);
     
    159161            throw e;
    160162        } catch(NumberFormatException e) {
    161             throw new WindowGeometryException(tr("Preference with key ''{0}'' does not provide an int value for ''{1}''. Got {2}. Cannot restore window geometry from preferences.", preferenceKey, field, v));
     163            throw new WindowGeometryException(
     164                    tr("Preference with key ''{0}'' does not provide an int value for ''{1}''. Got {2}. Cannot restore window geometry from preferences.",
     165                            preferenceKey, field, v), e);
    162166        } catch(Exception e) {
    163             throw new WindowGeometryException(tr("Failed to parse field ''{1}'' in preference with key ''{0}''. Exception was: {2}. Cannot restore window geometry from preferences.", preferenceKey, field, e.toString()), e);
     167            throw new WindowGeometryException(
     168                    tr("Failed to parse field ''{1}'' in preference with key ''{0}''. Exception was: {2}. Cannot restore window geometry from preferences.",
     169                            preferenceKey, field, e.toString()), e);
    164170        }
    165171    }
     
    168174        String value = Main.pref.get(preferenceKey);
    169175        if (value == null || value.isEmpty())
    170             throw new WindowGeometryException(tr("Preference with key ''{0}'' does not exist. Cannot restore window geometry from preferences.", preferenceKey));
     176            throw new WindowGeometryException(
     177                    tr("Preference with key ''{0}'' does not exist. Cannot restore window geometry from preferences.", preferenceKey));
    171178        topLeft = new Point();
    172179        extent = new Dimension();
Note: See TracChangeset for help on using the changeset viewer.