protected Link selectLink(List<Link> links, String type, String hreflang) { for (Link link : links) { MimeType mt = link.getMimeType(); boolean typematch = MimeTypeHelper.isMatch((mt != null) ? mt.toString() : null, type); boolean langmatch = "*".equals(hreflang) || ((hreflang != null) ? hreflang.equals(link.getHrefLang()) : link.getHrefLang() == null); if (typematch && langmatch) return link; } return null; }
public static Link selectLink(List<Link> links, String type, String hreflang) { for (Link link : links) { MimeType mt = link.getMimeType(); boolean typematch = MimeTypeHelper.isMatch((mt != null) ? mt.toString() : null, type); boolean langmatch = "*".equals(hreflang) || ((hreflang != null) ? hreflang.equals(link.getHrefLang()) : link.getHrefLang() == null); if (typematch && langmatch) return link; } return null; } }
public static String getEditUriFromEntry(Entry entry) { String editUri = null; List<Link> editLinks = entry.getLinks("edit"); if (editLinks != null) { for (Link link : editLinks) { // if there is more than one edit link, we should not automatically // assume that it's always going to point to an Atom document // representation. if (link.getMimeType() != null) { if (MimeTypeHelper.isMatch(link.getMimeType().toString(), Constants.ATOM_MEDIA_TYPE)) { editUri = link.getResolvedHref().toString(); break; } } else { // edit link with no type attribute is the right one to use editUri = link.getResolvedHref().toString(); break; } } } return editUri; }
public static InReplyTo addInReplyTo(Entry entry, Entry ref) { if (ref.equals(entry)) return null; InReplyTo irt = addInReplyTo(entry); try { irt.setRef(ref.getId()); Link altlink = ref.getAlternateLink(); if (altlink != null) { irt.setHref(altlink.getResolvedHref()); if (altlink.getMimeType() != null) irt.setMimeType(altlink.getMimeType()); } Source src = ref.getSource(); if (src != null) { Link selflink = src.getSelfLink(); if (selflink != null) irt.setSource(selflink.getResolvedHref()); } } catch (Exception e) { } return irt; }
jstream.writeField("rel", link.getRel()); jstream.writeField("title", link.getTitle()); jstream.writeField("type", link.getMimeType()); jstream.writeField("hreflang", link.getHrefLang()); if (link.getLength() > -1) {