wam 2003/08/14 07:41:45
Modified: src/webdav/server/org/apache/slide/webdav/util XMLValue.java
Log:
implement Comparable
Revision Changes Path
1.12 +39 -5
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java
Index: XMLValue.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XMLValue.java 13 May 2003 12:48:04 -0000 1.11
+++ XMLValue.java 14 Aug 2003 14:41:45 -0000 1.12
@@ -93,12 +93,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stuckert</a>
**/
-public class XMLValue implements Cloneable {
+public class XMLValue implements Cloneable, Comparable {
/**
* Constant for the message of the IllegalArgumentException that may be
* thrown in method [EMAIL PROTECTED] #add add()}.
*/
+
public static final String ELEMENT_MUST_NOT_BE_NULL = "'null' Element is not
allowed";
/**
@@ -548,5 +549,38 @@
}
+ /**
+ * concatenates the text() values of all Elements in elementList
+ *
+ * @return a String
+ *
+ */
+ String getTextValue() {
+ Iterator it = elementList.iterator();
+ StringBuffer sb = new StringBuffer();
+
+ while (it.hasNext()) {
+ Object o = it.next();
+ if (o instanceof Element) {
+ sb.append (((Element)o).getTextTrim());
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * compares the concatenated Text values of all Elements in elementList
+ *
+ * @param o an Object
+ *
+ * @return an int
+ *
+ */
+ public int compareTo (Object o) {
+
+ String s1 = getTextValue();
+ String s2 = ((XMLValue)o).getTextValue();
+ return s1.compareTo (s2);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]