Ignore:
Timestamp:
2014-04-19T00:36:43+02:00 (10 years ago)
Author:
Don-vip
Message:

sonar - place Strings literals on the left side when checking for equality (can avoid NPEs)

File:
1 edited

Legend:

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

    r6986 r6990  
    13651365            int event = parser.next();
    13661366            if (event == XMLStreamConstants.START_ELEMENT) {
    1367                 if (parser.getLocalName().equals("tag")) {
     1367                String localName = parser.getLocalName();
     1368                if ("tag".equals(localName)) {
    13681369                    settingsMap.put(parser.getAttributeValue(null, "key"), new StringSetting(parser.getAttributeValue(null, "value")));
    13691370                    jumpToEnd();
    1370                 } else if (parser.getLocalName().equals("list") ||
    1371                         parser.getLocalName().equals("collection") ||
    1372                         parser.getLocalName().equals("lists") ||
    1373                         parser.getLocalName().equals("maps")
     1371                } else if ("list".equals(localName) ||
     1372                        "collection".equals(localName) ||
     1373                        "lists".equals(localName) ||
     1374                        "maps".equals(localName)
    13741375                ) {
    13751376                    parseToplevelList();
    13761377                } else {
    1377                     throwException("Unexpected element: "+parser.getLocalName());
     1378                    throwException("Unexpected element: "+localName);
    13781379                }
    13791380            } else if (event == XMLStreamConstants.END_ELEMENT) {
     
    14041405            int event = parser.next();
    14051406            if (event == XMLStreamConstants.START_ELEMENT) {
    1406                 if (parser.getLocalName().equals("entry")) {
     1407                String localName = parser.getLocalName();
     1408                if ("entry".equals(localName)) {
    14071409                    if (entries == null) {
    14081410                        entries = new ArrayList<String>();
     
    14101412                    entries.add(parser.getAttributeValue(null, "value"));
    14111413                    jumpToEnd();
    1412                 } else if (parser.getLocalName().equals("list")) {
     1414                } else if ("list".equals(localName)) {
    14131415                    if (lists == null) {
    14141416                        lists = new ArrayList<List<String>>();
    14151417                    }
    14161418                    lists.add(parseInnerList());
    1417                 } else if (parser.getLocalName().equals("map")) {
     1419                } else if ("map".equals(localName)) {
    14181420                    if (maps == null) {
    14191421                        maps = new ArrayList<Map<String, String>>();
     
    14211423                    maps.add(parseMap());
    14221424                } else {
    1423                     throwException("Unexpected element: "+parser.getLocalName());
     1425                    throwException("Unexpected element: "+localName);
    14241426                }
    14251427            } else if (event == XMLStreamConstants.END_ELEMENT) {
     
    14341436            settingsMap.put(key, new MapListSetting(Collections.unmodifiableList(maps)));
    14351437        } else {
    1436             if (name.equals("lists")) {
     1438            if ("lists".equals(name)) {
    14371439                settingsMap.put(key, new ListListSetting(Collections.<List<String>>emptyList()));
    1438             } else if (name.equals("maps")) {
     1440            } else if ("maps".equals(name)) {
    14391441                settingsMap.put(key, new MapListSetting(Collections.<Map<String, String>>emptyList()));
    14401442            } else {
     
    14491451            int event = parser.next();
    14501452            if (event == XMLStreamConstants.START_ELEMENT) {
    1451                 if (parser.getLocalName().equals("entry")) {
     1453                if ("entry".equals(parser.getLocalName())) {
    14521454                    entries.add(parser.getAttributeValue(null, "value"));
    14531455                    jumpToEnd();
     
    14671469            int event = parser.next();
    14681470            if (event == XMLStreamConstants.START_ELEMENT) {
    1469                 if (parser.getLocalName().equals("tag")) {
     1471                if ("tag".equals(parser.getLocalName())) {
    14701472                    map.put(parser.getAttributeValue(null, "key"), parser.getAttributeValue(null, "value"));
    14711473                    jumpToEnd();
     
    15001502        @Override
    15011503        public void visit(StringSetting setting) {
    1502             if (noPassword && key.equals("osm-server.password"))
     1504            if (noPassword && "osm-server.password".equals(key))
    15031505                return; // do not store plain password.
    15041506            /* don't save default values */
Note: See TracChangeset for help on using the changeset viewer.