TagSet: fix C-style string comparisons #185, fixes #190

This commit is contained in:
Andrey Novikov 2016-09-28 14:57:32 +03:00 committed by Emux
parent 98924b83af
commit 52bb54c006

View File

@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 Andrey Novikov
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -83,7 +84,7 @@ public class TagSet {
*/
public Tag get(String key) {
for (int i = 0; i < numTags; i++) {
if (tags[i].key == key)
if (tags[i].key.equals(key))
return tags[i];
}
return null;
@ -97,7 +98,7 @@ public class TagSet {
*/
public boolean containsKey(String key) {
for (int i = 0; i < numTags; i++) {
if (tags[i].key == key)
if (tags[i].key.equals(key))
return true;
}
return false;
@ -111,7 +112,7 @@ public class TagSet {
*/
public String getValue(String key) {
for (int i = 0; i < numTags; i++) {
if (tags[i].key == key)
if (tags[i].key.equals(key))
return tags[i].value;
}
return null;
@ -154,7 +155,7 @@ public class TagSet {
public boolean contains(Tag tag) {
for (int i = 0; i < numTags; i++) {
Tag t = tags[i];
if ((t == tag) || (t.key == tag.key && t.value == tag.value))
if ((t == tag) || (t.key.equals(tag.key) && t.value.equals(tag.value)))
return true;
}
return false;
@ -169,7 +170,7 @@ public class TagSet {
*/
public boolean contains(String key, String value) {
for (int i = 0; i < numTags; i++) {
if (tags[i].key == key)
if (tags[i].key.equals(key))
return value.equals(tags[i].value);
}
return false;