Package com.rometools.rome.feed.synd

Examples of com.rometools.rome.feed.synd.SyndEnclosure


        if (message.getEnclosures() != null && message.getEnclosures().size() > 0) {
            out.startArray(Rss.ENCLOSURES);
            for (Object oEnclosure : message.getEnclosures()) {
                if (oEnclosure instanceof SyndEnclosure) {
                    out.startObject();
                    SyndEnclosure enclosure = (SyndEnclosure) oEnclosure;
                    out.field(Rss.Enclosures.URL, enclosure.getUrl());
                    out.field(Rss.Enclosures.TYPE, enclosure.getType());
                    out.field(Rss.Enclosures.LENGTH, enclosure.getLength());
                    out.endObject();
                }
            }
            out.endArray();
        }
View Full Code Here


        FeedEntryContent content = new FeedEntryContent();
        content.setContent(getContent(item));
        content.setTitle(getTitle(item));
        content.setAuthor(StringUtils.trimToNull(item.getAuthor()));
        SyndEnclosure enclosure = Iterables.getFirst(item.getEnclosures(), null);
        if (enclosure != null) {
          content.setEnclosureUrl(FeedUtils.truncate(enclosure.getUrl(), 2048));
          content.setEnclosureType(enclosure.getType());
        }
        entry.setContent(content);

        entries.add(entry);
      }
View Full Code Here

        return syndEntry;
    }

    public SyndEnclosure createSyndEnclosure(final Entry entry, final Link link) {
        final SyndEnclosure syndEncl = new SyndEnclosureImpl();
        syndEncl.setUrl(link.getHrefResolved());
        syndEncl.setType(link.getType());
        syndEncl.setLength(link.getLength());
        return syndEncl;
    }
View Full Code Here

        return syndEntry;
    }

    public SyndEnclosure createSyndEnclosure(final Feed feed, final Entry entry, final Link link) {
        final SyndEnclosure syndEncl = new SyndEnclosureImpl();
        syndEncl.setUrl(link.getHrefResolved());
        syndEncl.setType(link.getType());
        syndEncl.setLength(link.getLength());
        return syndEncl;
    }
View Full Code Here

        // add SyndEnclosures as links with rel="enclosure" ONLY if
        // there are no SyndEntry.getLinks() with rel="enclosure"
        if (enclosures != null && linkRelEnclosureExists == false) {
            for (final SyndEnclosure syndEnclosure : enclosures) {
                final SyndEnclosure syndEncl = syndEnclosure;
                final Link link = createAtomEnclosure(syndEncl);
                otherLinks.add(link);
            }
        }
View Full Code Here

    }

    protected List<SyndEnclosure> createSyndEnclosures(final List<Enclosure> enclosures) {
        final List<SyndEnclosure> sEnclosures = new ArrayList<SyndEnclosure>();
        for (final Enclosure enc : enclosures) {
            final SyndEnclosure sEnc = new SyndEnclosureImpl();
            sEnc.setUrl(enc.getUrl());
            sEnc.setType(enc.getType());
            sEnc.setLength(enc.getLength());
            sEnclosures.add(sEnc);
        }
        return sEnclosures;
    }
View Full Code Here

    @Override
    protected void testEnclosures(final List<SyndEnclosure> encs, final String prefix) throws Exception {
        final Set<String> s1 = new HashSet<String>();
        final Set<String> s2 = new HashSet<String>();
        for (int i = 0; i < encs.size(); i++) {
            final SyndEnclosure enc = encs.get(i);
            s1.add(enc.getUrl() + " " + enc.getType() + " " + enc.getLength());
            s2.add(getPrefix() + "." + prefix + ".enclousure[" + i + "]^url" + " " + getPrefix() + "." + prefix + ".enclousure[" + i + "]^type" + " " + "0");
        }
        assertTrue(s1.equals(s2));
    }
View Full Code Here

    protected void testEnclosures(final List<SyndEnclosure> encs, final String prefix) throws Exception {
        final Set<String> s1 = new HashSet<String>();
        final Set<String> s2 = new HashSet<String>();
        for (int i = 0; i < encs.size(); i++) {
            final SyndEnclosure enc = encs.get(i);
            s1.add(enc.getUrl() + " " + enc.getType() + " " + enc.getLength());
            s2.add(getPrefix() + "." + prefix + ".enclousure[" + i + "]^url" + " " + getPrefix() + "." + prefix + ".enclousure[" + i + "]^type" + " " + "100");
        }
        assertTrue(s1.equals(s2));
    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.feed.synd.SyndEnclosure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.