Changeset 2115 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-09-13T19:30:36+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 added
- 4 edited
-
Changeset.java (modified) (3 diffs)
-
DataSet.java (modified) (1 diff)
-
OsmPrimitive.java (modified) (1 diff)
-
OsmPrimitiveType.java (modified) (2 diffs)
-
Tagged.java (added)
-
UserInfo.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r2081 r2115 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import javax.print.attribute.standard.MediaSize.Other; 7 6 import java.util.Collection; 7 import java.util.Date; 8 import java.util.HashMap; 9 import java.util.Map; 10 11 import org.openstreetmap.josm.data.coor.LatLon; 8 12 import org.openstreetmap.josm.data.osm.visitor.Visitor; 9 13 … … 13 17 * 14 18 */ 15 public final class Changeset extends OsmPrimitive { 19 public final class Changeset implements Tagged { 20 /** the changeset id */ 21 private long id; 22 /** the user who owns the changeset */ 23 private User user; 24 /** date this changeset was created at */ 25 private Date createdAt; 26 /** the date this changeset was closed at*/ 27 private Date closedAt; 28 /** indicates whether this changeset is still open or not */ 29 private boolean open; 30 /** the min. coordinates of the bounding box of this changeset */ 31 private LatLon min; 32 /** the max. coordinates of the bounding box of this changeset */ 33 private LatLon max; 34 /** the map of tags */ 35 private Map<String,String> tags; 36 /** indicates whether this changeset is incomplete. For an 37 * incomplete changeset we only know its id 38 */ 39 private boolean incomplete; 40 41 16 42 /** 17 * Time of last modification to this object. This is not set by JOSM but 18 * read from the server and delivered back to the server unmodified. 43 * Creates a new changeset with id 0. 19 44 */ 20 public String end_timestamp = null; 45 public Changeset() { 46 this.id = 0; 47 this.tags = new HashMap<String, String>(); 48 } 21 49 22 50 /** 23 * Time of first modification to this object. This is not set by JOSM but 24 * read from the server and delivered back to the server unmodified. 51 * Creates a changeset with id <code>id</code>. If id > 0, sets incomplete to true. 52 * 53 * @param id the id 25 54 */ 26 public String start_timestamp = null;27 28 public Changeset() {29 super(0);30 }31 32 55 public Changeset(long id) { 33 super(id); 34 } 35 36 public Changeset(Changeset clone){ 37 super(clone.getId()); 38 cloneFrom(clone); 39 } 40 41 @Override 56 this.id = id; 57 this.incomplete = id > 0; 58 this.tags = new HashMap<String, String>(); 59 } 60 61 /** 62 * Creates a clone of <code>other</code> 63 * 64 * @param other the other changeset. If null, creates a new changeset with id 0. 65 */ 66 public Changeset(Changeset other) { 67 if (other == null) { 68 this.id = 0; 69 this.tags = new HashMap<String, String>(); 70 } else if (other.isIncomplete()) { 71 setId(other.getId()); 72 this.incomplete = true; 73 } else { 74 cloneFrom(other); 75 this.incomplete = false; 76 } 77 } 78 79 public void cloneFrom(Changeset other) { 80 setId(other.getId()); 81 setUser(other.getUser()); 82 setCreatedAt(other.getCreatedAt()); 83 setClosedAt(other.getClosedAt()); 84 setMin(other.getMin()); 85 setMax(other.getMax()); 86 setKeys(other.getKeys()); 87 setOpen(other.isOpen()); 88 } 89 42 90 public void visit(Visitor v) { 43 91 v.visit(this); 44 92 } 45 93 46 public int compareTo(OsmPrimitive other) { 47 if (other instanceof Changeset) return Long.valueOf(getId()).compareTo(other.getId()); 48 return 1; 49 } 50 51 @Override 94 public int compareTo(Changeset other) { 95 return Long.valueOf(getId()).compareTo(other.getId()); 96 } 97 52 98 public String getName() { 53 99 // no translation … … 55 101 } 56 102 57 @Override58 103 public String getLocalName(){ 59 104 return tr("Changeset {0}",getId()); 60 105 } 61 106 62 @Override63 107 public String getDisplayName(NameFormatter formatter) { 64 108 return formatter.format(this); 65 109 } 66 110 67 68 @Override public void cloneFrom(OsmPrimitive osm) { 69 super.cloneFrom(osm); 111 public long getId() { 112 return id; 113 } 114 115 public void setId(long id) { 116 this.id = id; 117 } 118 119 public User getUser() { 120 return user; 121 } 122 123 public void setUser(User user) { 124 this.user = user; 125 } 126 127 public Date getCreatedAt() { 128 return createdAt; 129 } 130 131 public void setCreatedAt(Date createdAt) { 132 this.createdAt = createdAt; 133 } 134 135 public Date getClosedAt() { 136 return closedAt; 137 } 138 139 public void setClosedAt(Date closedAt) { 140 this.closedAt = closedAt; 141 } 142 143 public boolean isOpen() { 144 return open; 145 } 146 147 public void setOpen(boolean open) { 148 this.open = open; 149 } 150 151 public LatLon getMin() { 152 return min; 153 } 154 155 public void setMin(LatLon min) { 156 this.min = min; 157 } 158 159 public LatLon getMax() { 160 return max; 161 } 162 163 public void setMax(LatLon max) { 164 this.max = max; 165 } 166 167 public Map<String, String> getKeys() { 168 return tags; 169 } 170 171 public void setKeys(Map<String, String> keys) { 172 this.tags = keys; 173 } 174 175 public boolean isIncomplete() { 176 return incomplete; 177 } 178 179 public void setIncomplete(boolean incomplete) { 180 this.incomplete = incomplete; 181 } 182 183 public void put(String key, String value) { 184 this.tags.put(key, value); 185 } 186 187 public String get(String key) { 188 return this.tags.get(key); 189 } 190 191 public void remove(String key) { 192 this.tags.remove(key); 193 } 194 195 public boolean hasEqualSemanticAttributes(Changeset other) { 196 if (other == null) 197 return false; 198 if (closedAt == null) { 199 if (other.closedAt != null) 200 return false; 201 } else if (!closedAt.equals(other.closedAt)) 202 return false; 203 if (createdAt == null) { 204 if (other.createdAt != null) 205 return false; 206 } else if (!createdAt.equals(other.createdAt)) 207 return false; 208 if (id != other.id) 209 return false; 210 if (max == null) { 211 if (other.max != null) 212 return false; 213 } else if (!max.equals(other.max)) 214 return false; 215 if (min == null) { 216 if (other.min != null) 217 return false; 218 } else if (!min.equals(other.min)) 219 return false; 220 if (open != other.open) 221 return false; 222 if (tags == null) { 223 if (other.tags != null) 224 return false; 225 } else if (!tags.equals(other.tags)) 226 return false; 227 if (user == null) { 228 if (other.user != null) 229 return false; 230 } else if (!user.equals(other.user)) 231 return false; 232 return true; 233 } 234 235 @Override 236 public int hashCode() { 237 final int prime = 31; 238 int result = 1; 239 result = prime * result + (int) (id ^ (id >>> 32)); 240 if (id > 0) 241 return prime * result + getClass().hashCode(); 242 result = prime * result + ((closedAt == null) ? 0 : closedAt.hashCode()); 243 result = prime * result + ((createdAt == null) ? 0 : createdAt.hashCode()); 244 result = prime * result + ((max == null) ? 0 : max.hashCode()); 245 result = prime * result + ((min == null) ? 0 : min.hashCode()); 246 result = prime * result + (open ? 1231 : 1237); 247 result = prime * result + ((tags == null) ? 0 : tags.hashCode()); 248 result = prime * result + ((user == null) ? 0 : user.hashCode()); 249 return result; 250 } 251 252 @Override 253 public boolean equals(Object obj) { 254 if (this == obj) 255 return true; 256 if (obj == null) 257 return false; 258 if (getClass() != obj.getClass()) 259 return false; 260 Changeset other = (Changeset) obj; 261 if (this.id > 0 && other.id == this.id) 262 return true; 263 if (closedAt == null) { 264 if (other.closedAt != null) 265 return false; 266 } else if (!closedAt.equals(other.closedAt)) 267 return false; 268 if (createdAt == null) { 269 if (other.createdAt != null) 270 return false; 271 } else if (!createdAt.equals(other.createdAt)) 272 return false; 273 if (id != other.id) 274 return false; 275 if (max == null) { 276 if (other.max != null) 277 return false; 278 } else if (!max.equals(other.max)) 279 return false; 280 if (min == null) { 281 if (other.min != null) 282 return false; 283 } else if (!min.equals(other.min)) 284 return false; 285 if (open != other.open) 286 return false; 287 if (tags == null) { 288 if (other.tags != null) 289 return false; 290 } else if (!tags.equals(other.tags)) 291 return false; 292 if (user == null) { 293 if (other.user != null) 294 return false; 295 } else if (!user.equals(other.user)) 296 return false; 297 return true; 298 } 299 300 public boolean hasKeys() { 301 return !tags.keySet().isEmpty(); 302 } 303 304 public Collection<String> keySet() { 305 return tags.keySet(); 70 306 } 71 307 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2077 r2115 326 326 Collection<? extends OsmPrimitive> primitives = null; 327 327 switch(type) { 328 case NODE: primitives = nodes; break; 329 case WAY: primitives = ways; break; 330 case RELATION: primitives = relations; break; 331 case CHANGESET: throw new IllegalArgumentException(tr("unsupported value ''{0}'' or parameter ''{1}''", type, "type")); 328 case NODE: primitives = nodes; break; 329 case WAY: primitives = ways; break; 330 case RELATION: primitives = relations; break; 332 331 } 333 332 for (OsmPrimitive primitive : primitives) { -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2083 r2115 33 33 * @author imi 34 34 */ 35 abstract public class OsmPrimitive implements Comparable<OsmPrimitive> { 35 abstract public class OsmPrimitive implements Comparable<OsmPrimitive>, Tagged { 36 36 37 37 static public <T extends OsmPrimitive> List<T> getFilteredList(Collection<OsmPrimitive> list, Class<T> type) { -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r2077 r2115 7 7 NODE ("node"), 8 8 WAY ("way"), 9 RELATION ("relation"), 10 CHANGESET ("changeset"); 9 RELATION ("relation"); 11 10 12 11 private String apiTypeName; … … 35 34 if (cls.equals(Way.class)) return WAY; 36 35 if (cls.equals(Relation.class)) return RELATION; 37 if (cls.equals(Changeset.class)) return CHANGESET;38 36 throw new IllegalArgumentException(tr("parameter ''{0}'' is not an acceptable class, got ''{1}''", "cls", cls.toString())); 39 37 }
Note:
See TracChangeset
for help on using the changeset viewer.
