Changeset 10755 in josm for trunk


Ignore:
Timestamp:
2016-08-07T14:46:57+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - various fixes

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

Legend:

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

    r10619 r10755  
    2121import org.openstreetmap.josm.io.FileExporter;
    2222import org.openstreetmap.josm.io.FileImporter;
     23import org.openstreetmap.josm.io.GpxImporter;
     24import org.openstreetmap.josm.io.JpgImporter;
     25import org.openstreetmap.josm.io.NMEAImporter;
     26import org.openstreetmap.josm.io.NoteImporter;
     27import org.openstreetmap.josm.io.OsmChangeImporter;
     28import org.openstreetmap.josm.io.OsmImporter;
     29import org.openstreetmap.josm.io.WMSLayerImporter;
     30import org.openstreetmap.josm.io.session.SessionImporter;
    2331import org.openstreetmap.josm.tools.Utils;
    2432
     
    5159
    5260        final List<Class<? extends FileImporter>> importerNames = Arrays.asList(
    53                 org.openstreetmap.josm.io.OsmImporter.class,
    54                 org.openstreetmap.josm.io.OsmChangeImporter.class,
    55                 org.openstreetmap.josm.io.GpxImporter.class,
    56                 org.openstreetmap.josm.io.NMEAImporter.class,
    57                 org.openstreetmap.josm.io.NoteImporter.class,
    58                 org.openstreetmap.josm.io.JpgImporter.class,
    59                 org.openstreetmap.josm.io.WMSLayerImporter.class,
    60                 org.openstreetmap.josm.io.AllFormatsImporter.class,
    61                 org.openstreetmap.josm.io.session.SessionImporter.class
     61                OsmImporter.class,
     62                OsmChangeImporter.class,
     63                GpxImporter.class,
     64                NMEAImporter.class,
     65                NoteImporter.class,
     66                JpgImporter.class,
     67                WMSLayerImporter.class,
     68                AllFormatsImporter.class,
     69                SessionImporter.class
    6270        );
    6371
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r10463 r10755  
    10081008     * @return outer ways
    10091009     */
    1010     private List<AssembledMultipolygon> findPolygons(Collection<AssembledPolygon> boundaries) {
     1010    private static List<AssembledMultipolygon> findPolygons(Collection<AssembledPolygon> boundaries) {
    10111011
    10121012        List<PolygonLevel> list = findOuterWaysImpl(0, boundaries);
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r10728 r10755  
    4646 */
    4747public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements ICachedLoaderJob<K> {
    48     private static final Logger log = FeatureAdapter.getLogger(JCSCachedTileLoaderJob.class.getCanonicalName());
     48    private static final Logger LOG = FeatureAdapter.getLogger(JCSCachedTileLoaderJob.class.getCanonicalName());
    4949    protected static final long DEFAULT_EXPIRE_TIME = 1000L * 60 * 60 * 24 * 7; // 7 days
    5050    // Limit for the max-age value send by the server.
     
    159159        }
    160160        if (deduplicationKey == null) {
    161             log.log(Level.WARNING, "No url returned for: {0}, skipping", getCacheKey());
     161            LOG.log(Level.WARNING, "No url returned for: {0}, skipping", getCacheKey());
    162162            throw new IllegalArgumentException("No url returned");
    163163        }
     
    174174        if (first || force) {
    175175            // submit all jobs to separate thread, so calling thread is not blocked with IO when loading from disk
    176             log.log(Level.FINE, "JCS - Submitting job for execution for url: {0}", getUrlNoException());
     176            LOG.log(Level.FINE, "JCS - Submitting job for execution for url: {0}", getUrlNoException());
    177177            downloadJobExecutor.execute(this);
    178178        }
     
    222222        final String oldName = currentThread.getName();
    223223        currentThread.setName("JCS Downloading: " + getUrlNoException());
    224         log.log(Level.FINE, "JCS - starting fetch of url: {0} ", getUrlNoException());
     224        LOG.log(Level.FINE, "JCS - starting fetch of url: {0} ", getUrlNoException());
    225225        ensureCacheElement();
    226226        try {
     
    228228            if (!force && cacheElement != null && isCacheElementValid() && isObjectLoadable()) {
    229229                // we got something in cache, and it's valid, so lets return it
    230                 log.log(Level.FINE, "JCS - Returning object from cache: {0}", getCacheKey());
     230                LOG.log(Level.FINE, "JCS - Returning object from cache: {0}", getCacheKey());
    231231                finishLoading(LoadResult.SUCCESS);
    232232                return;
     
    241241                    // try to get stale entry in cache
    242242                    finishLoading(LoadResult.SUCCESS);
    243                     log.log(Level.FINE, "JCS - found stale object in cache: {0}", getUrlNoException());
     243                    LOG.log(Level.FINE, "JCS - found stale object in cache: {0}", getUrlNoException());
    244244                } else {
    245245                    // failed completely
     
    259259        }
    260260        if (listeners == null) {
    261             log.log(Level.WARNING, "Listener not found for URL: {0}. Listener not notified!", getUrlNoException());
     261            LOG.log(Level.WARNING, "Listener not found for URL: {0}. Listener not notified!", getUrlNoException());
    262262            return;
    263263        }
     
    276276            expires = Math.min(expires, attributes.getCreateTime() + EXPIRE_TIME_SERVER_LIMIT);
    277277            if (now > expires) {
    278                 log.log(Level.FINE, "JCS - Object {0} has expired -> valid to {1}, now is: {2}",
     278                LOG.log(Level.FINE, "JCS - Object {0} has expired -> valid to {1}, now is: {2}",
    279279                        new Object[]{getUrlNoException(), Long.toString(expires), Long.toString(now)});
    280280                return false;
     
    283283                now - attributes.getLastModification() > DEFAULT_EXPIRE_TIME) {
    284284            // check by file modification date
    285             log.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrlNoException());
     285            LOG.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrlNoException());
    286286            return false;
    287287        } else if (now - attributes.getCreateTime() > DEFAULT_EXPIRE_TIME) {
    288             log.log(Level.FINE, "JCS - Object has expired, maximum time since object creation reached {0}", getUrlNoException());
     288            LOG.log(Level.FINE, "JCS - Object has expired, maximum time since object creation reached {0}", getUrlNoException());
    289289            return false;
    290290        }
     
    305305                    Boolean.TRUE.equals(useHead.get(getServerKey())) &&
    306306                    isCacheValidUsingHead()) {
    307                 log.log(Level.FINE, "JCS - cache entry verified using HEAD request: {0}", getUrl());
     307                LOG.log(Level.FINE, "JCS - cache entry verified using HEAD request: {0}", getUrl());
    308308                return true;
    309309            }
     
    324324                // If isModifiedSince or If-None-Match has been set
    325325                // and the server answers with a HTTP 304 = "Not Modified"
    326                 log.log(Level.FINE, "JCS - If-Modified-Since/ETag test: local version is up to date: {0}", getUrl());
     326                LOG.log(Level.FINE, "JCS - If-Modified-Since/ETag test: local version is up to date: {0}", getUrl());
    327327                return true;
    328328            } else if (isObjectLoadable() // we have an object in cache, but we haven't received 304 response code
     
    334334                // for further requests - use HEAD
    335335                String serverKey = getServerKey();
    336                 log.log(Level.INFO, "JCS - Host: {0} found not to return 304 codes for If-Modified-Since or If-None-Match headers",
     336                LOG.log(Level.INFO, "JCS - Host: {0} found not to return 304 codes for If-Modified-Since or If-None-Match headers",
    337337                        serverKey);
    338338                useHead.put(serverKey, Boolean.TRUE);
     
    360360                    cacheData = createCacheEntry(raw);
    361361                    cache.put(getCacheKey(), cacheData, attributes);
    362                     log.log(Level.FINE, "JCS - downloaded key: {0}, length: {1}, url: {2}",
     362                    LOG.log(Level.FINE, "JCS - downloaded key: {0}, length: {1}, url: {2}",
    363363                            new Object[] {getCacheKey(), raw.length, getUrl()});
    364364                    return true;
     
    366366                    cacheData = createCacheEntry(new byte[]{});
    367367                    cache.put(getCacheKey(), cacheData, attributes);
    368                     log.log(Level.FINE, "JCS - Caching empty object {0}", getUrl());
     368                    LOG.log(Level.FINE, "JCS - Caching empty object {0}", getUrl());
    369369                    return true;
    370370                } else {
    371                     log.log(Level.FINE, "JCS - failure during load - reponse is not loadable nor cached as empty");
     371                    LOG.log(Level.FINE, "JCS - failure during load - reponse is not loadable nor cached as empty");
    372372                    return false;
    373373                }
    374374            }
    375375        } catch (FileNotFoundException e) {
    376             log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrlNoException());
     376            LOG.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrlNoException());
    377377            attributes.setResponseCode(404);
    378378            attributes.setError(e);
     
    384384            return doCache;
    385385        } catch (IOException e) {
    386             log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrlNoException());
     386            LOG.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrlNoException());
    387387            if (isObjectLoadable()) {
    388388                return true;
     
    395395        } catch (InterruptedException e) {
    396396            attributes.setError(e);
    397             log.log(Level.WARNING, "JCS - Exception during download {0}", getUrlNoException());
     397            LOG.log(Level.WARNING, "JCS - Exception during download {0}", getUrlNoException());
    398398            Main.warn(e);
    399399        }
    400         log.log(Level.WARNING, "JCS - Silent failure during download: {0}", getUrlNoException());
     400        LOG.log(Level.WARNING, "JCS - Silent failure during download: {0}", getUrlNoException());
    401401        return false;
    402402    }
  • trunk/src/org/openstreetmap/josm/data/osm/TagMap.java

    r10736 r10755  
    280280        stringBuilder.append("TagMap[");
    281281        boolean first = true;
    282         for (java.util.Map.Entry<String, String> e : entrySet()) {
     282        for (Map.Entry<String, String> e : entrySet()) {
    283283            if (!first) {
    284284                stringBuilder.append(',');
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java

    r10378 r10755  
    3838     * @since 6390
    3939     */
    40     private class UnclosedWaysCheck {
     40    private static class UnclosedWaysCheck {
    4141        /** The unique numeric code for this check */
    4242        public final int code;
     
    9090         * Returns the test error of the given way, if any.
    9191         * @param w The way to check
     92         * @param test parent test
    9293         * @return The test error if the way is erroneous, {@code null} otherwise
    9394         */
    94         public final TestError getTestError(Way w) {
     95        public final TestError getTestError(Way w, UnclosedWays test) {
    9596            String value = w.get(key);
    9697            if (isValueErroneous(value)) {
     
    99100                String etype = engMessage.contains("{0}") ? MessageFormat.format(engMessage, value) : engMessage;
    100101                // CHECKSTYLE.ON: SingleSpaceSeparator
    101                 return new TestError(UnclosedWays.this, Severity.WARNING, tr("Unclosed way"),
     102                return new TestError(test, Severity.WARNING, tr("Unclosed way"),
    102103                        type, etype, code, Arrays.asList(w),
    103104                        // The important parts of an unclosed way are the first and
     
    117118     * @since 6390
    118119     */
    119     private final class UnclosedWaysBooleanCheck extends UnclosedWaysCheck {
     120    private static final class UnclosedWaysBooleanCheck extends UnclosedWaysCheck {
    120121
    121122        /**
     
    137138    }
    138139
    139     private final UnclosedWaysCheck[] checks = {
     140    private static final UnclosedWaysCheck[] checks = {
    140141        // CHECKSTYLE.OFF: SingleSpaceSeparator
    141142        new UnclosedWaysCheck(1101, "natural",   marktr("natural type {0}"),
     
    183184
    184185        for (UnclosedWaysCheck c : checks) {
    185             TestError error = c.getTestError(w);
     186            TestError error = c.getTestError(w, this);
    186187            if (error != null) {
    187188                errors.add(error);
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r10680 r10755  
    683683        }
    684684
    685         private boolean handleNetworkErrors() {
     685        private static boolean handleNetworkErrors() {
    686686            boolean condition = !NETWORK_ERRORS.isEmpty();
    687687            if (condition) {
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r10742 r10755  
    267267    /**
    268268     * This class is an adapter for the old layer change interface.
    269      * <p>
    270      * New implementations should use {@link org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener}
    271269     * @author Michael Zangl
    272270     * @since 10271
    273      */
     271     * @deprecated New implementations should use {@link org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener}
     272     */
     273    @Deprecated
    274274    protected static class EditLayerChangeAdapter implements ActiveLayerChangeListener {
    275275
     
    326326     */
    327327    private static class WarningLayerPainter implements LayerPainter {
    328         boolean warningPrinted = false;
     328        boolean warningPrinted;
    329329        private final Layer layer;
    330330
  • trunk/src/org/openstreetmap/josm/gui/SideButton.java

    r10611 r10755  
    8585        if (action != null) {
    8686            propertyChangeListener = evt -> {
    87                 if (javax.swing.Action.SMALL_ICON.equals(evt.getPropertyName())) {
     87                if (Action.SMALL_ICON.equals(evt.getPropertyName())) {
    8888                    fixIcon(null);
    8989                }
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r10627 r10755  
    173173    }
    174174
    175     private List<TileSource> getAllTileSources() {
     175    private static List<TileSource> getAllTileSources() {
    176176        List<TileSource> tileSources = new ArrayList<>();
    177177        for (TileSourceProvider provider: providers) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r10680 r10755  
    468468        public void performTagEdit() {
    469469            String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString());
    470             value = Normalizer.normalize(value, java.text.Normalizer.Form.NFC);
     470            value = Normalizer.normalize(value, Normalizer.Form.NFC);
    471471            if (value.isEmpty()) {
    472472                value = null; // delete the key
    473473            }
    474474            String newkey = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString());
    475             newkey = Normalizer.normalize(newkey, java.text.Normalizer.Form.NFC);
     475            newkey = Normalizer.normalize(newkey, Normalizer.Form.NFC);
    476476            if (newkey.isEmpty()) {
    477477                newkey = key;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTransferHandler.java

    r10604 r10755  
    5858    }
    5959
    60     private int computeInsertionRow(TransferSupport support, MemberTable destination) {
     60    private static int computeInsertionRow(TransferSupport support, MemberTable destination) {
    6161        final int insertRow;
    6262        if (support.isDrop()) {
  • trunk/src/org/openstreetmap/josm/gui/history/SelectionSynchronizer.java

    r10637 r10755  
    1313
    1414    private final Set<ListSelectionModel> participants;
    15     private boolean preventRecursion = false;
     15    private boolean preventRecursion;
    1616
    1717    /**
  • trunk/src/org/openstreetmap/josm/gui/history/TagInfoTransferHandler.java

    r10637 r10755  
    2323
    2424    @Override
    25     public void exportToClipboard(JComponent comp, Clipboard clip, int action) throws IllegalStateException {
     25    public void exportToClipboard(JComponent comp, Clipboard clip, int action) {
    2626        if (comp instanceof JTable) {
    2727            TableModel model = ((JTable) comp).getModel();
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r10611 r10755  
    177177
    178178        info.append(tr("Length: {0}", SystemOfMeasurement.getSystemOfMeasurement().getDistText(data.length()))).append("<br>")
    179             .append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append(
    180                 trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>")
    181             .append("</html>");
     179            .append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size()))
     180            .append(trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br></html>");
    182181
    183182        final JScrollPane sp = new JScrollPane(new HtmlPanel(info.toString()));
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java

    r10680 r10755  
    128128     * @return non-editable table
    129129     */
    130     private JTable buildTable(Object[]... content) {
     130    private static JTable buildTable(Object[]... content) {
    131131        final String[] headers = {tr("Name"), tr("Description"), tr("Timespan"), tr("Length"), tr("URL")};
    132132        DefaultTableModel model = new DefaultTableModel(content, headers);
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/SharpenImageProcessor.java

    r10547 r10755  
    6868    }
    6969
    70     private ConvolveOp generateMixed(float aFactor, float[] a, float[] b) {
     70    private static ConvolveOp generateMixed(float aFactor, float[] a, float[] b) {
    7171        if (a.length != 9 || b.length != 9) {
    7272            throw new IllegalArgumentException("Illegal kernel array length.");
  • trunk/src/org/openstreetmap/josm/gui/widgets/ButtonColumn.java

    r10547 r10755  
    2929    private final JButton editButton;
    3030    private Object editorValue;
    31     private String buttonName = null;
     31    private String buttonName;
    3232
    3333    /**
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r10671 r10755  
    274274    protected String buildRequestString(final OsmPrimitiveType type, Set<Long> idPackage) {
    275275        return type.getAPIName() + "s?" + type.getAPIName() + "s=" + Utils.join(",", idPackage);
    276     }
    277 
    278     @Override
    279     protected String getBaseUrl() {
    280         return super.getBaseUrl();
    281276    }
    282277
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r10746 r10755  
    291291    protected List<ImageOverlay> overlayInfo;
    292292    /** <code>true</code> if icon must be grayed out */
    293     protected boolean isDisabled = false;
     293    protected boolean isDisabled;
    294294
    295295    private static SVGUniverse svgUniverse;
  • trunk/src/org/openstreetmap/josm/tools/ImageResource.java

    r10642 r10755  
    4949     * <code>true</code> if icon must be grayed out
    5050     */
    51     protected boolean isDisabled = false;
     51    protected boolean isDisabled;
    5252    /**
    5353     * The base raster image for the final output
Note: See TracChangeset for help on using the changeset viewer.