boolean bodyFound = false;
do {
if (elementType == HTMLParser.REDIRECT_URL) {
RssItunesFeed [] feeds = new RssItunesFeed[1];
feeds[0] = new RssItunesFeed("", parser.getRedirectUrl(),
"", "");
return feeds;
}
/** RSS item properties */
String title = "";
String link = "";
String tagName = parser.getName();
//#ifdef DLOGGING
//@ if (finerLoggable) {logger.finer("tagname: " + tagName);}
//#endif
if (tagName.length() == 0) {
continue;
}
switch (tagName.charAt(0)) {
case 'm':
case 'M':
if (bodyFound) {
break;
}
break;
case 'b':
case 'B':
if (!bodyFound) {
bodyFound = parser.isBodyFound();
}
break;
case 'a':
case 'A':
//#ifdef DLOGGING
//@ if (finerLoggable) {logger.finer("Parsing <a> tag");}
//#endif
title = parser.getText();
// Title can be 0 as this is used also for
// getting
title = title.trim();
title = StringUtil.removeHtml( title );
if (((link = parser.getAttributeValue( "href" ))
== null) || ( link.length() == 0 )) {
continue;
}
link = link.trim();
if ( link.length() == 0 ) {
continue;
}
if (link.indexOf("://") >= 0) {
if (!link.startsWith("http:") &&
!link.startsWith("https:") &&
!link.startsWith("file:") &&
!link.startsWith("jar:")) {
//#ifdef DLOGGING
//@ if (finerLoggable) {logger.finer("Not support for protocol or no protocol=" + link);}
//#endif
continue;
}
} else {
if (link.charAt(0) == '/') {
int purl = url.indexOf("://");
if ((purl + 4) >= url.length()) {
//#ifdef DLOGGING
//@ if (finerLoggable) {logger.finer("Url too short=" + url + "," + purl);}
//#endif
continue;
}
int pslash = url.indexOf("/", purl + 3);
String burl = url;
if (pslash >= 0) {
burl = url.substring(0, pslash);
}
link = burl + link;
} else {
link = url + "/" + link;
}
}
/** Debugging information */
//#ifdef DLOGGING
//@ if (finerLoggable) {logger.finer("Title: " + title);}
//@ if (finerLoggable) {logger.finer("Link: " + link);}
//#endif
if (( feedURLFilter != null) &&
( link.toLowerCase().indexOf(feedURLFilter) < 0)) {
continue;
}
if (( feedNameFilter != null) &&
((title != null) &&
(title.toLowerCase().indexOf(feedNameFilter) < 0))) {
continue;
}
RssItunesFeed feed = new RssItunesFeed(title, link, "", "");
rssFeeds.addElement( feed );
break;
default:
}
}