Package javax.ws.rs.core

Examples of javax.ws.rs.core.Link$Builder


        if (linkValues == null) {
            return Collections.emptyMap();
        } else {
            Map<String, Link> links = new HashMap<String, Link>();
            for (Object o : linkValues) {
                Link link = Link.valueOf(o.toString());
                links.put(link.getRel(), link);
            }
            return links;
        }
    }
View Full Code Here


       
        meta.add(HttpHeaders.LINK, "<http://next>;rel=next");
        meta.add(HttpHeaders.LINK, "<http://prev>;rel=prev");
       
        assertTrue(ri.hasLink("next"));
        Link next = ri.getLink("next");
        assertNotNull(next);
        assertTrue(ri.hasLink("prev"));
        Link prev = ri.getLink("prev");
        assertNotNull(prev);
       
        Set<Link> links = ri.getLinks();
        assertTrue(links.contains(next));
        assertTrue(links.contains(prev));
       
        assertEquals("http://next", next.getUri().toString());
        assertEquals("next", next.getRel());
        assertEquals("http://prev", prev.getUri().toString());
        assertEquals("prev", prev.getRel());
    }
View Full Code Here

        if (linkValues == null) {
            return Collections.emptyMap();
        } else {
            Map<String, Link> links = new HashMap<String, Link>();
            for (Object o : linkValues) {
                Link link = Link.valueOf(o.toString());
                links.put(link.getRel(), link);
            }
            return links;
        }
    }
View Full Code Here

     * @param relation link relation.
     * @return the link builder for the relation, otherwise {@code null} if not
     *         present.
     */
    public Link.Builder getLinkBuilder(String relation) {
        Link link = getLink(relation);
        if (link == null) {
            return null;
        }

        return Link.fromLink(link);
View Full Code Here

     * @param relation link relation.
     * @return the link builder for the relation, otherwise {@code null} if not
     *         present.
     */
    public Link.Builder getLinkBuilder(String relation) {
        Link link = getLink(relation);
        if (link == null) {
            return null;
        }

        return Link.fromLink(link);
View Full Code Here

    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof Link) {
            final Link otherLink = (Link) other;
            return uri.equals(otherLink.getUri()) && params.equals(otherLink.getParams());
        }
        return false;
    }
View Full Code Here

public class LinkHeaderProviderTest extends Assert {
   
    @Test
    public void testFromSimpleString() {
        Link l = Link.valueOf("<http://bar>");
        assertEquals("http://bar", l.getUri().toString());
    }
View Full Code Here

        assertEquals("/", l.getUri().toString());
    }
   
    @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"));
    }
View Full Code Here

   
    @Test
    public void testToString() {
        String headerValue = "<http://bar>;rel=next;title=\"Next Link\";type=text/xml;method=get";
        String expected = "<http://bar>;rel=\"next\";title=\"Next Link\";type=\"text/xml\";method=\"get\"";
        Link l = Link.valueOf(headerValue);
        String result = l.toString();
        assertEquals(expected, result);
    }
View Full Code Here

        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
        m.add("Link", Link.valueOf("<http://example.com/page1>;rel=\"previous\""));
        m.add("Link", Link.valueOf("<http://example.com/page3>;rel=\"next\""));
        RuntimeDelegateImpl delegate = new RuntimeDelegateImpl();
        Link.Builder linkBuilder = delegate.createLinkBuilder();
        Link prevLink = linkBuilder.uri("http://example.com/page1").rel("previous").build();
        // Reset linkbuilder
        linkBuilder = delegate.createLinkBuilder();
        Link nextLink = linkBuilder.uri("http://example.com/page3").rel("next").build();
        checkBuild(Response.ok().links(prevLink, nextLink).build(), 200, null, m);
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Link$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.