- Timestamp:
- 2014-04-27T15:35:47+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r7005 r7012 96 96 int shortcut = -1; 97 97 98 // TODO: convert this to switch/case and make sure the parsing still works 98 99 /* leave as single line for shortcut overview parsing! */ 99 100 if (mode.equals("data")) { shortcut = KeyEvent.VK_1; } … … 130 131 putValue("help", "Action/AutoScale/" + modeHelp); 131 132 this.mode = mode; 132 if (mode.equals("data")) { 133 switch (mode) { 134 case "data": 133 135 putValue("help", ht("/Action/ZoomToData")); 134 } else if (mode.equals("layer")) { 136 break; 137 case "layer": 135 138 putValue("help", ht("/Action/ZoomToLayer")); 136 } else if (mode.equals("selection")) { 139 break; 140 case "selection": 137 141 putValue("help", ht("/Action/ZoomToSelection")); 138 } else if (mode.equals("conflict")) { 142 break; 143 case "conflict": 139 144 putValue("help", ht("/Action/ZoomToConflict")); 140 } else if (mode.equals("problem")) { 145 break; 146 case "problem": 141 147 putValue("help", ht("/Action/ZoomToProblem")); 142 } else if (mode.equals("download")) { 148 break; 149 case "download": 143 150 putValue("help", ht("/Action/ZoomToDownload")); 144 } else if (mode.equals("previous")) { 151 break; 152 case "previous": 145 153 putValue("help", ht("/Action/ZoomToPrevious")); 146 } else if (mode.equals("next")) { 154 break; 155 case "next": 147 156 putValue("help", ht("/Action/ZoomToNext")); 148 } else { 157 break; 158 default: 149 159 throw new IllegalArgumentException("Unknown mode: "+mode); 150 160 } … … 154 164 public void autoScale() { 155 165 if (Main.isDisplayingMapView()) { 156 if (mode.equals("previous")) { 166 switch(mode) { 167 case "previous": 157 168 Main.map.mapView.zoomPrevious(); 158 } else if (mode.equals("next")) { 169 break; 170 case "next": 159 171 Main.map.mapView.zoomNext(); 160 } else { 172 break; 173 default: 161 174 BoundingXYVisitor bbox = getBoundingBox(); 162 175 if (bbox != null && bbox.getBounds() != null) { … … 187 200 188 201 private BoundingXYVisitor getBoundingBox() { 189 BoundingXYVisitor v = mode.equals("problem") ? new ValidatorBoundingXYVisitor() : new BoundingXYVisitor(); 190 191 if (mode.equals("problem")) { 202 BoundingXYVisitor v = "problem".equals(mode) ? new ValidatorBoundingXYVisitor() : new BoundingXYVisitor(); 203 204 switch(mode) { 205 case "problem": 192 206 TestError error = Main.map.validatorDialog.getSelectedError(); 193 207 if (error == null) return null; … … 195 209 if (v.getBounds() == null) return null; 196 210 v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002)); 197 } else if (mode.equals("data")) { 211 break; 212 case "data": 198 213 for (Layer l : Main.map.mapView.getAllLayers()) { 199 214 l.visitBoundingBox(v); 200 215 } 201 } else if (mode.equals("layer")) { 216 break; 217 case "layer": 202 218 if (Main.main.getActiveLayer() == null) 203 219 return null; … … 206 222 if (l == null) return null; 207 223 l.visitBoundingBox(v); 208 } else if (mode.equals("selection") || mode.equals("conflict")) { 224 break; 225 case "selection": 226 case "conflict": 209 227 Collection<OsmPrimitive> sel = new HashSet<>(); 210 if ( mode.equals("selection")) {228 if ("selection".equals(mode)) { 211 229 sel = getCurrentDataSet().getSelected(); 212 } else if (mode.equals("conflict")){230 } else { 213 231 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict(); 214 232 if (c != null) { … … 221 239 JOptionPane.showMessageDialog( 222 240 Main.parent, 223 ( mode.equals("selection") ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to")),241 ("selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to")), 224 242 tr("Information"), 225 243 JOptionPane.INFORMATION_MESSAGE … … 236 254 // ensure reasonable zoom level when zooming onto single nodes. 237 255 v.enlargeToMinDegrees(0.0005); 238 } else if (mode.equals("download")) { 256 break; 257 case "download": 239 258 Bounds bounds = DownloadDialog.getSavedDownloadBounds(); 240 259 if (bounds != null) { … … 245 264 } 246 265 } 266 break; 247 267 } 248 268 return v; … … 251 271 @Override 252 272 protected void updateEnabledState() { 253 if ("selection".equals(mode)) { 273 switch(mode) { 274 case "selection": 254 275 setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty()); 255 } else if ("layer".equals(mode)) { 276 break; 277 case "layer": 256 278 if (!Main.isDisplayingMapView() || Main.map.mapView.getAllLayersAsList().isEmpty()) { 257 279 setEnabled(false); … … 260 282 setEnabled(true); 261 283 } 262 } else if ("conflict".equals(mode)) { 284 break; 285 case "conflict": 263 286 setEnabled(Main.map != null && Main.map.conflictDialog.getSelectedConflict() != null); 264 } else if ("problem".equals(mode)) { 287 break; 288 case "problem": 265 289 setEnabled(Main.map != null && Main.map.validatorDialog.getSelectedError() != null); 266 } else if ("previous".equals(mode)) { 290 break; 291 case "previous": 267 292 setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasZoomUndoEntries()); 268 } else if ("next".equals(mode)) { 293 break; 294 case "next": 269 295 setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasZoomRedoEntries()); 270 } else { 271 setEnabled( 272 Main.isDisplayingMapView() 273 && Main.map.mapView.hasLayers() 296 break; 297 default: 298 setEnabled(Main.isDisplayingMapView() && Main.map.mapView.hasLayers() 274 299 ); 275 300 } … … 311 336 312 337 public MapFrameAdapter() { 313 if ( mode.equals("conflict")) {338 if ("conflict".equals(mode)) { 314 339 conflictSelectionListener = new ListSelectionListener() { 315 340 @Override public void valueChanged(ListSelectionEvent e) { … … 317 342 } 318 343 }; 319 } else if ( mode.equals("problem")) {344 } else if ("problem".equals(mode)) { 320 345 validatorSelectionListener = new TreeSelectionListener() { 321 346 @Override public void valueChanged(TreeSelectionEvent e) { -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r7005 r7012 355 355 if( !Main.pref.getBoolean("multipoly.alltags", false) ) 356 356 for( RelationMember m : relation.getMembers() ) 357 if( m.hasRole() && m.getRole().equals("outer") && m.isWay() )357 if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() ) 358 358 for( String key : values.keySet() ) 359 359 if( !m.getWay().hasKey(key) && !relation.hasKey(key) ) … … 407 407 for (Entry<String, String> entry : values.entrySet()) { 408 408 String key = entry.getKey(); 409 if (!r2.hasKey(key) && ! key.equals("area") ) {409 if (!r2.hasKey(key) && !"area".equals(key) ) { 410 410 if (relation.isNew()) 411 411 relation.put(key, entry.getValue()); -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r7005 r7012 186 186 } catch (InvalidUserInputException ex) { 187 187 String msg; 188 if ( ex.getMessage().equals("usage")) {188 if ("usage".equals(ex.getMessage())) { 189 189 msg = "<h2>" + tr("Usage") + "</h2>" + USAGE; 190 190 } else { -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r7005 r7012 105 105 @Override 106 106 public Match get(String keyword, PushbackTokenizer tokenizer) throws ParseError { 107 if ("modified".equals(keyword)) 107 switch(keyword) { 108 case "modified": 108 109 return new Modified(); 109 else if ("selected".equals(keyword))110 case "selected": 110 111 return new Selected(); 111 else if ("incomplete".equals(keyword))112 case "incomplete": 112 113 return new Incomplete(); 113 else if ("untagged".equals(keyword))114 case "untagged": 114 115 return new Untagged(); 115 else if ("closed".equals(keyword))116 case "closed": 116 117 return new Closed(); 117 else if ("new".equals(keyword))118 case "new": 118 119 return new New(); 119 else if ("indownloadedarea".equals(keyword))120 case "indownloadedarea": 120 121 return new InDataSourceArea(false); 121 else if ("allindownloadedarea".equals(keyword))122 case "allindownloadedarea": 122 123 return new InDataSourceArea(true); 123 else if ("inview".equals(keyword))124 case "inview": 124 125 return new InView(false); 125 else if ("allinview".equals(keyword))126 case "allinview": 126 127 return new InView(true); 127 else if (tokenizer != null) { 128 if ("id".equals(keyword)) 129 return new Id(tokenizer); 130 else if ("version".equals(keyword)) 131 return new Version(tokenizer); 132 else if ("changeset".equals(keyword)) 133 return new ChangesetId(tokenizer); 134 else if ("nodes".equals(keyword)) 135 return new NodeCountRange(tokenizer); 136 else if ("tags".equals(keyword)) 137 return new TagCountRange(tokenizer); 138 else if ("areasize".equals(keyword)) 139 return new AreaSize(tokenizer); 140 else if ("nth".equals(keyword)) 141 return new Nth(tokenizer, false); 142 else if ("nth%".equals(keyword)) 143 return new Nth(tokenizer, true); 144 else if ("timestamp".equals(keyword)) { 145 String rangeS = " " + tokenizer.readTextOrNumber() + " "; // add leading/trailing space in order to get expected split (e.g. "a--" => {"a", ""}) 146 String[] rangeA = rangeS.split("/"); 147 if (rangeA.length == 1) 148 return new KeyValue(keyword, rangeS.trim(), regexSearch, caseSensitive); 149 else if (rangeA.length == 2) { 150 String rangeA1 = rangeA[0].trim(); 151 String rangeA2 = rangeA[1].trim(); 152 long minDate = DateUtils.fromString(rangeA1.isEmpty() ? "1980" : rangeA1).getTime(); // if min timestap is empty: use lowest possible date 153 long maxDate = rangeA2.isEmpty() ? System.currentTimeMillis() : DateUtils.fromString(rangeA2).getTime(); // if max timestamp is empty: use "now" 154 return new TimestampRange(minDate, maxDate); 155 } else 156 /* 157 * I18n: Don't translate timestamp keyword 158 */ throw new ParseError(tr("Expecting <i>min</i>/<i>max</i> after ''timestamp''")); 128 default: 129 if (tokenizer != null) { 130 switch (keyword) { 131 case "id": 132 return new Id(tokenizer); 133 case "version": 134 return new Version(tokenizer); 135 case "changeset": 136 return new ChangesetId(tokenizer); 137 case "nodes": 138 return new NodeCountRange(tokenizer); 139 case "tags": 140 return new TagCountRange(tokenizer); 141 case "areasize": 142 return new AreaSize(tokenizer); 143 case "nth": 144 return new Nth(tokenizer, false); 145 case "nth%": 146 return new Nth(tokenizer, true); 147 case "timestamp": 148 // add leading/trailing space in order to get expected split (e.g. "a--" => {"a", ""}) 149 String rangeS = " " + tokenizer.readTextOrNumber() + " "; 150 String[] rangeA = rangeS.split("/"); 151 if (rangeA.length == 1) { 152 return new KeyValue(keyword, rangeS.trim(), regexSearch, caseSensitive); 153 } else if (rangeA.length == 2) { 154 String rangeA1 = rangeA[0].trim(); 155 String rangeA2 = rangeA[1].trim(); 156 // if min timestap is empty: use lowest possible date 157 long minDate = DateUtils.fromString(rangeA1.isEmpty() ? "1980" : rangeA1).getTime(); 158 // if max timestamp is empty: use "now" 159 long maxDate = rangeA2.isEmpty() ? System.currentTimeMillis() : DateUtils.fromString(rangeA2).getTime(); 160 return new TimestampRange(minDate, maxDate); 161 } else { 162 // I18n: Don't translate timestamp keyword 163 throw new ParseError(tr("Expecting <i>min</i>/<i>max</i> after ''timestamp''")); 164 } 165 } 159 166 } 160 167 } … … 1314 1321 value = ""; 1315 1322 } 1316 if ("type".equals(key)) 1323 switch(key) { 1324 case "type": 1317 1325 return new ExactType(value); 1318 else if ("user".equals(key))1326 case "user": 1319 1327 return new UserMatch(value); 1320 else if ("role".equals(key))1328 case "role": 1321 1329 return new RoleMatch(value); 1322 else1330 default: 1323 1331 return new KeyValue(key, value, regexSearch, caseSensitive); 1332 } 1324 1333 } 1325 1334 -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r7005 r7012 490 490 Element elem = (Element) item; 491 491 492 if ("var".equals(elementName)) { 492 switch(elementName) { 493 case "var": 493 494 setVar(elem.getAttribute("name"), evalVars(elem.getAttribute("value"))); 494 } else if ("task".equals(elementName)) { 495 break; 496 case "task": 495 497 tasksMap.put(elem.getAttribute("name"), elem); 496 } else if ("runtask".equals(elementName)) { 498 break; 499 case "runtask": 497 500 if (processRunTaskElement(elem)) return; 498 } else if ("ask".equals(elementName)) { 501 break; 502 case "ask": 499 503 processAskElement(elem); 500 } else if ("if".equals(elementName)) { 504 break; 505 case "if": 501 506 processIfElement(elem); 502 } else if ("else".equals(elementName)) { 507 break; 508 case "else": 503 509 processElseElement(elem); 504 } else if ("break".equals(elementName)) { 510 break; 511 case "break": 505 512 return; 506 } else if ("plugin".equals(elementName)) {513 case "plugin": 507 514 processPluginInstallElement(elem); 508 } else if ("messagebox".equals(elementName)){ 515 break; 516 case "messagebox": 509 517 processMsgBoxElement(elem); 510 } else if ("preferences".equals(elementName)) { 518 break; 519 case "preferences": 511 520 processPreferencesElement(elem); 512 } else if ("download".equals(elementName)) { 521 break; 522 case "download": 513 523 processDownloadElement(elem); 514 } else if ("delete".equals(elementName)) { 524 break; 525 case "delete": 515 526 processDeleteElement(elem); 516 } else if ("script".equals(elementName)) { 527 break; 528 case "script": 517 529 processScriptElement(elem); 518 } else { 530 break; 531 default: 519 532 log("Error: Unknown element " + elementName); 520 533 } 521 522 } 523 } 524 525 534 } 535 } 526 536 527 537 private void processPreferencesElement(Element item) { 528 538 String oper = evalVars(item.getAttribute("operation")); 529 539 String id = evalVars(item.getAttribute("id")); 530 531 540 532 541 if ("delete-keys".equals(oper)) { … … 614 623 } 615 624 616 617 625 private void processAskElement(Element elem) { 618 626 String text = evalVars(elem.getAttribute("text")); … … 672 680 return false; 673 681 } 674 675 682 676 683 private void processScriptElement(Element elem) { … … 730 737 return s; 731 738 } 732 733 734 739 } 735 740 -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r7005 r7012 1360 1360 if (event == XMLStreamConstants.START_ELEMENT) { 1361 1361 String localName = parser.getLocalName(); 1362 if ("tag".equals(localName)) { 1362 switch(localName) { 1363 case "tag": 1363 1364 settingsMap.put(parser.getAttributeValue(null, "key"), new StringSetting(parser.getAttributeValue(null, "value"))); 1364 1365 jumpToEnd(); 1365 } else if ("list".equals(localName) ||1366 "collection".equals(localName) ||1367 "lists".equals(localName) ||1368 "maps".equals(localName)1369 ) {1366 break; 1367 case "list": 1368 case "collection": 1369 case "lists": 1370 case "maps": 1370 1371 parseToplevelList(); 1371 } else { 1372 break; 1373 default: 1372 1374 throwException("Unexpected element: "+localName); 1373 1375 } … … 1400 1402 if (event == XMLStreamConstants.START_ELEMENT) { 1401 1403 String localName = parser.getLocalName(); 1402 if ("entry".equals(localName)) { 1404 switch(localName) { 1405 case "entry": 1403 1406 if (entries == null) { 1404 1407 entries = new ArrayList<>(); … … 1406 1409 entries.add(parser.getAttributeValue(null, "value")); 1407 1410 jumpToEnd(); 1408 } else if ("list".equals(localName)) { 1411 break; 1412 case "list": 1409 1413 if (lists == null) { 1410 1414 lists = new ArrayList<>(); 1411 1415 } 1412 1416 lists.add(parseInnerList()); 1413 } else if ("map".equals(localName)) { 1417 break; 1418 case "map": 1414 1419 if (maps == null) { 1415 1420 maps = new ArrayList<>(); 1416 1421 } 1417 1422 maps.add(parseMap()); 1418 } else { 1423 break; 1424 default: 1419 1425 throwException("Unexpected element: "+localName); 1420 1426 } -
trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java
r7005 r7012 453 453 String zoom = SystemOfMeasurement.METRIC.getDistText(ll1.greatCircleDistance(ll2)); 454 454 String extension; 455 if ("image/jpeg".equals(mimeType) || "image/jpg".equals(mimeType)) { 455 switch(mimeType) { 456 case "image/jpeg": 457 case "image/jpg": 456 458 extension = "jpg"; 457 } else if ("image/png".equals(mimeType)) { 459 break; 460 case "image/png": 458 461 extension = "png"; 459 } else if ("image/gif".equals(mimeType)) { 462 break; 463 case "image/gif": 460 464 extension = "gif"; 461 } else { 465 break; 466 default: 462 467 extension = "dat"; 463 468 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r7005 r7012 916 916 917 917 /* find the "from", "via" and "to" elements */ 918 for (RelationMember m : r.getMembers()) 919 { 918 for (RelationMember m : r.getMembers()) { 920 919 if(m.getMember().isIncomplete()) 921 920 return; 922 else 923 { 924 if(m.isWay()) 925 { 921 else { 922 if(m.isWay()) { 926 923 Way w = m.getWay(); 927 924 if(w.getNodesCount() < 2) { … … 929 926 } 930 927 931 if("from".equals(m.getRole())) { 928 switch(m.getRole()) { 929 case "from": 932 930 if(fromWay == null) { 933 931 fromWay = w; 934 932 } 935 } else if("to".equals(m.getRole())) { 933 break; 934 case "to": 936 935 if(toWay == null) { 937 936 toWay = w; 938 937 } 939 } else if("via".equals(m.getRole())) { 938 break; 939 case "via": 940 940 if(via == null) { 941 941 via = w; 942 942 } 943 943 } 944 } 945 else if(m.isNode()) 946 { 944 } else if(m.isNode()) { 947 945 Node n = m.getNode(); 948 946 if("via".equals(m.getRole()) && via == null) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r7005 r7012 127 127 String role = m.getRole(); 128 128 OsmPrimitive p = m.getMember(); 129 if ( role.equals("house")) {129 if ("house".equals(role)) { 130 130 houses.add(p); 131 131 String number = p.get(ADDR_HOUSE_NUMBER); … … 138 138 list.add(p); 139 139 } 140 } else if ( role.equals("street")) {140 } else if ("street".equals(role)) { 141 141 if (p instanceof Way) { 142 142 street.add((Way) p); -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r7005 r7012 99 99 public void visit(Way w) { 100 100 if (w.isUsable()) { 101 if (w.hasKey("highway") && w.hasKey("junction") && w.get("junction").equals("roundabout")) {101 if (w.hasKey("highway") && w.hasKey("junction") && "roundabout".equals(w.get("junction"))) { 102 102 testWrongRoundabout(w); 103 103 } … … 180 180 String highway = w.get("highway"); 181 181 if (highway != null) { 182 if ( highway.equals("footway") || highway.equals("path")) {182 if ("footway".equals(highway) || "path".equals(highway)) { 183 183 handlePedestrianWay(n, w); 184 184 if (w.hasTag("bicycle", "yes", "designated")) { 185 185 handleCyclistWay(n, w); 186 186 } 187 } else if ( highway.equals("cycleway")) {187 } else if ("cycleway".equals(highway)) { 188 188 handleCyclistWay(n, w); 189 189 if (w.hasTag("foot", "yes", "designated")) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r7005 r7012 198 198 line = line.substring(2); 199 199 200 if (key.equals("S:")) { 200 switch (key) { 201 case "S:": 201 202 ignoreDataStartsWith.add(line); 202 } else if (key.equals("E:")) { 203 break; 204 case "E:": 203 205 ignoreDataEquals.add(line); 204 } else if (key.equals("F:")) { 206 break; 207 case "F:": 205 208 ignoreDataEndsWith.add(line); 206 } else if (key.equals("K:")) { 209 break; 210 case "K:": 207 211 IgnoreKeyPair tmp = new IgnoreKeyPair(); 208 212 int mid = line.indexOf('='); … … 637 641 String n = m.group(1).trim(); 638 642 639 if (n.equals("*")) {643 if ("*".equals(n)) { 640 644 tagAll = true; 641 645 } else { 642 646 tag = n.startsWith("/") ? getPattern(n) : n; 643 noMatch = m.group(2).equals("!=");647 noMatch = "!=".equals(m.group(2)); 644 648 n = m.group(3).trim(); 645 if ( n.equals("*")) {649 if ("*".equals(n)) { 646 650 valueAll = true; 647 } else if ( n.equals("BOOLEAN_TRUE")) {651 } else if ("BOOLEAN_TRUE".equals(n)) { 648 652 valueBool = true; 649 653 value = OsmUtils.trueval; 650 } else if ( n.equals("BOOLEAN_FALSE")) {654 } else if ("BOOLEAN_FALSE".equals(n)) { 651 655 valueBool = true; 652 656 value = OsmUtils.falseval; … … 685 689 } 686 690 String[] n = SPLIT_TRIMMED_PATTERN.split(trimmed, 3); 687 if (n[0].equals("way")) { 691 switch (n[0]) { 692 case "way": 688 693 type = OsmPrimitiveType.WAY; 689 } else if (n[0].equals("node")) { 694 break; 695 case "node": 690 696 type = OsmPrimitiveType.NODE; 691 } else if (n[0].equals("relation")) { 697 break; 698 case "relation": 692 699 type = OsmPrimitiveType.RELATION; 693 } else if (n[0].equals("*")) { 700 break; 701 case "*": 694 702 type = null; 695 } else 703 break; 704 default: 696 705 return tr("Could not find element type"); 706 } 697 707 if (n.length != 3) 698 708 return tr("Incorrect number of parameters"); 699 709 700 if (n[1].equals("W")) { 710 switch (n[1]) { 711 case "W": 701 712 severity = Severity.WARNING; 702 713 code = TAG_CHECK_WARN; 703 } else if (n[1].equals("E")) { 714 break; 715 case "E": 704 716 severity = Severity.ERROR; 705 717 code = TAG_CHECK_ERROR; 706 } else if(n[1].equals("I")) { 718 break; 719 case "I": 707 720 severity = Severity.OTHER; 708 721 code = TAG_CHECK_INFO; 709 } else 722 break; 723 default: 710 724 return tr("Could not find warning level"); 725 } 711 726 for (String exp: SPLIT_ELEMENTS_PATTERN.split(n[2])) { 712 727 try { -
trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java
r7005 r7012 75 75 } 76 76 77 if ("from".equals(m.getRole())) { 77 switch (m.getRole()) { 78 case "from": 78 79 if (fromWay != null) { 79 80 morefrom = true; … … 81 82 fromWay = w; 82 83 } 83 } else if ("to".equals(m.getRole())) { 84 break; 85 case "to": 84 86 if (toWay != null) { 85 87 moreto = true; … … 87 89 toWay = w; 88 90 } 89 } else if ("via".equals(m.getRole())) { 91 break; 92 case "via": 90 93 if (!via.isEmpty() && via.get(0) instanceof Node) { 91 94 mixvia = true; … … 93 96 via.add(w); 94 97 } 95 } else { 98 break; 99 default: 96 100 errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE, 97 101 l, Collections.singletonList(m))); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r7005 r7012 87 87 break; 88 88 } 89 if ( key.equals("junction")) {90 isRoundabout = w.get("junction").equals("roundabout");89 if ("junction".equals(key)) { 90 isRoundabout = "roundabout".equals(w.get("junction")); 91 91 break; 92 92 } -
trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java
r7004 r7012 240 240 @Override 241 241 public void preferenceChanged(PreferenceChangeEvent evt) { 242 if ("osm-server.username".equals(evt.getKey())) { 242 switch (evt.getKey()) { 243 case "osm-server.username": 243 244 if (!(evt.getNewValue() instanceof StringSetting)) return; 244 String new Value = ((StringSetting) evt.getNewValue()).getValue();245 if (new Value == null || newValue.trim().length() == 0) {245 String newUserName = ((StringSetting) evt.getNewValue()).getValue(); 246 if (newUserName == null || newUserName.trim().isEmpty()) { 246 247 setAnonymous(); 247 248 } else { 248 if (! new Value.equals(userName)) {249 setPartiallyIdentified(new Value);249 if (! newUserName.equals(userName)) { 250 setPartiallyIdentified(newUserName); 250 251 } 251 252 } 252 253 return; 253 254 254 } else if ("osm-server.url".equals(evt.getKey())) {255 case "osm-server.url": 255 256 if (!(evt.getNewValue() instanceof StringSetting)) return; 256 String new Value= ((StringSetting) evt.getNewValue()).getValue();257 if (new Value == null || newValue.trim().isEmpty()) {257 String newUrl = ((StringSetting) evt.getNewValue()).getValue(); 258 if (newUrl == null || newUrl.trim().isEmpty()) { 258 259 setAnonymous(); 259 260 } else if (isFullyIdentified()) { 260 261 setPartiallyIdentified(getUserName()); 261 262 } 262 263 } else if ("oauth.access-token.key".equals(evt.getKey())) { 263 break; 264 265 case "oauth.access-token.key": 264 266 accessTokenKeyChanged = true; 265 266 } else if ("oauth.access-token.secret".equals(evt.getKey())) { 267 break; 268 269 case "oauth.access-token.secret": 267 270 accessTokenSecretChanged = true; 271 break; 268 272 } 269 273 -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r6990 r7012 51 51 EastNorth center = nc.getCenter(); 52 52 EastNorth newcenter = nc.getEastNorth(nc.getWidth()/2+nc.getWidth()/5, nc.getHeight()/2+nc.getHeight()/5); 53 if ("left".equals(action)) 53 switch(action) { 54 case "left": 54 55 nc.zoomTo(new EastNorth(2*center.east()-newcenter.east(), center.north())); 55 else if ("right".equals(action)) 56 break; 57 case "right": 56 58 nc.zoomTo(new EastNorth(newcenter.east(), center.north())); 57 else if ("up".equals(action)) 59 break; 60 case "up": 58 61 nc.zoomTo(new EastNorth(center.east(), 2*center.north()-newcenter.north())); 59 else if ("down".equals(action)) 62 break; 63 case "down": 60 64 nc.zoomTo(new EastNorth(center.east(), newcenter.north())); 65 break; 66 } 61 67 } 62 68 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java
r6986 r7012 355 355 356 356 public boolean appliesImpl(Environment e) { 357 if ("closed".equals(id)) { 357 switch(id) { 358 case "closed": 358 359 if (e.osm instanceof Way && ((Way) e.osm).isClosed()) 359 360 return true; 360 361 if (e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon()) 361 362 return true; 362 return false;363 } else if ("modified".equals(id)) {363 break; 364 case "modified": 364 365 return e.osm.isModified() || e.osm.isNewOrUndeleted(); 365 } else if ("new".equals(id)) {366 case "new": 366 367 return e.osm.isNew(); 367 } else if ("connection".equals(id) && (e.osm instanceof Node)) {368 return ((Node) e.osm).isConnectionNode();369 } else if ("tagged".equals(id)) {368 case "connection": 369 return e.osm instanceof Node && ((Node) e.osm).isConnectionNode(); 370 case "tagged": 370 371 return e.osm.isTagged(); 371 } else if ("sameTags".equals(id)) {372 case "sameTags": 372 373 return e.osm.hasSameInterestingTags(Utils.firstNonNull(e.child, e.parent)); 373 } else if ("areaStyle".equals(id)) {374 case "areaStyle": 374 375 return ElemStyles.hasAreaElemStyle(e.osm, false); 375 } else if ("unconnected".equals(id) && (e.osm instanceof Node)) {376 return OsmPrimitive.getFilteredList(e.osm.getReferrers(), Way.class).isEmpty();376 case "unconnected": 377 return e.osm instanceof Node && OsmPrimitive.getFilteredList(e.osm.getReferrers(), Way.class).isEmpty(); 377 378 } 378 379 return false; -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
r7005 r7012 14 14 import org.xml.sax.helpers.DefaultHandler; 15 15 16 public class XmlStyleSourceHandler extends DefaultHandler 17 { 16 public class XmlStyleSourceHandler extends DefaultHandler { 18 17 private boolean inDoc, inRule, inCondition, inLine, inLineMod, inIcon, inArea, inScaleMax, inScaleMin; 19 18 private boolean hadLine, hadLineMod, hadIcon, hadArea; … … 79 78 private void startElementLine(String qName, Attributes atts, LinePrototype line) { 80 79 for (int count=0; count<atts.getLength(); count++) { 81 if(atts.getQName(count).equals("width")) { 80 switch (atts.getQName(count)) { 81 case "width": 82 82 String val = atts.getValue(count); 83 83 if (! (val.startsWith("+") || val.startsWith("-") || val.endsWith("%"))) { 84 84 line.setWidth(Integer.parseInt(val)); 85 85 } 86 } else if (atts.getQName(count).equals("colour")) { 87 line.color=convertColor(atts.getValue(count)); 88 } else if (atts.getQName(count).equals("realwidth")) { 89 line.realWidth=Integer.parseInt(atts.getValue(count)); 90 } else if (atts.getQName(count).equals("dashed")) { 86 break; 87 case "colour": 88 line.color = convertColor(atts.getValue(count)); 89 break; 90 case "realwidth": 91 line.realWidth = Integer.parseInt(atts.getValue(count)); 92 break; 93 case "dashed": 91 94 Float[] dashed; 92 95 try { … … 105 108 } 106 109 line.setDashed(dashed == null ? null : Arrays.asList(dashed)); 107 } else if (atts.getQName(count).equals("dashedcolour")) { 108 line.dashedColor=convertColor(atts.getValue(count)); 109 } else if(atts.getQName(count).equals("priority")) { 110 break; 111 case "dashedcolour": 112 line.dashedColor = convertColor(atts.getValue(count)); 113 break; 114 case "priority": 110 115 line.priority = Integer.parseInt(atts.getValue(count)); 111 } else if (!(atts.getQName(count).equals("mode") && line instanceof LinemodPrototype)){ 116 break; 117 case "mode": 118 if (line instanceof LinemodPrototype) 119 break; 120 default: 112 121 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 113 122 } … … 118 127 startElementLine(qName, atts, line); 119 128 for (int count=0; count<atts.getLength(); count++) { 120 if (atts.getQName(count).equals("width")) { 129 switch (atts.getQName(count)) { 130 case "width": 121 131 String val = atts.getValue(count); 122 132 if (val.startsWith("+")) { … … 132 142 line.setWidth(Integer.parseInt(val)); 133 143 } 134 } else if(atts.getQName(count).equals("mode")) { 135 line.over = !atts.getValue(count).equals("under"); 136 } 137 } 138 } 139 140 @Override public void startElement(String uri,String name, String qName, Attributes atts) { 144 break; 145 case "mode": 146 line.over = !"under".equals(atts.getValue(count)); 147 break; 148 } 149 } 150 } 151 152 @Override 153 public void startElement(String uri,String name, String qName, Attributes atts) { 141 154 if (inDoc) { 142 if (qName.equals("rule")) { 143 inRule=true; 144 } else if (qName.equals("rules")) { 155 switch(qName) { 156 case "rule": 157 inRule = true; 158 break; 159 case "rules": 145 160 if (style.name == null) { 146 161 style.name = atts.getValue("name"); … … 152 167 style.icon = atts.getValue("icon"); 153 168 } 154 } else if (qName.equals("scale_max")) { 169 break; 170 case "scale_max": 155 171 inScaleMax = true; 156 } else if (qName.equals("scale_min")) { 172 break; 173 case "scale_min": 157 174 inScaleMin = true; 158 } else if (qName.equals("condition") && inRule) { 159 inCondition=true; 160 XmlCondition c = rule.cond; 161 if (c.key != null) { 162 if(rule.conditions == null) { 163 rule.conditions = new LinkedList<>(); 164 } 165 rule.conditions.add(new XmlCondition(rule.cond)); 166 c = new XmlCondition(); 167 rule.conditions.add(c); 168 } 169 for (int count=0; count<atts.getLength(); count++) { 170 if (atts.getQName(count).equals("k")) { 171 c.key = atts.getValue(count); 172 } else if (atts.getQName(count).equals("v")) { 173 c.value = atts.getValue(count); 174 } else if(atts.getQName(count).equals("b")) { 175 c.boolValue = atts.getValue(count); 176 } else { 177 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 178 } 179 } 180 if(c.key == null) { 181 error("The condition has no key!"); 182 } 183 } else if (qName.equals("line")) { 175 break; 176 case "condition": 177 if (inRule) { 178 inCondition = true; 179 XmlCondition c = rule.cond; 180 if (c.key != null) { 181 if(rule.conditions == null) { 182 rule.conditions = new LinkedList<>(); 183 } 184 rule.conditions.add(new XmlCondition(rule.cond)); 185 c = new XmlCondition(); 186 rule.conditions.add(c); 187 } 188 for (int count=0; count<atts.getLength(); count++) { 189 switch (atts.getQName(count)) { 190 case "k": 191 c.key = atts.getValue(count); 192 break; 193 case "v": 194 c.value = atts.getValue(count); 195 break; 196 case "b": 197 c.boolValue = atts.getValue(count); 198 break; 199 default: 200 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 201 } 202 } 203 if(c.key == null) { 204 error("The condition has no key!"); 205 } 206 } 207 break; 208 case "line": 184 209 hadLine = inLine = true; 185 210 startElementLine(qName, atts, rule.line); 186 } else if (qName.equals("linemod")) { 211 break; 212 case "linemod": 187 213 hadLineMod = inLineMod = true; 188 214 startElementLinemod(qName, atts, rule.linemod); 189 } else if (qName.equals("icon")) { 215 break; 216 case "icon": 190 217 inIcon = true; 191 218 for (int count=0; count<atts.getLength(); count++) { 192 if (atts.getQName(count).equals("src")) { 219 switch (atts.getQName(count)) { 220 case "src": 193 221 IconReference icon = new IconReference(atts.getValue(count), style); 194 222 hadIcon = (icon != null); 195 223 rule.icon.icon = icon; 196 } else if (atts.getQName(count).equals("annotate")) { 224 break; 225 case "annotate": 197 226 rule.icon.annotate = Boolean.parseBoolean (atts.getValue(count)); 198 } else if(atts.getQName(count).equals("priority")) { 227 break; 228 case "priority": 199 229 rule.icon.priority = Integer.parseInt(atts.getValue(count)); 200 } else { 230 break; 231 default: 201 232 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 202 233 } 203 234 } 204 } else if (qName.equals("area")) { 235 break; 236 case "area": 205 237 hadArea = inArea = true; 206 for (int count=0; count<atts.getLength(); count++) 207 {208 if (atts.getQName(count).equals("colour")) {238 for (int count=0; count<atts.getLength(); count++) { 239 switch (atts.getQName(count)) { 240 case "colour": 209 241 rule.area.color=convertColor(atts.getValue(count)); 210 } else if (atts.getQName(count).equals("closed")) { 242 break; 243 case "closed": 211 244 rule.area.closed=Boolean.parseBoolean(atts.getValue(count)); 212 } else if(atts.getQName(count).equals("priority")) { 245 break; 246 case "priority": 213 247 rule.area.priority = Integer.parseInt(atts.getValue(count)); 214 } else { 248 break; 249 default: 215 250 error("The element \"" + qName + "\" has unknown attribute \"" + atts.getQName(count) + "\"!"); 216 251 } 217 252 } 218 } else { 253 break; 254 default: 219 255 error("The element \"" + qName + "\" is unknown!"); 220 256 } … … 222 258 } 223 259 224 @Override public void endElement(String uri,String name, String qName)225 {226 if (inRule && qName.equals("rule")) {260 @Override 261 public void endElement(String uri,String name, String qName) { 262 if (inRule && "rule".equals(qName)) { 227 263 if (hadLine) { 228 264 style.add(rule.cond, rule.conditions, 229 265 new LinePrototype(rule.line, new Range(rule.scaleMin, rule.scaleMax))); 230 266 } 231 if (hadLineMod) 232 { 267 if (hadLineMod) { 233 268 style.add(rule.cond, rule.conditions, 234 269 new LinemodPrototype(rule.linemod, new Range(rule.scaleMin, rule.scaleMax))); 235 270 } 236 if (hadIcon) 237 { 271 if (hadIcon) { 238 272 style.add(rule.cond, rule.conditions, 239 273 new IconPrototype(rule.icon, new Range(rule.scaleMin, rule.scaleMax))); 240 274 } 241 if (hadArea) 242 { 275 if (hadArea) { 243 276 style.add(rule.cond, rule.conditions, 244 277 new AreaPrototype(rule.area, new Range(rule.scaleMin, rule.scaleMax))); … … 247 280 hadLine = hadLineMod = hadIcon = hadArea = false; 248 281 rule.init(); 249 } else if (inCondition && qName.equals("condition")) {282 } else if (inCondition && "condition".equals(qName)) { 250 283 inCondition = false; 251 } else if (inLine && qName.equals("line")) {284 } else if (inLine && "line".equals(qName)) { 252 285 inLine = false; 253 } else if (inLineMod && qName.equals("linemod")) {286 } else if (inLineMod && "linemod".equals(qName)) { 254 287 inLineMod = false; 255 } else if (inIcon && qName.equals("icon")) {288 } else if (inIcon && "icon".equals(qName)) { 256 289 inIcon = false; 257 } else if (inArea && qName.equals("area")) {290 } else if (inArea && "area".equals(qName)) { 258 291 inArea = false; 259 } else if ( qName.equals("scale_max")) {292 } else if ("scale_max".equals(qName)) { 260 293 inScaleMax = false; 261 } else if ( qName.equals("scale_min")) {294 } else if ("scale_min".equals(qName)) { 262 295 inScaleMin = false; 263 296 } 264 297 } 265 298 266 @Override public void characters(char[] ch, int start, int length) { 299 @Override 300 public void characters(char[] ch, int start, int length) { 267 301 if (inScaleMax) { 268 302 rule.scaleMax = Long.parseLong(new String(ch, start, length)); -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java
r7005 r7012 1230 1230 } 1231 1231 String nodeType = st.sval.toUpperCase(); 1232 if ( nodeType.equals("LEAF")) {1232 if ("LEAF".equals(nodeType)) { 1233 1233 parseLeaf(st, parent); 1234 1234 } 1235 else if ( nodeType.equals("ROW") || nodeType.equals("COLUMN")) {1235 else if ("ROW".equals(nodeType) || "COLUMN".equals(nodeType)) { 1236 1236 Split split = new Split(); 1237 split.setRowLayout( nodeType.equals("ROW"));1237 split.setRowLayout("ROW".equals(nodeType)); 1238 1238 addSplitChild(parent, split); 1239 1239 parseSplit(st, split); -
trunk/src/org/openstreetmap/josm/io/AbstractParser.java
r6362 r7012 183 183 184 184 protected final boolean doStartElement(String qName, Attributes atts) throws SAXException { 185 if (qName.equals("node")) { 185 switch (qName) { 186 case "node": 186 187 startNode(atts); 187 188 return true; 188 } else if (qName.equals("way")) {189 case "way": 189 190 startWay(atts); 190 191 return true; 191 } else if (qName.equals("relation")) {192 case "relation": 192 193 startRelation(atts); 193 194 return true; 194 } else if (qName.equals("tag")) {195 case "tag": 195 196 handleTag(atts); 196 197 return true; 197 } else if (qName.equals("nd")) {198 case "nd": 198 199 handleNodeReference(atts); 199 200 return true; 200 } else if (qName.equals("member")) {201 case "member": 201 202 handleMember(atts); 202 203 return true; 203 } else {204 default: 204 205 return false; 205 206 } -
trunk/src/org/openstreetmap/josm/io/Capabilities.java
r7005 r7012 89 89 90 90 public void put(String element, String attribute, String value) { 91 if ( element.equals("blacklist")) {92 if ( attribute.equals("regex")) {91 if ("blacklist".equals(element)) { 92 if ("regex".equals(attribute)) { 93 93 imageryBlacklist.add(value); 94 94 } -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r7005 r7012 28 28 29 29 /** 30 * Replies a changeset query object from the query part of a OSM API URL for querying 31 * changesets. 30 * Replies a changeset query object from the query part of a OSM API URL for querying changesets. 32 31 * 33 32 * @param query the query part … … 348 347 } 349 348 350 protected boolean parseOpen(String value) throws ChangesetQueryUrlException {351 if (value == null || value.trim().isEmpty())352 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "open",value));353 if (value.equals("true"))354 return true;355 else if (value.equals("false"))356 return false;357 else358 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", "open",value));359 }360 361 349 protected boolean parseBoolean(String value, String parameter) throws ChangesetQueryUrlException { 362 350 if (value == null || value.trim().isEmpty()) 363 351 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter,value)); 364 if (value.equals("true")) 352 switch (value) { 353 case "true": 365 354 return true; 366 else if (value.equals("false"))355 case "false": 367 356 return false; 368 else357 default: 369 358 throw new ChangesetQueryUrlException(tr("Unexpected value for ''{0}'' in changeset query url, got {1}", parameter,value)); 359 } 370 360 } 371 361 … … 414 404 for (Entry<String, String> entry: queryParams.entrySet()) { 415 405 String k = entry.getKey(); 416 if (k.equals("uid")) { 406 switch(k) { 407 case "uid": 417 408 if (queryParams.containsKey("display_name")) 418 409 throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''")); 419 410 csQuery.forUser(parseUid(queryParams.get("uid"))); 420 } else if (k.equals("display_name")) { 411 break; 412 case "display_name": 421 413 if (queryParams.containsKey("uid")) 422 414 throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''")); 423 415 csQuery.forUser(queryParams.get("display_name")); 424 } else if (k.equals("open")) { 425 boolean b = parseBoolean(entry.getValue(), "open"); 426 csQuery.beingOpen(b); 427 } else if (k.equals("closed")) { 428 boolean b = parseBoolean(entry.getValue(), "closed"); 429 csQuery.beingClosed(b); 430 } else if (k.equals("time")) { 416 break; 417 case "open": 418 csQuery.beingOpen(parseBoolean(entry.getValue(), "open")); 419 break; 420 case "closed": 421 csQuery.beingClosed(parseBoolean(entry.getValue(), "closed")); 422 break; 423 case "time": 431 424 Date[] dates = parseTime(entry.getValue()); 432 425 switch(dates.length) { … … 438 431 break; 439 432 } 440 } else if (k.equals("bbox")) { 433 break; 434 case "bbox": 441 435 try { 442 436 csQuery.inBbox(new Bounds(entry.getValue(), ",")); … … 444 438 throw new ChangesetQueryUrlException(e); 445 439 } 446 } else if (k.equals("changesets")) { 440 break; 441 case "changesets": 447 442 try { 448 443 csQuery.forChangesetIds(parseLongs(entry.getValue())); … … 450 445 throw new ChangesetQueryUrlException(e); 451 446 } 452 } else 447 break; 448 default: 453 449 throw new ChangesetQueryUrlException(tr("Unsupported parameter ''{0}'' in changeset query string", k)); 450 } 454 451 } 455 452 return csQuery; -
trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
r7005 r7012 148 148 } 149 149 150 @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 150 @Override 151 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 151 152 try { 152 if (qName.equals("diffResult")) { 153 switch (qName) { 154 case "diffResult": 153 155 // the root element, ignore 154 } else if (qName.equals("node") || qName.equals("way") || qName.equals("relation")) { 155 156 break; 157 case "node": 158 case "way": 159 case "relation": 156 160 PrimitiveId id = new SimplePrimitiveId( 157 161 Long.parseLong(atts.getValue("old_id")), … … 166 170 } 167 171 diffResults.put(id, entry); 168 } else { 172 break; 173 default: 169 174 throwException(tr("Unexpected XML element with name ''{0}''", qName)); 170 175 } -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r7005 r7012 93 93 } 94 94 95 @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 95 @Override 96 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 96 97 elements.push(localName); 97 98 switch(currentState) { … … 109 110 break; 110 111 case gpx: 111 if (localName.equals("metadata")) { 112 switch (localName) { 113 case "metadata": 112 114 states.push(currentState); 113 115 currentState = State.metadata; 114 } else if (localName.equals("wpt")) { 116 break; 117 case "wpt": 115 118 states.push(currentState); 116 119 currentState = State.wpt; 117 120 currentWayPoint = new WayPoint(parseLatLon(atts)); 118 } else if (localName.equals("rte")) { 121 break; 122 case "rte": 119 123 states.push(currentState); 120 124 currentState = State.rte; 121 125 currentRoute = new GpxRoute(); 122 } else if (localName.equals("trk")) { 126 break; 127 case "trk": 123 128 states.push(currentState); 124 129 currentState = State.trk; 125 130 currentTrack = new ArrayList<>(); 126 131 currentTrackAttr = new HashMap<>(); 127 } else if (localName.equals("extensions")) { 132 break; 133 case "extensions": 128 134 states.push(currentState); 129 135 currentState = State.ext; 130 136 currentExtensions = new Extensions(); 131 } else if (localName.equals("gpx") && atts.getValue("creator") != null && atts.getValue("creator").startsWith("Nokia Sports Tracker")) { 132 nokiaSportsTrackerBug = true; 137 break; 138 case "gpx": 139 if (atts.getValue("creator") != null && atts.getValue("creator").startsWith("Nokia Sports Tracker")) { 140 nokiaSportsTrackerBug = true; 141 } 133 142 } 134 143 break; 135 144 case metadata: 136 if (localName.equals("author")) { 145 switch (localName) { 146 case "author": 137 147 states.push(currentState); 138 148 currentState = State.author; 139 } else if (localName.equals("extensions")) { 149 break; 150 case "extensions": 140 151 states.push(currentState); 141 152 currentState = State.ext; 142 153 currentExtensions = new Extensions(); 143 } else if (localName.equals("copyright")) { 154 break; 155 case "copyright": 144 156 states.push(currentState); 145 157 currentState = State.copyright; 146 158 data.attr.put(META_COPYRIGHT_AUTHOR, atts.getValue("author")); 147 } else if (localName.equals("link")) { 159 break; 160 case "link": 148 161 states.push(currentState); 149 162 currentState = State.link; … … 152 165 break; 153 166 case author: 154 if (localName.equals("link")) { 167 switch (localName) { 168 case "link": 155 169 states.push(currentState); 156 170 currentState = State.link; 157 171 currentLink = new GpxLink(atts.getValue("href")); 158 } else if (localName.equals("email")) { 172 break; 173 case "email": 159 174 data.attr.put(META_AUTHOR_EMAIL, atts.getValue("id") + "@" + atts.getValue("domain")); 160 175 } 161 176 break; 162 177 case trk: 163 if (localName.equals("trkseg")) { 178 switch (localName) { 179 case "trkseg": 164 180 states.push(currentState); 165 181 currentState = State.trkseg; 166 182 currentTrackSeg = new ArrayList<>(); 167 } else if (localName.equals("link")) { 183 break; 184 case "link": 168 185 states.push(currentState); 169 186 currentState = State.link; 170 187 currentLink = new GpxLink(atts.getValue("href")); 171 } else if (localName.equals("extensions")) { 188 break; 189 case "extensions": 172 190 states.push(currentState); 173 191 currentState = State.ext; … … 176 194 break; 177 195 case trkseg: 178 if ( localName.equals("trkpt")) {196 if ("trkpt".equals(localName)) { 179 197 states.push(currentState); 180 198 currentState = State.wpt; … … 183 201 break; 184 202 case wpt: 185 if (localName.equals("link")) { 203 switch (localName) { 204 case "link": 186 205 states.push(currentState); 187 206 currentState = State.link; 188 207 currentLink = new GpxLink(atts.getValue("href")); 189 } else if (localName.equals("extensions")) { 208 break; 209 case "extensions": 190 210 states.push(currentState); 191 211 currentState = State.ext; 192 212 currentExtensions = new Extensions(); 213 break; 193 214 } 194 215 break; 195 216 case rte: 196 if (localName.equals("link")) { 217 switch (localName) { 218 case "link": 197 219 states.push(currentState); 198 220 currentState = State.link; 199 221 currentLink = new GpxLink(atts.getValue("href")); 200 } else if (localName.equals("rtept")) { 222 break; 223 case "rtept": 201 224 states.push(currentState); 202 225 currentState = State.wpt; 203 226 currentWayPoint = new WayPoint(parseLatLon(atts)); 204 } else if (localName.equals("extensions")) { 227 break; 228 case "extensions": 205 229 states.push(currentState); 206 230 currentState = State.ext; 207 231 currentExtensions = new Extensions(); 232 break; 208 233 } 209 234 break; … … 212 237 } 213 238 214 @Override public void characters(char[] ch, int start, int length) { 239 @Override 240 public void characters(char[] ch, int start, int length) { 215 241 /** 216 242 * Remove illegal characters generated by the Nokia Sports Tracker device. … … 241 267 242 268 @SuppressWarnings("unchecked") 243 @Override public void endElement(String namespaceURI, String localName, String qName) { 269 @Override 270 public void endElement(String namespaceURI, String localName, String qName) { 244 271 elements.pop(); 245 272 switch (currentState) { 246 273 case gpx: // GPX 1.0 247 274 case metadata: // GPX 1.1 248 if (localName.equals("name")) { 275 switch (localName) { 276 case "name": 249 277 data.attr.put(META_NAME, accumulator.toString()); 250 } else if (localName.equals("desc")) { 278 break; 279 case "desc": 251 280 data.attr.put(META_DESC, accumulator.toString()); 252 } else if (localName.equals("time")) { 281 break; 282 case "time": 253 283 data.attr.put(META_TIME, accumulator.toString()); 254 } else if (localName.equals("keywords")) { 284 break; 285 case "keywords": 255 286 data.attr.put(META_KEYWORDS, accumulator.toString()); 256 } else if (version.equals("1.0") && localName.equals("author")) { 257 // author is a string in 1.0, but complex element in 1.1 287 break; 288 case "author": 289 if ("1.0".equals(version)) { 290 // author is a string in 1.0, but complex element in 1.1 291 data.attr.put(META_AUTHOR_NAME, accumulator.toString()); 292 } 293 break; 294 case "email": 295 if ("1.0".equals(version)) { 296 data.attr.put(META_AUTHOR_EMAIL, accumulator.toString()); 297 } 298 break; 299 case "url": 300 case "urlname": 301 data.attr.put(localName, accumulator.toString()); 302 break; 303 case "metadata": 304 case "gpx": 305 if ((currentState == State.metadata && "metadata".equals(localName)) || 306 (currentState == State.gpx && "gpx".equals(localName))) { 307 convertUrlToLink(data.attr); 308 if (currentExtensions != null && !currentExtensions.isEmpty()) { 309 data.attr.put(META_EXTENSIONS, currentExtensions); 310 } 311 currentState = states.pop(); 312 break; 313 } 314 default: 315 //TODO: parse bounds, extensions 316 } 317 break; 318 case author: 319 switch (localName) { 320 case "author": 321 currentState = states.pop(); 322 break; 323 case "name": 258 324 data.attr.put(META_AUTHOR_NAME, accumulator.toString()); 259 } else if (version.equals("1.0") && localName.equals("email")) { 260 data.attr.put(META_AUTHOR_EMAIL, accumulator.toString()); 261 } else if (localName.equals("url") || localName.equals("urlname")) { 262 data.attr.put(localName, accumulator.toString()); 263 } else if ((currentState == State.metadata && localName.equals("metadata")) || 264 (currentState == State.gpx && localName.equals("gpx"))) { 265 convertUrlToLink(data.attr); 266 if (currentExtensions != null && !currentExtensions.isEmpty()) { 267 data.attr.put(META_EXTENSIONS, currentExtensions); 268 } 269 currentState = states.pop(); 270 } 271 //TODO: parse bounds, extensions 272 break; 273 case author: 274 if (localName.equals("author")) { 275 currentState = states.pop(); 276 } else if (localName.equals("name")) { 277 data.attr.put(META_AUTHOR_NAME, accumulator.toString()); 278 } else if (localName.equals("email")) { 325 break; 326 case "email": 279 327 // do nothing, has been parsed on startElement 280 } else if (localName.equals("link")) { 328 break; 329 case "link": 281 330 data.attr.put(META_AUTHOR_LINK, currentLink); 331 break; 282 332 } 283 333 break; 284 334 case copyright: 285 if (localName.equals("copyright")) { 286 currentState = states.pop(); 287 } else if (localName.equals("year")) { 335 switch (localName) { 336 case "copyright": 337 currentState = states.pop(); 338 break; 339 case "year": 288 340 data.attr.put(META_COPYRIGHT_YEAR, accumulator.toString()); 289 } else if (localName.equals("license")) { 341 break; 342 case "license": 290 343 data.attr.put(META_COPYRIGHT_LICENSE, accumulator.toString()); 344 break; 291 345 } 292 346 break; 293 347 case link: 294 if (localName.equals("text")) { 348 switch (localName) { 349 case "text": 295 350 currentLink.text = accumulator.toString(); 296 } else if (localName.equals("type")) { 351 break; 352 case "type": 297 353 currentLink.type = accumulator.toString(); 298 } else if (localName.equals("link")) { 354 break; 355 case "link": 299 356 if (currentLink.uri == null && accumulator != null && accumulator.toString().length() != 0) { 300 357 currentLink = new GpxLink(accumulator.toString()); 301 358 } 302 359 currentState = states.pop(); 360 break; 303 361 } 304 362 if (currentState == State.author) { … … 313 371 break; 314 372 case wpt: 315 if ( localName.equals("ele") || localName.equals("magvar") 316 || localName.equals("name") || localName.equals("src") 317 || localName.equals("geoidheight") || localName.equals("type") 318 || localName.equals("sym") || localName.equals("url") 319 || localName.equals("urlname")) { 373 switch (localName) { 374 case "ele": 375 case "magvar": 376 case "name": 377 case "src": 378 case "geoidheight": 379 case "type": 380 case "sym": 381 case "url": 382 case "urlname": 320 383 currentWayPoint.attr.put(localName, accumulator.toString()); 321 } else if(localName.equals("hdop") || localName.equals("vdop") || 322 localName.equals("pdop")) { 384 break; 385 case "hdop": 386 case "vdop": 387 case "pdop": 323 388 try { 324 389 currentWayPoint.attr.put(localName, Float.parseFloat(accumulator.toString())); … … 326 391 currentWayPoint.attr.put(localName, new Float(0)); 327 392 } 328 } else if (localName.equals("time")) { 393 break; 394 case "time": 329 395 currentWayPoint.attr.put(localName, accumulator.toString()); 330 396 currentWayPoint.setTime(); 331 } else if (localName.equals("cmt") || localName.equals("desc")) { 397 break; 398 case "cmt": 399 case "desc": 332 400 currentWayPoint.attr.put(localName, accumulator.toString()); 333 401 currentWayPoint.setTime(); 334 } else if (localName.equals("rtept")) { 402 break; 403 case "rtept": 335 404 currentState = states.pop(); 336 405 convertUrlToLink(currentWayPoint.attr); 337 406 currentRoute.routePoints.add(currentWayPoint); 338 } else if (localName.equals("trkpt")) { 407 break; 408 case "trkpt": 339 409 currentState = states.pop(); 340 410 convertUrlToLink(currentWayPoint.attr); 341 411 currentTrackSeg.add(currentWayPoint); 342 } else if (localName.equals("wpt")) { 412 break; 413 case "wpt": 343 414 currentState = states.pop(); 344 415 convertUrlToLink(currentWayPoint.attr); … … 347 418 } 348 419 data.waypoints.add(currentWayPoint); 420 break; 349 421 } 350 422 break; 351 423 case trkseg: 352 if ( localName.equals("trkseg")) {424 if ("trkseg".equals(localName)) { 353 425 currentState = states.pop(); 354 426 currentTrack.add(currentTrackSeg); … … 356 428 break; 357 429 case trk: 358 if (localName.equals("trk")) { 430 switch (localName) { 431 case "trk": 359 432 currentState = states.pop(); 360 433 convertUrlToLink(currentTrackAttr); 361 434 data.tracks.add(new ImmutableGpxTrack(currentTrack, currentTrackAttr)); 362 } else if (localName.equals("name") || localName.equals("cmt") 363 || localName.equals("desc") || localName.equals("src") 364 || localName.equals("type") || localName.equals("number") 365 || localName.equals("url") || localName.equals("urlname")) { 435 break; 436 case "name": 437 case "cmt": 438 case "desc": 439 case "src": 440 case "type": 441 case "number": 442 case "url": 443 case "urlname": 366 444 currentTrackAttr.put(localName, accumulator.toString()); 445 break; 367 446 } 368 447 break; 369 448 case ext: 370 if (localName.equals("extensions")) { 371 currentState = states.pop(); 372 // only interested in extensions written by JOSM 449 if ("extensions".equals(localName)) { 450 currentState = states.pop(); 373 451 } else if (JOSM_EXTENSIONS_NAMESPACE_URI.equals(namespaceURI)) { 452 // only interested in extensions written by JOSM 374 453 currentExtensions.put(localName, accumulator.toString()); 375 454 } 376 455 break; 377 456 default: 378 if (localName.equals("wpt")) { 379 currentState = states.pop(); 380 } else if (localName.equals("rte")) { 457 switch (localName) { 458 case "wpt": 459 currentState = states.pop(); 460 break; 461 case "rte": 381 462 currentState = states.pop(); 382 463 convertUrlToLink(currentRoute.attr); 383 464 data.routes.add(currentRoute); 384 } 385 } 386 } 387 388 @Override public void endDocument() throws SAXException { 465 break; 466 } 467 } 468 } 469 470 @Override 471 public void endDocument() throws SAXException { 389 472 if (!states.empty()) 390 473 throw new SAXException(tr("Parse error: invalid document structure for GPX document.")); -
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r7005 r7012 131 131 try { 132 132 url = new URL(name); 133 if ( url.getProtocol().equals("file")) {133 if ("file".equals(url.getProtocol())) { 134 134 file = new File(name.substring("file:/".length())); 135 135 if (!file.exists()) { … … 234 234 try { 235 235 url = new URL(name); 236 if (! url.getProtocol().equals("file")) {236 if (!"file".equals(url.getProtocol())) { 237 237 String prefKey = getPrefKey(url, destDir); 238 238 List<String> localPath = new ArrayList<>(Main.pref.getCollection(prefKey)); -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r7005 r7012 264 264 265 265 // handle the packet content 266 if( e[0].equals("$GPGGA") || e[0].equals("$GNGGA")) {266 if("$GPGGA".equals(e[0]) || "$GNGGA".equals(e[0])) { 267 267 // Position 268 268 LatLon latLon = parseLatLon( … … 299 299 // elevation 300 300 accu=e[GPGGA.HEIGHT_UNTIS.position]; 301 if( accu.equals("M")) {301 if("M".equals(accu)) { 302 302 // Ignore heights that are not in meters for now 303 303 accu=e[GPGGA.HEIGHT.position]; … … 345 345 } 346 346 } 347 } else if( e[0].equals("$GPVTG") || e[0].equals("$GNVTG")) {347 } else if("$GPVTG".equals(e[0]) || "$GNVTG".equals(e[0])) { 348 348 // COURSE 349 349 accu = e[GPVTG.COURSE_REF.position]; 350 if( accu.equals("T")) {350 if("T".equals(accu)) { 351 351 // other values than (T)rue are ignored 352 352 accu = e[GPVTG.COURSE.position]; … … 366 366 } 367 367 } 368 } else if( e[0].equals("$GPGSA") || e[0].equals("$GNGSA")) {368 } else if("$GPGSA".equals(e[0]) || "$GNGSA".equals(e[0])) { 369 369 // vdop 370 370 accu=e[GPGSA.VDOP.position]; … … 383 383 } 384 384 } 385 else if( e[0].equals("$GPRMC") || e[0].equals("$GNRMC")) {385 else if("$GPRMC".equals(e[0]) || "$GNRMC".equals(e[0])) { 386 386 // coordinates 387 387 LatLon latLon = parseLatLon( -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r7005 r7012 620 620 } 621 621 622 if ( requestMethod.equals("PUT") || requestMethod.equals("POST") || requestMethod.equals("DELETE")) {622 if ("PUT".equals(requestMethod) || "POST".equals(requestMethod) || "DELETE".equals(requestMethod)) { 623 623 activeConnection.setDoOutput(true); 624 624 activeConnection.setRequestProperty("Content-type", "text/xml"); -
trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java
r6881 r7012 34 34 @Override 35 35 protected void parseRoot() throws XMLStreamException { 36 if ( parser.getLocalName().equals("osmChange")) {36 if ("osmChange".equals(parser.getLocalName())) { 37 37 parseOsmChange(); 38 38 } else { … … 69 69 if (event == XMLStreamConstants.START_ELEMENT) { 70 70 OsmPrimitive p = null; 71 if (parser.getLocalName().equals("node")) { 71 switch (parser.getLocalName()) { 72 case "node": 72 73 p = parseNode(); 73 } else if (parser.getLocalName().equals("way")) { 74 break; 75 case "way": 74 76 p = parseWay(); 75 } else if (parser.getLocalName().equals("relation")) { 77 break; 78 case "relation": 76 79 p = parseRelation(); 77 } else { 80 break; 81 default: 78 82 parseUnknown(); 79 83 } 80 84 if (p != null && action != null) { 81 if ( action.equals("modify")) {85 if ("modify".equals(action)) { 82 86 p.setModified(true); 83 } else if ( action.equals("delete")) {87 } else if ("delete".equals(action)) { 84 88 p.setDeleted(true); 85 89 } -
trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java
r7004 r7012 47 47 } 48 48 49 @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 49 @Override 50 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 50 51 if (super.doStartElement(qName, atts)) { 51 52 // done 52 } else if (qName.equals("osmChange")) { 53 return; 54 } 55 switch (qName) { 56 case "osmChange": 53 57 // do nothing 54 } else if (qName.equals("create")) { 58 break; 59 case "create": 55 60 currentModificationType = ChangesetModificationType.CREATED; 56 } else if (qName.equals("modify")) { 61 break; 62 case "modify": 57 63 currentModificationType = ChangesetModificationType.UPDATED; 58 } else if (qName.equals("delete")) { 64 break; 65 case "delete": 59 66 currentModificationType = ChangesetModificationType.DELETED; 60 } else { 61 Main.warn(tr("Unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.", qName, locator.getLineNumber(), locator.getColumnNumber())); 67 break; 68 default: 69 Main.warn(tr("Unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.", 70 qName, locator.getLineNumber(), locator.getColumnNumber())); 62 71 } 63 72 } … … 65 74 @Override 66 75 public void endElement(String uri, String localName, String qName) throws SAXException { 67 if (qName.equals("node") 68 || qName.equals("way") 69 || qName.equals("relation")) { 76 switch (qName) { 77 case "node": 78 case "way": 79 case "relation": 70 80 if (currentModificationType == null) { 71 81 throwException(tr("Illegal document structure. Found node, way, or relation outside of ''create'', ''modify'', or ''delete''.")); 72 82 } 73 83 data.put(currentPrimitive, currentModificationType); 74 } else if (qName.equals("osmChange")) { 84 break; 85 case "osmChange": 75 86 // do nothing 76 } else if (qName.equals("create")) { 87 break; 88 case "create": 77 89 currentModificationType = null; 78 } else if (qName.equals("modify")) { 90 break; 91 case "modify": 79 92 currentModificationType = null; 80 } else if (qName.equals("delete")) { 93 break; 94 case "delete": 81 95 currentModificationType = null; 82 } else if (qName.equals("tag")) { 96 break; 97 case "tag": 98 case "nd": 99 case "member": 83 100 // do nothing 84 } else if (qName.equals("nd")) { 85 // do nothing 86 } else if (qName.equals("member")) { 87 // do nothing 88 } else { 89 Main.warn(tr("Unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.", qName, locator.getLineNumber(), locator.getColumnNumber())); 101 break; 102 default: 103 Main.warn(tr("Unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.", 104 qName, locator.getLineNumber(), locator.getColumnNumber())); 90 105 } 91 106 } -
trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
r7005 r7012 112 112 if (value == null) { 113 113 throwException(tr("Missing mandatory attribute ''{0}''.", "open")); 114 } else if ( value.equals("true")) {114 } else if ("true".equals(value)) { 115 115 current.setOpen(true); 116 } else if ( value.equals("false")) {116 } else if ("false".equals(value)) { 117 117 current.setOpen(false); 118 118 } else { … … 160 160 @Override 161 161 public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { 162 if (qName.equals("osm")) { 162 switch (qName) { 163 case "osm": 163 164 if (atts == null) { 164 165 throwException(tr("Missing mandatory attribute ''{0}'' of XML element {1}.", "version", "osm")); … … 168 169 throwException(tr("Missing mandatory attribute ''{0}''.", "version")); 169 170 } 170 if (!( v.equals("0.6"))) {171 if (!("0.6".equals(v))) { 171 172 throwException(tr("Unsupported version: {0}", v)); 172 173 } 173 } else if (qName.equals("changeset")) { 174 break; 175 case "changeset": 174 176 current = new Changeset(); 175 177 parseChangesetAttributes(current, atts); 176 } else if (qName.equals("tag")) { 178 break; 179 case "tag": 177 180 String key = atts.getValue("k"); 178 181 String value = atts.getValue("v"); 179 182 current.put(key, value); 180 } else { 183 break; 184 default: 181 185 throwException(tr("Undefined element ''{0}'' found in input stream. Aborting.", qName)); 182 186 } … … 185 189 @Override 186 190 public void endElement(String uri, String localName, String qName) throws SAXException { 187 if ( qName.equals("changeset")) {191 if ("changeset".equals(qName)) { 188 192 changesets.add(current); 189 193 } -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r6643 r7012 131 131 protected void addAuth(HttpURLConnection connection) throws OsmTransferException { 132 132 String authMethod = Main.pref.get("osm-server.auth-method", "basic"); 133 if ( authMethod.equals("basic")) {133 if ("basic".equals(authMethod)) { 134 134 addBasicAuthorizationHeader(connection); 135 } else if ( authMethod.equals("oauth")) {135 } else if ("oauth".equals(authMethod)) { 136 136 addOAuthAuthorizationHeader(connection); 137 137 } else { -
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r6643 r7012 55 55 @Override 56 56 public void endElement(String uri, String localName, String qName) throws SAXException { 57 if ( qName.equals("node")58 || qName.equals("way")59 || qName.equals("relation")) {57 if ("node".equals(qName) 58 || "way".equals(qName) 59 || "relation".equals(qName)) { 60 60 data.put(currentPrimitive); 61 61 } -
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 } -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r7005 r7012 98 98 switch (states.peek()) { 99 99 case INIT: 100 if ( qName.equals("imagery")) {100 if ("imagery".equals(qName)) { 101 101 newState = State.IMAGERY; 102 102 } 103 103 break; 104 104 case IMAGERY: 105 if ( qName.equals("entry")) {105 if ("entry".equals(qName)) { 106 106 entry = new ImageryInfo(); 107 107 skipEntry = false; … … 128 128 }).contains(qName)) { 129 129 newState = State.ENTRY_ATTRIBUTE; 130 } else if ( qName.equals("bounds")) {130 } else if ("bounds".equals(qName)) { 131 131 try { 132 132 bounds = new ImageryBounds( … … 139 139 } 140 140 newState = State.BOUNDS; 141 } else if ( qName.equals("projections")) {141 } else if ("projections".equals(qName)) { 142 142 projections = new ArrayList<>(); 143 143 newState = State.PROJECTIONS; … … 145 145 break; 146 146 case BOUNDS: 147 if ( qName.equals("shape")) {147 if ("shape".equals(qName)) { 148 148 shape = new Shape(); 149 149 newState = State.SHAPE; … … 151 151 break; 152 152 case SHAPE: 153 if ( qName.equals("point")) {153 if ("point".equals(qName)) { 154 154 try { 155 155 shape.addPoint(atts.getValue("lat"), atts.getValue("lon")); … … 160 160 break; 161 161 case PROJECTIONS: 162 if ( qName.equals("code")) {162 if ("code".equals(qName)) { 163 163 newState = State.CODE; 164 164 } … … 192 192 throw new RuntimeException("parsing error: more closing than opening elements"); 193 193 case ENTRY: 194 if ( qName.equals("entry")) {194 if ("entry".equals(qName)) { 195 195 if (!skipEntry) { 196 196 entries.add(entry); … … 200 200 break; 201 201 case ENTRY_ATTRIBUTE: 202 if (qName.equals("name")) { 202 switch(qName) { 203 case "name": 203 204 entry.setTranslatedName(accumulator.toString()); 204 } else if (qName.equals("type")) { 205 break; 206 case "type": 205 207 boolean found = false; 206 208 for (ImageryType type : ImageryType.values()) { … … 214 216 skipEntry = true; 215 217 } 216 } else if (qName.equals("default")) { 217 if (accumulator.toString().equals("true")) { 218 break; 219 case "default": 220 switch (accumulator.toString()) { 221 case "true": 218 222 entry.setDefaultEntry(true); 219 } else if (accumulator.toString().equals("false")) { 223 break; 224 case "false": 220 225 entry.setDefaultEntry(false); 221 } else { 226 break; 227 default: 222 228 skipEntry = true; 223 229 } 224 } else if (qName.equals("url")) { 230 break; 231 case "url": 225 232 entry.setUrl(accumulator.toString()); 226 } else if (qName.equals("eula")) { 233 break; 234 case "eula": 227 235 entry.setEulaAcceptanceRequired(accumulator.toString()); 228 } else if (qName.equals("min-zoom") || qName.equals("max-zoom")) { 236 break; 237 case "min-zoom": 238 case "max-zoom": 229 239 Integer val = null; 230 240 try { … … 236 246 skipEntry = true; 237 247 } else { 238 if ( qName.equals("min-zoom")) {248 if ("min-zoom".equals(qName)) { 239 249 entry.setDefaultMinZoom(val); 240 250 } else { … … 242 252 } 243 253 } 244 } else if (qName.equals("attribution-text")) { 254 break; 255 case "attribution-text": 245 256 entry.setAttributionText(accumulator.toString()); 246 } else if (qName.equals("attribution-url")) { 257 break; 258 case "attribution-url": 247 259 entry.setAttributionLinkURL(accumulator.toString()); 248 } else if (qName.equals("logo-image")) { 260 break; 261 case "logo-image": 249 262 entry.setAttributionImage(accumulator.toString()); 250 } else if (qName.equals("logo-url")) { 263 break; 264 case "logo-url": 251 265 entry.setAttributionImageURL(accumulator.toString()); 252 } else if (qName.equals("terms-of-use-text")) { 266 break; 267 case "terms-of-use-text": 253 268 entry.setTermsOfUseText(accumulator.toString()); 254 } else if (qName.equals("terms-of-use-url")) { 269 break; 270 case "terms-of-use-url": 255 271 entry.setTermsOfUseURL(accumulator.toString()); 256 } else if (qName.equals("country-code")) { 272 break; 273 case "country-code": 257 274 entry.setCountryCode(accumulator.toString()); 258 } else if (qName.equals("icon")) { 275 break; 276 case "icon": 259 277 entry.setIcon(accumulator.toString()); 278 break; 260 279 } 261 280 break; -
trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
r7005 r7012 92 92 e = ne.lon(); 93 93 } 94 if ( myProj.equals("EPSG:4326") && !info.getServerProjections().contains(myProj) && info.getServerProjections().contains("CRS:84")) {94 if ("EPSG:4326".equals(myProj) && !info.getServerProjections().contains(myProj) && info.getServerProjections().contains("CRS:84")) { 95 95 myProj = "CRS:84"; 96 96 } … … 114 114 if (baseURL.toLowerCase().contains("crs=epsg:4326")) { 115 115 switchLatLon = true; 116 } else if (baseURL.toLowerCase().contains("crs=") && myProj.equals("EPSG:4326")) {116 } else if (baseURL.toLowerCase().contains("crs=") && "EPSG:4326".equals(myProj)) { 117 117 switchLatLon = true; 118 118 } -
trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java
r7005 r7012 45 45 Element attrElem = (Element) attrNode; 46 46 try { 47 String attrElemName = attrElem.getTagName();48 if ("file".equals(attrElemName)) {47 switch(attrElem.getTagName()) { 48 case "file": 49 49 entry.setFile(new File(attrElem.getTextContent())); 50 } else if ("position".equals(attrElemName)) { 50 break; 51 case "position": 51 52 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 52 53 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 53 54 entry.setPos(new LatLon(lat, lon)); 54 } else if ("speed".equals(attrElemName)) { 55 break; 56 case "speed": 55 57 entry.setSpeed(Double.parseDouble(attrElem.getTextContent())); 56 } else if ("elevation".equals(attrElemName)) { 58 break; 59 case "elevation": 57 60 entry.setElevation(Double.parseDouble(attrElem.getTextContent())); 58 } else if ("gps-time".equals(attrElemName)) { 61 break; 62 case "gps-time": 59 63 entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 60 } else if ("exif-orientation".equals(attrElemName)) { 64 break; 65 case "exif-orientation": 61 66 entry.setExifOrientation(Integer.parseInt(attrElem.getTextContent())); 62 } else if ("exif-time".equals(attrElemName)) { 67 break; 68 case "exif-time": 63 69 entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent()))); 64 } else if ("exif-gps-time".equals(attrElemName)) { 70 break; 71 case "exif-gps-time": 65 72 entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent()))); 66 } else if ("exif-coordinates".equals(attrElemName)) { 67 double lat = Double.parseDouble(attrElem.getAttribute("lat")); 68 double lon = Double.parseDouble(attrElem.getAttribute("lon")); 69 entry.setExifCoor(new LatLon(lat, lon)); 70 } else if ("exif-image-direction".equals(attrElemName)) { 73 break; 74 case "exif-coordinates": 75 entry.setExifCoor(new LatLon( 76 Double.parseDouble(attrElem.getAttribute("lat")), 77 Double.parseDouble(attrElem.getAttribute("lon")))); 78 break; 79 case "exif-image-direction": 71 80 entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent())); 72 } else if ("is-new-gps-data".equals(attrElemName) && Boolean.parseBoolean(attrElem.getTextContent())) { 73 entry.flagNewGpsData(); 81 break; 82 case "is-new-gps-data": 83 if (Boolean.parseBoolean(attrElem.getTextContent())) { 84 entry.flagNewGpsData(); 85 } 74 86 } 75 87 // TODO: handle thumbnail loading -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r7005 r7012 351 351 // check whether automatic update at startup was disabled 352 352 // 353 String policy = Main.pref.get(togglePreferenceKey, "ask") ;354 policy = policy.trim().toLowerCase();355 if ("never".equals(policy)) {353 String policy = Main.pref.get(togglePreferenceKey, "ask").trim().toLowerCase(); 354 switch(policy) { 355 case "never": 356 356 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 357 357 Main.info(tr("Skipping plugin update after JOSM upgrade. Automatic update at startup is disabled.")); … … 360 360 } 361 361 return false; 362 } 363 364 if ("always".equals(policy)) { 362 363 case "always": 365 364 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { 366 365 Main.info(tr("Running plugin update after JOSM upgrade. Automatic update at startup is enabled.")); … … 369 368 } 370 369 return true; 371 } 372 373 if (!"ask".equals(policy)) { 370 371 case "ask": 372 break; 373 374 default: 374 375 Main.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey)); 375 376 } 377 376 378 int ret = HelpAwareOptionPane.showOptionDialog( 377 379 parent, -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7005 r7012 834 834 for (RelationMember m : multiPolygon.getMembers()) { 835 835 if (m.getType().equals(OsmPrimitiveType.WAY)) { 836 if ( m.getRole().equals("outer")) {836 if ("outer".equals(m.getRole())) { 837 837 outers.add(m.getWay()); 838 } else if ( m.getRole().equals("inner")) {838 } else if ("inner".equals(m.getRole())) { 839 839 inners.add(m.getWay()); 840 840 } -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r7005 r7012 394 394 } 395 395 396 public static void addTexts(File source) 397 { 398 if(loadedCode.equals("en")) 396 public static void addTexts(File source) { 397 if ("en".equals(loadedCode)) 399 398 return; 400 399 FileInputStream fis = null; … … 440 439 } 441 440 442 private static boolean load(String l) 443 { 444 if(l.equals("en") || l.equals("en_US")) 445 { 441 private static boolean load(String l) { 442 if ("en".equals(l) || "en_US".equals(l)) { 446 443 strings = null; 447 444 pstrings = null; … … 451 448 } 452 449 URL en = getTranslationFile("en"); 453 if (en == null)450 if (en == null) 454 451 return false; 455 452 URL tr = getTranslationFile(l); 456 if(tr == null || !languages.containsKey(l)) 457 { 453 if (tr == null || !languages.containsKey(l)) { 458 454 int i = l.indexOf('_'); 459 455 if (i > 0) { … … 461 457 } 462 458 tr = getTranslationFile(l); 463 if (tr == null || !languages.containsKey(l))459 if (tr == null || !languages.containsKey(l)) 464 460 return false; 465 461 } … … 643 639 Locale.setDefault(l); 644 640 } else { 645 if (! l.getLanguage().equals("en")) {641 if (!"en".equals(l.getLanguage())) { 646 642 Main.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.", 647 643 l.getDisplayName(), Locale.getDefault().getDisplayName())); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r7005 r7012 606 606 try { 607 607 zipFile = new ZipFile(archive); 608 if (inArchiveDir == null || inArchiveDir.equals(".")) {608 if (inArchiveDir == null || ".".equals(inArchiveDir)) { 609 609 inArchiveDir = ""; 610 610 } else if (!inArchiveDir.isEmpty()) { … … 805 805 } 806 806 Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(), 807 name.equals("crosshair") ? new Point(10, 10) : new Point(3, 2), "Cursor");807 "crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2), "Cursor"); 808 808 return c; 809 809 } -
trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java
r6889 r7012 87 87 if (locale == null) return "en"; 88 88 String full = locale.toString(); 89 if ( full.equals("iw_IL"))89 if ("iw_IL".equals(full)) 90 90 return "he"; 91 else if ( full.equals("in"))91 else if ("in".equals(full)) 92 92 return "id"; 93 93 else if (I18n.hasCode(full)) // catch all non-single codes … … 107 107 */ 108 108 public static Locale getLocale(String localeName) { 109 if ( localeName.equals("he")) {109 if ("he".equals(localeName)) { 110 110 localeName = "iw_IL"; 111 111 } 112 else if ( localeName.equals("id")) {112 else if ("id".equals(localeName)) { 113 113 localeName = "in"; 114 114 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r7001 r7012 53 53 public Object invoke (Object proxy, Method method, Object[] args) throws Throwable { 54 54 Boolean handled = Boolean.TRUE; 55 if (method.getName().equals("handleQuit")) { 55 switch (method.getName()) { 56 case "handleQuit": 56 57 handled = Main.exitJosm(false, 0); 57 } else if (method.getName().equals("handleAbout")) { 58 break; 59 case "handleAbout": 58 60 Main.main.menu.about.actionPerformed(null); 59 } else if (method.getName().equals("handlePreferences")) { 61 break; 62 case "handlePreferences": 60 63 Main.main.menu.preferences.actionPerformed(null); 61 } else 64 break; 65 default: 62 66 return null; 67 } 63 68 if (args[0] != null) { 64 69 try { -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r7006 r7012 165 165 public String getJavaPackageDetails() { 166 166 if (isDebianOrUbuntu()) { 167 String javaHome = System.getProperty("java.home");168 if ("/usr/lib/jvm/java-7-openjdk-amd64/jre".equals(javaHome) ||169 "/usr/lib/jvm/java-7-openjdk-i386/jre".equals(javaHome)) {167 switch(System.getProperty("java.home")) { 168 case "/usr/lib/jvm/java-7-openjdk-amd64/jre": 169 case "/usr/lib/jvm/java-7-openjdk-i386/jre": 170 170 return getPackageDetails("openjdk-7-jre"); 171 171 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r7005 r7012 95 95 96 96 public boolean isChangeable() { 97 return !automatic && ! shortText.equals("core:none");97 return !automatic && !"core:none".equals(shortText); 98 98 } 99 99 … … 255 255 for(Shortcut c : shortcuts.values()) 256 256 { 257 if(! c.shortText.equals("core:none")) {257 if(!"core:none".equals(c.shortText)) { 258 258 l.add(c); 259 259 } -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r6890 r7012 189 189 x = Integer.valueOf(m.group(5)); 190 190 y = Integer.valueOf(m.group(7)); 191 if ( m.group(4).equals("-")) {191 if ("-".equals(m.group(4))) { 192 192 x = screenDimension.x + screenDimension.width - x - w; 193 193 } 194 if ( m.group(6).equals("-")) {194 if ("-".equals(m.group(6))) { 195 195 y = screenDimension.y + screenDimension.height - y - h; 196 196 } -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r7005 r7012 133 133 private void setValue(Entry entry, String fieldName, String value) throws SAXException { 134 134 CheckParameterUtil.ensureParameterNotNull(entry, "entry"); 135 if ( fieldName.equals("class") || fieldName.equals("default") || fieldName.equals("throw") || fieldName.equals("new") || fieldName.equals("null")) {135 if ("class".equals(fieldName) || "default".equals(fieldName) || "throw".equals(fieldName) || "new".equals(fieldName) || "null".equals(fieldName)) { 136 136 fieldName += "_"; 137 137 } … … 165 165 private boolean parseBoolean(String s) { 166 166 return s != null 167 && ! s.equals("0")167 && !"0".equals(s) 168 168 && !s.startsWith("off") 169 169 && !s.startsWith("false")
Note:
See TracChangeset
for help on using the changeset viewer.