1 23 24 package org.apache.webdav.lib.properties; 25 26 import java.util.Vector ; 27 import org.apache.webdav.lib.BaseProperty; 28 import org.apache.webdav.lib.ResponseEntity; 29 import org.apache.webdav.lib.util.DOMUtils; 30 import org.w3c.dom.Element ; 31 import org.w3c.dom.Node ; 32 import org.w3c.dom.NodeList ; 33 34 40 public class PrincipalCollectionSetProperty extends BaseProperty { 41 42 45 public static final String TAG_NAME = "principal-collection-set"; 46 47 49 52 public PrincipalCollectionSetProperty(ResponseEntity response, Element element) { 53 super(response, element); 54 } 55 56 57 59 private String [] hrefs=null; 60 61 private void init() 62 { 63 if (this.hrefs!=null) 65 return; 66 67 Vector hrefVector = new Vector (); 68 NodeList hrefNodes = DOMUtils.getElementsByTagNameNS(element, "href", "DAV:"); 69 if (hrefNodes!=null) 70 { 71 for (int i = 0; i < hrefNodes.getLength(); i++) 72 { 73 Node hrefNode = hrefNodes.item(i); 74 String href = DOMUtils.getTextValue(hrefNode); 75 if ((href!=null) && (href.length()>0)) 76 hrefVector.add(href); 77 } 78 } 79 80 this.hrefs=(String []) hrefVector.toArray(new String [hrefVector.size()]); 81 } 82 83 88 public String [] getHrefs() 89 { 90 init(); 91 return this.hrefs; 92 } 93 94 public String getPropertyAsString() { 95 String [] hrefs = getHrefs(); 96 97 if ((hrefs==null) || (hrefs.length==0)) 98 return ""; 99 100 StringBuffer tmp = new StringBuffer (hrefs[0]); 101 for (int i=1; i<hrefs.length ; i++) { 102 tmp.append(", "); 103 tmp.append(hrefs[i]); 104 } 105 106 return tmp.toString(); 107 } 108 109 } 110 | Popular Tags |