]> granicus.if.org Git - icu/commitdiff
ICU-9101 Fixed some coding issues reported by FindBugs in the new collation code.
authorYoshito Umaoka <y.umaoka@gmail.com>
Tue, 4 Mar 2014 16:22:17 +0000 (16:22 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Tue, 4 Mar 2014 16:22:17 +0000 (16:22 +0000)
X-SVN-Rev: 35322

icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationBuilder.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationIterator.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationSettings.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/FCDUTF16CollationIterator.java
icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/UTF16CollationIterator.java

index 07039353b5b28c3ef2f191045972563325af8213..54ea9fe1daae9efe6d9194bec9c47ae83b3c15f6 100644 (file)
@@ -839,7 +839,7 @@ public final class CollationBuilder extends CollationRuleParser.Sink {
             for(;;) {
                 String str = stringIter.next();
                 if(str == null) { break; }
-                if(ignoreString(str) || str == nfdString) { continue; }
+                if(ignoreString(str) || str.contentEquals(nfdString)) { continue; }
                 ce32 = addIfDifferent(prefix, str, newCEs, newCEsLength, ce32);
             }
         } else {
@@ -849,11 +849,11 @@ public final class CollationBuilder extends CollationRuleParser.Sink {
                 String prefix = prefixIter.next();
                 if(prefix == null) { break; }
                 if(ignorePrefix(prefix)) { continue; }
-                boolean samePrefix = prefix == nfdPrefix;
+                boolean samePrefix = prefix.contentEquals(nfdPrefix);
                 for(;;) {
                     String str = stringIter.next();
                     if(str == null) { break; }
-                    if(ignoreString(str) || (samePrefix && str == nfdString)) { continue; }
+                    if(ignoreString(str) || (samePrefix && str.contentEquals(nfdString))) { continue; }
                     ce32 = addIfDifferent(prefix, str, newCEs, newCEsLength, ce32);
                 }
                 stringIter.reset();
index 46dfd1710558ded62ae81221296f2f736989c775..7088e75933306636c6d0b42aa0e0abcf0d06f665 100644 (file)
@@ -201,6 +201,7 @@ public abstract class CollationIterator {
         // Assume that the caller compares the data.
         // Ignore skipped since that should be unused between calls to nextCE().
         // (It only stays around to avoid another memory allocation.)
+        if(other == null) { return false; }
         if(!this.getClass().equals(other.getClass())) { return false; }
         CollationIterator o = (CollationIterator)other;
         if(!(ceBuffer.length == o.ceBuffer.length &&
index cb5e5b745ab8d427ac5c0fb13b6c3af2f68878f7..498dcd4e4dbbbd5d5270d2a168a97c21f140cdb7 100644 (file)
@@ -101,6 +101,7 @@ public final class CollationSettings extends SharedObject {
 
     @Override
     public boolean equals(Object other) {
+        if(other == null) { return false; }
         if(!this.getClass().equals(other.getClass())) { return false; }
         CollationSettings o = (CollationSettings)other;
         if(options != o.options) { return false; }
index 7a9957d093d2d6b2e50a99db6bd4f1a888a37631..40b7d39ee4aa0d6c30b742666e319ec13892e88a 100644 (file)
@@ -50,6 +50,12 @@ public final class FCDUTF16CollationIterator extends UTF16CollationIterator {
         }
     }
 
+    @Override
+    public int hashCode() {
+        assert false : "hashCode not designed";
+        return 42; // any arbitrary constant will do
+    }
+
     @Override
     public void resetToOffset(int newOffset) {
         reset();
index db4062768a6cb955b680782a37b9fb216e34a87e..938b04981c310434f388d17a070c828772843d77 100644 (file)
@@ -40,6 +40,12 @@ public class UTF16CollationIterator extends CollationIterator {
         return (pos - start) == (o.pos - o.start);
     }
 
+    @Override
+    public int hashCode() {
+        assert false : "hashCode not designed";
+        return 42; // any arbitrary constant will do
+    }
+
     @Override
     public void resetToOffset(int newOffset) {
         reset();