public class WireFeedInput
extends java.lang.Object
It accepts all flavors of RSS (0.90, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0) and Atom 0.3 feeds. Parsers are plugable (they must implement the WireFeedParser interface).
The WireFeedInput useds liberal parsers.
Modifier and Type | Class and Description |
---|---|
private static class |
WireFeedInput.EmptyEntityResolver |
Modifier and Type | Field and Description |
---|---|
private boolean |
allowDoctypes |
private static java.util.Map<java.lang.ClassLoader,FeedParsers> |
clMap |
private static org.xml.sax.InputSource |
EMPTY_INPUTSOURCE |
private java.util.Locale |
locale |
private static org.xml.sax.EntityResolver |
RESOLVER |
private boolean |
validate |
private boolean |
xmlHealerOn |
Constructor and Description |
---|
WireFeedInput()
Creates a WireFeedInput instance with input validation turned off.
|
WireFeedInput(boolean validate,
java.util.Locale locale)
Creates a WireFeedInput instance.
|
Modifier and Type | Method and Description |
---|---|
WireFeed |
build(org.w3c.dom.Document document)
Builds an WireFeed (RSS or Atom) from an W3C DOM document.
|
WireFeed |
build(org.jdom2.Document document)
Builds an WireFeed (RSS or Atom) from an JDOM document.
|
WireFeed |
build(java.io.File file)
Builds an WireFeed (RSS or Atom) from a file.
|
WireFeed |
build(org.xml.sax.InputSource is)
Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.
|
WireFeed |
build(java.io.Reader reader)
Builds an WireFeed (RSS or Atom) from an Reader.
|
protected SAXBuilder |
createSAXBuilder()
Creates and sets up a org.jdom2.input.SAXBuilder for parsing.
|
private static FeedParsers |
getFeedParsers() |
static java.util.List<java.lang.String> |
getSupportedFeedTypes()
Returns the list of supported input feed types.
|
boolean |
getXmlHealerOn()
Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.
|
boolean |
isAllowDoctypes()
Indicates whether Doctype declarations are allowed.
|
private boolean |
isFeatureSupported(org.xml.sax.XMLReader parser,
java.lang.String feature,
boolean value) |
void |
setAllowDoctypes(boolean allowDoctypes)
Since ROME 1.5.1 we fixed a security vulnerability by disallowing Doctype declarations by default.
|
private void |
setFeature(SAXBuilder saxBuilder,
org.xml.sax.XMLReader parser,
java.lang.String feature,
boolean value) |
void |
setXmlHealerOn(boolean heals)
Enables XML healing in the WiredFeedInput instance.
|
private static final org.xml.sax.InputSource EMPTY_INPUTSOURCE
private static final org.xml.sax.EntityResolver RESOLVER
private static java.util.Map<java.lang.ClassLoader,FeedParsers> clMap
private final boolean validate
private final java.util.Locale locale
private boolean xmlHealerOn
private boolean allowDoctypes
public WireFeedInput()
public WireFeedInput(boolean validate, java.util.Locale locale)
validate
- indicates if the input should be validated. NOT IMPLEMENTED YET (validation
does not happen)private static FeedParsers getFeedParsers()
public static java.util.List<java.lang.String> getSupportedFeedTypes()
for details on the format of these strings.
public void setXmlHealerOn(boolean heals)
Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
Healing resolves HTML entities (from literal to code number) in the reader.
The healing is done only with the build(File) and build(Reader) signatures.
By default is TRUE.
heals
- TRUE enables stream healing, FALSE disables it.public boolean getXmlHealerOn()
Healing trims leading chars from the stream (empty spaces and comments) until the XML prolog.
Healing resolves HTML entities (from literal to code number) in the reader.
The healing is done only with the build(File) and build(Reader) signatures.
By default is TRUE.
public boolean isAllowDoctypes()
public void setAllowDoctypes(boolean allowDoctypes)
allowDoctypes
- true when Doctype declarations should be allowed again, false otherwisepublic WireFeed build(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException, java.lang.IllegalArgumentException, FeedException
NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
file
- file to read to create the WireFeed.java.io.FileNotFoundException
- thrown if the file could not be found.java.io.IOException
- thrown if there is problem reading the file.java.lang.IllegalArgumentException
- thrown if feed type could not be understood by any of the
underlying parsers.FeedException
- if the feed could not be parsedpublic WireFeed build(java.io.Reader reader) throws java.lang.IllegalArgumentException, FeedException
NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
reader
- Reader to read to create the WireFeed.java.lang.IllegalArgumentException
- thrown if feed type could not be understood by any of the
underlying parsers.FeedException
- if the feed could not be parsedpublic WireFeed build(org.xml.sax.InputSource is) throws java.lang.IllegalArgumentException, FeedException
NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
is
- W3C SAX InputSource to read to create the WireFeed.java.lang.IllegalArgumentException
- thrown if feed type could not be understood by any of the
underlying parsers.FeedException
- if the feed could not be parsedpublic WireFeed build(org.w3c.dom.Document document) throws java.lang.IllegalArgumentException, FeedException
NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
document
- W3C DOM document to read to create the WireFeed.java.lang.IllegalArgumentException
- thrown if feed type could not be understood by any of the
underlying parsers.FeedException
- if the feed could not be parsedpublic WireFeed build(org.jdom2.Document document) throws java.lang.IllegalArgumentException, FeedException
NOTE: All other build methods delegate to this method.
document
- JDOM document to read to create the WireFeed.java.lang.IllegalArgumentException
- thrown if feed type could not be understood by any of the
underlying parsers.FeedException
- if the feed could not be parsedprotected SAXBuilder createSAXBuilder()
private void setFeature(SAXBuilder saxBuilder, org.xml.sax.XMLReader parser, java.lang.String feature, boolean value)
private boolean isFeatureSupported(org.xml.sax.XMLReader parser, java.lang.String feature, boolean value)