Changeset 10216 in josm for trunk/src


Ignore:
Timestamp:
2016-05-15T14:48:06+02:00 (8 years ago)
Author:
Don-vip
Message:

findbugs - SF_SWITCH_NO_DEFAULT + various sonar fixes

Location:
trunk/src/org/openstreetmap/josm
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r10181 r10216  
    234234        switch (mode) {
    235235        case "problem":
    236             TestError error = Main.map.validatorDialog.getSelectedError();
    237             if (error == null)
    238                 return null;
    239             ((ValidatorBoundingXYVisitor) v).visit(error);
    240             if (v.getBounds() == null)
    241                 return null;
    242             v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002));
    243             break;
     236            return modeProblem(v);
    244237        case "data":
    245             for (Layer l : Main.map.mapView.getAllLayers()) {
    246                 l.visitBoundingBox(v);
    247             }
    248             break;
     238            return modeData(v);
    249239        case "layer":
    250             // try to zoom to the first selected layer
    251             Layer l = getFirstSelectedLayer();
    252             if (l == null)
    253                 return null;
    254             l.visitBoundingBox(v);
    255             break;
     240            return modeLayer(v);
    256241        case "selection":
    257242        case "conflict":
    258             Collection<OsmPrimitive> sel = new HashSet<>();
    259             if ("selection".equals(mode)) {
    260                 sel = getCurrentDataSet().getSelected();
     243            return modeSelectionOrConflict(v);
     244        case "download":
     245            return modeDownload(v);
     246        default:
     247            return v;
     248        }
     249    }
     250
     251    private static BoundingXYVisitor modeProblem(BoundingXYVisitor v) {
     252        TestError error = Main.map.validatorDialog.getSelectedError();
     253        if (error == null)
     254            return null;
     255        ((ValidatorBoundingXYVisitor) v).visit(error);
     256        if (v.getBounds() == null)
     257            return null;
     258        v.enlargeBoundingBox(Main.pref.getDouble("validator.zoom-enlarge-bbox", 0.0002));
     259        return v;
     260    }
     261
     262    private static BoundingXYVisitor modeData(BoundingXYVisitor v) {
     263        for (Layer l : Main.map.mapView.getAllLayers()) {
     264            l.visitBoundingBox(v);
     265        }
     266        return v;
     267    }
     268
     269    private BoundingXYVisitor modeLayer(BoundingXYVisitor v) {
     270        // try to zoom to the first selected layer
     271        Layer l = getFirstSelectedLayer();
     272        if (l == null)
     273            return null;
     274        l.visitBoundingBox(v);
     275        return v;
     276    }
     277
     278    private BoundingXYVisitor modeSelectionOrConflict(BoundingXYVisitor v) {
     279        Collection<OsmPrimitive> sel = new HashSet<>();
     280        if ("selection".equals(mode)) {
     281            sel = getCurrentDataSet().getSelected();
     282        } else {
     283            Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict();
     284            if (c != null) {
     285                sel.add(c.getMy());
     286            } else if (Main.map.conflictDialog.getConflicts() != null) {
     287                sel = Main.map.conflictDialog.getConflicts().getMyConflictParties();
     288            }
     289        }
     290        if (sel.isEmpty()) {
     291            JOptionPane.showMessageDialog(
     292                    Main.parent,
     293                    "selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"),
     294                    tr("Information"),
     295                    JOptionPane.INFORMATION_MESSAGE);
     296            return null;
     297        }
     298        for (OsmPrimitive osm : sel) {
     299            osm.accept(v);
     300        }
     301
     302        // Increase the bounding box by up to 100% to give more context.
     303        v.enlargeBoundingBoxLogarithmically(100);
     304        // Make the bounding box at least 100 meter wide to
     305        // ensure reasonable zoom level when zooming onto single nodes.
     306        v.enlargeToMinSize(Main.pref.getDouble("zoom_to_selection_min_size_in_meter", 100));
     307        return v;
     308    }
     309
     310    private BoundingXYVisitor modeDownload(BoundingXYVisitor v) {
     311        if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {
     312            lastZoomTime = -1;
     313        }
     314        final DataSet dataset = getCurrentDataSet();
     315        if (dataset != null) {
     316            List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources());
     317            int s = dataSources.size();
     318            if (s > 0) {
     319                if (lastZoomTime == -1 || lastZoomArea == -1 || lastZoomArea > s) {
     320                    lastZoomArea = s-1;
     321                    v.visit(dataSources.get(lastZoomArea).bounds);
     322                } else if (lastZoomArea > 0) {
     323                    lastZoomArea -= 1;
     324                    v.visit(dataSources.get(lastZoomArea).bounds);
     325                } else {
     326                    lastZoomArea = -1;
     327                    Area sourceArea = Main.main.getCurrentDataSet().getDataSourceArea();
     328                    if (sourceArea != null) {
     329                        v.visit(new Bounds(sourceArea.getBounds2D()));
     330                    }
     331                }
     332                lastZoomTime = System.currentTimeMillis();
    261333            } else {
    262                 Conflict<? extends OsmPrimitive> c = Main.map.conflictDialog.getSelectedConflict();
    263                 if (c != null) {
    264                     sel.add(c.getMy());
    265                 } else if (Main.map.conflictDialog.getConflicts() != null) {
    266                     sel = Main.map.conflictDialog.getConflicts().getMyConflictParties();
    267                 }
     334                lastZoomTime = -1;
     335                lastZoomArea = -1;
    268336            }
    269             if (sel.isEmpty()) {
    270                 JOptionPane.showMessageDialog(
    271                         Main.parent,
    272                         "selection".equals(mode) ? tr("Nothing selected to zoom to.") : tr("No conflicts to zoom to"),
    273                         tr("Information"),
    274                         JOptionPane.INFORMATION_MESSAGE);
    275                 return null;
    276             }
    277             for (OsmPrimitive osm : sel) {
    278                 osm.accept(v);
    279             }
    280 
    281             // Increase the bounding box by up to 100% to give more context.
    282             v.enlargeBoundingBoxLogarithmically(100);
    283             // Make the bounding box at least 100 meter wide to
    284             // ensure reasonable zoom level when zooming onto single nodes.
    285             v.enlargeToMinSize(Main.pref.getDouble("zoom_to_selection_min_size_in_meter", 100));
    286             break;
    287         case "download":
    288 
    289             if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {
    290                 lastZoomTime = -1;
    291             }
    292             final DataSet dataset = getCurrentDataSet();
    293             if (dataset != null) {
    294                 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources());
    295                 int s = dataSources.size();
    296                 if (s > 0) {
    297                     if (lastZoomTime == -1 || lastZoomArea == -1 || lastZoomArea > s) {
    298                         lastZoomArea = s-1;
    299                         v.visit(dataSources.get(lastZoomArea).bounds);
    300                     } else if (lastZoomArea > 0) {
    301                         lastZoomArea -= 1;
    302                         v.visit(dataSources.get(lastZoomArea).bounds);
    303                     } else {
    304                         lastZoomArea = -1;
    305                         Area sourceArea = Main.main.getCurrentDataSet().getDataSourceArea();
    306                         if (sourceArea != null) {
    307                             v.visit(new Bounds(sourceArea.getBounds2D()));
    308                         }
    309                     }
    310                     lastZoomTime = System.currentTimeMillis();
    311                 } else {
    312                     lastZoomTime = -1;
    313                     lastZoomArea = -1;
    314                 }
    315             }
    316             break;
    317337        }
    318338        return v;
  • trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java

    r10152 r10216  
    118118        }
    119119        KeyEvent kev = (KeyEvent) event;
    120         int dx = 0, dy = 0;
     120        int dx = 0;
     121        int dy = 0;
    121122        switch (kev.getKeyCode()) {
    122123        case KeyEvent.VK_UP : dy = +1; break;
     
    124125        case KeyEvent.VK_LEFT : dx = -1; break;
    125126        case KeyEvent.VK_RIGHT : dx = +1; break;
     127        default: // Do nothing
    126128        }
    127129        if (dx != 0 || dy != 0) {
  • trunk/src/org/openstreetmap/josm/actions/PasteAction.java

    r8513 r10216  
    6464    public void pasteData(PrimitiveDeepCopy pasteBuffer, Layer source, ActionEvent e) {
    6565        /* Find the middle of the pasteBuffer area */
    66         double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100;
     66        double maxEast = -1E100;
     67        double minEast = 1E100;
     68        double maxNorth = -1E100;
     69        double minNorth = 1E100;
    6770        boolean incomplete = false;
    6871        for (PrimitiveData data : pasteBuffer.getAll()) {
     
    9295
    9396        // Allow to cancel paste if there are incomplete primitives
    94         if (incomplete) {
    95             if (!confirmDeleteIncomplete()) return;
     97        if (incomplete && !confirmDeleteIncomplete()) {
     98            return;
    9699        }
    97100
     
    158161                for (RelationMemberData member: ((RelationData) data).getMembers()) {
    159162                    OsmPrimitiveType memberType = member.getMemberType();
    160                     Long newId = null;
     163                    Long newId;
    161164                    switch (memberType) {
    162165                    case NODE:
     
    169172                        newId = newRelationIds.get(member.getMemberId());
    170173                        break;
     174                    default: throw new AssertionError();
    171175                    }
    172176                    if (newId != null) {
     
    183187    }
    184188
    185     protected boolean confirmDeleteIncomplete() {
     189    private static boolean confirmDeleteIncomplete() {
    186190        ExtendedDialog ed = new ExtendedDialog(Main.parent,
    187191                tr("Delete incomplete members?"),
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r10163 r10216  
    135135            }
    136136        } catch (SecurityException e) {
    137             // Ignore exception
    138137            if (Main.isTraceEnabled()) {
    139138                Main.trace(e.getMessage());
     
    165164    }
    166165
    167     protected static Collection<String> getCustomUrls(SourceEditor.SourcePrefHelper helper) {
     166    private static Collection<String> getCustomUrls(SourceEditor.SourcePrefHelper helper) {
    168167        Set<String> set = new TreeSet<>();
    169168        for (SourceEntry entry : helper.get()) {
     
    221220    }
    222221
    223     protected static <T> void appendCollection(StringBuilder text, String label, Collection<T> col) {
     222    private static <T> void appendCollection(StringBuilder text, String label, Collection<T> col) {
    224223        if (!col.isEmpty()) {
    225224            text.append(label+":\n");
     
    267266            case 1: ta.copyToClippboard(); break;
    268267            case 2: BugReportSender.reportBug(reportHeader); break;
     268            default: // Do nothing
    269269        }
    270270    }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    r10212 r10216  
    184184                if (canceled)
    185185                    return;
    186                 String msg = "";
     186                String msg;
    187187                switch(entry.getValue()) {
    188188                case NODE: msg = tr("({0}/{1}) Loading parents of node {2}", i+1, children.size(), entry.getKey()); break;
    189189                case WAY: msg = tr("({0}/{1}) Loading parents of way {2}", i+1, children.size(), entry.getKey()); break;
    190190                case RELATION: msg = tr("({0}/{1}) Loading parents of relation {2}", i+1, children.size(), entry.getKey()); break;
     191                default: throw new AssertionError();
    191192                }
    192193                progressMonitor.subTask(msg);
  • trunk/src/org/openstreetmap/josm/command/ChangeCommand.java

    r9371 r10216  
    7676    @Override
    7777    public String getDescriptionText() {
    78         String msg = "";
     78        String msg;
    7979        switch(OsmPrimitiveType.from(osm)) {
    8080        case NODE: msg = marktr("Change node {0}"); break;
    8181        case WAY: msg = marktr("Change way {0}"); break;
    8282        case RELATION: msg = marktr("Change relation {0}"); break;
     83        default: throw new AssertionError();
    8384        }
    8485        return tr(msg, osm.getDisplayName(DefaultNameFormatter.getInstance()));
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r9371 r10216  
    161161                case WAY: msg = marktr("Remove \"{0}\" for way ''{1}''"); break;
    162162                case RELATION: msg = marktr("Remove \"{0}\" for relation ''{1}''"); break;
     163                default: throw new AssertionError();
    163164                }
    164165                text = tr(msg, entry.getKey(), primitive.getDisplayName(DefaultNameFormatter.getInstance()));
     
    168169                case WAY: msg = marktr("Set {0}={1} for way ''{2}''"); break;
    169170                case RELATION: msg = marktr("Set {0}={1} for relation ''{2}''"); break;
     171                default: throw new AssertionError();
    170172                }
    171173                text = tr(msg, entry.getKey(), entry.getValue(), primitive.getDisplayName(DefaultNameFormatter.getInstance()));
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r10174 r10216  
    160160    }
    161161
    162     private Set<OsmPrimitiveType> getTypesToDelete() {
    163         Set<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class);
     162    private EnumSet<OsmPrimitiveType> getTypesToDelete() {
     163        EnumSet<OsmPrimitiveType> typesToDelete = EnumSet.noneOf(OsmPrimitiveType.class);
    164164        for (OsmPrimitive osm : toDelete) {
    165165            typesToDelete.add(OsmPrimitiveType.from(osm));
     
    172172        if (toDelete.size() == 1) {
    173173            OsmPrimitive primitive = toDelete.iterator().next();
    174             String msg = "";
     174            String msg;
    175175            switch(OsmPrimitiveType.from(primitive)) {
    176176            case NODE: msg = marktr("Delete node {0}"); break;
    177177            case WAY: msg = marktr("Delete way {0}"); break;
    178178            case RELATION:msg = marktr("Delete relation {0}"); break;
     179            default: throw new AssertionError();
    179180            }
    180181
     
    182183        } else {
    183184            Set<OsmPrimitiveType> typesToDelete = getTypesToDelete();
    184             String msg = "";
     185            String msg;
    185186            if (typesToDelete.size() > 1) {
    186187                msg = trn("Delete {0} object", "Delete {0} objects", toDelete.size(), toDelete.size());
     
    191192                case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break;
    192193                case RELATION: msg = trn("Delete {0} relation", "Delete {0} relations", toDelete.size(), toDelete.size()); break;
     194                default: throw new AssertionError();
    193195                }
    194196            }
  • trunk/src/org/openstreetmap/josm/command/conflict/ModifiedConflictResolveCommand.java

    r9371 r10216  
    1717/**
    1818 * Represents the resolution of a conflict between the modified flag of two {@link OsmPrimitive}s.
    19  *
    20  *
     19 * @since 2624
    2120 */
    2221public class ModifiedConflictResolveCommand extends ConflictResolveCommand {
     
    3534    @Override
    3635    public String getDescriptionText() {
    37         String msg = "";
     36        String msg;
    3837        switch(OsmPrimitiveType.from(conflict.getMy())) {
    3938        case NODE: msg = marktr("Set the ''modified'' flag for node {0}"); break;
    4039        case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break;
    4140        case RELATION: msg = marktr("Set the ''modified'' flag for relation {0}"); break;
     41        default: throw new AssertionError();
    4242        }
    4343        return tr(msg, conflict.getMy().getId());
  • trunk/src/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommand.java

    r9371 r10216  
    1717/**
    1818 * Represents the resolution of a version conflict between two {@link OsmPrimitive}s.
    19  *
    20  *
     19 * @since 1622
    2120 */
    2221public class VersionConflictResolveCommand extends ConflictResolveCommand {
     
    3534    @Override
    3635    public String getDescriptionText() {
    37         String msg = "";
     36        String msg;
    3837        switch(OsmPrimitiveType.from(conflict.getMy())) {
    3938        case NODE: msg = marktr("Resolve version conflict for node {0}"); break;
    4039        case WAY: msg = marktr("Resolve version conflict for way {0}"); break;
    4140        case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break;
     41        default: throw new AssertionError();
    4242        }
    4343        return tr(msg, conflict.getMy().getId());
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r10212 r10216  
    192192     */
    193193    public static void messageBox(String type, String text) {
    194         if (type == null || type.isEmpty()) type = "plain";
    195 
    196         switch (type.charAt(0)) {
     194        char c = (type == null || type.isEmpty() ? "plain" : type).charAt(0);
     195        switch (c) {
    197196            case 'i': JOptionPane.showMessageDialog(Main.parent, text, tr("Information"), JOptionPane.INFORMATION_MESSAGE); break;
    198197            case 'w': JOptionPane.showMessageDialog(Main.parent, text, tr("Warning"), JOptionPane.WARNING_MESSAGE); break;
     
    200199            case 'q': JOptionPane.showMessageDialog(Main.parent, text, tr("Question"), JOptionPane.QUESTION_MESSAGE); break;
    201200            case 'p': JOptionPane.showMessageDialog(Main.parent, text, tr("Message"), JOptionPane.PLAIN_MESSAGE); break;
     201            default: Main.warn("Unsupported messageBox type: " + c);
    202202        }
    203203    }
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java

    r9891 r10216  
    44import java.io.Serializable;
    55import java.util.Objects;
     6
     7import org.openstreetmap.josm.tools.CheckParameterUtil;
    68
    79public class RelationMemberData implements PrimitiveId, Serializable {
     
    1214    private final OsmPrimitiveType memberType;
    1315
     16    /**
     17     * Constructs a new {@code RelationMemberData}.
     18     * @param role member role - can be null
     19     * @param type member type - cannot be null
     20     * @param id member id - cannot be null
     21     * @throws IllegalArgumentException is type or id is null
     22     */
    1423    public RelationMemberData(String role, OsmPrimitiveType type, long id) {
     24        CheckParameterUtil.ensureParameterNotNull(type, "type");
    1525        this.role = role == null ? "" : role;
    1626        this.memberType = type;
     
    1828    }
    1929
     30    /**
     31     * Constructs a new {@code RelationMemberData}.
     32     * @param role member role - can be null
     33     * @param primitive member type and id - cannot be null
     34     * @throws NullPointerException if primitive is null
     35     */
    2036    public RelationMemberData(String role, PrimitiveId primitive) {
    2137        this(role, primitive.getType(), primitive.getUniqueId());
    2238    }
    2339
     40    /**
     41     * Get member id.
     42     * @return member id
     43     */
    2444    public long getMemberId() {
    2545        return memberId;
    2646    }
    2747
     48    /**
     49     * Get member role.
     50     * @return member role
     51     */
    2852    public String getRole() {
    2953        return role;
    3054    }
    3155
     56    /**
     57     * Get member type.
     58     * @return member type
     59     */
    3260    public OsmPrimitiveType getMemberType() {
    3361        return memberType;
    3462    }
    3563
     64    /**
     65     * Determines if this member has a role.
     66     * @return {@code true} if this member has a role
     67     */
    3668    public boolean hasRole() {
    3769        return !"".equals(role);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r10181 r10216  
    10911091                            via = w;
    10921092                        }
     1093                        break;
     1094                    default: // Do nothing
    10931095                    }
    10941096                } else if (m.isNode()) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r9952 r10216  
    264264                        }
    265265                        total++;
     266                        break;
     267                    default: // Do nothing
    266268                }
    267269            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r9997 r10216  
    211211                        case "K:":
    212212                            ignoreDataTag.add(Tag.ofString(line));
     213                            break;
     214                        default:
     215                            Main.warn("Unsupported TagChecker key: " + key);
    213216                        }
    214217                    } else if (tagcheckerfile) {
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java

    r10021 r10216  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Color;
    76import java.awt.Component;
    87import java.util.EnumMap;
     
    4847
    4948    protected void renderRole(Item diffItem) {
    50         String text = "";
    51         Color bgColor = diffItem.state.getColor();
    5249        RelationMemberData member = (RelationMemberData) diffItem.value;
    53         text = member == null ? "" : member.getRole();
     50        String text = member == null ? "" : member.getRole();
    5451        setText(text);
    5552        setToolTipText(text);
    56         GuiHelper.setBackgroundReadable(this, bgColor);
     53        GuiHelper.setBackgroundReadable(this, diffItem.state.getColor());
    5754    }
    5855
    5956    protected void renderPrimitive(Item diffItem) {
    6057        String text = "";
    61         Color bgColor = diffItem.state.getColor();
    6258        RelationMemberData member = (RelationMemberData) diffItem.value;
    63         text = "";
    6459        if (member != null) {
    6560            switch(member.getMemberType()) {
     
    6762            case WAY: text = tr("Way {0}", member.getMemberId()); break;
    6863            case RELATION: text = tr("Relation {0}", member.getMemberId()); break;
     64            default: throw new AssertionError();
    6965            }
    7066        }
    7167        setText(text);
    7268        setToolTipText(text);
    73         GuiHelper.setBackgroundReadable(this, bgColor);
     69        GuiHelper.setBackgroundReadable(this, diffItem.state.getColor());
    7470    }
    7571
     
    8985            renderPrimitive(member);
    9086            break;
     87        default: // Do nothing
    9188        }
    9289
  • trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java

    r10194 r10216  
    400400            else if (dates.length == 2)
    401401                return new Date[]{parseDate(dates[0], "time"), parseDate(dates[1], "time")};
    402             return null;
     402            return new Date[]{};
    403403        }
    404404
     
    447447                        csQuery.closedAfterAndCreatedBefore(dates[0], dates[1]);
    448448                        break;
     449                    default:
     450                        Main.warn("Unable to parse time: " + entry.getValue());
    449451                    }
    450452                    break;
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r10212 r10216  
    4545
    4646    private enum State {
    47         init,
    48         gpx,
    49         metadata,
    50         wpt,
    51         rte,
    52         trk,
    53         ext,
    54         author,
    55         link,
    56         trkseg,
    57         copyright
     47        INIT,
     48        GPX,
     49        METADATA,
     50        WPT,
     51        RTE,
     52        TRK,
     53        EXT,
     54        AUTHOR,
     55        LINK,
     56        TRKSEG,
     57        COPYRIGHT
    5858    }
    5959
     
    7272        private WayPoint currentWayPoint;
    7373
    74         private State currentState = State.init;
     74        private State currentState = State.INIT;
    7575
    7676        private GpxLink currentLink;
     
    108108            elements.push(localName);
    109109            switch(currentState) {
    110             case init:
     110            case INIT:
    111111                states.push(currentState);
    112                 currentState = State.gpx;
     112                currentState = State.GPX;
    113113                data.creator = atts.getValue("creator");
    114114                version = atts.getValue("version");
     
    120120                }
    121121                break;
    122             case gpx:
     122            case GPX:
    123123                switch (localName) {
    124124                case "metadata":
    125125                    states.push(currentState);
    126                     currentState = State.metadata;
     126                    currentState = State.METADATA;
    127127                    break;
    128128                case "wpt":
    129129                    states.push(currentState);
    130                     currentState = State.wpt;
     130                    currentState = State.WPT;
    131131                    currentWayPoint = new WayPoint(parseLatLon(atts));
    132132                    break;
    133133                case "rte":
    134134                    states.push(currentState);
    135                     currentState = State.rte;
     135                    currentState = State.RTE;
    136136                    currentRoute = new GpxRoute();
    137137                    break;
    138138                case "trk":
    139139                    states.push(currentState);
    140                     currentState = State.trk;
     140                    currentState = State.TRK;
    141141                    currentTrack = new ArrayList<>();
    142142                    currentTrackAttr = new HashMap<>();
     
    144144                case "extensions":
    145145                    states.push(currentState);
    146                     currentState = State.ext;
     146                    currentState = State.EXT;
    147147                    currentExtensions = new Extensions();
    148148                    break;
     
    151151                        nokiaSportsTrackerBug = true;
    152152                    }
    153                 }
    154                 break;
    155             case metadata:
     153                    break;
     154                default: // Do nothing
     155                }
     156                break;
     157            case METADATA:
    156158                switch (localName) {
    157159                case "author":
    158160                    states.push(currentState);
    159                     currentState = State.author;
     161                    currentState = State.AUTHOR;
    160162                    break;
    161163                case "extensions":
    162164                    states.push(currentState);
    163                     currentState = State.ext;
     165                    currentState = State.EXT;
    164166                    currentExtensions = new Extensions();
    165167                    break;
    166168                case "copyright":
    167169                    states.push(currentState);
    168                     currentState = State.copyright;
     170                    currentState = State.COPYRIGHT;
    169171                    data.put(META_COPYRIGHT_AUTHOR, atts.getValue("author"));
    170172                    break;
    171173                case "link":
    172174                    states.push(currentState);
    173                     currentState = State.link;
     175                    currentState = State.LINK;
    174176                    currentLink = new GpxLink(atts.getValue("href"));
    175177                    break;
     
    180182                                parseCoord(atts.getValue("maxlat")),
    181183                                parseCoord(atts.getValue("maxlon"))));
    182                 }
    183                 break;
    184             case author:
    185                 switch (localName) {
    186                 case "link":
    187                     states.push(currentState);
    188                     currentState = State.link;
     184                    break;
     185                default: // Do nothing
     186                }
     187                break;
     188            case AUTHOR:
     189                switch (localName) {
     190                case "link":
     191                    states.push(currentState);
     192                    currentState = State.LINK;
    189193                    currentLink = new GpxLink(atts.getValue("href"));
    190194                    break;
    191195                case "email":
    192196                    data.put(META_AUTHOR_EMAIL, atts.getValue("id") + '@' + atts.getValue("domain"));
    193                 }
    194                 break;
    195             case trk:
     197                    break;
     198                default: // Do nothing
     199                }
     200                break;
     201            case TRK:
    196202                switch (localName) {
    197203                case "trkseg":
    198204                    states.push(currentState);
    199                     currentState = State.trkseg;
     205                    currentState = State.TRKSEG;
    200206                    currentTrackSeg = new ArrayList<>();
    201207                    break;
    202208                case "link":
    203209                    states.push(currentState);
    204                     currentState = State.link;
     210                    currentState = State.LINK;
    205211                    currentLink = new GpxLink(atts.getValue("href"));
    206212                    break;
    207213                case "extensions":
    208214                    states.push(currentState);
    209                     currentState = State.ext;
     215                    currentState = State.EXT;
    210216                    currentExtensions = new Extensions();
    211                 }
    212                 break;
    213             case trkseg:
     217                    break;
     218                default: // Do nothing
     219                }
     220                break;
     221            case TRKSEG:
    214222                if ("trkpt".equals(localName)) {
    215223                    states.push(currentState);
    216                     currentState = State.wpt;
     224                    currentState = State.WPT;
    217225                    currentWayPoint = new WayPoint(parseLatLon(atts));
    218226                }
    219227                break;
    220             case wpt:
    221                 switch (localName) {
    222                 case "link":
    223                     states.push(currentState);
    224                     currentState = State.link;
     228            case WPT:
     229                switch (localName) {
     230                case "link":
     231                    states.push(currentState);
     232                    currentState = State.LINK;
    225233                    currentLink = new GpxLink(atts.getValue("href"));
    226234                    break;
    227235                case "extensions":
    228236                    states.push(currentState);
    229                     currentState = State.ext;
     237                    currentState = State.EXT;
    230238                    currentExtensions = new Extensions();
    231239                    break;
    232                 }
    233                 break;
    234             case rte:
    235                 switch (localName) {
    236                 case "link":
    237                     states.push(currentState);
    238                     currentState = State.link;
     240                default: // Do nothing
     241                }
     242                break;
     243            case RTE:
     244                switch (localName) {
     245                case "link":
     246                    states.push(currentState);
     247                    currentState = State.LINK;
    239248                    currentLink = new GpxLink(atts.getValue("href"));
    240249                    break;
    241250                case "rtept":
    242251                    states.push(currentState);
    243                     currentState = State.wpt;
     252                    currentState = State.WPT;
    244253                    currentWayPoint = new WayPoint(parseLatLon(atts));
    245254                    break;
    246255                case "extensions":
    247256                    states.push(currentState);
    248                     currentState = State.ext;
     257                    currentState = State.EXT;
    249258                    currentExtensions = new Extensions();
    250259                    break;
    251                 }
    252                 break;
     260                default: // Do nothing
     261                }
     262                break;
     263            default: // Do nothing
    253264            }
    254265            accumulator.setLength(0);
     
    276287        private Map<String, Object> getAttr() {
    277288            switch (currentState) {
    278             case rte: return currentRoute.attr;
    279             case metadata: return data.attr;
    280             case wpt: return currentWayPoint.attr;
    281             case trk: return currentTrackAttr;
     289            case RTE: return currentRoute.attr;
     290            case METADATA: return data.attr;
     291            case WPT: return currentWayPoint.attr;
     292            case TRK: return currentTrackAttr;
    282293            default: return null;
    283294            }
     
    289300            elements.pop();
    290301            switch (currentState) {
    291             case gpx:       // GPX 1.0
    292             case metadata:  // GPX 1.1
     302            case GPX:       // GPX 1.0
     303            case METADATA:  // GPX 1.1
    293304                switch (localName) {
    294305                case "name":
     
    321332                case "metadata":
    322333                case "gpx":
    323                     if ((currentState == State.metadata && "metadata".equals(localName)) ||
    324                         (currentState == State.gpx && "gpx".equals(localName))) {
     334                    if ((currentState == State.METADATA && "metadata".equals(localName)) ||
     335                        (currentState == State.GPX && "gpx".equals(localName))) {
    325336                        convertUrlToLink(data.attr);
    326337                        if (currentExtensions != null && !currentExtensions.isEmpty()) {
     
    337348                }
    338349                break;
    339             case author:
     350            case AUTHOR:
    340351                switch (localName) {
    341352                case "author":
     
    351362                    data.put(META_AUTHOR_LINK, currentLink);
    352363                    break;
    353                 }
    354                 break;
    355             case copyright:
     364                default: // Do nothing
     365                }
     366                break;
     367            case COPYRIGHT:
    356368                switch (localName) {
    357369                case "copyright":
     
    364376                    data.put(META_COPYRIGHT_LICENSE, accumulator.toString());
    365377                    break;
    366                 }
    367                 break;
    368             case link:
     378                default: // Do nothing
     379                }
     380                break;
     381            case LINK:
    369382                switch (localName) {
    370383                case "text":
     
    380393                    currentState = states.pop();
    381394                    break;
    382                 }
    383                 if (currentState == State.author) {
     395                default: // Do nothing
     396                }
     397                if (currentState == State.AUTHOR) {
    384398                    data.put(META_AUTHOR_LINK, currentLink);
    385                 } else if (currentState != State.link) {
     399                } else if (currentState != State.LINK) {
    386400                    Map<String, Object> attr = getAttr();
    387401                    if (!attr.containsKey(META_LINKS)) {
     
    391405                }
    392406                break;
    393             case wpt:
     407            case WPT:
    394408                switch (localName) {
    395409                case "ele":
     
    437451                    data.waypoints.add(currentWayPoint);
    438452                    break;
    439                 }
    440                 break;
    441             case trkseg:
     453                default: // Do nothing
     454                }
     455                break;
     456            case TRKSEG:
    442457                if ("trkseg".equals(localName)) {
    443458                    currentState = states.pop();
     
    445460                }
    446461                break;
    447             case trk:
     462            case TRK:
    448463                switch (localName) {
    449464                case "trk":
     
    462477                    currentTrackAttr.put(localName, accumulator.toString());
    463478                    break;
    464                 }
    465                 break;
    466             case ext:
     479                default: // Do nothing
     480                }
     481                break;
     482            case EXT:
    467483                if ("extensions".equals(localName)) {
    468484                    currentState = states.pop();
     
    482498                    data.routes.add(currentRoute);
    483499                    break;
     500                default: // Do nothing
    484501                }
    485502            }
     
    516533        }
    517534
    518         public void tryToFinish() throws SAXException {
     535        void tryToFinish() throws SAXException {
    519536            List<String> remainingElements = new ArrayList<>(elements);
    520537            for (int i = remainingElements.size() - 1; i >= 0; i--) {
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r10212 r10216  
    125125        case WAY: ways.add(id.getUniqueId()); break;
    126126        case RELATION: relations.add(id.getUniqueId()); break;
     127        default: throw new AssertionError();
    127128        }
    128129    }
     
    580581            for (long id : pkg) {
    581582                try {
    582                     String msg = "";
     583                    String msg;
    583584                    switch (type) {
    584585                        case NODE:     msg = tr("Fetching node with id {0} from ''{1}''",     id, baseUrl); break;
    585586                        case WAY:      msg = tr("Fetching way with id {0} from ''{1}''",      id, baseUrl); break;
    586587                        case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, baseUrl); break;
     588                        default: throw new AssertionError();
    587589                    }
    588590                    progressMonitor.setCustomText(msg);
  • trunk/src/org/openstreetmap/josm/io/NoteReader.java

    r10136 r10216  
    126126                }
    127127                break;
     128            default: // Do nothing
    128129            }
    129130        }
  • trunk/src/org/openstreetmap/josm/io/OsmApiPrimitiveGoneException.java

    r8510 r10216  
    1111 * Represents an exception thrown by the OSM API if JOSM tries to update or delete a primitive
    1212 * which is already deleted on the server.
    13  *
     13 * @since 2198
    1414 */
    1515public class OsmApiPrimitiveGoneException extends OsmApiException {
     
    1919    public static final String ERROR_HEADER_PATTERN = "The (\\S+) with the id (\\d+) has already been deleted";
    2020    /** the type of the primitive which is gone on the server */
    21     private OsmPrimitiveType type;
     21    private final OsmPrimitiveType type;
    2222    /** the id of the primitive */
    23     private long id;
     23    private final long id;
    2424
     25    /**
     26     * Constructs a new {@code OsmApiPrimitiveGoneException}.
     27     * @param errorHeader error header
     28     * @param errorBody error body
     29     */
    2530    public OsmApiPrimitiveGoneException(String errorHeader, String errorBody) {
    2631        super(HttpURLConnection.HTTP_GONE, errorHeader, errorBody);
    27         if (errorHeader == null) return;
    28         Pattern p = Pattern.compile(ERROR_HEADER_PATTERN);
    29         Matcher m = p.matcher(errorHeader);
    30         if (m.matches()) {
    31             type = OsmPrimitiveType.from(m.group(1));
    32             id = Long.parseLong(m.group(2));
     32        if (errorHeader != null) {
     33            Matcher m = Pattern.compile(ERROR_HEADER_PATTERN).matcher(errorHeader);
     34            if (m.matches()) {
     35                type = OsmPrimitiveType.from(m.group(1));
     36                id = Long.parseLong(m.group(2));
     37            } else {
     38                type = null;
     39                id = 0;
     40            }
     41        } else {
     42            type = null;
     43            id = 0;
    3344        }
    3445    }
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r10181 r10216  
    219219                break;
    220220            case CHUNKED_DATASET_STRATEGY:
     221            default:
    221222                uploadChangesInChunks(primitives, monitor.createSubTaskMonitor(0, false), strategy.getChunkSize());
    222223                break;
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r9977 r10216  
    228228                }
    229229                break;
     230            default: // Do nothing
    230231            }
    231232            /**
     
    433434                    entry.setEpsg4326To3857Supported(Boolean.valueOf(accumulator.toString()));
    434435                    break;
     436                default: // Do nothing
    435437                }
    436438                break;
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r10212 r10216  
    5555    private List<String> formats;
    5656
     57    /**
     58     * Returns the list of layers.
     59     * @return the list of layers
     60     */
    5761    public List<LayerDetails> getLayers() {
    5862        return layers;
    5963    }
    6064
     65    /**
     66     * Returns the service URL.
     67     * @return the service URL
     68     */
    6169    public URL getServiceUrl() {
    6270        return serviceUrl;
    6371    }
    6472
     73    /**
     74     * Returns the list of supported formats.
     75     * @return the list of supported formats
     76     */
    6577    public List<String> getFormats() {
    6678        return Collections.unmodifiableList(formats);
     
    311323                    content.append(node.getNodeValue());
    312324                    break;
     325                default: // Do nothing
    313326            }
    314327        }
     
    371384                return this.name;
    372385        }
    373 
    374386    }
    375387}
  • trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java

    r9455 r10216  
    4949                        Node attrNode = attrNodes.item(j);
    5050                        if (attrNode.getNodeType() == Node.ELEMENT_NODE) {
    51                             Element attrElem = (Element) attrNode;
    52                             try {
    53                                 switch(attrElem.getTagName()) {
    54                                 case "file":
    55                                     entry.setFile(new File(attrElem.getTextContent()));
    56                                     break;
    57                                 case "position":
    58                                     double lat = Double.parseDouble(attrElem.getAttribute("lat"));
    59                                     double lon = Double.parseDouble(attrElem.getAttribute("lon"));
    60                                     entry.setPos(new LatLon(lat, lon));
    61                                     break;
    62                                 case "speed":
    63                                     entry.setSpeed(Double.valueOf(attrElem.getTextContent()));
    64                                     break;
    65                                 case "elevation":
    66                                     entry.setElevation(Double.valueOf(attrElem.getTextContent()));
    67                                     break;
    68                                 case "gps-time":
    69                                     entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
    70                                     break;
    71                                 case "exif-orientation":
    72                                     entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent()));
    73                                     break;
    74                                 case "exif-time":
    75                                     entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent())));
    76                                     break;
    77                                 case "exif-gps-time":
    78                                     entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
    79                                     break;
    80                                 case "exif-coordinates":
    81                                     entry.setExifCoor(new LatLon(
    82                                             Double.parseDouble(attrElem.getAttribute("lat")),
    83                                             Double.parseDouble(attrElem.getAttribute("lon"))));
    84                                     break;
    85                                 case "exif-image-direction":
    86                                     entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent()));
    87                                     break;
    88                                 case "is-new-gps-data":
    89                                     if (Boolean.parseBoolean(attrElem.getTextContent())) {
    90                                         entry.flagNewGpsData();
    91                                     }
    92                                 }
    93                                 // TODO: handle thumbnail loading
    94                             } catch (NumberFormatException e) {
    95                                 // do nothing
    96                                 if (Main.isTraceEnabled()) {
    97                                     Main.trace(e.getMessage());
    98                                 }
    99                             }
     51                            handleElement(entry, (Element) attrNode);
    10052                        }
    10153                    }
     
    11870        return new GeoImageLayer(entries, gpxLayer, useThumbs);
    11971    }
     72
     73    private static void handleElement(ImageEntry entry, Element attrElem) {
     74        try {
     75            switch(attrElem.getTagName()) {
     76            case "file":
     77                entry.setFile(new File(attrElem.getTextContent()));
     78                break;
     79            case "position":
     80                double lat = Double.parseDouble(attrElem.getAttribute("lat"));
     81                double lon = Double.parseDouble(attrElem.getAttribute("lon"));
     82                entry.setPos(new LatLon(lat, lon));
     83                break;
     84            case "speed":
     85                entry.setSpeed(Double.valueOf(attrElem.getTextContent()));
     86                break;
     87            case "elevation":
     88                entry.setElevation(Double.valueOf(attrElem.getTextContent()));
     89                break;
     90            case "gps-time":
     91                entry.setGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
     92                break;
     93            case "exif-orientation":
     94                entry.setExifOrientation(Integer.valueOf(attrElem.getTextContent()));
     95                break;
     96            case "exif-time":
     97                entry.setExifTime(new Date(Long.parseLong(attrElem.getTextContent())));
     98                break;
     99            case "exif-gps-time":
     100                entry.setExifGpsTime(new Date(Long.parseLong(attrElem.getTextContent())));
     101                break;
     102            case "exif-coordinates":
     103                entry.setExifCoor(new LatLon(
     104                        Double.parseDouble(attrElem.getAttribute("lat")),
     105                        Double.parseDouble(attrElem.getAttribute("lon"))));
     106                break;
     107            case "exif-image-direction":
     108                entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent()));
     109                break;
     110            case "is-new-gps-data":
     111                if (Boolean.parseBoolean(attrElem.getTextContent())) {
     112                    entry.flagNewGpsData();
     113                }
     114                break;
     115            default: // Do nothing
     116            }
     117            // TODO: handle thumbnail loading
     118        } catch (NumberFormatException e) {
     119            if (Main.isTraceEnabled()) {
     120                Main.trace(e.getMessage());
     121            }
     122        }
     123    }
    120124}
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r10212 r10216  
    451451                Main.pref.put(togglePreferenceKey, "never");
    452452                break;
     453            default: // Do nothing
    453454            }
    454455        } else {
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r10212 r10216  
    286286                        command.possiblyInterrupt();
    287287                        break;
     288                    default: // Do nothing
    288289                }
    289290            } catch (InterruptedException e) {
     
    355356                            stateChange = State.PAUSED;
    356357                            break;
     358                        default: // Do nothing
    357359                    }
    358360                    command.ok(stateChange);
Note: See TracChangeset for help on using the changeset viewer.