juergen 02/03/08 04:39:45
Modified: src/webdav/server/org/apache/slide/webdav/util XMLValue.java
Log:
Added method add(String).
Equality is now based on string representation equality.
(ralf)
Revision Changes Path
1.2 +29 -16
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLValue.java 8 Mar 2002 12:00:47 -0000 1.1
+++ XMLValue.java 8 Mar 2002 12:39:45 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java,v
1.1 2002/03/08 12:00:47 juergen Exp $
- * $Revision: 1.1 $
- * $Date: 2002/03/08 12:00:47 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/XMLValue.java,v
1.2 2002/03/08 12:39:45 juergen Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/03/08 12:39:45 $
*
* ====================================================================
*
@@ -84,7 +84,7 @@
* The {@link #toString toString()} method provides a XML document fragment
* describing the Elements of this XMLValue.
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ralf Stuckert</a>
**/
@@ -153,7 +153,6 @@
* <code>Element</code>.
*/
public XMLValue(List elementList) throws IllegalArgumentException{
-
this.elementList = new ArrayList();
add(elementList);
}
@@ -167,17 +166,7 @@
*/
public XMLValue(String xmlString) throws JDOMException,
IllegalArgumentException{
this((List)null);
- if (xmlString != null) {
- StringBuffer buffer = new StringBuffer(START_TAG.length() +
- xmlString.length() +
- END_TAG.length());
- buffer.append(START_TAG);
- buffer.append(xmlString);
- buffer.append(END_TAG);
- SAXBuilder builder = new SAXBuilder();
- Document document = builder.build(new StringReader(buffer.toString()));
- add(document.getRootElement().getChildren());
- }
+ add(xmlString);
}
@@ -221,6 +210,30 @@
}
/**
+ * Adds the Elements given by an XML string representation.
+ *
+ * @param xmlString a String representation of a list of XML Elements.
+ *
+ * @throws IllegalArgumentException if one of the list items
+ * is not a <code>Element</code>.
+ * @throws JDOMException if parsing the <code>xmlString</code> fails.
+ */
+ public void add(String xmlString) throws IllegalArgumentException,
JDOMException {
+
+ if (xmlString != null) {
+ StringBuffer buffer = new StringBuffer(START_TAG.length() +
+ xmlString.length() +
+ END_TAG.length());
+ buffer.append(START_TAG);
+ buffer.append(xmlString);
+ buffer.append(END_TAG);
+ SAXBuilder builder = new SAXBuilder();
+ Document document = builder.build(new StringReader(buffer.toString()));
+ add(document.getRootElement().getChildren());
+ }
+ }
+
+ /**
* Returns an iterator of JDOM Elements.
*
* @return an iterator of JDOM Elements.
@@ -249,18 +262,18 @@
/**
* Returns <code>true</code> if the other object is an XMLValue and
- * both their Element Lists are equal.
+ * both their String representations are equal.
*
* @param other the Object to test for equality.
*
* @return <code>true</code> if the other object is an XMLValue and
- * both their Element Lists are equal.
+ * both their String representations are equal.
*/
public boolean equals(Object other) {
if ( ! (other instanceof XMLValue) ) {
return false;
}
- return (this.elementList.equals(((XMLValue)other).elementList));
+ return (this.toString().equals(other.toString()));
}
/**
@@ -269,7 +282,7 @@
* @return the hash code of this instance.
*/
public int hashCode() {
- return elementList.hashCode();
+ return toString().hashCode();
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>