luetzkendorf 2005/01/19 07:15:48 Modified: src/webdav/server/org/apache/slide/webdav/util PropertyHelper.java Log: new helper method replaceElementAtProperty Revision Changes Path 1.91 +23 -0 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java Index: PropertyHelper.java =================================================================== RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- PropertyHelper.java 10 Jan 2005 18:11:32 -0000 1.90 +++ PropertyHelper.java 19 Jan 2005 15:15:47 -0000 1.91 @@ -616,6 +616,29 @@ return found; } + public static boolean replaceElementAtProperty( + NodeRevisionDescriptor revisionDescriptor, + PropertyName propertyName, String elementName, + String oldElementValue, String newElementValue) throws JDOMException { + + NodeProperty property = revisionDescriptor.getProperty(propertyName); + + XMLValue xmlValue = new XMLValue((String)property.getValue()); + Iterator iterator = xmlValue.iterator(); + + boolean anythingReplaced = false; + + while (iterator.hasNext()) { + Element element = (Element)iterator.next(); + if (element.getName().equals(elementName) && element.getText().equals(oldElementValue)) { + anythingReplaced = true; + element.setText(newElementValue); + } + } + revisionDescriptor.setProperty(propertyName, xmlValue.toString()); + return !anythingReplaced; + } + /** * Any leading <code>/</code> in the given <code>uri</code> will be removed. *
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]