Changeset 7012 in josm for trunk/src/org/openstreetmap/josm/io/OsmReader.java
- Timestamp:
- 2014-04-27T15:35:47+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r7005 r7012 109 109 110 110 protected void parseRoot() throws XMLStreamException { 111 if ( parser.getLocalName().equals("osm")) {111 if ("osm".equals(parser.getLocalName())) { 112 112 parseOsm(); 113 113 } else { … … 121 121 throwException(tr("Missing mandatory attribute ''{0}''.", "version")); 122 122 } 123 if (!( v.equals("0.5") || v.equals("0.6"))) {123 if (!("0.5".equals(v) || "0.6".equals(v))) { 124 124 throwException(tr("Unsupported version: {0}", v)); 125 125 } … … 143 143 144 144 if (event == XMLStreamConstants.START_ELEMENT) { 145 if (parser.getLocalName().equals("bounds")) { 145 switch (parser.getLocalName()) { 146 case "bounds": 146 147 parseBounds(generator); 147 } else if (parser.getLocalName().equals("node")) { 148 break; 149 case "node": 148 150 parseNode(); 149 } else if (parser.getLocalName().equals("way")) { 151 break; 152 case "way": 150 153 parseWay(); 151 } else if (parser.getLocalName().equals("relation")) { 154 break; 155 case "relation": 152 156 parseRelation(); 153 } else if (parser.getLocalName().equals("changeset")) { 157 break; 158 case "changeset": 154 159 parseChangeset(uploadChangesetId); 155 } else { 160 break; 161 default: 156 162 parseUnknown(); 157 163 } … … 205 211 int event = parser.next(); 206 212 if (event == XMLStreamConstants.START_ELEMENT) { 207 if ( parser.getLocalName().equals("tag")) {213 if ("tag".equals(parser.getLocalName())) { 208 214 parseTag(n); 209 215 } else { … … 227 233 int event = parser.next(); 228 234 if (event == XMLStreamConstants.START_ELEMENT) { 229 if (parser.getLocalName().equals("nd")) { 235 switch (parser.getLocalName()) { 236 case "nd": 230 237 nodeIds.add(parseWayNode(w)); 231 } else if (parser.getLocalName().equals("tag")) { 238 break; 239 case "tag": 232 240 parseTag(w); 233 } else { 241 break; 242 default: 234 243 parseUnknown(); 235 244 } … … 274 283 int event = parser.next(); 275 284 if (event == XMLStreamConstants.START_ELEMENT) { 276 if (parser.getLocalName().equals("member")) { 285 switch (parser.getLocalName()) { 286 case "member": 277 287 members.add(parseRelationMember(r)); 278 } else if (parser.getLocalName().equals("tag")) { 288 break; 289 case "tag": 279 290 parseTag(r); 280 } else { 291 break; 292 default: 281 293 parseUnknown(); 282 294 } … … 337 349 int event = parser.next(); 338 350 if (event == XMLStreamConstants.START_ELEMENT) { 339 if ( parser.getLocalName().equals("tag")) {351 if ("tag".equals(parser.getLocalName())) { 340 352 parseTag(uploadChangeset); 341 353 } else { … … 447 459 throwException(tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", Long.toString(current.getUniqueId()), versionString), e); 448 460 } 449 if (ds.getVersion().equals("0.6")){ 461 switch (ds.getVersion()) { 462 case "0.6": 450 463 if (version <= 0 && !current.isNew()) { 451 464 throwException(tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", Long.toString(current.getUniqueId()), versionString)); … … 454 467 version = 0; 455 468 } 456 } else if (ds.getVersion().equals("0.5")) { 469 break; 470 case "0.5": 457 471 if (version <= 0 && !current.isNew()) { 458 472 Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 1, "0.5")); … … 462 476 version = 0; 463 477 } 464 } else { 478 break; 479 default: 465 480 // should not happen. API version has been checked before 466 481 throwException(tr("Unknown or unsupported API version. Got {0}.", ds.getVersion())); … … 469 484 // version expected for OSM primitives with an id assigned by the server (id > 0), since API 0.6 470 485 // 471 if (!current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.6")) {486 if (!current.isNew() && ds.getVersion() != null && "0.6".equals(ds.getVersion())) { 472 487 throwException(tr("Missing attribute ''version'' on OSM primitive with ID {0}.", Long.toString(current.getUniqueId()))); 473 } else if (!current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.5")) {488 } else if (!current.isNew() && ds.getVersion() != null && "0.5".equals(ds.getVersion())) { 474 489 // default version in 0.5 files for existing primitives 475 490 Main.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.getUniqueId(), version, 1, "0.5")); 476 491 version= 1; 477 } else if (current.isNew() && ds.getVersion() != null && ds.getVersion().equals("0.5")) { 478 // default version in 0.5 files for new primitives, no warning necessary. This is 479 // (was) legal in API 0.5 492 } else if (current.isNew() && ds.getVersion() != null && "0.5".equals(ds.getVersion())) { 493 // default version in 0.5 files for new primitives, no warning necessary. This is (was) legal in API 0.5 480 494 version= 0; 481 495 } … … 486 500 if (action == null) { 487 501 // do nothing 488 } else if ( action.equals("delete")) {502 } else if ("delete".equals(action)) { 489 503 current.setDeleted(true); 490 504 current.setModified(current.isVisible()); 491 } else if ( action.equals("modify")) {505 } else if ("modify".equals(action)) { 492 506 current.setModified(true); 493 507 }
Note:
See TracChangeset
for help on using the changeset viewer.