protected Element generateLinkElement(Link link) {
    Element linkElement = new Element("link", getFeedNamespace());

    if (link.getRel() != null) {
      Attribute relAttribute = new Attribute("rel", link.getRel());
      linkElement.setAttribute(relAttribute);
    }

    if (link.getType() != null) {
      Attribute typeAttribute = new Attribute("type", link.getType());
      linkElement.setAttribute(typeAttribute);
    }

    if (link.getHref() != null) {
      Attribute hrefAttribute = new Attribute("href", link.getHref());
      linkElement.setAttribute(hrefAttribute);
    }

    if (link.getHreflang() != null) {
      Attribute hreflangAttribute = new Attribute("hreflang", link.getHreflang());
      linkElement.setAttribute(hreflangAttribute);
    }
    if (link.getTitle() != null) {
      Attribute title = new Attribute("title", link.getTitle());
      linkElement.setAttribute(title);
    }
    if (link.getLength() != 0) {
      Attribute lenght = new Attribute("length", Long.toString(link.getLength()));
      linkElement.setAttribute(lenght);
    }
    return linkElement;
  }
Ejemplo n.º 2
0
 /** Get the URI that can be used to edit the entry via HTTP PUT or DELETE. */
 public String getEditURI() {
   for (int i = 0; i < getOtherLinks().size(); i++) {
     Link link = (Link) getOtherLinks().get(i);
     if (link.getRel() != null && link.getRel().equals("edit")) {
       return link.getHrefResolved();
     }
   }
   return null;
 }
Ejemplo n.º 3
0
 // List(Elements) -> List(Link)
 private List<Link> parseAlternateLinks(
     final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {
   final List<Link> links = new ArrayList<Link>();
   for (int i = 0; i < eLinks.size(); i++) {
     final Element eLink = eLinks.get(i);
     final Link link = parseLink(feed, entry, baseURI, eLink);
     if (link.getRel() == null
         || "".equals(link.getRel().trim())
         || "alternate".equals(link.getRel())) {
       links.add(link);
     }
   }
   if (links.size() > 0) {
     return links;
   } else {
     return null;
   }
 }