Package javax.ws.rs.core

Examples of javax.ws.rs.core.PathSegment


        Message m = createMessage();
       
       
        List<Object> params =
            JAXRSUtils.processParameters(ori, values, m);
        PathSegment ps = (PathSegment)params.get(0);
        assertEquals("1", ps.getPath());
       
        SimpleFactory sf = (SimpleFactory)params.get(1);
        assertEquals(2, sf.getId());
    }
View Full Code Here


    @GET
    @Produces("text/plain")
    @Path("b")
    public String getB(@Context UriInfo uriInfo) {
        final PathSegment pSeg = TestUtils.getLastElement(uriInfo
                .getPathSegments());
        final String vorname = pSeg.getMatrixParameters().getFirst("firstname");
        final String nachname = pSeg.getMatrixParameters().getFirst("lastname");
        return vorname + " " + nachname;
    }
View Full Code Here

    @GET
    @Produces("text/plain")
    public String get(@MatrixParam("firstname") String firstname,
            @MatrixParam("lastname") String lastname, @Context UriInfo uriInfo) {
        final List<PathSegment> pathSegents = uriInfo.getPathSegments();
        final PathSegment lastPathSegm = pathSegents.get(0);
        final MultivaluedMap<String, String> mp = lastPathSegm
                .getMatrixParameters();
        if (mp.isEmpty()) {
            final ResponseBuilder rb = Response.status(Status.NOT_FOUND);
            rb.entity("matrix parameters are empty");
            throw new WebApplicationException(rb.build());
View Full Code Here

     */
    private void checkPathSegments(List<PathSegment> pathSegments,
            String path0, int tpSize0, String path1, int tpSize1, String path2,
            int tpSize2) {
        assertEquals(3, pathSegments.size());
        final PathSegment pathSegment0 = pathSegments.get(0);
        final PathSegment pathSegment1 = pathSegments.get(1);
        final PathSegment pathSegment2 = pathSegments.get(2);
        assertEquals(path0, pathSegment0.getPath());
        assertEquals(tpSize0, pathSegment0.getMatrixParameters().size());
        assertEquals(path1, pathSegment1.getPath());
        assertEquals(tpSize1, pathSegment1.getMatrixParameters().size());
        assertEquals(path2, pathSegment2.getPath());
        assertEquals(tpSize2, pathSegment2.getMatrixParameters().size());
    }
View Full Code Here

            return true;
        }
        if (!(object instanceof PathSegmentImpl)) {
            return false;
        }
        final PathSegment other = (PathSegment) object;
        if (!getPath().equals(other.getPath())) {
            return false;
        }
        if (!getMatrixParameters().equals(other.getMatrixParameters())) {
            return false;
        }
        return true;
    }
View Full Code Here

        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           values,
                                                           messageImpl);
        assertEquals("2 params should've been identified", 2, params.size());
       
        PathSegment ps = (PathSegment)params.get(0);
        assertEquals("bar foo", ps.getPath());
        assertEquals(1, ps.getMatrixParameters().size());
        assertEquals("0 1", ps.getMatrixParameters().getFirst("p4"));
        assertEquals("bar foo", params.get(1));
    }
View Full Code Here

        Message m = createMessage();
       
       
        List<Object> params =
            JAXRSUtils.processParameters(ori, values, m);
        PathSegment ps = (PathSegment)params.get(0);
        assertEquals("1", ps.getPath());
       
        SimpleFactory sf = (SimpleFactory)params.get(1);
        assertEquals(2, sf.getId());
    }
View Full Code Here

    if ((segments == null) || (segments.size() == 0)) {
      return null;
    }

    PathSegment lastPathSegment = (PathSegment) segments.toArray()[segments.size() - 1];
    return lastPathSegment.getMatrixParameters();
  }
View Full Code Here

      path = "/" + path;
    }

    String[] subPaths = path.split("/");
    if (subPaths.length == 0) {
      PathSegment pathSegment = new PathSegmentImpl("", new MultivaluedMapImpl());
      pathSegments.add(pathSegment);
      return pathSegments;
    }

    for (String subPath : subPaths) {
      if (subPath.length() == 0) {
        continue;
      }
      MultivaluedMap<String, String> matrixMap = null;

      int colon = subPath.indexOf(';');
      if (colon != -1) {
        String matrixParameters = subPath.substring(colon + 1);
        subPath = (colon == 0) ? "" : subPath.substring(0, colon);
        matrixMap = extractPathParameters(matrixParameters, ";", decode);
      }

      if (decode) {
        subPath = UriEncoder.decodeString(subPath);
      }
      PathSegment pathSegment = new PathSegmentImpl(subPath, matrixMap);
      pathSegments.add(pathSegment);
    }

    return pathSegments;
  }
View Full Code Here

        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
                                                           values,
                                                           messageImpl);
        assertEquals("2 params should've been identified", 2, params.size());
       
        PathSegment ps = (PathSegment)params.get(0);
        assertEquals("bar foo", ps.getPath());
        assertEquals(1, ps.getMatrixParameters().size());
        assertEquals("0 1", ps.getMatrixParameters().getFirst("p4"));
        assertEquals("bar foo", params.get(1));
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.PathSegment

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.