Changeset 4098 in josm
- Timestamp:
- 2011-05-29T19:45:59+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r3653 r4098 12 12 * @author imi 13 13 */ 14 public final class Node extends OsmPrimitive {14 public final class Node extends OsmPrimitive implements INode { 15 15 16 16 private CachedLatLon coor; 17 17 18 @Override 18 19 public final void setCoor(LatLon coor) { 19 20 if(coor != null){ … … 22 23 } 23 24 25 @Override 24 26 public final void setEastNorth(EastNorth eastNorth) { 25 27 if(eastNorth != null) { … … 41 43 } 42 44 45 @Override 43 46 public final LatLon getCoor() { 44 47 return coor; 45 48 } 46 49 50 @Override 47 51 public final EastNorth getEastNorth() { 48 52 return coor != null ? coor.getEastNorth() : null; … … 210 214 } 211 215 216 @Override 212 217 public int compareTo(OsmPrimitive o) { 213 218 return o instanceof Node ? Long.valueOf(getUniqueId()).compareTo(o.getUniqueId()) : 1; … … 219 224 } 220 225 226 @Override 221 227 public OsmPrimitiveType getType() { 222 228 return OsmPrimitiveType.NODE; -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r3083 r4098 6 6 import org.openstreetmap.josm.data.coor.LatLon; 7 7 8 public class NodeData extends PrimitiveData {8 public class NodeData extends PrimitiveData implements INode { 9 9 10 10 private final CachedLatLon coor = new CachedLatLon(0, 0); … … 28 28 } 29 29 30 @Override 30 31 public LatLon getCoor() { 31 32 return coor; 32 33 } 33 34 35 @Override 34 36 public void setCoor(LatLon coor) { 35 37 this.coor.setCoor(coor); 36 38 } 37 39 40 @Override 38 41 public EastNorth getEastNorth() { 39 42 return this.coor.getEastNorth(); 40 43 } 41 44 45 @Override 42 46 public void setEastNorth(EastNorth eastNorth) { 43 47 this.coor.setEastNorth(eastNorth); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r4074 r4098 40 40 * @author imi 41 41 */ 42 abstract public class OsmPrimitive implements Comparable<OsmPrimitive>, Tagged, PrimitiveId{42 abstract public class OsmPrimitive implements Comparable<OsmPrimitive>, IPrimitive { 43 43 44 44 private static final AtomicLong idCounter = new AtomicLong(0); … … 188 188 */ 189 189 public static final Predicate<OsmPrimitive> isUsablePredicate = new Predicate<OsmPrimitive>() { 190 public boolean evaluate(OsmPrimitive primitive) {190 @Override public boolean evaluate(OsmPrimitive primitive) { 191 191 return primitive.isUsable(); 192 192 } … … 194 194 195 195 public static final Predicate<OsmPrimitive> isSelectablePredicate = new Predicate<OsmPrimitive>() { 196 public boolean evaluate(OsmPrimitive primitive) {196 @Override public boolean evaluate(OsmPrimitive primitive) { 197 197 return primitive.isSelectable(); 198 198 } … … 200 200 201 201 public static final Predicate<OsmPrimitive> nonDeletedPredicate = new Predicate<OsmPrimitive>() { 202 public boolean evaluate(OsmPrimitive primitive) {202 @Override public boolean evaluate(OsmPrimitive primitive) { 203 203 return !primitive.isDeleted(); 204 204 } … … 206 206 207 207 public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate = new Predicate<OsmPrimitive>() { 208 public boolean evaluate(OsmPrimitive primitive) {208 @Override public boolean evaluate(OsmPrimitive primitive) { 209 209 return !primitive.isDeleted() && !primitive.isIncomplete(); 210 210 } … … 212 212 213 213 public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate = new Predicate<OsmPrimitive>() { 214 public boolean evaluate(OsmPrimitive primitive) {214 @Override public boolean evaluate(OsmPrimitive primitive) { 215 215 return !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation); 216 216 } … … 218 218 219 219 public static final Predicate<OsmPrimitive> modifiedPredicate = new Predicate<OsmPrimitive>() { 220 public boolean evaluate(OsmPrimitive primitive) {220 @Override public boolean evaluate(OsmPrimitive primitive) { 221 221 return primitive.isModified(); 222 222 } … … 224 224 225 225 public static final Predicate<OsmPrimitive> nodePredicate = new Predicate<OsmPrimitive>() { 226 public boolean evaluate(OsmPrimitive primitive) {226 @Override public boolean evaluate(OsmPrimitive primitive) { 227 227 return primitive.getClass() == Node.class; 228 228 } … … 230 230 231 231 public static final Predicate<OsmPrimitive> wayPredicate = new Predicate<OsmPrimitive>() { 232 public boolean evaluate(OsmPrimitive primitive) {232 @Override public boolean evaluate(OsmPrimitive primitive) { 233 233 return primitive.getClass() == Way.class; 234 234 } … … 236 236 237 237 public static final Predicate<OsmPrimitive> relationPredicate = new Predicate<OsmPrimitive>() { 238 public boolean evaluate(OsmPrimitive primitive) {238 @Override public boolean evaluate(OsmPrimitive primitive) { 239 239 return primitive.getClass() == Relation.class; 240 240 } … … 242 242 243 243 public static final Predicate<OsmPrimitive> allPredicate = new Predicate<OsmPrimitive>() { 244 public boolean evaluate(OsmPrimitive primitive) {244 @Override public boolean evaluate(OsmPrimitive primitive) { 245 245 return true; 246 246 } … … 397 397 * @see #setVersion(int) 398 398 */ 399 public long getVersion() { 399 @Override 400 public int getVersion() { 400 401 return version; 401 402 } … … 406 407 * @return the id of this primitive. 407 408 */ 409 @Override 408 410 public long getId() { 409 411 long id = this.id; … … 415 417 * @return Osm id if primitive already exists on the server. Unique negative value if primitive is new 416 418 */ 419 @Override 417 420 public long getUniqueId() { 418 421 return id; … … 423 426 * @return True if primitive is new (not yet uploaded the server, id <= 0) 424 427 */ 428 @Override 425 429 public boolean isNew() { 426 430 return id <= 0; … … 449 453 * @throws DataIntegrityProblemException If id is changed and primitive was already added to the dataset 450 454 */ 455 @Override 451 456 public void setOsmId(long id, int version) { 452 457 boolean locked = writeLock(); … … 496 501 * @return the user who has last touched this object. May be null. 497 502 */ 503 @Override 498 504 public User getUser() { 499 505 return user; … … 505 511 * @param user the user 506 512 */ 513 @Override 507 514 public void setUser(User user) { 508 515 boolean locked = writeLock(); … … 521 528 * @return the id of the changeset this primitive was last uploaded to. 522 529 */ 530 @Override 523 531 public int getChangesetId() { 524 532 return changesetId; … … 533 541 * @throws IllegalArgumentException thrown if id < 0 534 542 */ 543 @Override 535 544 public void setChangesetId(int changesetId) throws IllegalStateException, IllegalArgumentException { 536 545 boolean locked = writeLock(); … … 566 575 } 567 576 577 @Override 568 578 public void setTimestamp(Date timestamp) { 569 579 boolean locked = writeLock(); … … 581 591 * 582 592 */ 593 @Override 583 594 public Date getTimestamp() { 584 595 return new Date(timestamp * 1000l); 585 596 } 586 597 598 @Override 587 599 public boolean isTimestampEmpty() { 588 600 return timestamp == 0; … … 674 686 * @param modified true, if this primitive is to be modified 675 687 */ 688 @Override 676 689 public void setModified(boolean modified) { 677 690 updateFlags(FLAG_MODIFIED, modified); … … 688 701 * the server 689 702 */ 703 @Override 690 704 public boolean isModified() { 691 705 return (flags & FLAG_MODIFIED) != 0; … … 698 712 * @see #setDeleted(boolean) 699 713 */ 714 @Override 700 715 public boolean isDeleted() { 701 716 return (flags & FLAG_DELETED) != 0; … … 737 752 * @see #setVisible(boolean) 738 753 */ 754 @Override 739 755 public boolean isVisible() { 740 756 return (flags & FLAG_VISIBLE) != 0; … … 749 765 * id==0 750 766 */ 767 @Override 751 768 public void setVisible(boolean visible) throws IllegalStateException{ 752 769 boolean locked = writeLock(); … … 767 784 * @param deleted true, if this primitive is deleted; false, otherwise 768 785 */ 786 @Override 769 787 public void setDeleted(boolean deleted) { 770 788 boolean locked = writeLock(); … … 805 823 } 806 824 825 @Override 807 826 public boolean isIncomplete() { 808 827 return (flags & FLAG_INCOMPLETE) != 0; … … 995 1014 * back to the primitive, use setKeys() to modify the keys 996 1015 */ 1016 @Override 997 1017 public Map<String, String> getKeys() { 998 1018 Map<String, String> result = new HashMap<String, String>(); … … 1012 1032 * @param keys the key/value pairs to set. If null, removes all existing key/value pairs. 1013 1033 */ 1034 @Override 1014 1035 public void setKeys(Map<String, String> keys) { 1015 1036 boolean locked = writeLock(); … … 1043 1064 * @see #remove(String) 1044 1065 */ 1066 @Override 1045 1067 public final void put(String key, String value) { 1046 1068 boolean locked = writeLock(); … … 1081 1103 * @param key the key to be removed. Ignored, if key is null. 1082 1104 */ 1105 @Override 1083 1106 public final void remove(String key) { 1084 1107 boolean locked = writeLock(); … … 1113 1136 * @since 1843 1114 1137 */ 1138 @Override 1115 1139 public final void removeAll() { 1116 1140 boolean locked = writeLock(); … … 1133 1157 * @return the value for key <code>key</code>. 1134 1158 */ 1159 @Override 1135 1160 public final String get(String key) { 1136 1161 String[] keys = this.keys; … … 1145 1170 } 1146 1171 1172 @Override 1147 1173 public final Collection<String> keySet() { 1148 1174 String[] keys = this.keys; … … 1162 1188 * otherwise 1163 1189 */ 1190 @Override 1164 1191 public final boolean hasKeys() { 1165 1192 return keys != null; -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r3083 r4098 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.util.ArrayList; … … 16 18 * 17 19 */ 18 public abstract class PrimitiveData implements Tagged, PrimitiveId{20 public abstract class PrimitiveData implements IPrimitive { 19 21 20 22 // Useful? … … 51 53 private int changesetId; 52 54 55 @Override 53 56 public boolean isModified() { 54 57 return modified; 55 58 } 59 @Override 56 60 public void setModified(boolean modified) { 57 61 this.modified = modified; 58 62 } 63 @Override 59 64 public boolean isVisible() { 60 65 return visible; 61 66 } 67 @Override 62 68 public void setVisible(boolean visible) { 63 69 this.visible = visible; 64 70 } 71 @Override 65 72 public boolean isDeleted() { 66 73 return deleted; 67 74 } 75 @Override 68 76 public void setDeleted(boolean deleted) { 69 77 this.deleted = deleted; 70 78 } 79 @Override 71 80 public long getId() { 72 81 return id > 0 ? id : 0; … … 75 84 this.id = id; 76 85 } 86 @Override 77 87 public User getUser() { 78 88 return user; 79 89 } 90 @Override 80 91 public void setUser(User user) { 81 92 this.user = user; 82 93 } 94 @Override 83 95 public int getVersion() { 84 96 return version; … … 87 99 this.version = version; 88 100 } 101 @Override 102 public void setOsmId(long id, int version) { 103 if (id <= 0) 104 throw new IllegalArgumentException(tr("ID > 0 expected. Got {0}.", id)); 105 if (version <= 0) 106 throw new IllegalArgumentException(tr("Version > 0 expected. Got {0}.", version)); 107 this.id = id; 108 this.version = version; 109 this.setIncomplete(false); 110 } 111 @Override 89 112 public Date getTimestamp() { 90 113 return timestamp; 91 114 } 115 @Override 92 116 public void setTimestamp(Date timestamp) { 93 117 this.timestamp = timestamp; 94 118 } 95 119 @Override 120 public boolean isTimestampEmpty() { 121 return timestamp == null || timestamp.getTime() == 0; 122 } 123 124 @Override 96 125 public int getChangesetId() { 97 126 return changesetId; 98 127 } 99 128 129 @Override 100 130 public void setChangesetId(int changesetId) { 101 131 this.changesetId = changesetId; 102 132 } 103 133 134 @Override 104 135 public Map<String, String> getKeys() { 105 136 return keys; 106 137 } 138 @Override 107 139 public boolean isIncomplete() { 108 140 return incomplete; … … 141 173 // Tagged implementation 142 174 175 @Override 143 176 public String get(String key) { 144 177 return keys.get(key); 145 178 } 146 179 180 @Override 147 181 public boolean hasKeys() { 148 182 return !keys.isEmpty(); 149 183 } 150 184 185 @Override 151 186 public Collection<String> keySet() { 152 187 return keys.keySet(); 153 188 } 154 189 190 @Override 155 191 public void put(String key, String value) { 156 192 keys.put(key, value); 157 193 } 158 194 195 @Override 159 196 public void remove(String key) { 160 197 keys.remove(key); 161 198 } 162 199 200 @Override 163 201 public void removeAll() { 164 202 keys.clear(); 165 203 } 166 204 205 @Override 167 206 public void setKeys(Map<String, String> keys) { 168 207 this.keys.clear(); … … 191 230 * PrimitiveId implementation. Returns the same value as getId() 192 231 */ 232 @Override 193 233 public long getUniqueId() { 194 234 return id; … … 204 244 } 205 245 246 @Override 206 247 public boolean isNew() { 207 248 return id <= 0; 208 249 } 209 250 251 @Override 210 252 public abstract OsmPrimitiveType getType(); 211 253 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r3943 r4098 18 18 * @author Frederik Ramm <frederik@remote.org> 19 19 */ 20 public final class Relation extends OsmPrimitive {20 public final class Relation extends OsmPrimitive implements IRelation { 21 21 22 22 private RelationMember[] members = new RelationMember[0]; … … 65 65 * @return number of members 66 66 */ 67 @Override 67 68 public int getMembersCount() { 68 69 return members.length; … … 143 144 writeUnlock(locked); 144 145 } 146 } 147 148 @Override 149 public long getMemberId(int idx) { 150 return members[idx].getUniqueId(); 151 } 152 153 @Override 154 public String getRole(int idx) { 155 return members[idx].getRole(); 156 } 157 158 @Override 159 public OsmPrimitiveType getMemberType(int idx) { 160 return members[idx].getType(); 145 161 } 146 162 … … 266 282 } 267 283 284 @Override 268 285 public int compareTo(OsmPrimitive o) { 269 286 return o instanceof Relation ? Long.valueOf(getUniqueId()).compareTo(o.getUniqueId()) : -1; … … 373 390 } 374 391 392 @Override 375 393 public OsmPrimitiveType getType() { 376 394 return OsmPrimitiveType.RELATION; 377 395 } 378 396 397 @Override 379 398 public OsmPrimitiveType getDisplayType() { 380 399 return isMultipolygon() ? OsmPrimitiveType.MULTIPOLYGON -
trunk/src/org/openstreetmap/josm/data/osm/RelationData.java
r3083 r4098 5 5 import java.util.List; 6 6 7 public class RelationData extends PrimitiveData {7 public class RelationData extends PrimitiveData implements IRelation { 8 8 9 9 private List<RelationMemberData> members = new ArrayList<RelationMemberData>(); … … 27 27 28 28 @Override 29 public int getMembersCount() { 30 return members.size(); 31 } 32 33 @Override 34 public long getMemberId(int idx) { 35 return members.get(idx).getMemberId(); 36 } 37 38 @Override 39 public String getRole(int idx) { 40 return members.get(idx).getRole(); 41 } 42 43 @Override 44 public OsmPrimitiveType getMemberType(int idx) { 45 return members.get(idx).getMemberType(); 46 } 47 48 @Override 29 49 public RelationData makeCopy() { 30 50 return new RelationData(this); -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r4054 r4098 19 19 * @author imi 20 20 */ 21 public final class Way extends OsmPrimitive {21 public final class Way extends OsmPrimitive implements IWay { 22 22 23 23 /** … … 94 94 * @since 1862 95 95 */ 96 @Override 96 97 public int getNodesCount() { 97 98 return nodes.length; … … 109 110 public Node getNode(int index) { 110 111 return nodes[index]; 112 } 113 114 @Override 115 public long getNodeId(int idx) { 116 return nodes[idx].getUniqueId(); 111 117 } 112 118 … … 275 281 } 276 282 283 @Override 277 284 public int compareTo(OsmPrimitive o) { 278 285 if (o instanceof Relation) … … 444 451 } 445 452 453 @Override 446 454 public OsmPrimitiveType getType() { 447 455 return OsmPrimitiveType.WAY; -
trunk/src/org/openstreetmap/josm/data/osm/WayData.java
r3083 r4098 5 5 import java.util.List; 6 6 7 public class WayData extends PrimitiveData {7 public class WayData extends PrimitiveData implements IWay { 8 8 9 9 private List<Long> nodes = new ArrayList<Long>(); … … 20 20 public List<Long> getNodes() { 21 21 return nodes; 22 } 23 24 @Override 25 public int getNodesCount() { 26 return nodes.size(); 27 } 28 29 @Override 30 public long getNodeId(int idx) { 31 return nodes.get(idx); 22 32 } 23 33
Note:
See TracChangeset
for help on using the changeset viewer.