com.rometools.opml.feed.opml.Outline Java Examples
The following examples show how to use
com.rometools.opml.feed.opml.Outline.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OPML20Parser.java From rome with Apache License 2.0 | 6 votes |
@Override protected Outline parseOutline(final Element e, final boolean validate, final Locale locale) throws FeedException { Outline retValue; retValue = super.parseOutline(e, validate, locale); if (e.getAttributeValue("created") != null) { retValue.setCreated(DateParser.parseRFC822(e.getAttributeValue("created"), locale)); } final List<Attribute> atts = retValue.getAttributes(); for (int i = 0; i < atts.size(); i++) { final Attribute a = atts.get(i); if (a.getName().equals("created")) { retValue.getAttributes().remove(a); break; } } return retValue; }
Example #2
Source File: OPML10Generator.java From rome with Apache License 2.0 | 6 votes |
protected Element generateOutline(final Outline outline) { final Element e = new Element("outline"); addNotNullAttribute(e, "text", outline.getText()); addNotNullAttribute(e, "type", outline.getType()); addNotNullAttribute(e, "title", outline.getTitle()); if (outline.isBreakpoint()) { addNotNullAttribute(e, "isBreakpoint", "true"); } if (outline.isComment()) { addNotNullAttribute(e, "isComment", "true"); } final List<Attribute> atts = Collections.synchronizedList(outline.getAttributes()); for (int i = 0; i < atts.size(); i++) { final Attribute att = atts.get(i); addNotNullAttribute(e, att.getName(), att.getValue()); } super.generateItemModules(outline.getModules(), e); e.addContent(generateOutlines(outline.getChildren())); return e; }
Example #3
Source File: OPMLExporterTest.java From commafeed with Apache License 2.0 | 6 votes |
@Test public void generates_OPML_correctly() { when(feedCategoryDAO.findAll(user)).thenReturn(categories); when(feedSubscriptionDAO.findAll(user)).thenReturn(subscriptions); Opml opml = new OPMLExporter(feedCategoryDAO, feedSubscriptionDAO).export(user); List<Outline> rootOutlines = opml.getOutlines(); assertEquals(2, rootOutlines.size()); assertTrue(containsCategory(rootOutlines, "cat1")); assertTrue(containsFeed(rootOutlines, "rootFeed", "rootFeed.com")); Outline cat1Outline = getCategoryOutline(rootOutlines, "cat1"); List<Outline> cat1Children = cat1Outline.getChildren(); assertEquals(2, cat1Children.size()); assertTrue(containsCategory(cat1Children, "cat2")); assertTrue(containsFeed(cat1Children, "cat1Feed", "cat1Feed.com")); Outline cat2Outline = getCategoryOutline(cat1Children, "cat2"); List<Outline> cat2Children = cat2Outline.getChildren(); assertEquals(1, cat2Children.size()); assertTrue(containsFeed(cat2Children, "cat2Feed", "cat2Feed.com")); }
Example #4
Source File: OPML20GeneratorTest.java From rome with Apache License 2.0 | 6 votes |
private NodeList categoryOf(final String... categories) { try { final Outline outline = new Outline("outline1", null); outline.setCategories(Arrays.asList(categories)); final Opml opml = new Opml(); opml.setFeedType("opml_2.0"); opml.setTitle("title"); opml.setOutlines(Arrays.asList(outline)); final WireFeedOutput output = new WireFeedOutput(); final String xml = output.outputString(opml); final Document document = XMLUnit.buildControlDocument(xml); return XMLUnit.newXpathEngine().getMatchingNodes("/opml/body/outline/@category", document); } catch (final Exception e) { throw new RuntimeException(e); } }
Example #5
Source File: OPMLExporter.java From commafeed with Apache License 2.0 | 6 votes |
private Outline buildCategoryOutline(FeedCategory cat, List<FeedCategory> categories, List<FeedSubscription> subscriptions) { Outline outline = new Outline(); outline.setText(cat.getName()); outline.setTitle(cat.getName()); for (FeedCategory child : categories.stream().filter(c -> c.getParent() != null && c.getParent().getId().equals(cat.getId())) .collect(Collectors.toList())) { outline.getChildren().add(buildCategoryOutline(child, categories, subscriptions)); } for (FeedSubscription sub : subscriptions.stream() .filter(s -> s.getCategory() != null && s.getCategory().getId().equals(cat.getId())).collect(Collectors.toList())) { outline.getChildren().add(buildSubscriptionOutline(sub)); } return outline; }
Example #6
Source File: OpmlConverter.java From SimpleNews with Apache License 2.0 | 5 votes |
private static List<Feed> convertOutlineToFeedList(Outline outline) { List<Feed> feeds = new ArrayList<>(); if (outline != null && outline.getChildren() != null && outline.getChildren().size() > 0) { for (Outline childrenOutline : outline.getChildren()) { feeds.addAll(convertOutlineToFeedList(childrenOutline)); } } else { feeds.add(convertOutlineToFeed(outline)); } return feeds; }
Example #7
Source File: OPMLExporterTest.java From commafeed with Apache License 2.0 | 5 votes |
private Outline getCategoryOutline(List<Outline> outlines, String title) { for (Outline o : outlines) if (o.getTitle().equals(title)) return o; return null; }
Example #8
Source File: OPMLExporterTest.java From commafeed with Apache License 2.0 | 5 votes |
private boolean containsFeed(List<Outline> outlines, String title, String url) { for (Outline o : outlines) if ("rss".equals(o.getType())) if (title.equals(o.getTitle()) && o.getAttributeValue("xmlUrl").equals(url)) return true; return false; }
Example #9
Source File: OPMLExporterTest.java From commafeed with Apache License 2.0 | 5 votes |
private boolean containsCategory(List<Outline> outlines, String category) { for (Outline o : outlines) if (!"rss".equals(o.getType())) if (category.equals(o.getTitle())) return true; return false; }
Example #10
Source File: OPMLExporter.java From commafeed with Apache License 2.0 | 5 votes |
private Outline buildSubscriptionOutline(FeedSubscription sub) { Outline outline = new Outline(); outline.setText(sub.getTitle()); outline.setTitle(sub.getTitle()); outline.setType("rss"); outline.getAttributes().add(new Attribute("xmlUrl", sub.getFeed().getUrl())); if (sub.getFeed().getLink() != null) { outline.getAttributes().add(new Attribute("htmlUrl", sub.getFeed().getLink())); } return outline; }
Example #11
Source File: OPMLImporter.java From commafeed with Apache License 2.0 | 5 votes |
public void importOpml(User user, String xml) { xml = xml.substring(xml.indexOf('<')); WireFeedInput input = new WireFeedInput(); try { Opml feed = (Opml) input.build(new StringReader(xml)); List<Outline> outlines = feed.getOutlines(); for (int i = 0; i < outlines.size(); i++) { handleOutline(user, outlines.get(i), null, i); } } catch (Exception e) { log.error(e.getMessage(), e); } }
Example #12
Source File: OpmlConverter.java From SimpleNews with Apache License 2.0 | 5 votes |
public static Opml convertCategoriesToOpml(List<Category> categories) { List<Outline> children = new ArrayList<>(); for (Category category : categories){ children.add(convertFeedsToOutline(category.getName(), category.getFeeds())); } Opml opml = new Opml(); opml.setTitle("SimpleNews - OPML"); opml.setOutlines(children); return opml; }
Example #13
Source File: OpmlConverter.java From SimpleNews with Apache License 2.0 | 5 votes |
private static Feed convertOutlineToFeed(Outline element) { Feed feed = new Feed(); feed.setDescription(element.getText()); feed.setTitle(element.getTitle()); String url = element.getXmlUrl(); if (url == null || "".equals(url)) { url = element.getUrl(); } feed.setXmlUrl(url); feed.setHtmlUrl(element.getHtmlUrl()); return feed; }
Example #14
Source File: OpmlReader.java From reactor-workshop with GNU General Public License v3.0 | 5 votes |
/** * TODO Return {@link reactor.core.publisher.Flux} */ public List<Outline> allFeeds() throws FeedException, IOException { WireFeedInput input = new WireFeedInput(); try(final InputStream inputStream = OpmlReader.class.getResourceAsStream("/feed-jvm-bloggers.xml")) { final InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); final Reader reader = new BufferedReader(streamReader); Opml feed = (Opml) input.build(reader); return feed.getOutlines(); } }
Example #15
Source File: OpmlConverter.java From SimpleNews with Apache License 2.0 | 5 votes |
public static List<Feed> convertOpmlListToFeedList(Opml opml) { List<Feed> feeds = new ArrayList<>(); for (Outline element : opml.getOutlines()) { feeds.addAll(convertOutlineToFeedList(element)); } return feeds; }
Example #16
Source File: OPML10Parser.java From rome with Apache License 2.0 | 5 votes |
protected List<Outline> parseOutlines(final List<Element> elements, final boolean validate, final Locale locale) throws FeedException { final ArrayList<Outline> results = new ArrayList<Outline>(); for (int i = 0; i < elements.size(); i++) { results.add(parseOutline(elements.get(i), validate, locale)); } return results; }
Example #17
Source File: OPML10Generator.java From rome with Apache License 2.0 | 5 votes |
protected List<Element> generateOutlines(final List<Outline> outlines) { final ArrayList<Element> elements = new ArrayList<Element>(); for (int i = 0; outlines != null && i < outlines.size(); i++) { elements.add(generateOutline(outlines.get(i))); } return elements; }
Example #18
Source File: ConverterForOPML10.java From rome with Apache License 2.0 | 5 votes |
protected void createEntries(final Stack<Integer> context, final List<SyndEntry> allEntries, final List<Outline> outlines) { final List<Outline> so = Collections.synchronizedList(outlines); for (int i = 0; i < so.size(); i++) { createEntry(context, allEntries, so.get(i)); } }
Example #19
Source File: OPML20Generator.java From rome with Apache License 2.0 | 4 votes |
@Override protected Element generateOutline(final Outline outline) { final Element outlineElement = super.generateOutline(outline); if (outline.getCreated() != null) { outlineElement.setAttribute("created", DateParser.formatRFC822(outline.getCreated(), Locale.US)); } final List<String> categories = outline.getCategories(); final String categoryValue = generateCategoryValue(categories); addNotNullAttribute(outlineElement, "category", categoryValue); return outlineElement; }
Example #20
Source File: ConverterForOPML10.java From rome with Apache License 2.0 | 4 votes |
public OutlineHolder(final Outline outline, final String parent) { this.outline = outline; this.parent = parent; }