public IteratorImpl createIteratorImpl(boolean remove_scanner, IteratorImpl ret) throws ParserException {
Node node;
MetaTag meta;
String httpEquiv;
String charset;
EndTag end;
if (null != url_conn)
try {
if (null == scanners.get("-m")) {
addScanner(new MetaTagScanner("-m"));
remove_scanner = true;
}
/* pre-read up to </HEAD> looking for charset directive */
while (null != (node = ret.peek())) {
if (node instanceof MetaTag) { // check for charset on
// Content-Type
meta = (MetaTag) node;
httpEquiv = meta.getAttribute("HTTP-EQUIV");
if ("Content-Type".equalsIgnoreCase(httpEquiv)) {
charset = getCharset(meta.getAttribute("CONTENT"));
if (!charset.equalsIgnoreCase(character_set)) { // oops,
// different
// character
// set,
// restart
character_set = charset;
recreateReader();
ret = new IteratorImpl(reader, resourceLocn, feedback);
}
// once we see the Content-Type meta tag we're
// finished the pre-read
break;
}
} else if (node instanceof EndTag) {
end = (EndTag) node;
if (end.getTagName().equalsIgnoreCase("HEAD"))
// or, once we see the </HEAD> tag we're finished
// the pre-read
break;
}
}