Changeset 8848 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2015-10-10T14:08:30+02:00 (9 years ago)
- 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 296 296 @Override 297 297 public String toString() { 298 String s ="ImageryPreferenceEntry [name="+ name;298 StringBuilder s = new StringBuilder("ImageryPreferenceEntry [name=").append(name); 299 299 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(); 304 304 } 305 305 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r8846 r8848 131 131 protected EditableList sourcesList; 132 132 133 protected static final Entities entities = new Entities();134 135 133 private static final List<String> DEFAULT_SOURCES = Arrays.asList(/*DATA_FILE, */IGNORE_FILE, SPELL_FILE); 136 134 … … 371 369 withErrors.put(p, "SPACE"); 372 370 } 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")) { 374 372 errors.add(new TestError(this, Severity.OTHER, tr("Property values contain HTML entity"), 375 373 tr(s, key), MessageFormat.format(s, key), INVALID_HTML, p)); … … 620 618 commands.add(new ChangePropertyKeyCommand(p, key, Tag.removeWhiteSpaces(key))); 621 619 } else { 622 String evalue = entities.unescape(value);620 String evalue = Entities.unescape(value); 623 621 if (!evalue.equals(value)) { 624 622 commands.add(new ChangePropertyCommand(p, key, evalue)); -
trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java
r8840 r8848 31 31 * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML 4.01 Code positions</a> 32 32 */ 33 public class Entities { 33 public final class Entities { 34 34 private static final String[][] ARRAY = { 35 35 /* BASIC */ … … 336 336 private static volatile Map<String, String> mapNameToValue; 337 337 338 public String unescape(String str) { 338 private Entities() { 339 // Private constructor for utilities classes 340 } 341 342 public static String unescape(String str) { 339 343 int firstAmp = str.indexOf('&'); 340 344 if (firstAmp < 0) 341 345 return str; 342 String res =str.substring(0, firstAmp);346 StringBuilder res = new StringBuilder(str.substring(0, firstAmp)); 343 347 int len = str.length(); 344 348 for (int i = firstAmp; i < len; i++) { … … 348 352 int semiColonIdx = str.indexOf(';', nextIdx); 349 353 if (semiColonIdx == -1) { 350 res += c;354 res.append(c); 351 355 continue; 352 356 } … … 354 358 if (amphersandIdx != -1 && amphersandIdx < semiColonIdx) { 355 359 // Then the text looks like &...&...; 356 res += c;360 res.append(c); 357 361 continue; 358 362 } … … 394 398 395 399 if (entityValue == -1) { 396 res += '&' +entityContent+ ';';400 res.append('&').append(entityContent).append(';'); 397 401 } else { 398 res +=(char) entityValue;402 res.append((char) entityValue); 399 403 } 400 404 i = semiColonIdx; // move index up to the semi-colon 401 405 } else { 402 res += c;406 res.append(c); 403 407 } 404 408 } 405 return res; 409 return res.toString(); 406 410 } 407 411 }
Note:
See TracChangeset
for help on using the changeset viewer.