Package javax.ws.rs.core

Examples of javax.ws.rs.core.PathSegment


        if (l.isEmpty()) {
            return;
        }

        // Get the last non-empty path segment
        PathSegment segment = null;
        for (int i = l.size() - 1; i >= 0; i--) {
            segment = l.get(i);
            if (segment.getPath().length() > 0) {
                break;
            }
        }
        if (segment == null) {
            return;
        }

        final int length = path.length();

        // Get the suffixes
        final String[] suffixes = segment.getPath().split("\\.");

        for (int i = suffixes.length - 1; i >= 1; i--) {
            final String suffix = suffixes[i];
            if (suffix.length() == 0) {
                continue;
View Full Code Here


        }

        @Override
        public Object provide() {
            List<PathSegment> l = getContainerRequest().getUriInfo().getPathSegments(decode);
            PathSegment p = l.get(l.size() - 1);
            try {
                return extractor.extract(p.getMatrixParameters());
            } catch (ExtractorException e) {
                throw new ParamException.MatrixParamException(e.getCause(),
                        extractor.getName(), extractor.getDefaultValueString());
            }
        }
View Full Code Here

        } else {
            segments = new ArrayList<PathSegment>();
            segments.add(new PathSegmentImpl(path.replaceAll("/", "%2F"), false));
        }
        if (!paths.isEmpty() && !matrix.isEmpty()) {
            PathSegment ps = paths.remove(paths.size() - 1);
            paths.add(replacePathSegment(ps));
        }
        paths.addAll(segments);
        matrix.clear();
        if (!paths.isEmpty()) {
View Full Code Here

   
    private String buildPath() {
        StringBuilder sb = new StringBuilder();
        Iterator<PathSegment> iter = paths.iterator();
        while (iter.hasNext()) {
            PathSegment ps = iter.next();
            String p = ps.getPath();
            if (p.length() != 0 || !iter.hasNext()) {
                p = new URITemplate(p).encodeLiteralCharacters(false);
                if (sb.length() == 0 && leadingSlash) {
                    sb.append('/');
                } else if (!p.startsWith("/") && sb.length() > 0) {
                    sb.append('/');
                }
                sb.append(p);
                if (iter.hasNext()) {
                    buildMatrix(sb, ps.getMatrixParameters());
                }
            }
        }
        buildMatrix(sb, matrix);
        return sb.toString();
View Full Code Here

                                                               new ClassResourceInfo(Customer.class)),
                                                           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

        Message m = new MessageImpl();
       
       
        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

        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

    private static String PATH_WITH_ONE_MATRIX        = "matrix;a=a1";
    private static String PATH_WITH_TWO_MATRIX        = "matrix;a=a1;b=b1";
    private static String PATH_WITH_TWO_MATRIX_VALUES = "matrix;a=a1;a=a2;b=b1";

    public void testPathSegmentClean() {
        PathSegment segment = new PathSegmentImpl(PATH_CLEAN);
        assertEquals(PATH_CLEAN, segment.getPath());
        MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
        assertNotNull(matrixParameters);
        assertEquals(0, matrixParameters.size());
    }
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.