dirkv 01/08/08 14:46:41
Modified: src/webdav/client/src/org/apache/webdav/lib/methods
PropFindMethod.java
Log:
- use an array instead of enumeration to store properties
- first step in PropertyName support
Revision Changes Path
1.28 +57 -30
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- PropFindMethod.java 2001/08/01 01:15:07 1.27
+++ PropFindMethod.java 2001/08/08 21:46:41 1.28
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
1.27 2001/08/01 01:15:07 msmith Exp $
- * $Revision: 1.27 $
- * $Date: 2001/08/01 01:15:07 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
1.28 2001/08/08 21:46:41 dirkv Exp $
+ * $Revision: 1.28 $
+ * $Date: 2001/08/08 21:46:41 $
*
* ====================================================================
*
@@ -76,6 +76,7 @@
import org.apache.commons.httpclient.State;
import org.apache.webdav.lib.Property;
+import org.apache.webdav.lib.PropertyName;
import org.apache.webdav.lib.properties.GetLastModifiedProperty;
import org.apache.webdav.lib.properties.ResourceTypeProperty;
@@ -110,6 +111,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @author <a href="mailto:[EMAIL PROTECTED]">B.C. Holmes</a>
+ * @author Dirk Verbeeck
*/
public class PropFindMethod extends XMLResponseMethodBase
implements DepthSupport {
@@ -209,9 +211,8 @@
/**
* Property name list.
*/
- protected Enumeration propertyNames;
+ protected PropertyName[] propertyNames;
-
/**
* Depth.
*/
@@ -299,12 +300,55 @@
/**
* Property names setter.
+ * The enumeration may contain strings with or without a namespace prefix
+ * but the preferred way is to provide PropertyName objects.
*
* @param propertyNames List of the property names
*/
public void setPropertyNames(Enumeration propertyNames) {
checkNotUsed();
- this.propertyNames = propertyNames;
+
+ Vector list = new Vector();
+ while (propertyNames.hasMoreElements()) {
+
+ Object item = propertyNames.nextElement();
+
+ if (item instanceof PropertyName)
+ {
+ list.add(item);
+ }
+ else if (item instanceof String)
+ {
+ String propertyName = (String) item;
+
+ int length = propertyName.length();
+ boolean found = false;
+ int i = 1;
+ while (!found && (i <= length)) {
+ char chr = propertyName.charAt(length - i);
+ if (!Character.isUnicodeIdentifierPart(chr)
+ && chr!='-' && chr!='_' && chr!='.') {
+ found = true;
+ } else {
+ i++;
+ }
+ }
+ if ((i == 1) || (i >= length)) {
+ list.add(new PropertyName("DAV:",propertyName));
+ } else {
+ String namespace = propertyName.substring(0, length + 1 - i);
+ String localName = propertyName.substring(length + 1 - i);
+ list.add(new PropertyName(namespace,localName));
+ }
+ }
+ else
+ {
+ // unknown type
+ // ignore
+ }
+ }
+
+ this.propertyNames = (PropertyName[])list.toArray(new
PropertyName[list.size()]);
}
@@ -367,32 +411,15 @@
break;
case BY_NAME:
printer.writeElement("D", "prop", XMLPrinter.OPENING);
- while (propertyNames.hasMoreElements()) {
-
- String propertyName = (String) propertyNames.nextElement();
-
- int length = propertyName.length();
- boolean found = false;
- int i = 1;
- while (!found && (i <= length)) {
- char chr = propertyName.charAt(length - i);
- if (!Character.isUnicodeIdentifierPart(chr) && chr != '-') {
- found = true;
- } else {
- i++;
- }
- }
-
- if ((i == 1) || (i >= length)) {
- printer.writeElement("D", propertyName,
- XMLPrinter.NO_CONTENT);
+ for (int i=0 ; i<propertyNames.length ; i++)
+ {
+ String namespace = propertyNames[i].getNamespaceURI();
+ String localname = propertyNames[i].getLocalName();
+ if ("DAV:".equals(namespace)) {
+ printer.writeElement("D", localname, XMLPrinter.NO_CONTENT);
} else {
- String prefix = propertyName.substring(0, length + 1 - i);
- String local = propertyName.substring(length + 1 - i);
- printer.writeElement("ZZ", prefix, local,
- XMLPrinter.NO_CONTENT);
+ printer.writeElement("ZZ", namespace,localname ,
XMLPrinter.NO_CONTENT);
}
-
}
printer.writeElement("D", "prop", XMLPrinter.CLOSING);
break;