I've been looking over the source for parsing and I had
a couple of questions/suggestions.
Right now it appears that parsing an unknown feed is a
three step process:
1.) use FormatDetector.getFormat(URL) to determine the
to get a parser
3.) parse the feed to get a channel
Does it make sense to offer a class that does all that
in one go? Also one that supports Reader, InputStream
and File objects in addition to URLs?
Also, I noticed that FormatDetector's implementation
reads from the stream to determine type, and further
down the line, the parsers all re-read the feed again
using JDOM's SaxBuilder. Would a different scheme
allow for reading the xml feed just once? From viewing
the source of the 0.91, 1.0 and 2.0 parser, I think it
would be possible. It would go like this:
1.) Use SaxBuilder to parse the feed into a JDOM
2.) Read the root element to determine the RSS version
3.) Use the info obtained in #2 to instantiate the
proper AbstractParser subclass.
4.) Pass the Document obtain in #1 to the
AbstractParser subclass so that it can build a Channel
5.) return the Channel object to the user.
There are two things today that prevent this:
1.) The private synchronized ChannelIF parse(Document)
method in each subclass would need to be pushed up to
the superclass and marked as abstract
2.) The visibility scope would have to be lessened to
perhaps friendly package scope.
Any comments? or is there anything I overlooked (sorry
about anything obvious, I just came across this API today).
Log in to post a comment.