Changeset 11649 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2017-03-02T01:59:40+01:00 (7 years ago)
Author:
Don-vip
Message:

sonar - pmd:UseStringBufferForStringAppends

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

Legend:

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

    r11339 r11649  
    7070                        + "This may both clutter your screen with browser windows<br>"
    7171                        + "and take some time to finish.", numBrowsers, numBrowsers);
    72         msg = "<html>" + msg + "</html>";
    7372        ButtonSpec[] spec = new ButtonSpec[] {
    7473                new ButtonSpec(
     
    8887        return 0 == HelpAwareOptionPane.showOptionDialog(
    8988                Main.parent,
    90                 msg,
     89                new StringBuilder(msg).insert(0, "<html>").append("</html>").toString(),
    9190                tr("Warning"),
    9291                JOptionPane.WARNING_MESSAGE,
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r11619 r11649  
    859859     */
    860860    public String getToolTipText() {
    861         String res = getName();
     861        StringBuilder res = new StringBuilder(getName());
    862862        boolean html = false;
    863         String date = getDate();
    864         if (date != null && !date.isEmpty()) {
    865             res += "<br>" + tr("Date of imagery: {0}", date);
     863        String dateStr = getDate();
     864        if (dateStr != null && !dateStr.isEmpty()) {
     865            res.append("<br>").append(tr("Date of imagery: {0}", dateStr));
    866866            html = true;
    867867        }
    868868        if (bestMarked) {
    869             res += "<br>" + tr("This imagery is marked as best in this region in other editors.");
     869            res.append("<br>").append(tr("This imagery is marked as best in this region in other editors."));
    870870            html = true;
    871871        }
    872872        String desc = getDescription();
    873873        if (desc != null && !desc.isEmpty()) {
    874             res += "<br>" + desc;
     874            res.append("<br>").append(desc);
    875875            html = true;
    876876        }
    877877        if (html) {
    878             res = "<html>" + res + "</html>";
    879         }
    880         return res;
     878            res.insert(0, "<html>").append("</html>");
     879        }
     880        return res.toString();
    881881    }
    882882
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r11633 r11649  
    10551055        File file = getAssociatedFile();
    10561056        if (file == null && isRenamed()) {
    1057             String filename = Main.pref.get("lastDirectory") + '/' + getName();
    1058             if (!OsmImporter.FILE_FILTER.acceptName(filename))
    1059                 filename = filename + '.' + extension;
    1060             file = new File(filename);
     1057            StringBuilder filename = new StringBuilder(Main.pref.get("lastDirectory")).append('/').append(getName());
     1058            if (!OsmImporter.FILE_FILTER.acceptName(filename.toString())) {
     1059                filename.append('.').append(extension);
     1060            }
     1061            file = new File(filename.toString());
    10611062        }
    10621063        return new FileChooserManager()
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r11308 r11649  
    8989                String incomingData = ex3.getIncomingData().trim();
    9090                String title = tr("WMS Error");
    91                 String message = tr("Could not parse WMS layer list.");
     91                StringBuilder message = new StringBuilder(tr("Could not parse WMS layer list."));
    9292                Main.error(ex3, "Could not parse WMS layer list. Incoming data:\n"+incomingData);
    9393                if ((incomingData.startsWith("<html>") || incomingData.startsWith("<HTML>"))
    9494                  && (incomingData.endsWith("</html>") || incomingData.endsWith("</HTML>"))) {
    95                     GuiHelper.notifyUserHtmlError(this, title, message, incomingData);
     95                    GuiHelper.notifyUserHtmlError(this, title, message.toString(), incomingData);
    9696                } else {
    9797                    if (ex3.getMessage() != null) {
    98                         message += '\n' + ex3.getMessage();
     98                        message.append('\n').append(ex3.getMessage());
    9999                    }
    100                     JOptionPane.showMessageDialog(getParent(), message, title, JOptionPane.ERROR_MESSAGE);
     100                    JOptionPane.showMessageDialog(getParent(), message.toString(), title, JOptionPane.ERROR_MESSAGE);
    101101                }
    102102            }
  • trunk/src/org/openstreetmap/josm/io/XmlStreamParsingException.java

    r11553 r11649  
    4242        if (getLocation() == null)
    4343            return msg;
    44         msg += ' ' + tr("(at line {0}, column {1})", getLocation().getLineNumber(), getLocation().getColumnNumber());
     44        StringBuilder sb = new StringBuilder(msg).append(' ')
     45                .append(tr("(at line {0}, column {1})", getLocation().getLineNumber(), getLocation().getColumnNumber()));
    4546        int offset = getLocation().getCharacterOffset();
    4647        if (offset > -1) {
    47             msg += ". "+ tr("{0} bytes have been read", offset);
     48            sb.append(". ").append(tr("{0} bytes have been read", offset));
    4849        }
    49         return msg;
     50        return sb.toString();
    5051    }
    5152}
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r11620 r11649  
    789789                return null;
    790790
    791             String prefix = "";
    792             if (isDisabled)
    793                 prefix = "dis:"+prefix;
     791            String prefix = isDisabled ? "dis:" : "";
    794792            if (name.startsWith("data:")) {
    795793                String url = name;
  • trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java

    r10985 r11649  
    135135
    136136    private static String niceThreadName(Thread thread) {
    137         String name = "Thread: " + thread.getName() + " (" + thread.getId() + ')';
     137        StringBuilder name = new StringBuilder("Thread: ").append(thread.getName()).append(" (").append(thread.getId()).append(')');
    138138        ThreadGroup threadGroup = thread.getThreadGroup();
    139139        if (threadGroup != null) {
    140             name += " of " + threadGroup.getName();
    141         }
    142         return name;
     140            name.append(" of ").append(threadGroup.getName());
     141        }
     142        return name.toString();
    143143    }
    144144
Note: See TracChangeset for help on using the changeset viewer.