1 18 19 package org.apache.jmeter.protocol.http.parser; 20 21 import java.net.MalformedURLException ; 22 import java.net.URL ; 23 import java.util.Collection ; 24 import java.util.Iterator ; 25 26 38 public class URLCollection 39 { 40 Collection coll; 41 42 private URLCollection(){} 44 45 49 public URLCollection(Collection c) 50 { 51 coll = c; 52 } 53 54 61 public boolean add(URL u) 62 { 63 return coll.add(new URLString(u)); 64 } 65 66 73 private boolean add(String s) 74 { 75 return coll.add(new URLString(s)); 76 } 77 78 86 public boolean addURL(String url, URL baseUrl) 87 { 88 if (url == null || url.length() == 0) return false; 89 boolean b=false; 90 try 91 { 92 b=this.add(new URL (baseUrl, url)); 93 } 94 catch(MalformedURLException mfue) 95 { 96 b=this.add(url); } 99 return b; 100 } 101 102 103 public Iterator iterator() 104 { 105 return new UrlIterator(coll.iterator()); 106 } 107 108 112 private static class UrlIterator implements Iterator 113 { 114 Iterator iter; 115 116 UrlIterator(Iterator i) 117 { 118 iter=i; 119 } 120 121 public boolean hasNext() 122 { 123 return iter.hasNext(); 124 } 125 126 129 public Object next() 130 { 131 return ((URLString) iter.next()).getURL(); 132 } 133 134 public void remove() 135 { 136 throw new UnsupportedOperationException (); 137 } 138 } 139 } 140 | Popular Tags |