});
Pattern ratingPattern = Pattern.compile(RATING_EXPR);
Pattern movieIdPattern = Pattern.compile(MOVIE_ID_EXPR);
NodeList discs = new NodeList();
queue.collectInto(discs, discFilter);
NodeList info = new NodeList();
SimpleNodeIterator iter = discs.elements();
while (iter.hasMoreNodes()) {
info.removeAll();
infoCollector.clear();
Node disc = iter.nextNode();
//collect all the nodes for the movie items
disc.collectInto(info, infoCollector);
int i=0;
//parse out all the information
LinkTag titleLink = (LinkTag)infoCollector.getNode(i++);
String movieId = null;
Matcher matcher = movieIdPattern.matcher(titleLink.getLink());
if (matcher.matches()) {
movieId = matcher.group(1);
} else {
//not a valid movie
continue;
}
String title = titleLink.getLinkText();
int rating = -1;
ImageTag ratingNode = (ImageTag)infoCollector.getNode(i++);
if (ratingNode != null) {
String ratingStr = ratingNode.getImageURL();
matcher = ratingPattern.matcher(ratingStr);
if (matcher.matches()) {
rating = Integer.parseInt(matcher.group(1));
}
}
String mpaa = NodeUtils.getTextData(infoCollector.getNode(i++));
NodeList list = infoCollector.getNodeList(i++);
String category = NodeUtils.getTextData(list.elementAt(0));
String availability = NodeUtils.getTextData(list.elementAt(1));
//create a movie item
MovieItem movie = createMovieItem(movieId);
movie.setTitle(title);
movie.setMpaa(mpaa);