Changeset 8404 in josm


Ignore:
Timestamp:
2015-05-21T01:18:35+02:00 (9 years ago)
Author:
Don-vip
Message:

When doing a String.toLowerCase()/toUpperCase() call, use a Locale. This avoids problems with certain locales, i.e. Lithuanian or Turkish. See PMD UseLocaleWithCaseConversions rule and String.toLowerCase() javadoc.

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

Legend:

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

    r8395 r8404  
    2828import java.util.Iterator;
    2929import java.util.List;
     30import java.util.Locale;
    3031import java.util.Map;
    3132import java.util.Objects;
     
    542543    public Main() {
    543544        main = this;
    544         isOpenjdk = System.getProperty("java.vm.name").toUpperCase().indexOf("OPENJDK") != -1;
     545        isOpenjdk = System.getProperty("java.vm.name").toUpperCase(Locale.ENGLISH).indexOf("OPENJDK") != -1;
    545546
    546547        if (initListener != null) {
     
    11881189            warn("Your operating system has no name, so I'm guessing its some kind of *nix.");
    11891190            platform = new PlatformHookUnixoid();
    1190         } else if (os.toLowerCase().startsWith("windows")) {
     1191        } else if (os.toLowerCase(Locale.ENGLISH).startsWith("windows")) {
    11911192            platform = new PlatformHookWindows();
    11921193        } else if ("Linux".equals(os) || "Solaris".equals(os) ||
     
    11941195                "FreeBSD".equals(os) || "NetBSD".equals(os) || "OpenBSD".equals(os)) {
    11951196            platform = new PlatformHookUnixoid();
    1196         } else if (os.toLowerCase().startsWith("mac os x")) {
     1197        } else if (os.toLowerCase(Locale.ENGLISH).startsWith("mac os x")) {
    11971198            platform = new PlatformHookOsx();
    11981199        } else {
  • trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java

    r8338 r8404  
    1818import org.openstreetmap.josm.io.FileExporter;
    1919import org.openstreetmap.josm.io.FileImporter;
     20import org.openstreetmap.josm.tools.Utils;
    2021
    2122/**
     
    282283     */
    283284    public boolean acceptName(String filename) {
    284         String name = filename.toLowerCase();
    285         for (String ext : extensions.split(","))
    286             if (name.endsWith("."+ext))
    287                 return true;
    288         return false;
     285        return Utils.hasExtension(filename, extensions.split(","));
    289286    }
    290287
  • trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java

    r7578 r8404  
    5353        if (fc == null) return;
    5454        File file = fc.getSelectedFile();
    55         boolean zip = file.getName().toLowerCase().endsWith(".joz");
     55        boolean zip = Utils.hasExtension(file, "joz");
    5656        Main.worker.submit(new Loader(file, zip));
    5757    }
  • trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java

    r8308 r8404  
    4141import org.openstreetmap.josm.tools.GBC;
    4242import org.openstreetmap.josm.tools.MultiMap;
     43import org.openstreetmap.josm.tools.Utils;
    4344import org.openstreetmap.josm.tools.WindowGeometry;
    4445
     
    106107            zip = false;
    107108        } else {
    108             if (fn.toLowerCase().endsWith(".joz")) {
     109            if (Utils.hasExtension(fn, "joz")) {
    109110                zip = true;
    110111            } else {
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r8394 r8404  
    1515import java.util.List;
    1616import java.util.ListIterator;
     17import java.util.Locale;
    1718import java.util.Map;
    1819import java.util.Map.Entry;
     
    111112                    String[] param = value.split("=");
    112113                    // Hide some parameters for privacy concerns
    113                     if (param[0].toLowerCase().startsWith("-dproxy")) {
     114                    if (param[0].toLowerCase(Locale.ENGLISH).startsWith("-dproxy")) {
    114115                        it.set(param[0]+"=xxx");
    115116                    // Shorten some parameters for readability concerns
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r8394 r8404  
    1111import java.util.Collection;
    1212import java.util.HashMap;
     13import java.util.Locale;
    1314import java.util.Map;
    1415import java.util.regex.Matcher;
     
    477478                this.valuePattern = null;
    478479            } else {
    479                 this.key = key.toLowerCase();
     480                this.key = key.toLowerCase(Locale.ENGLISH);
    480481                this.value = value;
    481482                this.keyPattern = null;
     
    523524                    return false;
    524525
    525                 String v1 = caseSensitive ? mv : mv.toLowerCase();
    526                 String v2 = caseSensitive ? value : value.toLowerCase();
     526                String v1 = caseSensitive ? mv : mv.toLowerCase(Locale.ENGLISH);
     527                String v2 = caseSensitive ? value : value.toLowerCase(Locale.ENGLISH);
    527528
    528529                v1 = Normalizer.normalize(v1, Normalizer.Form.NFC);
     
    533534            return false;
    534535        }
    535         @Override public String toString() {return key+"="+value;}
     536        @Override
     537        public String toString() {
     538            return key + "=" + value;
     539        }
    536540    }
    537541
     
    719723                this.searchRegex = null;
    720724            } else {
    721                 this.search = s.toLowerCase();
     725                this.search = s.toLowerCase(Locale.ENGLISH);
    722726                this.searchRegex = null;
    723727            }
     
    744748                } else {
    745749                    if (!caseSensitive) {
    746                         key = key.toLowerCase();
    747                         value = value.toLowerCase();
     750                        key = key.toLowerCase(Locale.ENGLISH);
     751                        value = value.toLowerCase(Locale.ENGLISH);
    748752                    }
    749753
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java

    r8379 r8404  
    88import java.util.HashMap;
    99import java.util.List;
     10import java.util.Locale;
    1011import java.util.Map;
    1112import java.util.regex.Matcher;
     
    7576
    7677            if (m.lookingAt()) {
    77                 String leftRight = m.group(2).toLowerCase();
     78                String leftRight = m.group(2).toLowerCase(Locale.ENGLISH);
    7879
    7980                StringBuilder result = new StringBuilder();
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r8395 r8404  
    1919import java.util.Iterator;
    2020import java.util.List;
     21import java.util.Locale;
    2122import java.util.Map;
    2223import java.util.Map.Entry;
     
    281282    }
    282283
    283 
    284284    public static void deleteFile(String path, String base) {
    285285        String dir = getDirectoryByAbbr(base);
     
    320320    private static boolean busy=false;
    321321
    322 
    323322    public static void pluginOperation(String install, String uninstall, String delete)  {
    324323        final List<String> installList = new ArrayList<>();
    325324        final List<String> removeList = new ArrayList<>();
    326325        final List<String> deleteList = new ArrayList<>();
    327         Collections.addAll(installList, install.toLowerCase().split(";"));
    328         Collections.addAll(removeList, uninstall.toLowerCase().split(";"));
    329         Collections.addAll(deleteList, delete.toLowerCase().split(";"));
    330         installList.remove("");removeList.remove("");deleteList.remove("");
     326        Collections.addAll(installList, install.toLowerCase(Locale.ENGLISH).split(";"));
     327        Collections.addAll(removeList, uninstall.toLowerCase(Locale.ENGLISH).split(";"));
     328        Collections.addAll(deleteList, delete.toLowerCase(Locale.ENGLISH).split(";"));
     329        installList.remove("");
     330        removeList.remove("");
     331        deleteList.remove("");
    331332
    332333        if (!installList.isEmpty()) {
     
    346347                if (task.isCanceled()) return;
    347348                synchronized (CustomConfigurator.class) {
    348                 try { // proceed only after all other tasks were finished
    349                     while (busy) CustomConfigurator.class.wait();
    350                 } catch (InterruptedException ex) {
    351                     Main.warn("InterruptedException while reading local plugin information");
    352                 }
    353 
    354                 SwingUtilities.invokeLater(new Runnable() {
    355                     @Override
    356                     public void run() {
    357                         List<PluginInformation> availablePlugins = task.getAvailablePlugins();
    358                         List<PluginInformation> toInstallPlugins = new ArrayList<>();
    359                         List<PluginInformation> toRemovePlugins = new ArrayList<>();
    360                         List<PluginInformation> toDeletePlugins = new ArrayList<>();
    361                         for (PluginInformation pi: availablePlugins) {
    362                             String name = pi.name.toLowerCase();
    363                             if (installList.contains(name)) toInstallPlugins.add(pi);
    364                             if (removeList.contains(name)) toRemovePlugins.add(pi);
    365                             if (deleteList.contains(name)) toDeletePlugins.add(pi);
     349                    try { // proceed only after all other tasks were finished
     350                        while (busy) CustomConfigurator.class.wait();
     351                    } catch (InterruptedException ex) {
     352                        Main.warn("InterruptedException while reading local plugin information");
     353                    }
     354
     355                    SwingUtilities.invokeLater(new Runnable() {
     356                        @Override
     357                        public void run() {
     358                            List<PluginInformation> availablePlugins = task.getAvailablePlugins();
     359                            List<PluginInformation> toInstallPlugins = new ArrayList<>();
     360                            List<PluginInformation> toRemovePlugins = new ArrayList<>();
     361                            List<PluginInformation> toDeletePlugins = new ArrayList<>();
     362                            for (PluginInformation pi: availablePlugins) {
     363                                String name = pi.name.toLowerCase(Locale.ENGLISH);
     364                                if (installList.contains(name)) toInstallPlugins.add(pi);
     365                                if (removeList.contains(name)) toRemovePlugins.add(pi);
     366                                if (deleteList.contains(name)) toDeletePlugins.add(pi);
     367                            }
     368                            if (!installList.isEmpty()) {
     369                                PluginDownloadTask pluginDownloadTask =
     370                                        new PluginDownloadTask(Main.parent, toInstallPlugins, tr("Installing plugins"));
     371                                Main.worker.submit(pluginDownloadTask);
     372                            }
     373                            Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins"));
     374                            for (PluginInformation pi: toInstallPlugins) {
     375                                if (!pls.contains(pi.name)) {
     376                                    pls.add(pi.name);
     377                                }
     378                            }
     379                            for (PluginInformation pi: toRemovePlugins) {
     380                                pls.remove(pi.name);
     381                            }
     382                            for (PluginInformation pi: toDeletePlugins) {
     383                                pls.remove(pi.name);
     384                                new File(Main.pref.getPluginsDirectory(), pi.name+".jar").deleteOnExit();
     385                            }
     386                            Main.pref.putCollection("plugins",pls);
    366387                        }
    367                         if (!installList.isEmpty()) {
    368                             PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(Main.parent, toInstallPlugins, tr ("Installing plugins"));
    369                             Main.worker.submit(pluginDownloadTask);
    370                         }
    371                         Collection<String> pls = new ArrayList<>(Main.pref.getCollection("plugins"));
    372                         for (PluginInformation pi: toInstallPlugins) {
    373                             if (!pls.contains(pi.name)) {
    374                                 pls.add(pi.name);
    375                             }
    376                         }
    377                         for (PluginInformation pi: toRemovePlugins) {
    378                             pls.remove(pi.name);
    379                         }
    380                         for (PluginInformation pi: toDeletePlugins) {
    381                             pls.remove(pi.name);
    382                             new File(Main.pref.getPluginsDirectory(), pi.name+".jar").deleteOnExit();
    383                         }
    384                         Main.pref.putCollection("plugins",pls);
    385                     }
    386                 });
    387             }
    388             }
    389 
     388                    });
     389                }
     390            }
    390391        };
    391392        Main.worker.submit(task);
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r8393 r8404  
    1010import java.util.Collections;
    1111import java.util.List;
     12import java.util.Locale;
    1213import java.util.Map;
    1314import java.util.Objects;
     
    545546        int i = countryCode.compareTo(in.countryCode);
    546547        if (i == 0) {
    547             i = name.toLowerCase().compareTo(in.name.toLowerCase());
     548            i = name.toLowerCase(Locale.ENGLISH).compareTo(in.name.toLowerCase(Locale.ENGLISH));
    548549        }
    549550        if (i == 0) {
     
    690691            try {
    691692                serverProjections = new ArrayList<>();
    692                 Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase());
     693                Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase(Locale.ENGLISH));
    693694                if(m.matches()) {
    694695                    for(String p : m.group(1).split(","))
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r8395 r8404  
    1515import java.util.LinkedList;
    1616import java.util.List;
     17import java.util.Locale;
    1718import java.util.Map;
    1819import java.util.Set;
     
    13421343    public Object getTemplateValue(String name, boolean special) {
    13431344        if (special) {
    1344             String lc = name.toLowerCase();
     1345            String lc = name.toLowerCase(Locale.ENGLISH);
    13451346            if (SPECIAL_VALUE_ID.equals(lc))
    13461347                return getId();
  • trunk/src/org/openstreetmap/josm/data/preferences/ColorProperty.java

    r7937 r8404  
    33
    44import java.awt.Color;
     5import java.util.Locale;
    56
    67import org.openstreetmap.josm.Main;
     
    1415
    1516    private final String name;
    16    
     17
    1718    /**
    1819     * Constructs a new {@code ColorProperty}.
     
    2425        this.name = colName;
    2526    }
    26    
     27
    2728    @Override
    2829    public Color get() {
     
    3435        return Main.pref.putColor(getColorKey(name), value);
    3536    }
    36    
     37
    3738    /**
    3839     * Replies the color key used in JOSM preferences for this property.
     
    4142     */
    4243    public static String getColorKey(String colName) {
    43         return colName == null ? null : colName.toLowerCase().replaceAll("[^a-z0-9]+",".");
     44        return colName == null ? null : colName.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]+",".");
    4445    }
    4546
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r8255 r8404  
    1111import java.util.HashMap;
    1212import java.util.HashSet;
     13import java.util.Locale;
    1314import java.util.Map;
    1415import java.util.Set;
     
    133134     */
    134135    public static String getInit(String id) {
    135         Pair<String, String> r = inits.get(id.toUpperCase());
     136        Pair<String, String> r = inits.get(id.toUpperCase(Locale.ENGLISH));
    136137        if (r == null) return null;
    137138        return r.b;
  • trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java

    r8345 r8404  
    1818
    1919import java.util.Arrays;
     20import java.util.Locale;
    2021
    2122/**
     
    170171     */
    171172    public boolean isValidInfrastructureTld(String iTld) {
    172         return Arrays.binarySearch(INFRASTRUCTURE_TLDS, chompLeadingDot(iTld.toLowerCase())) >= 0;
     173        return Arrays.binarySearch(INFRASTRUCTURE_TLDS, chompLeadingDot(iTld.toLowerCase(Locale.ENGLISH))) >= 0;
    173174    }
    174175
     
    181182     */
    182183    public boolean isValidGenericTld(String gTld) {
    183         return Arrays.binarySearch(GENERIC_TLDS, chompLeadingDot(gTld.toLowerCase())) >= 0;
     184        return Arrays.binarySearch(GENERIC_TLDS, chompLeadingDot(gTld.toLowerCase(Locale.ENGLISH))) >= 0;
    184185    }
    185186
     
    192193     */
    193194    public boolean isValidIdnTld(String iTld) {
    194         return Arrays.binarySearch(IDN_TLDS, chompLeadingDot(iTld.toUpperCase())) >= 0;
     195        return Arrays.binarySearch(IDN_TLDS, chompLeadingDot(iTld.toUpperCase(Locale.ENGLISH))) >= 0;
    195196    }
    196197
     
    203204     */
    204205    public boolean isValidCountryCodeTld(String ccTld) {
    205         return Arrays.binarySearch(COUNTRY_CODE_TLDS, chompLeadingDot(ccTld.toLowerCase())) >= 0;
     206        return Arrays.binarySearch(COUNTRY_CODE_TLDS, chompLeadingDot(ccTld.toLowerCase(Locale.ENGLISH))) >= 0;
    206207    }
    207208
     
    214215     */
    215216    public boolean isValidLocalTld(String iTld) {
    216         return Arrays.binarySearch(LOCAL_TLDS, chompLeadingDot(iTld.toLowerCase())) >= 0;
     217        return Arrays.binarySearch(LOCAL_TLDS, chompLeadingDot(iTld.toLowerCase(Locale.ENGLISH))) >= 0;
    217218    }
    218219
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java

    r7986 r8404  
    1212import java.util.Iterator;
    1313import java.util.List;
     14import java.util.Locale;
    1415import java.util.Map;
    1516import java.util.Map.Entry;
     
    151152                    String number = p.get(ADDR_HOUSE_NUMBER);
    152153                    if (number != null) {
    153                         number = number.trim().toUpperCase();
     154                        number = number.trim().toUpperCase(Locale.ENGLISH);
    154155                        List<OsmPrimitive> list = map.get(number);
    155156                        if (list == null) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r8390 r8404  
    2121import java.util.LinkedList;
    2222import java.util.List;
     23import java.util.Locale;
    2324import java.util.Map;
    2425import java.util.Set;
     
    253254                sb.append("throw")
    254255                .append(s.name().charAt(0))
    255                 .append(s.name().substring(1).toLowerCase());
     256                .append(s.name().substring(1).toLowerCase(Locale.ENGLISH));
    256257            }
    257258            return sb.toString();
     
    276277                    if (ai.key.startsWith("throw")) {
    277278                        try {
    278                             final Severity severity = Severity.valueOf(ai.key.substring("throw".length()).toUpperCase());
     279                            final Severity severity = Severity.valueOf(ai.key.substring("throw".length()).toUpperCase(Locale.ENGLISH));
    279280                            check.errors.put(ai, severity);
    280281                        } catch (IllegalArgumentException e) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    r8390 r8404  
    1111import java.util.HashMap;
    1212import java.util.List;
     13import java.util.Locale;
    1314import java.util.Map;
    1415import java.util.regex.Matcher;
     
    250251
    251252        public SynonymRule(String replacement, String[] words) {
    252             this.replacement = replacement.toLowerCase();
     253            this.replacement = replacement.toLowerCase(Locale.ENGLISH);
    253254            this.words = words;
    254255
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r8394 r8404  
    1818import java.util.HashMap;
    1919import java.util.List;
     20import java.util.Locale;
    2021import java.util.Map;
    2122import java.util.Map.Entry;
     
    424425            }
    425426            if (checkFixmes && key != null && value != null && value.length() > 0) {
    426                 if ((value.toLowerCase().contains("fixme")
     427                if ((value.toLowerCase(Locale.ENGLISH).contains("fixme")
    427428                        || value.contains("check and delete")
    428                         || key.contains("todo") || key.toLowerCase().contains("fixme"))
     429                        || key.contains("todo") || key.toLowerCase(Locale.ENGLISH).contains("fixme"))
    429430                        && !withErrors.contains(p, "FIXME")) {
    430431                    errors.add(new TestError(this, Severity.OTHER,
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r8399 r8404  
    1515import java.util.Iterator;
    1616import java.util.List;
     17import java.util.Locale;
    1718
    1819import javax.swing.Action;
     
    5455        @Override
    5556        public int compare(ImageryInfo ii1, ImageryInfo ii2) {
    56             return ii1.getName().toLowerCase().compareTo(ii2.getName().toLowerCase());
     57            return ii1.getName().toLowerCase(Locale.ENGLISH).compareTo(ii2.getName().toLowerCase(Locale.ENGLISH));
    5758        }
    5859    };
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r8392 r8404  
    3434import java.util.LinkedList;
    3535import java.util.List;
     36import java.util.Locale;
    3637import java.util.Map;
    3738import java.util.Set;
     
    206207
    207208        private Option(boolean requiresArgument) {
    208             this.name = name().toLowerCase().replace("_", "-");
     209            this.name = name().toLowerCase(Locale.ENGLISH).replace("_", "-");
    209210            this.requiresArg = requiresArgument;
    210211        }
     
    229230            Map<Option, Collection<String>> res = new EnumMap<>(Option.class);
    230231            for (Map.Entry<String, Collection<String>> e : opts.entrySet()) {
    231                 Option o = Option.valueOf(e.getKey().toUpperCase().replace("-", "_"));
     232                Option o = Option.valueOf(e.getKey().toUpperCase(Locale.ENGLISH).replace("-", "_"));
    232233                if (o != null) {
    233234                    res.put(o, e.getValue());
     
    509510            for (String s : args.get(Option.OFFLINE).iterator().next().split(",")) {
    510511                try {
    511                     Main.setOffline(OnlineResource.valueOf(s.toUpperCase()));
     512                    Main.setOffline(OnlineResource.valueOf(s.toUpperCase(Locale.ENGLISH)));
    512513                } catch (IllegalArgumentException e) {
    513514                    Main.error(tr("''{0}'' is not a valid value for argument ''{1}''. Possible values are {2}, possibly delimited by commas.",
    514                             s.toUpperCase(), Option.OFFLINE.getName(), Arrays.toString(OnlineResource.values())));
     515                            s.toUpperCase(Locale.ENGLISH), Option.OFFLINE.getName(), Arrays.toString(OnlineResource.values())));
    515516                    System.exit(1);
    516517                    return;
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r8399 r8404  
    1616import java.util.HashMap;
    1717import java.util.List;
     18import java.util.Locale;
    1819import java.util.Map;
    1920
     
    857858     */
    858859    private List<JMenuItem> findMenuItems(String textToFind) {
    859         textToFind = textToFind.toLowerCase();
     860        // Explicitely use default locale in this case, because we're looking for translated strings
     861        textToFind = textToFind.toLowerCase(Locale.getDefault());
    860862        List<JMenuItem> result = new ArrayList<>();
    861863
    862864        // Iterate over main menus
    863865        for (MenuElement menuElement : getSubElements()) {
    864             if( !(menuElement instanceof JMenu)) continue;
     866            if (!(menuElement instanceof JMenu)) continue;
    865867
    866868            JMenu mainMenuItem = (JMenu) menuElement;
    867             if(mainMenuItem.getAction()!=null && mainMenuItem.getText().toLowerCase().contains(textToFind)) {
     869            if (mainMenuItem.getAction() != null && mainMenuItem.getText().toLowerCase(Locale.getDefault()).contains(textToFind)) {
    868870                result.add(mainMenuItem);
    869871            }
     
    887889            if (menuItem == null) continue;
    888890
    889             if (menuItem.getAction()!=null && menuItem.getText().toLowerCase().contains(textToFind)) {
     891            // Explicitely use default locale in this case, because we're looking for translated strings
     892            if (menuItem.getAction() != null && menuItem.getText().toLowerCase(Locale.getDefault()).contains(textToFind)) {
    890893                result.add(menuItem);
    891894            }
     
    10071010        //TODO: perform some delay (maybe 200 ms) before actual searching.
    10081011        void doSearch(String searchTerm) {
    1009             searchTerm = searchTerm.trim().toLowerCase();
     1012            // Explicitely use default locale in this case, because we're looking for translated strings
     1013            searchTerm = searchTerm.trim().toLowerCase(Locale.getDefault());
    10101014
    10111015            if (searchTerm.equals(currentSearchText)) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java

    r8390 r8404  
    374374                } else if (m.group(7) != null) {
    375375                    sb.append('x');     // cardinal direction
    376                     String c = m.group(7).toUpperCase();
     376                    String c = m.group(7).toUpperCase(Locale.ENGLISH);
    377377                    if ("N".equals(c) || "S".equals(c) || "E".equals(c) || "W".equals(c)) {
    378378                        list.add(c);
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java

    r8390 r8404  
    1111import java.util.LinkedList;
    1212import java.util.List;
     13import java.util.Locale;
    1314
    1415import javax.swing.DefaultListModel;
     
    7374        @Override
    7475        public int compareTo(Bookmark b) {
    75             return name.toLowerCase().compareTo(b.name.toLowerCase());
     76            return name.toLowerCase(Locale.ENGLISH).compareTo(b.name.toLowerCase(Locale.ENGLISH));
    7677        }
    7778
  • trunk/src/org/openstreetmap/josm/gui/io/UploadStrategy.java

    r6990 r8404  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5
     6import java.util.Locale;
    57
    68import org.openstreetmap.josm.Main;
     
    2830    public static UploadStrategy fromPreference(String preferenceValue) {
    2931        if (preferenceValue == null) return null;
    30         preferenceValue = preferenceValue.trim().toLowerCase();
     32        preferenceValue = preferenceValue.trim().toLowerCase(Locale.ENGLISH);
    3133        for (UploadStrategy strategy: values()) {
    3234            if (strategy.getPreferenceValue().equals(preferenceValue))
     
    7678                v = "";
    7779            }
    78             v = v.trim().toLowerCase();
     80            v = v.trim().toLowerCase(Locale.ENGLISH);
    7981            if ("true".equals(v))
    8082                return SINGLE_REQUEST_STRATEGY;
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r8384 r8404  
    2525import java.util.Iterator;
    2626import java.util.List;
     27import java.util.Locale;
    2728import java.util.Set;
    2829import java.util.concurrent.locks.Condition;
     
    10641065    public boolean isProjectionSupported(Projection proj) {
    10651066        List<String> serverProjections = info.getServerProjections();
    1066         return serverProjections.contains(proj.toCode().toUpperCase())
     1067        return serverProjections.contains(proj.toCode().toUpperCase(Locale.ENGLISH))
    10671068                || ("EPSG:3857".equals(proj.toCode()) && (serverProjections.contains("EPSG:4326") || serverProjections.contains("CRS:84")))
    10681069                || ("EPSG:4326".equals(proj.toCode()) && serverProjections.contains("CRS:84"));
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r8394 r8404  
    7979import org.openstreetmap.josm.tools.GBC;
    8080import org.openstreetmap.josm.tools.ImageProvider;
     81import org.openstreetmap.josm.tools.Utils;
    8182import org.openstreetmap.josm.tools.date.DateUtils;
    8283import org.openstreetmap.josm.tools.date.PrimaryDateParser;
     
    144145            FileFilter filter = new FileFilter(){
    145146                @Override public boolean accept(File f) {
    146                     return f.isDirectory()
    147                             || f .getName().toLowerCase().endsWith(".gpx")
    148                             || f.getName().toLowerCase().endsWith(".gpx.gz");
     147                    return f.isDirectory() || Utils.hasExtension(f, "gpx", "gpx.gz");
    149148                }
    150149                @Override public String getDescription() {
     
    214213
    215214        private InputStream createInputStream(File sel) throws IOException, FileNotFoundException {
    216             if (sel.getName().toLowerCase().endsWith(".gpx.gz")) {
     215            if (Utils.hasExtension(sel, "gpx.gz")) {
    217216                return new GZIPInputStream(new FileInputStream(sel));
    218217            } else {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/JpegFileFilter.java

    r8378 r8404  
    55
    66import java.io.File;
     7
     8import org.openstreetmap.josm.tools.Utils;
    79
    810class JpegFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter {
     
    1820            return true;
    1921        } else {
    20             String name = f.getName().toLowerCase();
    21             return name.endsWith(".jpg") || name.endsWith(".jpeg");
     22            return Utils.hasExtension(f, "jpg", "jpeg");
    2223        }
    2324    }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r8308 r8404  
    7171            @Override
    7272            public boolean accept(File f) {
    73                 return f.isDirectory() || f.getName().toLowerCase().endsWith(".wav");
     73                return f.isDirectory() || Utils.hasExtension(f, "wav");
    7474            }
    7575
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportImagesAction.java

    r8338 r8404  
    2222import org.openstreetmap.josm.io.JpgImporter;
    2323import org.openstreetmap.josm.tools.ImageProvider;
     24import org.openstreetmap.josm.tools.Utils;
    2425
    2526public class ImportImagesAction extends AbstractAction {
     
    4142            if (f.isDirectory()) {
    4243                addRecursiveFiles(files, f.listFiles());
    43             } else if (f.getName().toLowerCase().endsWith(".jpg")) {
     44            } else if (Utils.hasExtension(f, "jpg")) {
    4445                files.add(f);
    4546            }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Keyword.java

    r7083 r8404  
    22package org.openstreetmap.josm.gui.mappaint;
    33
     4import java.util.Locale;
    45import java.util.Objects;
    56
     
    89
    910    public Keyword(String val) {
    10         this.val = val.toLowerCase();
     11        this.val = val.toLowerCase(Locale.ENGLISH);
    1112    }
    1213
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r8394 r8404  
    287287            if (zipEntryPath != null)
    288288                return new XmlStyleSource(entry);
    289             if (entry.url.toLowerCase().endsWith(".mapcss"))
     289            if (Utils.hasExtension(entry.url, "mapcss"))
    290290                return new MapCSSStyleSource(entry);
    291             if (entry.url.toLowerCase().endsWith(".xml"))
     291            if (Utils.hasExtension(entry.url, "xml"))
    292292                return new XmlStyleSource(entry);
    293293            else {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r8331 r8404  
    1414import java.util.Collections;
    1515import java.util.List;
     16import java.util.Locale;
    1617
    1718import org.openstreetmap.josm.Main;
     
    388389    ( <PP_NOT> { invert = true; } pp_w() )?
    389390    (
    390             t=<IDENT> { mediatype = t.image.toLowerCase(); } pp_w()
     391            t=<IDENT> { mediatype = t.image.toLowerCase(Locale.ENGLISH); } pp_w()
    391392            ( <PP_AND> pp_w() e=pp_media_expression() { pass = pass && e; } pp_w() )*
    392393        |
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r8373 r8404  
    1919import java.util.Iterator;
    2020import java.util.List;
     21import java.util.Locale;
    2122import java.util.Map;
    2223import java.util.Map.Entry;
     
    102103            try {
    103104                SUPPORTED_KEYS.add((String) f.get(null));
    104                 if (!f.getName().toLowerCase().replace("_", "-").equals(f.get(null))) {
     105                if (!f.getName().toLowerCase(Locale.ENGLISH).replace("_", "-").equals(f.get(null))) {
    105106                    throw new RuntimeException(f.getName());
    106107                }
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r8308 r8404  
    1515import java.util.LinkedHashMap;
    1616import java.util.List;
     17import java.util.Locale;
    1718import java.util.Map;
    1819import java.util.Map.Entry;
     
    4950import org.openstreetmap.josm.gui.widgets.JosmTextField;
    5051import org.openstreetmap.josm.tools.GBC;
     52import org.openstreetmap.josm.tools.Utils;
    5153
    5254/**
     
    191193            @Override
    192194            public boolean accept(File f) {
    193                 return f.isDirectory() || f.getName().toLowerCase().endsWith(".xml");
     195                return f.isDirectory() || Utils.hasExtension(f, "xml");
    194196            }
    195197            @Override
     
    435437
    436438            // Make 'wmsplugin cache' search for e.g. 'cache.wmsplugin'
    437             final String prefKeyLower = prefKey.toLowerCase();
    438             final String prefValueLower = prefValue.toLowerCase();
     439            final String prefKeyLower = prefKey.toLowerCase(Locale.ENGLISH);
     440            final String prefValueLower = prefValue.toLowerCase(Locale.ENGLISH);
    439441            for (String bit : input) {
    440                 bit = bit.toLowerCase();
     442                bit = bit.toLowerCase(Locale.ENGLISH);
    441443                if (!prefKeyLower.contains(bit) && !prefValueLower.contains(bit)) {
    442444                    canHas = false;
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java

    r8378 r8404  
    88import java.util.ArrayList;
    99import java.util.List;
     10import java.util.Locale;
    1011import java.util.Map;
    1112
     
    2122import org.openstreetmap.josm.data.Preferences.Setting;
    2223import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
     24import org.openstreetmap.josm.tools.Utils;
    2325
    2426/**
     
    6567            @Override
    6668            public boolean accept(File f) {
    67                 return f.isDirectory() || f.getName().toLowerCase().endsWith(".xml") && f.getName().toLowerCase().startsWith(schemaKey);
     69                return f.isDirectory() || Utils.hasExtension(f, "xml") && f.getName().toLowerCase(Locale.ENGLISH).startsWith(schemaKey);
    6870            }
    6971            @Override
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java

    r8377 r8404  
    1111import java.util.LinkedList;
    1212import java.util.List;
     13import java.util.Locale;
    1314import java.util.Map;
    1415import java.util.Map.Entry;
     
    155156                    @Override
    156157                    public int compare(PluginInformation o1, PluginInformation o2) {
    157                         String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase();
    158                         String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase();
     158                        String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH);
     159                        String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH);
    159160                        return n1.compareTo(n2);
    160161                    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginUpdatePolicyPanel.java

    r8388 r8404  
    99import java.awt.Insets;
    1010import java.util.EnumMap;
     11import java.util.Locale;
    1112import java.util.Map;
    1213
     
    4647        static Policy fromPreferenceValue(String preferenceValue) {
    4748            if (preferenceValue == null) return null;
    48             preferenceValue = preferenceValue.trim().toLowerCase();
     49            preferenceValue = preferenceValue.trim().toLowerCase(Locale.ENGLISH);
    4950            for (Policy p: Policy.values()) {
    5051                if (p.getPreferencesValue().equals(preferenceValue))
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeProjectionChoice.java

    r8399 r8404  
    1313import java.util.Comparator;
    1414import java.util.List;
     15import java.util.Locale;
    1516import java.util.regex.Matcher;
    1617import java.util.regex.Pattern;
     
    164165        private void updateFilter() {
    165166            filteredData.clear();
    166             String filterTxt = filter.getText().trim().toLowerCase();
     167            String filterTxt = filter.getText().trim().toLowerCase(Locale.ENGLISH);
    167168            for (String code : data) {
    168                 if (code.toLowerCase().contains(filterTxt)) {
     169                if (code.toLowerCase(Locale.ENGLISH).contains(filterTxt)) {
    169170                    filteredData.add(code);
    170171                }
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreferencesPanel.java

    r8388 r8404  
    1616import java.net.ProxySelector;
    1717import java.util.EnumMap;
     18import java.util.Locale;
    1819import java.util.Map;
    1920
     
    7475        public static ProxyPolicy fromName(String policyName) {
    7576            if (policyName == null) return null;
    76             policyName = policyName.trim().toLowerCase();
     77            policyName = policyName.trim().toLowerCase(Locale.ENGLISH);
    7778            for(ProxyPolicy pp: values()) {
    7879                if (pp.getName().equals(policyName))
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSelector.java

    r8376 r8404  
    2222import java.util.Iterator;
    2323import java.util.List;
     24import java.util.Locale;
    2425import java.util.Objects;
    2526import java.util.Set;
     
    135136            TaggingPreset group = preset.group;
    136137            while (group != null) {
    137                 Collections.addAll(groups, group.getLocaleName().toLowerCase().split("\\s"));
     138                Collections.addAll(groups, group.getLocaleName().toLowerCase(Locale.ENGLISH).split("\\s"));
    138139                group = group.group;
    139140            }
    140             Collections.addAll(names, preset.getLocaleName().toLowerCase().split("\\s"));
     141            Collections.addAll(names, preset.getLocaleName().toLowerCase(Locale.ENGLISH).split("\\s"));
    141142            for (TaggingPresetItem item: preset.data) {
    142143                if (item instanceof KeyedItem) {
     
    165166                boolean foundFirst = false;
    166167                for (String value: values) {
    167                     int index = value.toLowerCase().indexOf(word);
     168                    int index = value.toLowerCase(Locale.ENGLISH).indexOf(word);
    168169                    if (index == 0) {
    169170                        foundFirst = true;
     
    329330    private synchronized void filterPresets() {
    330331        //TODO Save favorites to file
    331         String text = edSearchText.getText().toLowerCase();
     332        String text = edSearchText.getText().toLowerCase(Locale.ENGLISH);
    332333        boolean onlyApplicable = ckOnlyApplicable != null && ckOnlyApplicable.isSelected();
    333334        boolean inTags = ckSearchInTags != null && ckSearchInTags.isSelected();
  • trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java

    r8394 r8404  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.util;
     3
     4import java.util.Locale;
    35
    46import org.openstreetmap.josm.data.osm.Node;
     
    5557     */
    5658    public static double parseCardinalRotation(final String cardinal) {
    57         switch (cardinal.toLowerCase()) {
     59        switch (cardinal.toLowerCase(Locale.ENGLISH)) {
    5860            case "n":
    5961            case "north":
  • trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

    r8390 r8404  
    3838import java.util.List;
    3939import java.util.ListIterator;
     40import java.util.Locale;
    4041import java.util.Map;
    4142
     
    11881189                    throwParseException(st, "invalid node type");
    11891190                }
    1190                 String nodeType = st.sval.toUpperCase();
     1191                String nodeType = st.sval.toUpperCase(Locale.ENGLISH);
    11911192                if ("LEAF".equals(nodeType)) {
    11921193                    parseLeaf(st, parent);
  • trunk/src/org/openstreetmap/josm/io/JpgImporter.java

    r7178 r8404  
    1616import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    1717import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     18import org.openstreetmap.josm.tools.Utils;
    1819
    1920/**
     
    105106                    }
    106107                } else {
    107                     if (f.getName().toLowerCase().endsWith(".jpg")) {
     108                    if (Utils.hasExtension(f, "jpg")) {
    108109                        files.add(f);
    109110                    }
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java

    r8345 r8404  
    209209        // [1] https://www.epsg-registry.org/report.htm?type=selection&entity=urn:ogc:def:crs:EPSG::4326&reportDetail=short&style=urn:uuid:report-style:default-with-code&style_name=OGP%20Default%20With%20Code&title=EPSG:4326
    210210        boolean switchLatLon = false;
    211         if (baseURL.toLowerCase().contains("crs=epsg:4326")) {
     211        if (baseURL.toLowerCase(Locale.ENGLISH).contains("crs=epsg:4326")) {
    212212            switchLatLon = true;
    213         } else if (baseURL.toLowerCase().contains("crs=") && "EPSG:4326".equals(myProj)) {
     213        } else if (baseURL.toLowerCase(Locale.ENGLISH).contains("crs=") && "EPSG:4326".equals(myProj)) {
    214214            switchLatLon = true;
    215215        }
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r8390 r8404  
    1515import java.util.HashSet;
    1616import java.util.List;
     17import java.util.Locale;
    1718import java.util.Set;
    1819import java.util.regex.Pattern;
     
    263264            String crs = (String) getContent(child);
    264265            if (!crs.isEmpty()) {
    265                 String upperCase = crs.trim().toUpperCase();
     266                String upperCase = crs.trim().toUpperCase(Locale.ENGLISH);
    266267                crsList.add(upperCase);
    267268            }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/DNSName.java

    r8394 r8404  
    161161    @Override
    162162    public int hashCode() {
    163         return name.toUpperCase().hashCode();
     163        return name.toUpperCase(Locale.ENGLISH).hashCode();
    164164    }
    165165
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java

    r8377 r8404  
    2828import java.util.Date;
    2929import java.util.Enumeration;
     30import java.util.Locale;
    3031import java.util.Vector;
    3132
     
    117118    private static GeneralName createGeneralName(String t, String v) throws IOException {
    118119        GeneralNameInterface gn;
    119         switch (t.toLowerCase()) {
     120        switch (t.toLowerCase(Locale.ENGLISH)) {
    120121            case "uri": gn = new URIName(v); break;
    121122            case "dns": gn = new DNSName(v); break;
  • trunk/src/org/openstreetmap/josm/io/session/SessionImporter.java

    r7937 r8404  
    1313import org.openstreetmap.josm.io.FileImporter;
    1414import org.openstreetmap.josm.io.IllegalDataException;
     15import org.openstreetmap.josm.tools.Utils;
    1516
    1617/**
     
    3536    @Override
    3637    public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
    37         boolean zip = file.getName().toLowerCase().endsWith(".joz");
     38        boolean zip = Utils.hasExtension(file, "joz");
    3839        Main.worker.submit(new Loader(file, zip));
    3940    }
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r8394 r8404  
    582582        while (entries.hasMoreElements()) {
    583583            ZipEntry entry = entries.nextElement();
    584             if (entry.getName().toLowerCase().endsWith(".jos")) {
     584            if (Utils.hasExtension(entry.getName(), "jos")) {
    585585                josEntry = entry;
    586586                break;
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r8390 r8404  
    2828import java.util.LinkedList;
    2929import java.util.List;
     30import java.util.Locale;
    3031import java.util.Map;
    3132import java.util.Map.Entry;
     
    380381        // check whether automatic update at startup was disabled
    381382        //
    382         String policy = Main.pref.get(togglePreferenceKey, "ask").trim().toLowerCase();
     383        String policy = Main.pref.get(togglePreferenceKey, "ask").trim().toLowerCase(Locale.ENGLISH);
    383384        switch(policy) {
    384385        case "never":
     
    14081409        public void initDontShowAgain(String preferencesKey) {
    14091410            String policy = Main.pref.get(preferencesKey, "ask");
    1410             policy = policy.trim().toLowerCase();
     1411            policy = policy.trim().toLowerCase(Locale.ENGLISH);
    14111412            cbDontShowAgain.setSelected(!"ask".equals(policy));
    14121413        }
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r8395 r8404  
    1919import java.util.LinkedList;
    2020import java.util.List;
     21import java.util.Locale;
    2122import java.util.Map;
    2223import java.util.TreeMap;
     
    458459        if (filter == null) return true;
    459460        if (value == null) return false;
    460         return value.toLowerCase().contains(filter.toLowerCase());
     461        return value.toLowerCase(Locale.ENGLISH).contains(filter.toLowerCase(Locale.ENGLISH));
    461462    }
    462463
  • trunk/src/org/openstreetmap/josm/tools/ColorHelper.java

    r8345 r8404  
    33
    44import java.awt.Color;
     5import java.util.Locale;
    56
    67/**
     
    4041    private static String int2hex(int i) {
    4142        String s = Integer.toHexString(i / 16) + Integer.toHexString(i % 16);
    42         return s.toUpperCase();
     43        return s.toUpperCase(Locale.ENGLISH);
    4344    }
    4445
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r8395 r8404  
    693693            }
    694694
    695             ImageType type = name.toLowerCase().endsWith(".svg") ? ImageType.SVG : ImageType.OTHER;
     695            ImageType type = Utils.hasExtension(name, "svg") ? ImageType.SVG : ImageType.OTHER;
    696696
    697697            if (name.startsWith(HTTP_PROTOCOL) || name.startsWith(HTTPS_PROTOCOL)) {
  • trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java

    r8284 r8404  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.trc;
    53
    64import java.util.Collection;
     
    5553            return null;
    5654        } else if(code.matches(".+@.+")) {
    57           return code.substring(0,1).toUpperCase() + code.substring(1,2)
    58           + "-" + code.substring(3,4).toUpperCase() + code.substring(4) + ":";
    59         }
    60         return code.substring(0,1).toUpperCase() + code.substring(1) + ":";
     55          return code.substring(0,1).toUpperCase(Locale.ENGLISH) + code.substring(1,2)
     56          + "-" + code.substring(3,4).toUpperCase(Locale.ENGLISH) + code.substring(4) + ":";
     57        }
     58        return code.substring(0,1).toUpperCase(Locale.ENGLISH) + code.substring(1) + ":";
    6159    }
    6260
     
    8886     * to identify the locale of a localized resource, but in some cases it may use the
    8987     * programmatic name for locales, as replied by {@link Locale#toString()}.
    90      * 
     88     *
    9189     * For unknown country codes and variants this function already does fallback to
    9290     * internally known translations.
     
    191189        return want.equals(newLanguage) || (!want.equals(oldLanguage) && newLanguage.startsWith("en"));
    192190    }
    193    
     191
    194192    /**
    195193     * Replies the language prefix for use in XML elements (with a dot appended).
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r8390 r8404  
    3232import java.util.Collection;
    3333import java.util.List;
     34import java.util.Locale;
    3435import java.util.Properties;
    3536
     
    501502                for (FontEntry entry: extrasPref) {
    502503                    Collection<String> fontsAvail = getInstalledFonts();
    503                     if (fontsAvail != null && fontsAvail.contains(entry.file.toUpperCase())) {
     504                    if (fontsAvail != null && fontsAvail.contains(entry.file.toUpperCase(Locale.ENGLISH))) {
    504505                        if (!allCharSubsets.contains(entry.charset)) {
    505506                            allCharSubsets.add(entry.charset);
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r8379 r8404  
    5050import java.util.Enumeration;
    5151import java.util.List;
     52import java.util.Locale;
    5253
    5354import javax.swing.JOptionPane;
     
    320321                Path filename = p.getFileName();
    321322                if (filename != null) {
    322                     fontsAvail.add(filename.toString().toUpperCase());
     323                    fontsAvail.add(filename.toString().toUpperCase(Locale.ENGLISH));
    323324                }
    324325            }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8390 r8404  
    4242import java.util.Iterator;
    4343import java.util.List;
     44import java.util.Locale;
    4445import java.util.concurrent.ExecutorService;
    4546import java.util.concurrent.Executors;
     
    12061207        if (value != null) {
    12071208            String old = System.setProperty(key, value);
    1208             if (!key.toLowerCase().contains("password")) {
     1209            if (!key.toLowerCase(Locale.ENGLISH).contains("password")) {
    12091210                Main.debug("System property '"+key+"' set to '"+value+"'. Old value was '"+old+"'");
    12101211            } else {
     
    12511252        }
    12521253    }
     1254
     1255    /**
     1256     * Determines if the filename has one of the given extensions, in a robust manner.
     1257     * The comparison is case and locale insensitive.
     1258     * @param filename The file name
     1259     * @param extensions The list of extensions to look for (without dot)
     1260     * @return {@code true} if the filename has one of the given extensions
     1261     * @since 8404
     1262     */
     1263    public static boolean hasExtension(String filename, String ... extensions) {
     1264        String name = filename.toLowerCase(Locale.ENGLISH);
     1265        for (String ext : extensions)
     1266            if (name.endsWith("."+ext.toLowerCase(Locale.ENGLISH)))
     1267                return true;
     1268        return false;
     1269    }
     1270
     1271    /**
     1272     * Determines if the file's name has one of the given extensions, in a robust manner.
     1273     * The comparison is case and locale insensitive.
     1274     * @param file The file
     1275     * @param extensions The list of extensions to look for (without dot)
     1276     * @return {@code true} if the file's name has one of the given extensions
     1277     * @since 8404
     1278     */
     1279    public static boolean hasExtension(File file, String ... extensions) {
     1280        return hasExtension(file.getName(), extensions);
     1281    }
    12531282}
  • trunk/src/org/openstreetmap/josm/tools/template_engine/Variable.java

    r8390 r8404  
    33
    44import java.util.Collection;
     5import java.util.Locale;
    56
    67public class Variable implements TemplateEntry {
     
    1415
    1516    public Variable(String variableName) {
    16         if (variableName.toLowerCase().startsWith(SPECIAL_VARIABLE_PREFIX)) {
     17        if (variableName.toLowerCase(Locale.ENGLISH).startsWith(SPECIAL_VARIABLE_PREFIX)) {
    1718            this.variableName = variableName.substring(SPECIAL_VARIABLE_PREFIX.length());
    1819            // special:special:key means that real key named special:key is needed, not special variable
    19             this.special = !this.variableName.toLowerCase().startsWith(SPECIAL_VARIABLE_PREFIX);
     20            this.special = !this.variableName.toLowerCase(Locale.ENGLISH).startsWith(SPECIAL_VARIABLE_PREFIX);
    2021        } else {
    2122            this.variableName = variableName;
Note: See TracChangeset for help on using the changeset viewer.