Changeset 11608 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2017-02-25T03:14:20+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r11587 r11608 706 706 * Replies true, if the map of key/value pairs of this primitive is not empty. 707 707 * 708 * @return true, if the map of key/value pairs of this primitive is not empty; false 709 * otherwise 708 * @return true, if the map of key/value pairs of this primitive is not empty; false otherwise 710 709 */ 711 710 @Override … … 718 717 * 719 718 * @param key the key 720 * @return true, if his primitive has a tag with key <code>key</code> 721 */ 719 * @return true, if this primitive has a tag with key <code>key</code> 720 */ 721 @Override 722 722 public boolean hasKey(String key) { 723 723 return key != null && indexOfKey(keys, key) >= 0; … … 728 728 * 729 729 * @param keys the keys 730 * @return true, if his primitive has a tag with any of the <code>keys</code>730 * @return true, if this primitive has a tag with any of the <code>keys</code> 731 731 * @since 11587 732 732 */ … … 758 758 759 759 /** 760 * Tests whether this primitive contains a tag consisting of {@code key} and {@code value s}.760 * Tests whether this primitive contains a tag consisting of {@code key} and {@code value}. 761 761 * @param key the key forming the tag. 762 762 * @param value value forming the tag. 763 * @return true if fprimitive contains a tag consisting of {@code key} and {@code value}.763 * @return true if primitive contains a tag consisting of {@code key} and {@code value}. 764 764 */ 765 765 public boolean hasTag(String key, String value) { … … 781 781 * @param key the key forming the tag. 782 782 * @param values one or many values forming the tag. 783 * @return true if fprimitive contains a tag consisting of {@code key} and any of {@code values}.783 * @return true if primitive contains a tag consisting of {@code key} and any of {@code values}. 784 784 */ 785 785 public boolean hasTag(String key, Collection<String> values) { 786 786 return values.contains(get(key)); 787 787 } 788 789 /** 790 * Tests whether this primitive contains a tag consisting of {@code key} and a value different from {@code value}. 791 * @param key the key forming the tag. 792 * @param value value not forming the tag. 793 * @return true if primitive contains a tag consisting of {@code key} and a value different from {@code value}. 794 * @since 11608 795 */ 796 public boolean hasTagDifferent(String key, String value) { 797 String v = get(key); 798 return v != null && !v.equals(value); 799 } 800 801 /** 802 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}. 803 * @param key the key forming the tag. 804 * @param values one or many values forming the tag. 805 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}. 806 * @since 11608 807 */ 808 public boolean hasTagDifferent(String key, String... values) { 809 return hasTagDifferent(key, Arrays.asList(values)); 810 } 811 812 /** 813 * Tests whether this primitive contains a tag consisting of {@code key} and none of {@code values}. 814 * @param key the key forming the tag. 815 * @param values one or many values forming the tag. 816 * @return true if primitive contains a tag consisting of {@code key} and none of {@code values}. 817 * @since 11608 818 */ 819 public boolean hasTagDifferent(String key, Collection<String> values) { 820 String v = get(key); 821 return v != null && !values.contains(v); 822 } 788 823 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r11600 r11608 1353 1353 */ 1354 1354 public final boolean hasAreaTags() { 1355 return hasKey("landuse", "amenity", "leisure", "building", "building:part") 1356 || "yes".equals(get("area")) 1357 || "riverbank".equals(get("waterway")) 1355 return hasKey("landuse", "amenity", "building", "building:part") 1356 || hasTag("area", "yes") 1357 || hasTag("waterway", "riverbank") 1358 || hasTagDifferent("leisure", "picnic_table", "slipway", "firepit") 1358 1359 || hasTag("natural", "water", "wood", "scrub", "wetland", "grassland", "heath", "rock", "bare_rock", 1359 1360 "sand", "beach", "scree", "bay", "glacier", "shingle", "fell", "reef", "stone", -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r10736 r11608 4 4 import java.util.Collection; 5 5 import java.util.Map; 6 6 7 /** 7 8 * Objects implement Tagged if they provide a map of key/value pairs. 8 9 * 9 * 10 * @since 2115 10 11 */ 11 12 // FIXME: better naming? setTags(), getTags(), getKeys() instead of keySet() ? … … 67 68 68 69 /** 70 * Replies true if there is a tag with key <code>key</code>. 71 * 72 * @param key the key 73 * @return true, if there is a tag with key <code>key</code> 74 * @since 11608 75 */ 76 default boolean hasKey(String key) { 77 return get(key) != null; 78 } 79 80 /** 69 81 * Replies the set of keys 70 82 * -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java
r8509 r11608 10 10 11 11 /** 12 * Represents an immutable OSM node in the context of a historical view on 13 * OSM data. 14 * 12 * Represents an immutable OSM node in the context of a historical view on OSM data. 13 * @since 1670 15 14 */ 16 15 public class HistoryNode extends HistoryOsmPrimitive { -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r11553 r11608 5 5 6 6 import java.text.MessageFormat; 7 import java.util.Collection; 7 8 import java.util.Collections; 8 9 import java.util.Date; … … 19 20 import org.openstreetmap.josm.data.osm.Relation; 20 21 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 22 import org.openstreetmap.josm.data.osm.Tagged; 21 23 import org.openstreetmap.josm.data.osm.User; 22 24 import org.openstreetmap.josm.data.osm.Way; … … 24 26 25 27 /** 26 * Represents an immutable OSM primitive in the context of a historical view on 27 * OSM data. 28 * 28 * Represents an immutable OSM primitive in the context of a historical view on OSM data. 29 * @since 1670 29 30 */ 30 public abstract class HistoryOsmPrimitive implements Comparable<HistoryOsmPrimitive> {31 public abstract class HistoryOsmPrimitive implements Tagged, Comparable<HistoryOsmPrimitive> { 31 32 32 33 private long id; … … 38 39 private long version; 39 40 private Map<String, String> tags; 40 41 protected final void ensurePositiveLong(long value, String name) {42 if (value <= 0) {43 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", name, value));44 }45 }46 41 47 42 /** … … 119 114 } 120 115 116 /** 117 * Returns the id. 118 * @return the id 119 */ 121 120 public long getId() { 122 121 return id; 123 122 } 124 123 124 /** 125 * Returns the primitive id. 126 * @return the primitive id 127 */ 125 128 public PrimitiveId getPrimitiveId() { 126 129 return new SimplePrimitiveId(id, getType()); 127 130 } 128 131 132 /** 133 * Determines if the primitive is still visible. 134 * @return {@code true} if the primitive is still visible 135 */ 129 136 public boolean isVisible() { 130 137 return visible; 131 138 } 132 139 140 /** 141 * Returns the user. 142 * @return the user 143 */ 133 144 public User getUser() { 134 145 return user; 135 146 } 136 147 148 /** 149 * Returns the changeset id. 150 * @return the changeset id 151 */ 137 152 public long getChangesetId() { 138 153 return changesetId; 139 154 } 140 155 156 /** 157 * Returns the timestamp. 158 * @return the timestamp 159 */ 141 160 public Date getTimestamp() { 142 161 return timestamp; 143 162 } 144 163 164 /** 165 * Returns the version. 166 * @return the version 167 */ 145 168 public long getVersion() { 146 169 return version; 147 170 } 148 171 172 protected final void ensurePositiveLong(long value, String name) { 173 if (value <= 0) { 174 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", name, value)); 175 } 176 } 177 149 178 public boolean matches(long id, long version) { 150 179 return this.id == id && this.version == version; … … 155 184 } 156 185 186 /** 187 * Returns the primitive type. 188 * @return the primitive type 189 */ 157 190 public abstract OsmPrimitiveType getType(); 158 191 … … 164 197 } 165 198 166 public void put(String key, String value) { 199 @Override 200 public final void put(String key, String value) { 167 201 tags.put(key, value); 168 202 } 169 203 170 public String get(String key) { 204 @Override 205 public final String get(String key) { 171 206 return tags.get(key); 172 207 } 173 208 174 public boolean hasTag(String key) { 175 return tags.get(key) != null; 176 } 177 209 @Override 210 public final boolean hasKey(String key) { 211 return tags.containsKey(key); 212 } 213 214 @Override 215 public final Map<String, String> getKeys() { 216 return getTags(); 217 } 218 219 @Override 220 public final void setKeys(Map<String, String> keys) { 221 throw new UnsupportedOperationException(); 222 } 223 224 @Override 225 public final void remove(String key) { 226 throw new UnsupportedOperationException(); 227 } 228 229 @Override 230 public final void removeAll() { 231 throw new UnsupportedOperationException(); 232 } 233 234 @Override 235 public final boolean hasKeys() { 236 return !tags.isEmpty(); 237 } 238 239 @Override 240 public final Collection<String> keySet() { 241 return Collections.unmodifiableSet(tags.keySet()); 242 } 243 244 /** 245 * Replies the key/value map. 246 * @return the key/value map 247 */ 178 248 public Map<String, String> getTags() { 179 249 return Collections.unmodifiableMap(tags); … … 272 342 public String toString() { 273 343 return getClass().getSimpleName() + " [version=" + version + ", id=" + id + ", visible=" + visible + ", " 274 + (timestamp != null ? "timestamp=" + timestamp: "") + ", "275 + (user != null ? "user=" + user + ", ": "") + "changesetId="344 + (timestamp != null ? ("timestamp=" + timestamp) : "") + ", " 345 + (user != null ? ("user=" + user + ", ") : "") + "changesetId=" 276 346 + changesetId 277 347 + ']'; -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java
r10632 r11608 15 15 16 16 /** 17 * Represents an immutable OSM relation in the context of a historical view on 18 * OSM data. 19 * 17 * Represents an immutable OSM relation in the context of a historical view on OSM data. 18 * @since 1670 20 19 */ 21 20 public class HistoryRelation extends HistoryOsmPrimitive { -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java
r10662 r11608 15 15 16 16 /** 17 * Represents an immutable OSM way in the context of a historical view on 18 * OSM data. 19 * 17 * Represents an immutable OSM way in the context of a historical view on OSM data. 18 * @since 1670 20 19 */ 21 20 public class HistoryWay extends HistoryOsmPrimitive {
Note:
See TracChangeset
for help on using the changeset viewer.