* Command line program to wander the vpfservlet pages, to make sure
* all URLs generated are valid.
*/
public class URLCheck {
public static Set check(String surl, PrintStream out) throws IOException {
Set urls = new TreeSet();
out.println("URL " + surl);
Reader r;
URL url;
try {
url = new URL(surl);
r = new InputStreamReader(url.openStream());
} catch (MalformedURLException mue) {
out.println(" bad URL");
return urls;
}
Set names = new HashSet();
Set localrefs = new HashSet();
StringBuffer sb = new StringBuffer();
char buf[] = new char[8096];
int len;
while ((len = r.read(buf)) != -1) {
sb.append(buf, 0, len);
String str = sb.toString();
int fromIx = 0;
int gt;
while ((gt = str.indexOf('>', fromIx)) != -1) {
int lt = str.indexOf('<', fromIx);
fromIx = gt + 1;
char firstChar = str.charAt(lt + 1);
if ((firstChar != 'A') && (firstChar != 'a')) {
continue;
}
String substr = str.substring(lt + 1, gt);
String lsubstr = substr.toLowerCase();
int hquote = lsubstr.indexOf(href);
if (hquote != -1) {
hquote += href.length();
int lquote = substr.indexOf('"', hquote);
String rurl = substr.substring(hquote, lquote);
if (rurl.charAt(0) == '#') {
names.add(rurl.substring(1));
} else {
try {
urls.add(new URL(url, rurl).toExternalForm());
} catch (MalformedURLException mue) {
out.println(" MUE: " + mue.getMessage());
}
}
} else {