public Link getLocationLink() { if (location != null) return location; if (!headers.containsKey("Location")) return null; String header = headers.getFirst("Location"); location = new Link(); location.setHref(header); location.setExecutor(executor); return location; }
@Override public Link getHeaderAsLink(String headerName) { String value = headers.getFirst(headerName); if (value == null) return null; String type = headers.getFirst(headerName + "-type"); Link link = new Link(); link.setHref(value); link.setType(type); link.setExecutor(executor); return link; }
public LinkHeader getLinkHeader() { if (linkHeader != null) return linkHeader; linkHeader = new LinkHeader(); if (!headers.containsKey("Link")) { return linkHeader; } List<String> links = headers.get("Link"); LinkHeaderDelegate delegate = new LinkHeaderDelegate(); for (String link : links) { LinkHeader tmp = delegate.fromString(link); linkHeader.getLinks().addAll(tmp.getLinks()); linkHeader.getLinksByRelationship().putAll(tmp.getLinksByRelationship()); linkHeader.getLinksByTitle().putAll(tmp.getLinksByTitle()); } for (Link link : linkHeader.getLinks()) { link.setExecutor(executor); } return linkHeader; }