Changeset 2305 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-10-24T21:22:49+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 1 added
- 14 edited
-
Changeset.java (modified) (3 diffs)
-
DataSet.java (modified) (12 diffs)
-
NodeData.java (modified) (2 diffs)
-
OsmPrimitive.java (modified) (5 diffs)
-
OsmPrimitiveType.java (modified) (2 diffs)
-
PrimitiveData.java (modified) (5 diffs)
-
PrimitiveDeepCopy.java (added)
-
Relation.java (modified) (3 diffs)
-
RelationData.java (modified) (1 diff)
-
RelationMemberData.java (modified) (2 diffs)
-
Tag.java (modified) (10 diffs)
-
TagCollection.java (modified) (50 diffs)
-
Tagged.java (modified) (8 diffs)
-
Way.java (modified) (1 diff)
-
WayData.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r2115 r2305 50 50 /** 51 51 * Creates a changeset with id <code>id</code>. If id > 0, sets incomplete to true. 52 * 52 * 53 53 * @param id the id 54 54 */ … … 61 61 /** 62 62 * Creates a clone of <code>other</code> 63 * 63 * 64 64 * @param other the other changeset. If null, creates a new changeset with id 0. 65 65 */ … … 192 192 this.tags.remove(key); 193 193 } 194 195 public void removeAll() { 196 this.tags.clear(); 197 } 198 194 199 195 200 public boolean hasEqualSemanticAttributes(Changeset other) { -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2282 r2305 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm; 3 import static org.openstreetmap.josm.tools.I18n.tr;4 5 3 import java.awt.geom.Area; 6 4 import java.util.ArrayList; … … 16 14 17 15 import org.openstreetmap.josm.data.SelectionChangedListener; 18 import org.openstreetmap.josm.data.osm.QuadBuckets;19 16 20 17 /** … … 113 110 */ 114 111 public void addPrimitive(OsmPrimitive primitive) { 115 if (primitive == null)116 return;117 112 if (primitive instanceof Node) { 118 113 nodes.add((Node) primitive); … … 121 116 } else if (primitive instanceof Relation) { 122 117 relations.add((Relation) primitive); 118 } 119 } 120 121 public OsmPrimitive addPrimitive(PrimitiveData data) { 122 if (data instanceof NodeData) { 123 Node node = new Node((NodeData)data, this); 124 nodes.add(node); 125 return node; 126 } else if (data instanceof WayData) { 127 Way way = new Way((WayData)data, this); 128 ways.add(way); 129 return way; 130 } else if (data instanceof RelationData) { 131 Relation relation = new Relation((RelationData)data, this); 132 relations.add(relation); 133 return relation; 134 } else { 135 throw new AssertionError(); 123 136 } 124 137 } … … 145 158 } 146 159 160 public void removePrimitive(long id, OsmPrimitiveType type) { 161 removePrimitive(getPrimitiveById(id, type)); 162 } 163 147 164 public Collection<OsmPrimitive> getSelectedNodesAndWays() { 148 165 Collection<OsmPrimitive> sel = getSelected(nodes); … … 246 263 * Sets the current selection to the primitives in <code>selection</code>. 247 264 * Notifies all {@see SelectionChangedListener} if <code>fireSelectionChangeEvent</code> is true. 248 * 265 * 249 266 * @param selection the selection 250 267 * @param fireSelectionChangeEvent true, if the selection change listeners are to be notified; false, otherwise … … 265 282 * Sets the current selection to the primitives in <code>selection</code> 266 283 * and notifies all {@see SelectionChangedListener}. 267 * 284 * 268 285 * @param selection the selection 269 286 */ … … 275 292 * Adds the primitives in <code>selection</code> to the current selection 276 293 * and notifies all {@see SelectionChangedListener}. 277 * 294 * 278 295 * @param selection the selection 279 296 */ … … 285 302 * Adds the primitives in <code>selection</code> to the current selection. 286 303 * Notifies all {@see SelectionChangedListener} if <code>fireSelectionChangeEvent</code> is true. 287 * 304 * 288 305 * @param selection the selection 289 306 * @param fireSelectionChangeEvent true, if the selection change listeners are to be notified; false, otherwise … … 443 460 * exists 444 461 * 445 * @param id the id, > 0 required462 * @param id uniqueId of the primitive. Might be < 0 for newly created primitives 446 463 * @param type the type of the primitive. Must not be null. 447 464 * @return the primitive 448 * @exception IllegalArgumentException thrown, if id <= 0 449 * @exception IllegalArgumentException thrown, if type is null 450 * @exception IllegalArgumentException thrown, if type is neither NODE, or WAY or RELATION 465 * @exception NullPointerException thrown, if type is null 451 466 */ 452 467 public OsmPrimitive getPrimitiveById(long id, OsmPrimitiveType type) { 453 if (id <= 0)454 throw new IllegalArgumentException(tr("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "id", id));455 if (id <= 0) 456 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "type"));468 return getPrimitiveById(id, type, false); 469 } 470 471 public OsmPrimitive getPrimitiveById(long id, OsmPrimitiveType type, boolean createNew) { 457 472 Collection<? extends OsmPrimitive> primitives = null; 458 473 switch(type) { … … 462 477 } 463 478 for (OsmPrimitive primitive : primitives) { 464 if (primitive.getId() == id) return primitive; 465 } 466 return null; 479 if (primitive.getUniqueId() == id) return primitive; 480 } 481 482 if (createNew) { 483 OsmPrimitive result = null; 484 switch (type) { 485 case NODE: result = new Node(id, true); break; 486 case WAY: result = new Way(id, true); break; 487 case RELATION: result = new Relation(id, true); break; 488 } 489 addPrimitive(result); 490 return result; 491 } else { 492 return null; 493 } 467 494 } 468 495 … … 565 592 * Replies true if there is at least one primitive in this dataset with 566 593 * {@see OsmPrimitive#isModified()} == <code>true</code>. 567 * 594 * 568 595 * @return true if there is at least one primitive in this dataset with 569 596 * {@see OsmPrimitive#isModified()} == <code>true</code>. -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r2299 r2305 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.data.coor.CachedLatLon; 5 import org.openstreetmap.josm.data.coor.EastNorth; 4 6 import org.openstreetmap.josm.data.coor.LatLon; 5 7 6 8 public class NodeData extends PrimitiveData { 7 9 8 private LatLon coor; 10 private final CachedLatLon coor = new CachedLatLon(0, 0); 11 12 public NodeData() { 13 14 } 15 16 public NodeData(double lat, double lon, String... keys) { 17 setCoor(new LatLon(lat, lon)); 18 setKeysAsList(keys); 19 } 20 21 public NodeData(String... keys) { 22 setKeysAsList(keys); 23 } 24 25 public NodeData(NodeData data) { 26 super(data); 27 setCoor(data.getCoor()); 28 } 9 29 10 30 public LatLon getCoor() { … … 13 33 14 34 public void setCoor(LatLon coor) { 15 this.coor = coor; 35 this.coor.setCoor(coor); 36 } 37 38 public EastNorth getEastNorth() { 39 return this.coor.getEastNorth(); 40 } 41 42 public void setEastNorth(EastNorth eastNorth) { 43 this.coor.setEastNorth(eastNorth); 44 } 45 46 @Override 47 public NodeData makeCopy() { 48 return new NodeData(this); 49 } 50 51 @Override 52 public Node makePrimitive(DataSet dataSet) { 53 return new Node(this, dataSet); 16 54 } 17 55 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2300 r2305 36 36 abstract public class OsmPrimitive implements Comparable<OsmPrimitive>, Tagged { 37 37 38 static final AtomicLong idCounter = new AtomicLong(0); 38 private static final AtomicLong idCounter = new AtomicLong(0); 39 40 static long generateUniqueId() { 41 return idCounter.decrementAndGet(); 42 } 39 43 40 44 private static final int FLAG_MODIFIED = 1 << 0; … … 164 168 throw new IllegalArgumentException(tr("Expected ID >= 0. Got {0}.", id)); 165 169 else if (id == 0) { 166 this.id = idCounter.decrementAndGet();170 this.id = generateUniqueId(); 167 171 } else { 168 172 this.id = id; … … 400 404 */ 401 405 public void clearOsmId() { 402 this.id = idCounter.decrementAndGet();406 this.id = generateUniqueId(); 403 407 this.version = 0; 404 408 this.incomplete = false; … … 456 460 if(directionKeys == null) { 457 461 directionKeys = Main.pref.getCollection("tags.direction", 458 Arrays.asList( new String[]{"oneway","incline","incline_steep","aerialway"}));462 Arrays.asList("oneway","incline","incline_steep","aerialway")); 459 463 } 460 464 return directionKeys; … … 841 845 842 846 protected void saveCommonAttributes(PrimitiveData data) { 843 data.setId( data.getId());847 data.setId(id); 844 848 data.getKeys().clear(); 845 849 data.getKeys().putAll(getKeys()); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r2181 r2305 5 5 public enum OsmPrimitiveType { 6 6 7 NODE ("node"), 8 WAY ("way"), 9 RELATION ("relation"); 7 NODE ("node", Node.class, NodeData.class), 8 WAY ("way", Way.class, WayData.class), 9 RELATION ("relation", Relation.class, RelationData.class); 10 10 11 private String apiTypeName; 11 private final String apiTypeName; 12 private final Class<? extends OsmPrimitive> osmClass; 13 private final Class<? extends PrimitiveData> dataClass; 12 14 13 OsmPrimitiveType(String apiTypeName) { 15 OsmPrimitiveType(String apiTypeName, Class<? extends OsmPrimitive> osmClass, Class<? extends PrimitiveData> dataClass) { 14 16 this.apiTypeName = apiTypeName; 17 this.osmClass = osmClass; 18 this.dataClass = dataClass; 15 19 } 16 20 17 21 public String getAPIName() { 18 22 return apiTypeName; 23 } 24 25 public Class<? extends OsmPrimitive> getOsmClass() { 26 return osmClass; 27 } 28 29 public Class<? extends PrimitiveData> getDataClass() { 30 return dataClass; 19 31 } 20 32 … … 30 42 } 31 43 32 public static OsmPrimitiveType from(Class cls) { 44 public static OsmPrimitiveType from(Class<? extends OsmPrimitive> cls) { 33 45 if (cls.equals(Node.class)) return NODE; 34 46 if (cls.equals(Way.class)) return WAY; 35 47 if (cls.equals(Relation.class)) return RELATION; 36 48 throw new IllegalArgumentException(tr("Parameter ''{0}'' is not an acceptable class. Got ''{1}''.", "cls", cls.toString())); 49 } 50 51 public static OsmPrimitiveType fromData(Class<? extends PrimitiveData> cls) { 52 if (cls.equals(NodeData.class)) return NODE; 53 if (cls.equals(WayData.class)) return WAY; 54 if (cls.equals(RelationData.class)) return RELATION; 55 throw new IllegalArgumentException(tr("Parameter ''{0}'' is not an acceptable class. Got ''{1}''.", "cls", cls.toString())); 56 } 57 58 public static OsmPrimitiveType fromData(PrimitiveData data) { 59 return fromData(data.getClass()); 37 60 } 38 61 -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r2299 r2305 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.ArrayList; 5 import java.util.Collection; 4 6 import java.util.HashMap; 7 import java.util.List; 5 8 import java.util.Map; 6 9 … … 12 15 * 13 16 */ 14 public abstract class PrimitiveData { 17 public abstract class PrimitiveData implements Tagged { 15 18 16 19 // Useful? … … 19 22 //private boolean selected; 20 23 //private boolean highlighted; 24 25 public PrimitiveData() { 26 id = OsmPrimitive.generateUniqueId(); 27 } 28 29 public PrimitiveData(PrimitiveData data) { 30 this.keys.putAll(data.keys); 31 this.modified = data.modified; 32 this.visible = data.visible; 33 this.deleted = data.deleted; 34 this.id = data.id; 35 this.user = data.user; 36 this.version = data.version; 37 this.timestamp = data.timestamp; 38 } 21 39 22 40 private final Map<String, String> keys = new HashMap<String, String>(); … … 75 93 } 76 94 95 public void clearOsmId() { 96 id = OsmPrimitive.generateUniqueId(); 97 } 98 99 public abstract PrimitiveData makeCopy(); 100 101 public abstract OsmPrimitive makePrimitive(DataSet dataSet); 77 102 78 103 @Override … … 94 119 } 95 120 121 // Tagged implementation 122 123 public String get(String key) { 124 return keys.get(key); 125 } 126 127 public boolean hasKeys() { 128 return !keys.isEmpty(); 129 } 130 131 public Collection<String> keySet() { 132 return keys.keySet(); 133 } 134 135 public void put(String key, String value) { 136 keys.put(key, value); 137 } 138 139 public void remove(String key) { 140 keys.remove(key); 141 } 142 143 public void removeAll() { 144 keys.clear(); 145 } 146 147 public void setKeys(Map<String, String> keys) { 148 this.keys.clear(); 149 this.keys.putAll(keys); 150 } 151 152 153 @SuppressWarnings("unchecked") 154 static public <T extends PrimitiveData> List<T> getFilteredList(Collection<T> list, OsmPrimitiveType type) { 155 List<T> ret = new ArrayList<T>(); 156 for(PrimitiveData p: list) { 157 if (type.getDataClass().isInstance(p)) { 158 ret.add((T)p); 159 } 160 } 161 return ret; 162 } 163 164 protected void setKeysAsList(String... keys) { 165 assert keys.length % 2 == 0; 166 for (int i=0; i<keys.length/2; i++) { 167 this.keys.put(keys[i * 2], keys[i * 2 + 1]); 168 } 169 } 170 171 96 172 97 173 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2284 r2305 205 205 foundMember = nodes.get(member.getMemberId()); 206 206 if (foundMember == nodeMarker) { 207 foundMember = new Node(member.getMemberId(), true);207 throw new AssertionError("Data consistency problem - relation with missing member detected"); 208 208 } 209 209 break; … … 211 211 foundMember = ways.get(member.getMemberId()); 212 212 if (foundMember == wayMarker) { 213 foundMember = new Way(member.getMemberId(), true);213 throw new AssertionError("Data consistency problem - relation with missing member detected"); 214 214 } 215 215 break; … … 217 217 foundMember = relations.get(member.getMemberId()); 218 218 if (foundMember == relationMarker) { 219 foundMember = new Relation(member.getMemberId(), true);219 throw new AssertionError("Data consistency problem - relation with missing member detected"); 220 220 } 221 221 break; -
trunk/src/org/openstreetmap/josm/data/osm/RelationData.java
r2299 r2305 9 9 private final List<RelationMemberData> members = new ArrayList<RelationMemberData>(); 10 10 11 public RelationData() { 12 13 } 14 15 public RelationData(RelationData data) { 16 super(data); 17 members.addAll(data.members); 18 } 19 11 20 public List<RelationMemberData> getMembers() { 12 21 return members; 22 } 23 24 @Override 25 public RelationData makeCopy() { 26 return new RelationData(this); 27 } 28 29 @Override 30 public Relation makePrimitive(DataSet dataSet) { 31 return new Relation(this, dataSet); 13 32 } 14 33 -
trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java
r2299 r2305 4 4 public class RelationMemberData { 5 5 6 private String role; 7 private long memberId; 8 private OsmPrimitiveType memberType; 6 private final String role; 7 private final long memberId; 8 private final OsmPrimitiveType memberType; 9 9 10 public RelationMemberData() { 11 10 public RelationMemberData(String role, OsmPrimitiveType type, long id) { 11 this.role = role; 12 this.memberType = type; 13 this.memberId = id; 12 14 } 13 15 14 16 public RelationMemberData(String role, OsmPrimitive primitive) { 15 this.role = role; 16 this.memberId = primitive.getUniqueId(); 17 this.memberType = OsmPrimitiveType.from(primitive); 17 this(role, OsmPrimitiveType.from(primitive), primitive.getUniqueId()); 18 18 } 19 19 … … 21 21 return memberId; 22 22 } 23 public void setMemberId(long memberId) {24 this.memberId = memberId;25 }26 23 public String getRole() { 27 24 return role; 28 25 } 29 public void setRole(String role) {30 this.role = role;31 }32 26 public OsmPrimitiveType getMemberType() { 33 27 return memberType; 34 }35 public void setMemberType(OsmPrimitiveType memberType) {36 this.memberType = memberType;37 28 } 38 29 -
trunk/src/org/openstreetmap/josm/data/osm/Tag.java
r2070 r2305 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.ArrayList;5 import java.util.Collections;6 import java.util.Iterator;7 import java.util.List;8 4 9 5 /** … … 21 17 */ 22 18 public Tag(){ 23 this.key = ""; 24 this.value = ""; 19 this("", ""); 25 20 } 26 21 … … 28 23 * Create a tag whose key is <code>key</code> and whose value is 29 24 * empty. 30 * 25 * 31 26 * @param key the key. If null, it is set to the empty key. 32 27 */ 33 28 public Tag(String key) { 34 this(); 35 this.key = key == null ? "" : key; 29 this(key, ""); 36 30 } 37 31 … … 39 33 * Creates a tag for a key and a value. If key and/or value are null, 40 34 * the empty value "" is assumed. 41 * 35 * 42 36 * @param key the key 43 37 * @param value the value … … 50 44 /** 51 45 * Creates clone of the tag <code>tag</code>. 52 * 53 * @param tag the tag. If null, creates an empty tag.46 * 47 * @param tag the tag. 54 48 */ 55 49 public Tag(Tag tag) { 56 if (tag != null) { 57 key = tag.getKey(); 58 value = tag.getValue(); 59 } 50 this(tag.getKey(), tag.getValue()); 60 51 } 61 52 62 53 /** 63 54 * Replies the key of the tag. This is never null. 64 * 55 * 65 56 * @return the key of the tag 66 57 */ … … 71 62 /** 72 63 * Replies the value of the tag. This is never null. 73 * 64 * 74 65 * @return the value of the tag 75 66 */ … … 86 77 * Replies true if the key of this tag is equal to <code>key</code>. 87 78 * If <code>key</code> is null, assumes the empty key. 88 * 79 * 89 80 * @param key the key 90 81 * @return true if the key of this tag is equal to <code>key</code> 91 82 */ 92 83 public boolean matchesKey(String key) { 93 if (key == null) {94 key = "";95 }96 84 return this.key.equals(key); 97 85 } … … 102 90 * <li>removing leading and trailing white space</li> 103 91 * <ul> 104 * 92 * 105 93 */ 106 94 public void normalize() { … … 113 101 final int prime = 31; 114 102 int result = 1; 115 result = prime * result + ((key == null) ? 0 :key.hashCode());116 result = prime * result + ((value == null) ? 0 :value.hashCode());103 result = prime * result + key.hashCode(); 104 result = prime * result + value.hashCode(); 117 105 return result; 118 106 } … … 120 108 @Override 121 109 public boolean equals(Object obj) { 122 if (this == obj) 123 return true; 124 if (obj == null) 110 if (obj instanceof Tag) { 111 Tag other = (Tag) obj; 112 return key.equals(other.getKey()) && value.equals(other.getValue()); 113 } else { 125 114 return false; 126 if (getClass() != obj.getClass()) 127 return false; 128 Tag other = (Tag) obj; 129 if (key == null) { 130 if (other.key != null) 131 return false; 132 } else if (!key.equals(other.key)) 133 return false; 134 if (value == null) { 135 if (other.value != null) 136 return false; 137 } else if (!value.equals(other.value)) 138 return false; 139 return true; 115 } 116 } 117 118 @Override 119 public String toString() { 120 return key + "=" + value; 140 121 } 141 122 } -
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r2181 r2305 17 17 * TagCollection is a collection of tags which can be used to manipulate 18 18 * tags managed by {@see OsmPrimitive}s. 19 * 19 * 20 20 * A TagCollection can be created: 21 21 * <ul> … … 25 25 * <li>from the intersection of all tags managed by a collection of primitives with {@see #commonToAllPrimitives(Collection)}</li> 26 26 * </ul> 27 * 27 * 28 28 * It provides methods to query the collection, like {@see #size()}, {@see #hasTagsFor(String)}, etc. 29 * 29 * 30 30 * Basic set operations allow to create the union, the intersection and the difference 31 31 * of tag collections, see {@see #union(TagCollection)}, {@see #intersect(TagCollection)}, 32 32 * and {@see #minus(TagCollection)}. 33 * 33 * 34 34 * 35 35 */ … … 40 40 * {@see OsmPrimitive}. If <code>primitive</code> is null, replies 41 41 * an empty tag collection. 42 * 42 * 43 43 * @param primitive the primitive 44 44 * @return a tag collection with the tags managed by a specific 45 45 * {@see OsmPrimitive} 46 46 */ 47 public static TagCollection from( OsmPrimitiveprimitive) {47 public static TagCollection from(Tagged primitive) { 48 48 TagCollection tags = new TagCollection(); 49 49 for (String key: primitive.keySet()) { … … 62 62 * a collection of primitives 63 63 */ 64 public static TagCollection unionOfAllPrimitives(Collection<? extends OsmPrimitive> primitives) {64 public static TagCollection unionOfAllPrimitives(Collection<? extends Tagged> primitives) { 65 65 TagCollection tags = new TagCollection(); 66 66 if (primitives == null) return tags; 67 for ( OsmPrimitiveprimitive: primitives) {67 for (Tagged primitive: primitives) { 68 68 if (primitive == null) { 69 69 continue; … … 78 78 * <code>primitives</code>. Replies an empty tag collection of <code>primitives</code> 79 79 * is null. 80 * 80 * 81 81 * @param primitives the primitives 82 82 * @return a tag collection with the tags which are common to all primitives 83 83 */ 84 public static TagCollection commonToAllPrimitives(Collection<? extends OsmPrimitive> primitives) {84 public static TagCollection commonToAllPrimitives(Collection<? extends Tagged> primitives) { 85 85 TagCollection tags = new TagCollection(); 86 86 if (primitives == null || primitives.isEmpty()) return tags; … … 91 91 // intersect with the others 92 92 // 93 for ( OsmPrimitiveprimitive: primitives) {93 for (Tagged primitive: primitives) { 94 94 if (primitive == null) { 95 95 continue; … … 103 103 * Replies a tag collection with the union of the tags which are common to all primitives in 104 104 * the dataset <code>ds</code>. Returns an empty tag collection of <code>ds</code> is null. 105 * 105 * 106 106 * @param ds the dataset 107 107 * @return a tag collection with the union of the tags which are common to all primitives in … … 129 129 * Creates a clone of the tag collection <code>other</code>. Creats an empty 130 130 * tag collection if <code>other</code> is null. 131 * 131 * 132 132 * @param other the other collection 133 133 */ … … 141 141 /** 142 142 * Replies the number of tags in this tag collection 143 * 143 * 144 144 * @return the number of tags in this tag collection 145 145 */ … … 150 150 /** 151 151 * Replies true if this tag collection is empty 152 * 152 * 153 153 * @return true if this tag collection is empty; false, otherwise 154 154 */ … … 159 159 /** 160 160 * Adds a tag to the tag collection. If <code>tag</code> is null, nothing is added. 161 * 161 * 162 162 * @param tag the tag to add 163 163 */ … … 171 171 * Adds a collection of tags to the tag collection. If <code>tags</code> is null, nothing 172 172 * is added. null values in the collection are ignored. 173 * 173 * 174 174 * @param tags the collection of tags 175 175 */ … … 184 184 * Adds the tags of another tag collection to this collection. Adds nothing, if 185 185 * <code>tags</code> is null. 186 * 186 * 187 187 * @param tags the other tag collection 188 188 */ … … 195 195 * Removes a specific tag from the tag collection. Does nothing if <code>tag</code> is 196 196 * null. 197 * 197 * 198 198 * @param tag the tag to be removed 199 199 */ … … 206 206 * Removes a collection of tags from the tag collection. Does nothing if <code>tags</code> is 207 207 * null. 208 * 208 * 209 209 * @param tags the tags to be removed 210 210 */ … … 217 217 * Removes all tags in the tag collection <code>tags</code> from the current tag collection. 218 218 * Does nothing if <code>tags</code> is null. 219 * 219 * 220 220 * @param tags the tag collection to be removed. 221 221 */ … … 228 228 * Removes all tags whose keys are equal to <code>key</code>. Does nothing if <code>key</code> 229 229 * is null. 230 * 230 * 231 231 * @param key the key to be removed 232 232 */ … … 244 244 * Removes all tags whose key is in the collection <code>keys</code>. Does nothing if 245 245 * <code>keys</code> is null. 246 * 246 * 247 247 * @param keys the collection of keys to be removed 248 248 */ … … 256 256 /** 257 257 * Replies true if the this tag collection contains <code>tag</code>. 258 * 258 * 259 259 * @param tag the tag to look up 260 260 * @return true if the this tag collection contains <code>tag</code>; false, otherwise … … 266 266 /** 267 267 * Replies true if this tag collection contains at least one tag with key <code>key</code>. 268 * 268 * 269 269 * @param key the key to look up 270 270 * @return true if this tag collection contains at least one tag with key <code>key</code>; false, otherwise … … 281 281 * Replies true if this tag collection contains all tags in <code>tags</code>. Replies 282 282 * false, if tags is null. 283 * 283 * 284 284 * @param tags the tags to look up 285 285 * @return true if this tag collection contains all tags in <code>tags</code>. Replies … … 288 288 public boolean containsAll(Collection<Tag> tags) { 289 289 if (tags == null) return false; 290 return tags.containsAll(tags); 290 return this.tags.containsAll(tags); 291 291 } 292 292 … … 294 294 * Replies true if this tag collection at least one tag for every key in <code>keys</code>. 295 295 * Replies false, if <code>keys</code> is null. null values in <code>keys</code> are ignored. 296 * 296 * 297 297 * @param keys the keys to lookup 298 298 * @return true if this tag collection at least one tag for every key in <code>keys</code>. … … 311 311 /** 312 312 * Replies the number of tags with key <code>key</code> 313 * 313 * 314 314 * @param key the key to look up 315 315 * @return the number of tags with key <code>key</code>. 0, if key is null. … … 328 328 /** 329 329 * Replies true if there is at least one tag for the given key. 330 * 330 * 331 331 * @param key the key to look up 332 332 * @return true if there is at least one tag for the given key. false, if key is null. … … 339 339 * Replies true it there is at least one tag with a non empty value for key. 340 340 * Replies false if key is null. 341 * 341 * 342 342 * @param key the key 343 343 * @return true it there is at least one tag with a non empty value for key. … … 354 354 * if the value of this tag is not empty. Replies false if key is 355 355 * null. 356 * 356 * 357 357 * @param key the key 358 358 * @return true if there is exactly one tag for <code>key</code> and … … 368 368 * Replies true if there is a tag with an empty value for <code>key</code>. 369 369 * Replies false, if key is null. 370 * 370 * 371 371 * @param key the key 372 372 * @return true if there is a tag with an empty value for <code>key</code> … … 381 381 * Replies true if there is exactly one tag for <code>key</code> and if 382 382 * the value for this tag is empty. Replies false if key is null. 383 * 383 * 384 384 * @param key the key 385 385 * @return true if there is exactly one tag for <code>key</code> and if … … 395 395 * Replies a tag collection with the tags for a given key. Replies an empty collection 396 396 * if key is null. 397 * 397 * 398 398 * @param key the key to look up 399 399 * @return a tag collection with the tags for a given key. Replies an empty collection … … 415 415 * Replies a tag collection with all tags whose key is equal to one of the keys in 416 416 * <code>keys</code>. Replies an empty collection if keys is null. 417 * 417 * 418 418 * @param keys the keys to look up 419 419 * @return a tag collection with all tags whose key is equal to one of the keys in … … 434 434 /** 435 435 * Replies the tags of this tag collection as set 436 * 436 * 437 437 * @return the tags of this tag collection as set 438 438 */ … … 444 444 * Replies the tags of this tag collection as list. 445 445 * Note that the order of the list is not preserved between method invocations. 446 * 446 * 447 447 * @return the tags of this tag collection as list. 448 448 */ … … 453 453 /** 454 454 * Replies an iterator to iterate over the tags in this collection 455 * 455 * 456 456 * @return the iterator 457 457 */ … … 462 462 /** 463 463 * Replies the set of keys of this tag collection. 464 * 464 * 465 465 * @return the set of keys of this tag collection 466 466 */ … … 475 475 /** 476 476 * Replies the set of keys which have at least 2 matching tags. 477 * 477 * 478 478 * @return the set of keys which have at least 2 matching tags. 479 479 */ … … 496 496 * Sets a unique tag for the key of this tag. All other tags with the same key are 497 497 * removed from the collection. Does nothing if tag is null. 498 * 498 * 499 499 * @param tag the tag to set 500 500 */ … … 509 509 * removed from the collection. Assume the empty string for key and value if either 510 510 * key or value is null. 511 * 511 * 512 512 * @param key the key 513 513 * @param value the value … … 520 520 /** 521 521 * Replies the set of values in this tag collection 522 * 522 * 523 523 * @return the set of values 524 524 */ … … 534 534 * Replies the set of values for a given key. Replies an empty collection if there 535 535 * are no values for the given key. 536 * 536 * 537 537 * @param key the key to look up 538 538 * @return the set of values for a given key. Replies an empty collection if there … … 552 552 /** 553 553 * Replies true if for every key there is one tag only, i.e. exactly one value. 554 * 554 * 555 555 * @return 556 556 */ … … 562 562 * Applies this tag collection to an {@see OsmPrimitive}. Does nothing if 563 563 * primitive is null 564 * 564 * 565 565 * @param primitive the primitive 566 566 * @throws IllegalStateException thrown if this tag collection can't be applied 567 567 * because there are keys with multiple values 568 568 */ 569 public void applyTo( OsmPrimitiveprimitive) throws IllegalStateException {569 public void applyTo(Tagged primitive) throws IllegalStateException { 570 570 if (primitive == null) return; 571 571 if (! isApplicableToPrimitive()) … … 583 583 * Applies this tag collection to a collection of {@see OsmPrimitive}s. Does nothing if 584 584 * primitives is null 585 * 585 * 586 586 * @param primitives the collection of primitives 587 587 * @throws IllegalStateException thrown if this tag collection can't be applied 588 588 * because there are keys with multiple values 589 589 */ 590 public void applyTo(Collection<? extends OsmPrimitive> primitives) throws IllegalStateException{590 public void applyTo(Collection<? extends Tagged> primitives) throws IllegalStateException{ 591 591 if (primitives == null) return; 592 592 if (! isApplicableToPrimitive()) 593 593 throw new IllegalStateException(tr("Tag collection can't be applied to a primitive because there are keys with multiple values.")); 594 for ( OsmPrimitiveprimitive: primitives) {594 for (Tagged primitive: primitives) { 595 595 applyTo(primitive); 596 596 } … … 600 600 * Replaces the tags of an {@see OsmPrimitive} by the tags in this collection . Does nothing if 601 601 * primitive is null 602 * 602 * 603 603 * @param primitive the primitive 604 604 * @throws IllegalStateException thrown if this tag collection can't be applied 605 605 * because there are keys with multiple values 606 606 */ 607 public void replaceTagsOf( OsmPrimitiveprimitive) throws IllegalStateException {607 public void replaceTagsOf(Tagged primitive) throws IllegalStateException { 608 608 if (primitive == null) return; 609 609 if (! isApplicableToPrimitive()) … … 618 618 * Replaces the tags of a collection of{@see OsmPrimitive}s by the tags in this collection. 619 619 * Does nothing if primitives is null 620 * 620 * 621 621 * @param primitive the collection of primitives 622 622 * @throws IllegalStateException thrown if this tag collection can't be applied 623 623 * because there are keys with multiple values 624 624 */ 625 public void replaceTagsOf(Collection<? extends OsmPrimitive> primitives) throws IllegalStateException {625 public void replaceTagsOf(Collection<? extends Tagged> primitives) throws IllegalStateException { 626 626 if (primitives == null) return; 627 627 if (! isApplicableToPrimitive()) 628 628 throw new IllegalStateException(tr("Tag collection can't be applied to a primitive because there are keys with multiple values.")); 629 for ( OsmPrimitiveprimitive: primitives) {629 for (Tagged primitive: primitives) { 630 630 replaceTagsOf(primitive); 631 631 } … … 634 634 /** 635 635 * Builds the intersection of this tag collection and another tag collection 636 * 636 * 637 637 * @param other the other tag collection. If null, replies an empty tag collection. 638 638 * @return the intersection of this tag collection and another tag collection … … 653 653 /** 654 654 * Replies the difference of this tag collection and another tag collection 655 * 655 * 656 656 * @param other the other tag collection. May be null. 657 657 * @return the difference of this tag collection and another tag collection … … 667 667 /** 668 668 * Replies the union of this tag collection and another tag collection 669 * 669 * 670 670 * @param other the other tag collection. May be null. 671 671 * @return the union of this tag collection and another tag collection … … 690 690 /** 691 691 * Replies the concatenation of all tag values (concatenated by a semicolon) 692 * 692 * 693 693 * @return the concatenation of all tag values 694 694 */ … … 707 707 return buffer.toString(); 708 708 } 709 710 @Override 711 public String toString() { 712 return tags.toString(); 713 } 709 714 } -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r2115 r2305 6 6 /** 7 7 * Objects implement Tagged if they provide a map of key/value pairs. 8 * 9 * 8 * 9 * 10 10 */ 11 11 // FIXME: better naming? setTags(), getTags(), getKeys() instead of keySet() ? … … 14 14 /** 15 15 * Sets the map of key/value pairs 16 * 16 * 17 17 * @param keys the map of key value pairs. If null, reset to the empty map. 18 18 */ … … 21 21 /** 22 22 * Replies the map of key/value pairs. Never null, but may be the empty map. 23 * 23 * 24 24 * @return the map of key/value pairs 25 25 */ … … 28 28 /** 29 29 * Sets a key/value pairs 30 * 30 * 31 31 * @param key the key 32 32 * @param value the value. If null, removes the key/value pair. … … 36 36 /** 37 37 * Replies the value of the given key; null, if there is no value for this key 38 * 38 * 39 39 * @param key the key 40 40 * @return the value … … 44 44 /** 45 45 * Removes a given key/value pair 46 * 46 * 47 47 * @param key the key 48 48 */ … … 51 51 /** 52 52 * Replies true, if there is at least one key/value pair; false, otherwise 53 * 53 * 54 54 * @return true, if there is at least one key/value pair; false, otherwise 55 55 */ … … 58 58 /** 59 59 * Replies the set of keys 60 * 60 * 61 61 * @return the set of keys 62 62 */ 63 63 Collection<String> keySet(); 64 65 /** 66 * Removes all tags 67 */ 68 void removeAll(); 64 69 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2284 r2305 196 196 newNodes.add(foundNodes.get(nodeId)); 197 197 } else { 198 newNodes.add(new Node(nodeId, true));198 throw new AssertionError("Data consistency problem - way with missing node detected"); 199 199 } 200 200 } -
trunk/src/org/openstreetmap/josm/data/osm/WayData.java
r2299 r2305 9 9 private final List<Long> nodes = new ArrayList<Long>(); 10 10 11 public WayData() { 12 13 } 14 15 public WayData(WayData data) { 16 super(data); 17 nodes.addAll(data.getNodes()); 18 } 19 11 20 public List<Long> getNodes() { 12 21 return nodes; 22 } 23 24 @Override 25 public WayData makeCopy() { 26 return new WayData(this); 27 } 28 29 @Override 30 public OsmPrimitive makePrimitive(DataSet dataSet) { 31 return new Way(this, dataSet); 13 32 } 14 33
Note:
See TracChangeset
for help on using the changeset viewer.
