Ignore:
Timestamp:
2014-04-27T15:35:47+02:00 (10 years ago)
Author:
Don-vip
Message:

see #8465 - use String switch/case where applicable

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
9 edited

Legend:

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

    r7005 r7012  
    834834            for (RelationMember m : multiPolygon.getMembers()) {
    835835                if (m.getType().equals(OsmPrimitiveType.WAY)) {
    836                     if (m.getRole().equals("outer")) {
     836                    if ("outer".equals(m.getRole())) {
    837837                        outers.add(m.getWay());
    838                     } else if (m.getRole().equals("inner")) {
     838                    } else if ("inner".equals(m.getRole())) {
    839839                        inners.add(m.getWay());
    840840                    }
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r7005 r7012  
    394394    }
    395395
    396     public static void addTexts(File source)
    397     {
    398         if(loadedCode.equals("en"))
     396    public static void addTexts(File source) {
     397        if ("en".equals(loadedCode))
    399398            return;
    400399        FileInputStream fis = null;
     
    440439    }
    441440
    442     private static boolean load(String l)
    443     {
    444         if(l.equals("en") || l.equals("en_US"))
    445         {
     441    private static boolean load(String l) {
     442        if ("en".equals(l) || "en_US".equals(l)) {
    446443            strings = null;
    447444            pstrings = null;
     
    451448        }
    452449        URL en = getTranslationFile("en");
    453         if(en == null)
     450        if (en == null)
    454451            return false;
    455452        URL tr = getTranslationFile(l);
    456         if(tr == null || !languages.containsKey(l))
    457         {
     453        if (tr == null || !languages.containsKey(l)) {
    458454            int i = l.indexOf('_');
    459455            if (i > 0) {
     
    461457            }
    462458            tr = getTranslationFile(l);
    463             if(tr == null || !languages.containsKey(l))
     459            if (tr == null || !languages.containsKey(l))
    464460                return false;
    465461        }
     
    643639                Locale.setDefault(l);
    644640            } else {
    645                 if (!l.getLanguage().equals("en")) {
     641                if (!"en".equals(l.getLanguage())) {
    646642                    Main.info(tr("Unable to find translation for the locale {0}. Reverting to {1}.",
    647643                            l.getDisplayName(), Locale.getDefault().getDisplayName()));
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7005 r7012  
    606606        try {
    607607            zipFile = new ZipFile(archive);
    608             if (inArchiveDir == null || inArchiveDir.equals(".")) {
     608            if (inArchiveDir == null || ".".equals(inArchiveDir)) {
    609609                inArchiveDir = "";
    610610            } else if (!inArchiveDir.isEmpty()) {
     
    805805        }
    806806        Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
    807                 name.equals("crosshair") ? new Point(10, 10) : new Point(3, 2), "Cursor");
     807                "crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2), "Cursor");
    808808        return c;
    809809    }
  • trunk/src/org/openstreetmap/josm/tools/LanguageInfo.java

    r6889 r7012  
    8787        if (locale == null) return "en";
    8888        String full = locale.toString();
    89         if (full.equals("iw_IL"))
     89        if ("iw_IL".equals(full))
    9090            return "he";
    91         else if (full.equals("in"))
     91        else if ("in".equals(full))
    9292            return "id";
    9393        else if (I18n.hasCode(full)) // catch all non-single codes
     
    107107     */
    108108    public static Locale getLocale(String localeName) {
    109         if (localeName.equals("he")) {
     109        if ("he".equals(localeName)) {
    110110            localeName = "iw_IL";
    111111        }
    112         else if (localeName.equals("id")) {
     112        else if ("id".equals(localeName)) {
    113113            localeName = "in";
    114114        }
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    r7001 r7012  
    5353    public Object invoke (Object proxy, Method method, Object[] args) throws Throwable {
    5454        Boolean handled = Boolean.TRUE;
    55         if (method.getName().equals("handleQuit")) {
     55        switch (method.getName()) {
     56        case "handleQuit":
    5657            handled = Main.exitJosm(false, 0);
    57         } else if (method.getName().equals("handleAbout")) {
     58            break;
     59        case "handleAbout":
    5860            Main.main.menu.about.actionPerformed(null);
    59         } else if (method.getName().equals("handlePreferences")) {
     61            break;
     62        case "handlePreferences":
    6063            Main.main.menu.preferences.actionPerformed(null);
    61         } else
     64            break;
     65        default:
    6266            return null;
     67        }
    6368        if (args[0] != null) {
    6469            try {
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r7006 r7012  
    165165    public String getJavaPackageDetails() {
    166166        if (isDebianOrUbuntu()) {
    167             String javaHome = System.getProperty("java.home");
    168             if ("/usr/lib/jvm/java-7-openjdk-amd64/jre".equals(javaHome) ||
    169                     "/usr/lib/jvm/java-7-openjdk-i386/jre".equals(javaHome)) {
     167            switch(System.getProperty("java.home")) {
     168            case "/usr/lib/jvm/java-7-openjdk-amd64/jre":
     169            case "/usr/lib/jvm/java-7-openjdk-i386/jre":
    170170                return getPackageDetails("openjdk-7-jre");
    171171            }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r7005 r7012  
    9595
    9696    public boolean isChangeable() {
    97         return !automatic && !shortText.equals("core:none");
     97        return !automatic && !"core:none".equals(shortText);
    9898    }
    9999
     
    255255        for(Shortcut c : shortcuts.values())
    256256        {
    257             if(!c.shortText.equals("core:none")) {
     257            if(!"core:none".equals(c.shortText)) {
    258258                l.add(c);
    259259            }
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r6890 r7012  
    189189                    x = Integer.valueOf(m.group(5));
    190190                    y = Integer.valueOf(m.group(7));
    191                     if (m.group(4).equals("-")) {
     191                    if ("-".equals(m.group(4))) {
    192192                        x = screenDimension.x + screenDimension.width - x - w;
    193193                    }
    194                     if (m.group(6).equals("-")) {
     194                    if ("-".equals(m.group(6))) {
    195195                        y = screenDimension.y + screenDimension.height - y - h;
    196196                    }
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r7005 r7012  
    133133        private void setValue(Entry entry, String fieldName, String value) throws SAXException {
    134134            CheckParameterUtil.ensureParameterNotNull(entry, "entry");
    135             if (fieldName.equals("class") || fieldName.equals("default") || fieldName.equals("throw") || fieldName.equals("new") || fieldName.equals("null")) {
     135            if ("class".equals(fieldName) || "default".equals(fieldName) || "throw".equals(fieldName) || "new".equals(fieldName) || "null".equals(fieldName)) {
    136136                fieldName += "_";
    137137            }
     
    165165        private boolean parseBoolean(String s) {
    166166            return s != null
    167                     && !s.equals("0")
     167                    && !"0".equals(s)
    168168                    && !s.startsWith("off")
    169169                    && !s.startsWith("false")
Note: See TracChangeset for help on using the changeset viewer.