Added an equals(String) method to the XMLString interface. This allows the
caller to compare an XMLString to a Java String without forcing the XMLString
to be converted to a String.
Part of patch for XALANJ-1243. Reviewed by Brian Minchau (minchau@ca.ibm.com).
diff --git a/src/org/apache/xml/utils/XMLString.java b/src/org/apache/xml/utils/XMLString.java
index 122f80e..fa1bff4 100644
--- a/src/org/apache/xml/utils/XMLString.java
+++ b/src/org/apache/xml/utils/XMLString.java
@@ -125,7 +125,7 @@
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not
- * <code>null</code> and is a <code>String</code> object that represents
+ * <code>null</code> and is an <code>XMLString</code> object that represents
* the same sequence of characters as this object.
*
* @param anObject the object to compare this <code>String</code>
@@ -137,6 +137,20 @@
*/
public abstract boolean equals(XMLString anObject);
+ /**
+ * Compares this string to the specified <code>String</code>.
+ * The result is <code>true</code> if and only if the argument is not
+ * <code>null</code> and is a <code>String</code> object that represents
+ * the same sequence of characters as this object.
+ *
+ * @param anotherString the object to compare this <code>String</code>
+ * against.
+ * @return <code>true</code> if the <code>String</code>s are equal;
+ * <code>false</code> otherwise.
+ * @see java.lang.String#compareTo(java.lang.String)
+ * @see java.lang.String#equalsIgnoreCase(java.lang.String)
+ */
+ public abstract boolean equals(String anotherString);
/**
* Compares this string to the specified object.
diff --git a/src/org/apache/xml/utils/XMLStringDefault.java b/src/org/apache/xml/utils/XMLStringDefault.java
index 3aff888..ac37ffc 100644
--- a/src/org/apache/xml/utils/XMLStringDefault.java
+++ b/src/org/apache/xml/utils/XMLStringDefault.java
@@ -149,7 +149,23 @@
dst[destIndex++] = m_str.charAt(i);
}
}
-
+
+ /**
+ * Compares this string to the specified <code>String</code>.
+ * The result is <code>true</code> if and only if the argument is not
+ * <code>null</code> and is a <code>String</code> object that represents
+ * the same sequence of characters as this object.
+ *
+ * @param obj2 the object to compare this <code>String</code> against.
+ * @return <code>true</code> if the <code>String</code>s are equal;
+ * <code>false</code> otherwise.
+ * @see java.lang.String#compareTo(java.lang.String)
+ * @see java.lang.String#equalsIgnoreCase(java.lang.String)
+ */
+ public boolean equals(String obj2) {
+ return m_str.equals(obj2);
+ }
+
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not