Ignore:
Timestamp:
2015-10-10T14:08:30+02:00 (9 years ago)
Author:
Don-vip
Message:

sonar - squid:S2131 - Primitives should not be boxed just for "String" conversion

Location:
trunk/src/org/openstreetmap/josm/data
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r8846 r8848  
    296296        @Override
    297297        public String toString() {
    298             String s = "ImageryPreferenceEntry [name=" + name;
     298            StringBuilder s = new StringBuilder("ImageryPreferenceEntry [name=").append(name);
    299299            if (id != null) {
    300                 s += " id=" + id;
    301             }
    302             s += ']';
    303             return s;
     300                s.append(" id=").append(id);
     301            }
     302            s.append(']');
     303            return s.toString();
    304304        }
    305305    }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r8846 r8848  
    131131    protected EditableList sourcesList;
    132132
    133     protected static final Entities entities = new Entities();
    134 
    135133    private static final List<String> DEFAULT_SOURCES = Arrays.asList(/*DATA_FILE, */IGNORE_FILE, SPELL_FILE);
    136134
     
    371369                withErrors.put(p, "SPACE");
    372370            }
    373             if (checkValues && value != null && !value.equals(entities.unescape(value)) && !withErrors.contains(p, "HTML")) {
     371            if (checkValues && value != null && !value.equals(Entities.unescape(value)) && !withErrors.contains(p, "HTML")) {
    374372                errors.add(new TestError(this, Severity.OTHER, tr("Property values contain HTML entity"),
    375373                        tr(s, key), MessageFormat.format(s, key), INVALID_HTML, p));
     
    620618                        commands.add(new ChangePropertyKeyCommand(p, key, Tag.removeWhiteSpaces(key)));
    621619                    } else {
    622                         String evalue = entities.unescape(value);
     620                        String evalue = Entities.unescape(value);
    623621                        if (!evalue.equals(value)) {
    624622                            commands.add(new ChangePropertyCommand(p, key, evalue));
  • trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java

    r8840 r8848  
    3131 * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML 4.01 Code positions</a>
    3232 */
    33 public class Entities {
     33public final class Entities {
    3434    private static final String[][] ARRAY = {
    3535        /* BASIC */
     
    336336    private static volatile Map<String, String> mapNameToValue;
    337337
    338     public String unescape(String str) {
     338    private Entities() {
     339        // Private constructor for utilities classes
     340    }
     341
     342    public static String unescape(String str) {
    339343        int firstAmp = str.indexOf('&');
    340344        if (firstAmp < 0)
    341345            return str;
    342         String res = str.substring(0, firstAmp);
     346        StringBuilder res = new StringBuilder(str.substring(0, firstAmp));
    343347        int len = str.length();
    344348        for (int i = firstAmp; i < len; i++) {
     
    348352                int semiColonIdx = str.indexOf(';', nextIdx);
    349353                if (semiColonIdx == -1) {
    350                     res += c;
     354                    res.append(c);
    351355                    continue;
    352356                }
     
    354358                if (amphersandIdx != -1 && amphersandIdx < semiColonIdx) {
    355359                    // Then the text looks like &...&...;
    356                     res += c;
     360                    res.append(c);
    357361                    continue;
    358362                }
     
    394398
    395399                if (entityValue == -1) {
    396                     res += '&' + entityContent + ';';
     400                    res.append('&').append(entityContent).append(';');
    397401                } else {
    398                     res += (char) entityValue;
     402                    res.append((char) entityValue);
    399403                }
    400404                i = semiColonIdx; // move index up to the semi-colon
    401405            } else {
    402                 res += c;
     406                res.append(c);
    403407            }
    404408        }
    405         return res;
     409        return res.toString();
    406410    }
    407411}
Note: See TracChangeset for help on using the changeset viewer.