Changeset 10242 in josm


Ignore:
Timestamp:
2016-05-17T13:51:23+02:00 (4 years ago)
Author:
Don-vip
Message:

sonar - pmd:InsufficientStringBufferDeclaration - Insufficient String Buffer Declaration

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

Legend:

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

    r10212 r10242  
    183183
    184184        protected void alertFilesNotMatchingWithImporter(Collection<File> files, FileImporter importer) {
    185             final StringBuilder msg = new StringBuilder();
    186             msg.append("<html>").append(
    187                     trn(
    188                             "Cannot open {0} file with the file importer ''{1}''.",
    189                             "Cannot open {0} files with the file importer ''{1}''.",
    190                             files.size(),
    191                             files.size(),
    192                             importer.filter.getDescription()
     185            final StringBuilder msg = new StringBuilder(128).append("<html>").append(
     186                    trn("Cannot open {0} file with the file importer ''{1}''.",
     187                        "Cannot open {0} files with the file importer ''{1}''.",
     188                        files.size(),
     189                        files.size(),
     190                        importer.filter.getDescription()
    193191                    )
    194192            ).append("<br><ul>");
     
    196194                msg.append("<li>").append(f.getAbsolutePath()).append("</li>");
    197195            }
    198             msg.append("</ul>");
     196            msg.append("</ul></html>");
    199197
    200198            HelpAwareOptionPane.showMessageDialogInEDT(
     
    208206
    209207        protected void alertFilesWithUnknownImporter(Collection<File> files) {
    210             final StringBuilder msg = new StringBuilder();
    211             msg.append("<html>").append(
    212                     trn(
    213                             "Cannot open {0} file because file does not exist or no suitable file importer is available.",
    214                             "Cannot open {0} files because files do not exist or no suitable file importer is available.",
    215                             files.size(),
    216                             files.size()
     208            final StringBuilder msg = new StringBuilder(128).append("<html>").append(
     209                    trn("Cannot open {0} file because file does not exist or no suitable file importer is available.",
     210                        "Cannot open {0} files because files do not exist or no suitable file importer is available.",
     211                        files.size(),
     212                        files.size()
    217213                    )
    218214            ).append("<br><ul>");
     
    222218                   .append("</i>)</li>");
    223219            }
    224             msg.append("</ul>");
     220            msg.append("</ul></html>");
    225221
    226222            HelpAwareOptionPane.showMessageDialogInEDT(
     
    272268                                }
    273269                            });
    274                             // TODO when changing to Java 6: Don't cancel the
    275                             // task here but use different modality. (Currently 2 dialogs
     270                            // TODO when changing to Java 6: Don't cancel the task here but use different modality. (Currently 2 dialogs
    276271                            // would block each other.)
    277272                            return;
  • trunk/src/org/openstreetmap/josm/actions/SearchNotesDownloadAction.java

    r8855 r10242  
    7575    }
    7676
     77    /**
     78     * Perform search.
     79     * @param searchTerm search term
     80     */
    7781    public void performSearch(String searchTerm) {
    7882
    79         searchTerm = searchTerm.trim();
     83        String trimmedSearchTerm = searchTerm.trim();
    8084
    8185        try {
    82             final long id = Long.parseLong(searchTerm);
     86            final long id = Long.parseLong(trimmedSearchTerm);
    8387            new DownloadNotesTask().download(id, null);
    8488            return;
     
    9296        int closedLimit = Main.pref.getInteger("osm.notes.daysCloased", 7);
    9397
    94         StringBuilder sb = new StringBuilder();
     98        StringBuilder sb = new StringBuilder(128);
    9599        sb.append(OsmApi.getOsmApi().getBaseUrl())
    96100            .append("notes/search?limit=")
     
    99103            .append(closedLimit)
    100104            .append("&q=")
    101             .append(Utils.encodeUrl(searchTerm));
     105            .append(Utils.encodeUrl(trimmedSearchTerm));
    102106
    103107        new DownloadNotesTask().loadUrl(false, sb.toString(), null);
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r10226 r10242  
    7878     */
    7979    public static String getReportHeader() {
    80         StringBuilder text = new StringBuilder();
     80        StringBuilder text = new StringBuilder(256);
    8181        String runtimeVersion = System.getProperty("java.runtime.version");
    8282        text.append(Version.getInstance().getReleaseAttributes())
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java

    r10124 r10242  
    8484    @Override
    8585    public String acceptsDocumentationSummary() {
    86         StringBuilder buff = new StringBuilder("<tr><td>");
     86        StringBuilder buff = new StringBuilder(128).append("<tr><td>");
    8787        buff.append(getTitle())
    8888            .append(":</td><td>");
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r9979 r10242  
    267267    @Override
    268268    public String toString() {
    269         StringBuilder result = new StringBuilder();
     269        StringBuilder result = new StringBuilder(32);
    270270        result.append("{Relation id=")
    271271              .append(getUniqueId())
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java

    r9981 r10242  
    271271    @Override
    272272    public String toString() {
    273         StringBuilder buff = new StringBuilder("Headers  : ");
     273        StringBuilder buff = new StringBuilder(256).append("Headers  : ");
    274274        buff.append(overviewHeaderCount)
    275275            .append("\nSub Hdrs : ")
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java

    r9981 r10242  
    295295     */
    296296    public String getDetails() {
    297         StringBuilder buff = new StringBuilder("Sub Grid : ");
     297        StringBuilder buff = new StringBuilder(256).append("Sub Grid : ");
    298298        buff.append(subGridName)
    299299            .append("\nParent   : ")
  • trunk/src/org/openstreetmap/josm/data/validation/routines/RegexValidator.java

    r9922 r10242  
    219219    @Override
    220220    public String toString() {
    221         StringBuilder buffer = new StringBuilder();
     221        StringBuilder buffer = new StringBuilder(32);
    222222        buffer.append("RegexValidator{");
    223223        for (int i = 0; i < patterns.length; i++) {
  • trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java

    r10238 r10242  
    481481
    482482    private static String buildDefaultToolTip(long id, Map<String, String> tags) {
    483         StringBuilder sb = new StringBuilder();
     483        StringBuilder sb = new StringBuilder(128);
    484484        sb.append("<html><strong>id</strong>=")
    485485          .append(id)
  • trunk/src/org/openstreetmap/josm/gui/io/ChangesetCellRenderer.java

    r9078 r10242  
    3434
    3535    protected String buildToolTipText(Changeset cs) {
    36         StringBuilder sb = new StringBuilder();
     36        StringBuilder sb = new StringBuilder(64);
    3737        sb.append("<html><strong>").append(tr("Changeset id:")).append("</strong>").append(cs.getId()).append("<br>");
    3838        if (cs.getCreatedAt() != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r10240 r10242  
    379379
    380380    @Override
    381 
    382381    public String toString() {
    383         StringBuilder s = new StringBuilder("NodeElemStyle{");
     382        StringBuilder s = new StringBuilder(64).append("NodeElemStyle{");
    384383        s.append(super.toString());
    385384        if (mapImage != null) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r10235 r10242  
    15141514            if (entry == null)
    15151515                return null;
    1516             StringBuilder s = new StringBuilder("<html><b>");
     1516            StringBuilder s = new StringBuilder(128).append("<html><b>");
    15171517            if (entry.title != null) {
    15181518                s.append(entry.title).append("</b> <span color=\"gray\">");
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java

    r9059 r10242  
    164164
    165165        private static JComponent build() {
    166             StringBuilder s = new StringBuilder();
     166            StringBuilder s = new StringBuilder(1024);
    167167            s.append("<b>+proj=...</b> - <i>").append(tr("Projection name"))
    168168             .append("</i><br>&nbsp;&nbsp;&nbsp;&nbsp;").append(tr("Supported values:")).append(' ')
  • trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java

    r10006 r10242  
    4545    protected final InputStream getChangesetInputStream(long id, boolean includeDiscussion, ProgressMonitor monitor)
    4646            throws OsmTransferException {
    47         StringBuilder sb = new StringBuilder();
    48         sb.append("changeset/").append(id);
     47        StringBuilder sb = new StringBuilder(48).append("changeset/").append(id);
    4948        if (includeDiscussion) {
    5049            sb.append("?include_discussion=true");
     
    201200        try {
    202201            monitor.beginTask(tr("Downloading changeset content"));
    203             StringBuilder sb = new StringBuilder();
    204             sb.append("changeset/").append(id).append("/download");
     202            StringBuilder sb = new StringBuilder(32).append("changeset/").append(id).append("/download");
    205203            try (InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true))) {
    206204                if (in == null)
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r9543 r10242  
    9999
    100100        private String getToolTip() {
    101             StringBuilder sb = new StringBuilder();
     101            StringBuilder sb = new StringBuilder(64);
    102102            sb.append("<html>")
    103103              .append(tr("Old values of"))
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10238 r10242  
    919919
    920920    private static void alertFailedPluginUpdate(Component parent, Collection<PluginInformation> plugins) {
    921         StringBuilder sb = new StringBuilder();
     921        StringBuilder sb = new StringBuilder(128);
    922922        sb.append("<html>")
    923923          .append(trn(
     
    12961296        };
    12971297
    1298         final StringBuilder msg = new StringBuilder();
     1298        final StringBuilder msg = new StringBuilder(256);
    12991299        msg.append("<html>")
    13001300           .append(tr("An unexpected exception occurred that may have come from the ''{0}'' plugin.", plugin.getPluginInformation().name))
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r10178 r10242  
    323323            canHtml = false;
    324324        }
    325         StringBuilder result = new StringBuilder();
     325        StringBuilder result = new StringBuilder(48);
    326326        if (canHtml) {
    327327            result.append("<html>");
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r10200 r10242  
    262262     */
    263263    public void remember(String preferenceKey) {
    264         StringBuilder value = new StringBuilder();
     264        StringBuilder value = new StringBuilder(32);
    265265        value.append("x=").append(topLeft.x).append(",y=").append(topLeft.y)
    266266             .append(",width=").append(extent.width).append(",height=").append(extent.height);
Note: See TracChangeset for help on using the changeset viewer.