public static Link[] selectAlternate(Source source, Range... ranges) { return selectAlternate(source.getLinks("alternate"), ranges); }
/** * Adds a next-archive link relation to the feed * * @param feed The feed * @param iri The IRI of the next archive feed document * @return The newly created Link */ public static Link setNextArchive(Source feed, String iri) { Link link = feed.getLink("next-archive"); if (link == null) { // try the full IANA URI version link = feed.getLink(Link.IANA_BASE + "next-archive"); } if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "next-archive"); } return link; }
jstream.writeField("xml:base", element.getResolvedBaseUri()); Source source = (Source)element; jstream.writeField("id", source.getId()); writeElement("title", source.getTitleElement(), jstream); writeElement("subtitle", source.getSubtitleElement(), jstream); writeElement("rights", source.getRightsElement(), jstream); jstream.writeField("updated", source.getUpdated()); writeElement("generator", source.getGenerator(), jstream); if (source.getIconElement() != null) jstream.writeField("icon", source.getIconElement().getResolvedValue()); if (source.getLogoElement() != null) jstream.writeField("logo", source.getLogoElement().getResolvedValue()); writeList("authors", source.getAuthors(), jstream); writeList("contributors", source.getContributors(), jstream); writeList("links", source.getLinks(), jstream); writeList("categories", source.getCategories(), jstream); if (FeedPagingHelper.isComplete(source)) jstream.writeField("complete", true);
/** * Flag the feed as being an archive. * * @param feed The Feed to mark as an archive * @param archive True if the feed is an archive */ public static void setArchive(Source feed, boolean archive) { if (archive) { if (!isArchive(feed)) feed.addExtension(ARCHIVE); } else { if (isArchive(feed)) { Element ext = feed.getExtension(ARCHIVE); ext.discard(); } } }
public static Link addLicense(Base base, String iri, String type, String title, String hreflang) { if (hasLicense(base, iri, false)) throw new IllegalStateException("License '" + iri + "' has already been added"); if (hasUnspecifiedLicense(base, false)) throw new IllegalStateException("Unspecified license already added"); if (base instanceof Source) { return ((Source)base).addLink((new IRI(iri)).toString(), Link.REL_LICENSE, type, title, hreflang, -1); } else if (base instanceof Entry) { return ((Entry)base).addLink((new IRI(iri)).toString(), Link.REL_LICENSE, type, title, hreflang, -1); } return null; }
if (entry.getUpdated() == null) return false; if (entry.getAuthor() == null && (entry.getSource() != null && entry.getSource().getAuthor() == null)) return false; Content content = entry.getContentElement();
/** * Flag the feed as being complete. According to the Feed Paging and Archiving specification, in a complete feed, * "any entry not actually in the feed document SHOULD NOT be considered to be part of that feed." * * @param feed The Feed to mark as complete * @param complete True if the feed is complete */ public static void setComplete(Source feed, boolean complete) { if (complete) { if (!isComplete(feed)) feed.addExtension(COMPLETE); } else { if (isComplete(feed)) { Element ext = feed.getExtension(COMPLETE); ext.discard(); } } }
public static List<Link> getLicense(Base base, boolean inherited) { List<Link> links = null; if (base instanceof Source) { links = ((Source)base).getLinks(Link.REL_LICENSE); } else if (base instanceof Entry) { Entry entry = (Entry)base; Source source = entry.getSource(); Base parent = entry.getParentElement(); links = entry.getLinks(Link.REL_LICENSE); if (inherited && (links == null || links.size() == 0) && source != null) { links = getLicense(source, false); } if (inherited && (links == null || links.size() == 0) && parent != null) { links = getLicense(parent, false); } } return links; }
/** * Adds a prev-archive link relation to the feed * * @param feed The feed * @param iri The IRI of the previous archive feed document * @return The newly created Link */ public static Link setPreviousArchive(Source feed, String iri) { Link link = feed.getLink("prev-archive"); if (link == null) { // try the full IANA URI version link = feed.getLink(Link.IANA_BASE + "prev-archive"); } if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "prev-archive"); } return link; }
/** * Adds a current link relation to the feed * * @param feed The feed * @param iri The IRI of the current feed document * @return The newly created Link */ public static Link setCurrent(Source feed, String iri) { Link link = feed.getLink("current"); if (link == null) { // try the full IANA URI version link = feed.getLink(Link.IANA_BASE + "current"); } if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "current"); } return link; }
/** * Adds a last link relation to the feed * * @param feed The feed * @param iri The IRI of the last feed document * @return The newly created Link */ public static Link setLast(Source feed, String iri) { Link link = feed.getLink("last"); if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "last"); } return link; }
/** * Adds a next link relation to the feed * * @param feed The feed * @param iri The IRI of the next feed document * @return The newly created Link */ public static Link setNext(Source feed, String iri) { Link link = feed.getLink("next"); if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "next"); } return link; }
/** * Adds a previous link relation to the feed * * @param feed The feed * @param iri The IRI of the previous feed document * @return The newly created Link */ public static Link setPrevious(Source feed, String iri) { Link link = feed.getLink("previous"); if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "previous"); } return link; }
/** * Adds a first link relation to the feed * * @param feed The feed * @param iri The IRI of the first feed document * @return The newly created Link */ public static Link setFirst(Source feed, String iri) { Link link = feed.getLink("first"); if (link != null) { link.setHref(iri); } else { link = feed.addLink(iri, "first"); } return link; }