Changeset 17130 in josm
- Timestamp:
- 2020-10-08T23:32:32+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r16870 r17130 64 64 */ 65 65 public WayPoint(WayPoint p) { 66 attr = new LegacyMap();66 attr = new HashMap<>(); 67 67 attr.putAll(p.attr); 68 68 attr.put(PT_TIME, p.getDate()); … … 82 82 */ 83 83 public WayPoint(LatLon ll) { 84 attr = new LegacyMap();84 attr = new HashMap<>(); 85 85 lat = ll.lat(); 86 86 lon = ll.lon(); 87 }88 89 /**90 * Interim to detect legacy code that is not using {@code WayPoint.setTime(x)}91 * functions, but {@code attr.put(PT_TIME, (String) x)} logic.92 * To remove mid 201993 */94 private static class LegacyMap extends HashMap<String, Object> {95 private static final long serialVersionUID = 1;96 97 LegacyMap() {98 super(0);99 }100 101 @Override102 public Object put(String key, Object value) {103 Object ret = null;104 if (!PT_TIME.equals(key) || value instanceof Date) {105 ret = super.put(key, value);106 } else if (value instanceof String) {107 ret = super.put(PT_TIME, DateUtils.fromString((String) value));108 List<String> lastErrorAndWarnings = Logging.getLastErrorAndWarnings();109 if (!lastErrorAndWarnings.isEmpty() && !lastErrorAndWarnings.get(0).contains("calling WayPoint.put")) {110 StackTraceElement[] e = Thread.currentThread().getStackTrace();111 int n = 1;112 while (n < e.length && "put".equals(e[n].getMethodName())) {113 n++;114 }115 if (n < e.length) {116 Logging.warn("{0}:{1} calling WayPoint.put(PT_TIME, ..) is deprecated. " +117 "Use WayPoint.setTime(..) instead.", e[n].getClassName(), e[n].getMethodName());118 }119 }120 }121 return ret;122 }123 87 } 124 88
Note:
See TracChangeset
for help on using the changeset viewer.