Changeset 362 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2007-10-11T21:35:15+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r343 r362 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.text.ParseException; 4 5 import java.text.SimpleDateFormat; 5 6 import java.util.ArrayList; … … 12 13 13 14 import org.openstreetmap.josm.data.osm.visitor.Visitor; 15 import org.openstreetmap.josm.tools.DateParser; 14 16 15 17 … … 88 90 * used to check against edit conflicts. 89 91 */ 90 public Date timestamp = null; 91 92 public String timestamp = null; 93 94 /** 95 * The timestamp is only parsed when this is really necessary, and this 96 * is the cache for the result. 97 */ 98 public Date parsedTimestamp = null; 99 92 100 /** 93 101 * If set to true, this object is incomplete, which means only the id … … 108 116 modified = true; 109 117 } 118 119 /** 120 * Returns the timestamp for this object, or the current time if none is set. 121 * Internally, parses the timestamp from XML into a Date object and caches it 122 * for possible repeated calls. 123 */ 124 public Date getTimestamp() { 125 if (parsedTimestamp == null) { 126 try { 127 parsedTimestamp = DateParser.parse(timestamp); 128 } catch (ParseException ex) { 129 parsedTimestamp = new Date(); 130 } 131 } 132 return parsedTimestamp; 133 } 110 134 111 135 /** -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r343 r362 288 288 private <P extends OsmPrimitive> boolean mergeAfterId(Map<P,P> merged, Collection<P> primitives, P other) { 289 289 for (P my : primitives) { 290 Date d1 = my.timestamp == null ? new Date(0) : my.timestamp;291 Date d2 = other.timestamp == null ? new Date(0) : other.timestamp;292 290 if (my.realEqual(other, false)) { 293 291 if (merged != null) … … 299 297 if (merged != null) 300 298 merged.put(other, my); 301 if ( d1.before(d2)) {299 if (my.getTimestamp().before(other.getTimestamp())) { 302 300 my.modified = other.modified; 303 301 my.timestamp = other.timestamp; … … 311 309 merged.put(other, my); 312 310 } else if (!my.modified && !other.modified) { 313 if ( d1.before(d2)) {311 if (my.getTimestamp().before(other.getTimestamp())) { 314 312 cloneFromExceptIncomplete(my, other); 315 313 if (merged != null) … … 317 315 } 318 316 } else if (other.modified) { 319 if ( d1.after(d2)) {317 if (my.getTimestamp().after(other.getTimestamp())) { 320 318 conflicts.put(my, other); 321 319 if (merged != null) … … 327 325 } 328 326 } else if (my.modified) { 329 if ( d2.after(d1)) {327 if (my.getTimestamp().before(other.getTimestamp())) { 330 328 conflicts.put(my, other); 331 329 if (merged != null)
Note:
See TracChangeset
for help on using the changeset viewer.