1 23 package org.apache.webdav.lib; 24 25 import java.util.Enumeration ; 26 import java.util.Hashtable ; 27 28 35 36 public class WebdavResources { 37 38 40 43 public WebdavResources() { 44 } 45 46 47 52 public WebdavResources(WebdavResource resource) { 53 addResource(resource); 54 } 55 56 57 59 60 63 Hashtable hrefTable = new Hashtable (); 64 65 66 68 69 74 public boolean isEmpty() { 75 return hrefTable.isEmpty(); 76 } 77 78 79 84 public boolean isThereResourceName(String resourceName) { 85 return hrefTable.containsKey(resourceName); 86 } 87 88 89 95 public boolean isThereResource(WebdavResource resource) { 96 return hrefTable.contains(resource); 97 } 98 99 100 105 public Enumeration getResourceNames() { 106 return hrefTable.keys(); 107 } 108 109 110 115 public Enumeration getResources() { 116 return hrefTable.elements(); 117 } 118 119 120 125 public String [] list() { 126 127 synchronized (hrefTable) { 128 int num = hrefTable.size(); 129 String resourceNames[] = new String [num]; 130 131 Enumeration resources = getResourceNames(); 132 int i = 0; 133 while (resources.hasMoreElements()) { 134 resourceNames[i++] = (String ) resources.nextElement(); 135 } 136 137 return resourceNames; 138 } 139 } 140 141 142 147 public WebdavResource[] listResources() { 148 149 synchronized (hrefTable) { 150 int num = hrefTable.size(); 151 WebdavResource WebdavResources[] = new WebdavResource[num]; 152 153 Enumeration resources = getResources(); 154 int i = 0; 155 while (resources.hasMoreElements()) { 156 WebdavResources[i++] = 157 (WebdavResource) resources.nextElement(); 158 } 159 160 return WebdavResources; 161 } 162 } 163 164 165 171 public WebdavResource getResource(String resourceName) { 172 return (WebdavResource) hrefTable.get(resourceName); 173 } 174 175 176 185 public void addResource(String resourceName, WebdavResource resource) { 186 hrefTable.put(resourceName, resource); 187 } 188 189 190 195 public void addResource(WebdavResource resource) { 196 hrefTable.put(resource.getName(), resource); 197 } 198 199 200 206 public WebdavResource removeResource(String resourceName) { 207 return (WebdavResource) hrefTable.remove(resourceName); 208 } 209 210 211 214 public void removeAll() { 215 hrefTable.clear(); 216 } 217 218 219 222 public String toString() { 223 return hrefTable.toString(); 224 } 225 226 } 227 228 229 230 231 232 233 | Popular Tags |