/** * This is a hack to get at the protected {@link WireFeedInput#createSAXBuilder()} method so we can get the * raw jdom document for the feed to extract elements (e.g. 'image') not parsed by the built in feed parsers. */ public class MyWireFeedInput extends WireFeedInput { Document getDocument(Reader reader) { final SAXBuilder saxBuilder = createSAXBuilder(); try { if (xmlHealerOn) reader = new XmlFixerReader(reader) return saxBuilder.build(reader); } catch (final JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (final IllegalArgumentException ex) { throw ex; } catch (final Exception ex) { throw new ParsingFeedException("Invalid XML", ex); } } }
/** * Returns the line number of the end of the text where the * parse error occurred. * <p> * The first line in the document is line 1.</p> * * @return an integer representing the line number, or -1 * if the information is not available. */ public int getLineNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getLineNumber(): -1; }
@Override protected void validate(Document document) { try { SyndFeedInput input = new SyndFeedInput(); input.build(getDocument()); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (FeedException e) { if (e instanceof ParsingFeedException) { ParsingFeedException pfe = (ParsingFeedException) e; addError(Type.ERROR, pfe.getLineNumber(), pfe.getColumnNumber(), e.getMessage()); } else { addError(Type.ERROR, -1, -1, e.getMessage()); } } }
/** * {@inheritDoc} * * @see org.xwiki.validator.framework.AbstractXMLValidator#validate(org.w3c.dom.Document) */ @Override protected void validate(Document document) { try { SyndFeedInput input = new SyndFeedInput(); input.build(getDocument()); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (FeedException e) { if (e instanceof ParsingFeedException) { ParsingFeedException pfe = (ParsingFeedException) e; addError(Type.ERROR, pfe.getLineNumber(), pfe.getColumnNumber(), e.getMessage()); } else { addError(Type.ERROR, -1, -1, e.getMessage()); } } }
/** * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param is W3C SAX InputSource to read to create the WireFeed. * @return the WireFeed read from the W3C SAX InputSource. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { Document document = saxBuilder.build(is); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the column number of the end of the text where the * parse error occurred. * <p> * The first column in a line is position 1.</p> * * @return an integer representing the column number, or -1 * if the information is not available. */ public int getColumnNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getColumnNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'. * <p> * @param is W3C SAX InputSource to read to create the WireFeed. * @return the WireFeed read from the W3C SAX InputSource. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { Document document = saxBuilder.build(is); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the line number of the end of the text where the * parse error occurred. * <p> * The first line in the document is line 1.</p> * * @return an integer representing the line number, or -1 * if the information is not available. */ public int getLineNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getLineNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param is W3C SAX InputSource to read to create the WireFeed. * @return the WireFeed read from the W3C SAX InputSource. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { Document document = saxBuilder.build(is); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the column number of the end of the text where the * parse error occurred. * <p> * The first column in a line is position 1.</p> * * @return an integer representing the column number, or -1 * if the information is not available. */ public int getColumnNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getColumnNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an W3C SAX InputSource. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'. * <p> * @param is W3C SAX InputSource to read to create the WireFeed. * @return the WireFeed read from the W3C SAX InputSource. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(InputSource is) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { Document document = saxBuilder.build(is); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the line number of the end of the text where the * parse error occurred. * <p> * The first line in the document is line 1.</p> * * @return an integer representing the line number, or -1 * if the information is not available. */ public int getLineNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getLineNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an Reader. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'. * <p> * @param reader Reader to read to create the WireFeed. * @return the WireFeed read from the Reader. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(Reader reader) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { if (_xmlHealerOn) { reader = new XmlFixerReader(reader); } Document document = saxBuilder.build(reader); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the line number of the end of the text where the * parse error occurred. * <p> * The first line in the document is line 1.</p> * * @return an integer representing the line number, or -1 * if the information is not available. */ public int getLineNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getLineNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an Reader. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'. * <p> * @param reader Reader to read to create the WireFeed. * @return the WireFeed read from the Reader. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(Reader reader) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { if (_xmlHealerOn) { reader = new XmlFixerReader(reader); } Document document = saxBuilder.build(reader); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the column number of the end of the text where the * parse error occurred. * <p> * The first column in a line is position 1.</p> * * @return an integer representing the column number, or -1 * if the information is not available. */ public int getColumnNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getColumnNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an Reader. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param reader Reader to read to create the WireFeed. * @return the WireFeed read from the Reader. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(Reader reader) throws IllegalArgumentException,FeedException { SAXBuilder saxBuilder = createSAXBuilder(); try { if (_xmlHealerOn) { reader = new XmlFixerReader(reader); } Document document = saxBuilder.build(reader); return build(document); } catch (JDOMParseException ex) { throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Returns the column number of the end of the text where the * parse error occurred. * <p> * The first column in a line is position 1.</p> * * @return an integer representing the column number, or -1 * if the information is not available. */ public int getColumnNumber() { return (getCause() instanceof JDOMParseException)? ((JDOMParseException)getCause()).getColumnNumber(): -1; }
/** * Builds an WireFeed (RSS or Atom) from an W3C DOM document. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'. * <p> * @param document W3C DOM document to read to create the WireFeed. * @return the WireFeed read from the W3C DOM document. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(org.w3c.dom.Document document) throws IllegalArgumentException,FeedException { DOMBuilder domBuilder = new DOMBuilder(); try { Document jdomDoc = domBuilder.build(document); return build(jdomDoc); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }
/** * Builds an WireFeed (RSS or Atom) from an W3C DOM document. * <p> * NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom2.Document)'. * <p> * @param document W3C DOM document to read to create the WireFeed. * @return the WireFeed read from the W3C DOM document. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers. * @throws FeedException if the feed could not be parsed * */ public WireFeed build(org.w3c.dom.Document document) throws IllegalArgumentException,FeedException { DOMBuilder domBuilder = new DOMBuilder(); try { Document jdomDoc = domBuilder.build(document); return build(jdomDoc); } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) { throw new ParsingFeedException("Invalid XML",ex); } }