yarfraw.utils
Class FeedFormatDetector
java.lang.Object
yarfraw.utils.FeedFormatDetector
public class FeedFormatDetector
- extends Object
A (somewhat) primitive RSS feed format detection utility class.
It checks the root element of the input xml stream to determines the format
of a feed.
- Author:
- jliang
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FeedFormatDetector
public FeedFormatDetector()
getFormat
public static FeedFormat getFormat(InputStream stream)
throws YarfrawException
- Determines the format of the input feed stream.
Officially, Yarfraw currently only supports these
formats. But, the format detector
will report RSS 0.9x formats as RSS 2.0 because the FeedReader is able to read them using the RSS 2.0 parser.
If you want a stricter format detector, you can use getFormat(InputStream stream, boolean strictFormatDetection)
to pass in a strict enforcement flag to tell the detector you want strict format detection.
- Parameters:
stream
- input stream of a feed
- Returns:
- the format of the feed
- Throws:
YarfrawException
- if unable to detect the format, this usually means the detector
failed to parse the input stream.
getFormat
public static FeedFormat getFormat(InputStream stream,
boolean strictFormatDetection)
throws YarfrawException
- Determines the format of the input feed stream.
Officially, Yarfraw currently only supports these
formats. But, the format detector
will report RSS 0.9x formats as RSS 2.0 because the FeedReader is able to read them using the RSS 2.0 parser.
If you want a stricter format detector, you can use getFormat(InputStream stream, boolean strictFormatDetection)
to pass in a strict enforcement flag to tell the detector you want strict format detection.
- Parameters:
strictFormatDetection
- whether to use 'strict' format detection. if set to true, the method will only report
RSS 2.0 when the root element is 'rss' and it has a version 2.0 attribute: <rss version="2.0">stream
- input stream of a feed
- Returns:
- the format of the feed
- Throws:
YarfrawException
- if unable to detect the format, this usually means the detector
failed to parse the input stream.
Copyright © 2008. All Rights Reserved.