Ignore:
Timestamp:
2016-05-15T16:37:33+02:00 (4 years ago)
Author:
Don-vip
Message:

findbugs - SF_SWITCH_NO_DEFAULT + various sonar fixes

Location:
trunk/src/org/openstreetmap/josm/io
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r10216 r10217  
    311311     */
    312312    protected void fetchPrimitives(Set<Long> ids, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException {
    313         String msg = "";
     313        String msg;
    314314        final String baseUrl = getBaseUrl();
    315315        switch (type) {
     
    317317            case WAY:      msg = tr("Fetching a package of ways from ''{0}''",      baseUrl); break;
    318318            case RELATION: msg = tr("Fetching a package of relations from ''{0}''", baseUrl); break;
     319            default: throw new AssertionError();
    319320        }
    320321        progressMonitor.setTicksCount(ids.size());
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r10216 r10217  
    3939
    4040    private static volatile List<OsmServerWritePostprocessor> postprocessors;
     41
     42    /**
     43     * Registers a post-processor.
     44     * @param pp post-processor to register
     45     */
    4146    public static void registerPostprocessor(OsmServerWritePostprocessor pp) {
    4247        if (postprocessors == null) {
     
    4651    }
    4752
     53    /**
     54     * Unregisters a post-processor.
     55     * @param pp post-processor to unregister
     56     */
    4857    public static void unregisterPostprocessor(OsmServerWritePostprocessor pp) {
    4958        if (postprocessors != null) {
     
    6170    private long uploadStartTime;
    6271
    63     public String timeLeft(int progress, int listSize) {
     72    protected String timeLeft(int progress, int listSize) {
    6473        long now = System.currentTimeMillis();
    6574        long elapsed = now - uploadStartTime;
     
    93102            uploadStartTime = System.currentTimeMillis();
    94103            for (OsmPrimitive osm : primitives) {
    95                 int progress = progressMonitor.getTicks();
    96                 String timeLeftStr = timeLeft(progress, primitives.size());
    97                 String msg = "";
     104                String msg;
    98105                switch(OsmPrimitiveType.from(osm)) {
    99106                case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break;
    100107                case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break;
    101108                case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break;
     109                default: throw new AssertionError();
    102110                }
     111                int progress = progressMonitor.getTicks();
    103112                progressMonitor.subTask(
    104113                        tr(msg,
     
    106115                                progress,
    107116                                primitives.size(),
    108                                 timeLeftStr,
    109                                 osm.getName() == null ? osm.getId() : osm.getName(),
    110                                         osm.getId()));
     117                                timeLeft(progress, primitives.size()),
     118                                osm.getName() == null ? osm.getId() : osm.getName(), osm.getId()));
    111119                makeApiRequest(osm, progressMonitor);
    112120                processed.add(osm);
     
    134142            progressMonitor.beginTask(tr("Starting to upload in one request ..."));
    135143            processed.addAll(api.uploadDiff(primitives, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)));
    136         } catch (OsmTransferException e) {
    137             throw e;
    138144        } finally {
    139145            progressMonitor.finishTask();
     
    151157     */
    152158    protected void uploadChangesInChunks(Collection<? extends OsmPrimitive> primitives, ProgressMonitor progressMonitor, int chunkSize)
    153             throws OsmTransferException, IllegalArgumentException {
     159            throws OsmTransferException {
    154160        if (chunkSize <= 0)
    155161            throw new IllegalArgumentException(tr("Value >0 expected for parameter ''{0}'', got {1}", "chunkSize", chunkSize));
     
    176182                processed.addAll(api.uploadDiff(chunk, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)));
    177183            }
    178         } catch (OsmTransferException e) {
    179             throw e;
    180184        } finally {
    181185            progressMonitor.finishTask();
     
    223227                break;
    224228            }
    225         } catch (OsmTransferException e) {
    226             throw e;
    227229        } finally {
    228230            executePostprocessors(monitor);
     
    242244    }
    243245
     246    /**
     247     * Cancel operation.
     248     */
    244249    public void cancel() {
    245250        this.canceled = true;
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r10216 r10217  
    5454    }
    5555
     56    /**
     57     * Constructs a {@code ImageryReader} from a given filename, URL or internal resource.
     58     *
     59     * @param source can be:<ul>
     60     *  <li>relative or absolute file name</li>
     61     *  <li>{@code file:///SOME/FILE} the same as above</li>
     62     *  <li>{@code http://...} a URL. It will be cached on disk.</li>
     63     *  <li>{@code resource://SOME/FILE} file from the classpath (usually in the current *.jar)</li>
     64     *  <li>{@code josmdir://SOME/FILE} file inside josm user data directory (since r7058)</li>
     65     *  <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7834)</li></ul>
     66     */
    5667    public ImageryReader(String source) {
    5768        this.source = source;
    5869    }
    5970
     71    /**
     72     * Parses imagery source.
     73     * @return list of imagery info
     74     * @throws SAXException if any SAX error occurs
     75     * @throws IOException if any I/O error occurs
     76     */
    6077    public List<ImageryInfo> parse() throws SAXException, IOException {
    6178        Parser parser = new Parser();
     
    328345                        }
    329346                        break;
     347                    default: // Do nothing
    330348                    }
    331349                }
     
    456474                projections = null;
    457475                break;
    458             /* nothing to do for these or the unknown type:
    459476            case NO_TILE:
    460477            case NO_TILESUM:
    461478            case METADATA:
    462479            case UNKNOWN:
    463                 break;
    464             */
     480            default:
     481                // nothing to do for these or the unknown type
    465482            }
    466483        }
Note: See TracChangeset for help on using the changeset viewer.