Fix equals and enhance error checking

X-SVN-Rev: 917
This commit is contained in:
Alan Liu 2000-03-08 21:56:41 +00:00
parent 1c55f1f997
commit 80a86736aa
2 changed files with 14 additions and 4 deletions

View File

@ -229,7 +229,7 @@ import java.text.*;
* *Unsupported by Java (and hence unsupported by UnicodeSet). * *Unsupported by Java (and hence unsupported by UnicodeSet).
* *
* @author Alan Liu * @author Alan Liu
* @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.12 $ $Date: 2000/02/29 01:19:02 $ * @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.13 $ $Date: 2000/03/08 21:56:41 $
*/ */
public class UnicodeSet implements UnicodeFilter { public class UnicodeSet implements UnicodeFilter {
/** /**
@ -635,7 +635,7 @@ public class UnicodeSet implements UnicodeFilter {
*/ */
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof UnicodeSet && return o instanceof UnicodeSet &&
pairs.equals(((UnicodeSet)o).pairs); pairs.toString().equals(((UnicodeSet)o).pairs.toString());
} }
/** /**
@ -901,6 +901,11 @@ public class UnicodeSet implements UnicodeFilter {
} }
} }
if (mode == 0) {
throw new IllegalArgumentException("Missing '[' in \"" +
pattern.substring(start) + '"');
}
// Handle unprocessed stuff preceding the closing ']' // Handle unprocessed stuff preceding the closing ']'
if (lastOp == '-') { if (lastOp == '-') {
// Trailing '-' is treated as literal // Trailing '-' is treated as literal

View File

@ -229,7 +229,7 @@ import java.text.*;
* *Unsupported by Java (and hence unsupported by UnicodeSet). * *Unsupported by Java (and hence unsupported by UnicodeSet).
* *
* @author Alan Liu * @author Alan Liu
* @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.12 $ $Date: 2000/02/29 01:19:02 $ * @version $RCSfile: UnicodeSet.java,v $ $Revision: 1.13 $ $Date: 2000/03/08 21:56:41 $
*/ */
public class UnicodeSet implements UnicodeFilter { public class UnicodeSet implements UnicodeFilter {
/** /**
@ -635,7 +635,7 @@ public class UnicodeSet implements UnicodeFilter {
*/ */
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof UnicodeSet && return o instanceof UnicodeSet &&
pairs.equals(((UnicodeSet)o).pairs); pairs.toString().equals(((UnicodeSet)o).pairs.toString());
} }
/** /**
@ -901,6 +901,11 @@ public class UnicodeSet implements UnicodeFilter {
} }
} }
if (mode == 0) {
throw new IllegalArgumentException("Missing '[' in \"" +
pattern.substring(start) + '"');
}
// Handle unprocessed stuff preceding the closing ']' // Handle unprocessed stuff preceding the closing ']'
if (lastOp == '-') { if (lastOp == '-') {
// Trailing '-' is treated as literal // Trailing '-' is treated as literal