Java Code Examples for javax.ws.rs.core.Link#getRel()
The following examples show how to use
javax.ws.rs.core.Link#getRel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceSupport.java From container with Apache License 2.0 | 6 votes |
@Override public void serialize(final Link link, final JsonGenerator json, final SerializerProvider provider) throws IOException { if (link.getUri() == null || link.getRel() == null || link.getRel().isEmpty()) { return; } json.writeObjectFieldStart(link.getRel()); json.writeStringField("href", link.getUri().toString()); if (link.getTitle() != null && !link.getTitle().isEmpty()) { json.writeStringField(Link.TITLE, link.getTitle()); } if (link.getType() != null && !link.getType().isEmpty()) { json.writeStringField(Link.TYPE, link.getType()); } json.writeEndObject(); }
Example 2
Source File: LinkHeaderProvider.java From cxf with Apache License 2.0 | 5 votes |
public String toString(Link link) { StringBuilder sb = new StringBuilder(); sb.append('<'); sb.append(link.getUri()); sb.append('>'); String rels = link.getRel(); if (!rels.isEmpty()) { sb.append(';').append(REL).append('='); writeListParamValues(sb, rels); } if (link.getTitle() != null) { sb.append(';').append(TITLE).append("=\"").append(link.getTitle()).append('"'); } if (link.getType() != null) { sb.append(';').append(TYPE).append('=').append(link.getType()); } for (Map.Entry<String, String> entry : link.getParams().entrySet()) { if (KNOWN_PARAMETERS.contains(entry.getKey())) { continue; } sb.append(';').append(entry.getKey()).append('='); writeListParamValues(sb, entry.getValue()); } return sb.toString(); }
Example 3
Source File: ResponseImpl.java From cxf with Apache License 2.0 | 5 votes |
public Link getLink(String relation) { Set<Link> links = getAllLinks(); for (Link link : links) { if (link.getRel() != null && link.getRel().equals(relation)) { return link; } } return null; }
Example 4
Source File: LinkHeaderProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testFromComplexString() { Link l = Link.valueOf("<http://bar>;rel=next;title=\"Next Link\";type=text/xml;method=get"); assertEquals("http://bar", l.getUri().toString()); String rel = l.getRel(); assertEquals("next", rel); assertEquals("Next Link", l.getTitle()); assertEquals("text/xml", l.getType()); assertEquals("get", l.getParams().get("method")); }