You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-cvs@xml.apache.org by mr...@apache.org on 2008/06/22 06:21:07 UTC
svn commit: r670312 - in
/xml/commons/trunk/java/external/src/javax/xml/datatype: Duration.java
XMLGregorianCalendar.java
Author: mrglavas
Date: Sat Jun 21 21:21:06 2008
New Revision: 670312
URL: http://svn.apache.org/viewvc?rev=670312&view=rev
Log:
As of JAXP 1.4 XMLGregorianCalendar.equals() and Duration.equals() must return
false when passed null as parameter instead of throwing a NullPointerException.
Modified:
xml/commons/trunk/java/external/src/javax/xml/datatype/Duration.java
xml/commons/trunk/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java
Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/Duration.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/Duration.java?rev=670312&r1=670311&r2=670312&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/datatype/Duration.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/datatype/Duration.java Sat Jun 21 21:21:06 2008
@@ -827,26 +827,21 @@
* <code>true</code> if this duration is the same length as
* <code>duration</code>.
* <code>false</code> if <code>duration</code> is not a
- * <code>Duration</code> object
+ * <code>Duration</code> object, is <code>null</code>,
* or its length is different from this duration.
*
* @throws UnsupportedOperationException If the underlying implementation
* cannot reasonably process the request, e.g. W3C XML Schema allows for
* arbitrarily large/small/precise values, the request may be beyond the
* implementations capability.
- * @throws NullPointerException if parameter is null.
*
* @see #compare(Duration duration)
*/
public boolean equals(final Object duration) {
- if (duration == null) {
- throw new NullPointerException();
- }
-
+ // "instanceof" will return false if duration is null
if (!(duration instanceof Duration)) {
return false;
}
-
return compare((Duration) duration) == DatatypeConstants.EQUAL;
}
Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java?rev=670312&r1=670311&r2=670312&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/datatype/XMLGregorianCalendar.java Sat Jun 21 21:21:06 2008
@@ -658,21 +658,13 @@
*
* @return <code>true</code> when <code>obj</code> is an instance of <code>XMLGregorianCalendar</code>
* and {@link #compare(XMLGregorianCalendar obj)} returns {@link DatatypeConstants#EQUAL}, otherwise <code>false</code>.
- *
- * @throws NullPointerException If <code>obj</code> is <code>null</code>.
*/
public boolean equals(Object obj) {
-
- if (obj == null) {
- throw new NullPointerException("Cannot test null for equality with this XMLGregorianCalendar");
- }
-
- boolean result = false;
-
- if (obj instanceof XMLGregorianCalendar) {
- result = compare((XMLGregorianCalendar) obj) == DatatypeConstants.EQUAL;
- }
- return result;
+ // "instanceof" will return false if obj is null
+ if (!(obj instanceof XMLGregorianCalendar)) {
+ return false;
+ }
+ return compare((XMLGregorianCalendar) obj) == DatatypeConstants.EQUAL;
}
/**