1 23 24 package org.apache.webdav.lib.properties; 25 26 import org.apache.webdav.lib.BaseProperty; 27 import org.apache.webdav.lib.ResponseEntity; 28 import org.apache.webdav.lib.util.DOMUtils; 29 import org.w3c.dom.Element ; 30 import org.w3c.dom.NodeList ; 31 32 37 public class ResourceTypeProperty extends BaseProperty { 38 39 private boolean initialized = false; 40 private boolean isCollection = false; 41 private boolean isPrincipal = false; 42 43 45 46 49 public static final String TAG_NAME = "resourcetype"; 50 51 54 public static final String TAG_COLLECTION = "collection"; 55 public static final String TAG_PRINCIPAL = "principal"; 56 57 58 60 61 64 public ResourceTypeProperty(ResponseEntity response, Element element) { 65 super(response, element); 66 } 67 68 69 71 72 80 public boolean isCollection() { 81 init(); 82 return isCollection; 83 } 84 85 public boolean isPrincipal() { 86 init(); 87 return isPrincipal; 88 } 89 90 private void init() 91 { 92 93 if (initialized) 94 return; 95 96 initialized=true; 97 98 NodeList tmp = element.getChildNodes(); 99 for (int i = 0; tmp != null && i < tmp.getLength(); i++ ) { 100 try { 101 Element child = (Element ) tmp.item(i); 102 if (TAG_COLLECTION.equals(DOMUtils.getElementLocalName(child)) 103 && "DAV:".equals(DOMUtils.getElementNamespaceURI(child))) 104 { 105 isCollection=true; 106 } 107 if (TAG_PRINCIPAL.equals(DOMUtils.getElementLocalName(child)) 108 && "DAV:".equals(DOMUtils.getElementNamespaceURI(child))) 109 { 110 isPrincipal=true; 111 } 112 } catch (ClassCastException e) { 113 } 114 } 115 } 116 117 125 public String getPropertyAsString() { 126 init(); 127 return isCollection?"COLLECTION":""; 128 } 129 } 130 | Popular Tags |