/** * Constructor around an existing feed. * * @param feed * The feed (must have a valid feedType!) */ public SyndFeedRepresentation(SyndFeed feed) { super(getMediaType(feed.getFeedType())); this.feed = feed; }
@Override public void write(Writer writer) throws IOException { try { SyndFeedOutput output = new SyndFeedOutput(); if (this.feed.getFeedType() == null) { this.feed.setFeedType("atom_1.0"); } output.output(this.feed, writer); } catch (FeedException e) { IOException ioe = new IOException("Feed exception"); ioe.initCause(e); throw ioe; } } }
/** * Constructor that parses the given feed representation. * * @param feedRepresentation * The feed representation to parse. * @throws IOException */ public SyndFeedRepresentation(Representation feedRepresentation) throws IOException { super(null); InputSource source = new InputSource(feedRepresentation.getStream()); try { this.feed = new SyndFeedInput().build(source); } catch (IllegalArgumentException e) { IOException ioe = new IOException( "Couldn't read the feed representation. " + e.getMessage()); ioe.initCause(e); throw ioe; } catch (FeedException e) { IOException ioe = new IOException( "Couldn't read the feed representation. " + e.getMessage()); ioe.initCause(e); throw ioe; } setMediaType(getMediaType(this.feed.getFeedType())); }
@Override public Representation toRepresentation(Object source, Variant target, Resource resource) throws IOException { if (source instanceof SyndFeed) { SyndFeed feed = (SyndFeed) source; if (feed.getFeedType() == null) { if (VARIANT_APPLICATION_RSS.isCompatible(target)) { feed.setFeedType("rss_2.0"); } else { feed.setFeedType("atom_1.0"); } } return new SyndFeedRepresentation(feed); } return null; }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }