ICU-9101 Fixed some coding issues reported by FindBugs in the new collation code.

X-SVN-Rev: 35322
This commit is contained in:
Yoshito Umaoka 2014-03-04 16:22:17 +00:00
parent 246f3a9162
commit aaf4a4d807
5 changed files with 17 additions and 3 deletions

View 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();

View 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 &&

View 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; }

View 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();

View 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();