Class WireFeedInput
- java.lang.Object
-
- com.rometools.rome.io.WireFeedInput
-
public class WireFeedInput extends Object
Parses an XML document (File, InputStream, Reader, W3C SAX InputSource, W3C DOM Document or JDom DOcument) into an WireFeed (RSS/Atom).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.
-
-
Constructor Summary
Constructors Constructor Description WireFeedInput()Creates a WireFeedInput instance with input validation turned off.WireFeedInput(boolean validate, Locale locale)Creates a WireFeedInput instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WireFeedbuild(File file)Builds an WireFeed (RSS or Atom) from a file.WireFeedbuild(Reader reader)Builds an WireFeed (RSS or Atom) from an Reader.WireFeedbuild(org.jdom2.Document document)Builds an WireFeed (RSS or Atom) from an JDOM document.WireFeedbuild(Document document)Builds an WireFeed (RSS or Atom) from an W3C DOM document.WireFeedbuild(InputSource is)Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.protected SAXBuildercreateSAXBuilder()Creates and sets up a org.jdom2.input.SAXBuilder for parsing.static List<String>getSupportedFeedTypes()Returns the list of supported input feed types.booleangetXmlHealerOn()Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.booleanisAllowDoctypes()Indicates whether Doctype declarations are allowed.voidsetAllowDoctypes(boolean allowDoctypes)Since ROME 1.5.1 we fixed a security vulnerability by disallowing Doctype declarations by default.voidsetXmlHealerOn(boolean heals)Enables XML healing in the WiredFeedInput instance.
-
-
-
Constructor Detail
-
WireFeedInput
public WireFeedInput()
Creates a WireFeedInput instance with input validation turned off.
-
WireFeedInput
public WireFeedInput(boolean validate, Locale locale)Creates a WireFeedInput instance.- Parameters:
validate- indicates if the input should be validated. NOT IMPLEMENTED YET (validation does not happen)
-
-
Method Detail
-
getSupportedFeedTypes
public static List<String> getSupportedFeedTypes()
Returns the list of supported input feed types.- Returns:
- a list of String elements with the supported input feed types.
- See Also:
for details on the format of these strings.
-
setXmlHealerOn
public void setXmlHealerOn(boolean heals)
Enables XML healing in the WiredFeedInput instance.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.
- Parameters:
heals- TRUE enables stream healing, FALSE disables it.
-
getXmlHealerOn
public boolean getXmlHealerOn()
Indicates if the WiredFeedInput instance will XML heal (if necessary) the character stream.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.
- Returns:
- TRUE if healing is enabled, FALSE if not.
-
isAllowDoctypes
public boolean isAllowDoctypes()
Indicates whether Doctype declarations are allowed.- Returns:
- true when Doctype declarations are allowed, false otherwise
-
setAllowDoctypes
public void setAllowDoctypes(boolean allowDoctypes)
Since ROME 1.5.1 we fixed a security vulnerability by disallowing Doctype declarations by default. This change breaks the compatibility with at least RSS 0.91N because it requires a Doctype declaration. You are able to allow Doctype declarations again with this property. You should only activate it when the feeds that you process are absolutely trustful.- Parameters:
allowDoctypes- true when Doctype declarations should be allowed again, false otherwise
-
build
public WireFeed build(File file) throws FileNotFoundException, IOException, IllegalArgumentException, FeedException
Builds an WireFeed (RSS or Atom) from a file.NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
- Parameters:
file- file to read to create the WireFeed.- Returns:
- the WireFeed read from the file.
- Throws:
FileNotFoundException- thrown if the file could not be found.IOException- thrown if there is problem reading the file.IllegalArgumentException- thrown if feed type could not be understood by any of the underlying parsers.FeedException- if the feed could not be parsed
-
build
public WireFeed build(Reader reader) throws IllegalArgumentException, FeedException
Builds an WireFeed (RSS or Atom) from an Reader.NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
- Parameters:
reader- Reader to read to create the WireFeed.- Returns:
- the WireFeed read from the Reader.
- Throws:
IllegalArgumentException- thrown if feed type could not be understood by any of the underlying parsers.FeedException- if the feed could not be parsed
-
build
public WireFeed build(InputSource is) throws IllegalArgumentException, FeedException
Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource.NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
- Parameters:
is- W3C SAX InputSource to read to create the WireFeed.- Returns:
- the WireFeed read from the W3C SAX InputSource.
- Throws:
IllegalArgumentException- thrown if feed type could not be understood by any of the underlying parsers.FeedException- if the feed could not be parsed
-
build
public WireFeed build(Document document) throws IllegalArgumentException, FeedException
Builds an WireFeed (RSS or Atom) from an W3C DOM document.NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'.
- Parameters:
document- W3C DOM document to read to create the WireFeed.- Returns:
- the WireFeed read from the W3C DOM document.
- Throws:
IllegalArgumentException- thrown if feed type could not be understood by any of the underlying parsers.FeedException- if the feed could not be parsed
-
build
public WireFeed build(org.jdom2.Document document) throws IllegalArgumentException, FeedException
Builds an WireFeed (RSS or Atom) from an JDOM document.NOTE: All other build methods delegate to this method.
- Parameters:
document- JDOM document to read to create the WireFeed.- Returns:
- the WireFeed read from the JDOM document.
- Throws:
IllegalArgumentException- thrown if feed type could not be understood by any of the underlying parsers.FeedException- if the feed could not be parsed
-
createSAXBuilder
protected SAXBuilder createSAXBuilder()
Creates and sets up a org.jdom2.input.SAXBuilder for parsing.- Returns:
- a new org.jdom2.input.SAXBuilder object
-
-