Changeset 2410 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-11-08T15:19:50+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 4 edited
-
Node.java (modified) (1 diff)
-
OsmPrimitive.java (modified) (3 diffs)
-
Relation.java (modified) (1 diff)
-
Way.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r2405 r2410 68 68 69 69 /** 70 * 71 * @param clone 72 * @param clearId If true, set version to 0 and id to new unique value 73 */ 74 public Node(Node clone, boolean clearId) { 75 super(clone.getUniqueId(), true); 76 cloneFrom(clone); 77 if (clearId) { 78 clearOsmId(); 79 } 80 } 81 82 /** 70 83 * Create an identical clone of the argument (including the id) 71 84 */ 72 85 public Node(Node clone) { 73 super(clone.getUniqueId(), true); 74 cloneFrom(clone); 86 this(clone, false); 75 87 } 76 88 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2407 r2410 378 378 * @throws IllegalArgumentException thrown if id <= 0 379 379 * @throws IllegalArgumentException thrown if version <= 0 380 * @throws DataIntegrityProblemException If id is changed and primitive was already added to the dataset 380 381 */ 381 382 public void setOsmId(long id, int version) { … … 384 385 if (version <= 0) 385 386 throw new IllegalArgumentException(tr("Version > 0 expected. Got {0}.", version)); 387 if (dataSet != null && id != this.id) 388 throw new DataIntegrityProblemException("Id cannot be changed after primitive was added to the dataset"); 386 389 this.id = id; 387 390 this.version = version; … … 391 394 /** 392 395 * Clears the id and version known to the OSM API. The id and the version is set to 0. 393 * incomplete is set to false. 396 * incomplete is set to false. It's preferred to use copy constructor with clearId set to true instead 397 * of calling this method. 394 398 * 395 399 * <strong>Caution</strong>: Do not use this method on primitives which are already added to a {@see DataSet}. 396 * Ways and relations might already refer to the primitive and clearing the OSM ID 397 * result in corrupt data. 398 * 399 * Here's an example use case: 400 * <pre> 401 * // create a clone of an already existing node 402 * Node copy = new Node(otherExistingNode); 403 * 404 * // reset the clones OSM id 405 * copy.clearOsmId(); 406 * </pre> 407 * 400 * 401 * @throws DataIntegrityProblemException If primitive was already added to the dataset 408 402 */ 409 403 public void clearOsmId() { 404 if (dataSet != null) 405 throw new DataIntegrityProblemException("Method cannot be called after primitive was added to the dataset"); 410 406 this.id = generateUniqueId(); 411 407 this.version = 0; -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2407 r2410 140 140 } 141 141 142 /** 143 * Create an identical clone of the argument (including the id) 144 */ 145 public Relation(Relation clone) { 142 public Relation(Relation clone, boolean clearId) { 146 143 super(clone.getUniqueId(), true); 147 144 cloneFrom(clone); 145 if (clearId) { 146 clearOsmId(); 147 } 148 } 149 150 /** 151 * Create an identical clone of the argument (including the id) 152 */ 153 public Relation(Relation clone) { 154 this(clone, false); 148 155 } 149 156 -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2407 r2410 149 149 150 150 /** 151 * Create an identical clone of the argument (including the id).152 * 153 * @param original the original way. Must not be null.154 */ 155 public Way(Way original) { 151 * 152 * @param original 153 * @param clearId 154 */ 155 public Way(Way original, boolean clearId) { 156 156 super(original.getUniqueId(), true); 157 157 cloneFrom(original); 158 if (clearId) { 159 clearOsmId(); 160 } 161 } 162 163 /** 164 * Create an identical clone of the argument (including the id). 165 * 166 * @param original the original way. Must not be null. 167 */ 168 public Way(Way original) { 169 this(original, false); 158 170 } 159 171
Note:
See TracChangeset
for help on using the changeset viewer.
