Package javax.ws.rs.core

Examples of javax.ws.rs.core.PathSegment


      @Produces("text/plain")
      public String getFromUriInfo(@Context UriInfo info)
      {
         String make = info.getPathParameters().getFirst("make");
         String year = info.getPathParameters().getFirst("year");
         PathSegment model = info.getPathSegments().get(3);
         String color = model.getMatrixParameters().getFirst("color");

         return "A " + color + " " + year + " " + make + " " + model.getPath();
      }
View Full Code Here


   
    private String buildPath(boolean fromEncoded) {
        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 = fromEncoded ? new URITemplate(p).encodeLiteralCharacters() : p;
                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(), fromEncoded);
                }
            }
        }
        buildMatrix(sb, matrix, fromEncoded);
        return sb.toString();
View Full Code Here

        if (value == null) {
            return null;
        }
       
        if (pType == ParameterType.PATH) {
            PathSegment ps = new PathSegmentImpl(value, false);   
            if (PathSegment.class.isAssignableFrom(pClass)) {
                return ps;  
            } else {
                value = ps.getPath();                
            }
        }
       
        if (pClass.isPrimitive()) {
            try {
View Full Code Here

            }
            List<String> allValues = new ArrayList<String>();
            List<PathSegment> segments =
                runtimeContext.getAttribute(SearchResult.class).getData().getMatchedURIs().get(0);
            // get the matrix parameter only from the last segment
            PathSegment segment = segments.get(segments.size() - 1);
            MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
            List<String> values = matrixParameters.get(getName());
            if (values != null) {
                allValues.addAll(values);
            }
View Full Code Here

            List<PathSegment> segments = pathSegmentsMap.getFirst(getName());
            if (segments != null && segments.size() > 0) {
                // special handling for PathSegment
                if (isTypeOf(PathSegment.class)) {
                    // return only the last segment
                    PathSegment segment = segments.get(segments.size() - 1);
                    if (!isEncoded()) {
                        segment = PathSegmentImpl.decode(segment);
                    }
                    return segment;
                }
View Full Code Here

            }
            List<String> allValues = new ArrayList<String>();
            List<PathSegment> segments =
                runtimeContext.getAttribute(SearchResult.class).getData().getMatchedURIs().get(0);
            // get the matrix parameter only from the last segment
            PathSegment segment = segments.get(segments.size() - 1);
            MultivaluedMap<String, String> matrixParameters = segment.getMatrixParameters();
            List<String> values = matrixParameters.get(getName());
            if (values != null) {
                allValues.addAll(values);
            }
View Full Code Here

            List<PathSegment> segments = pathSegmentsMap.getFirst(getName());
            if (segments != null && segments.size() > 0) {
                // special handling for PathSegment
                if (isTypeOf(PathSegment.class)) {
                    // return only the last segment
                    PathSegment segment = segments.get(segments.size() - 1);
                    if (!isEncoded()) {
                        segment = PathSegmentImpl.decode(segment);
                    }
                    return segment;
                }
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(boolean fromEncoded) {
        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 = fromEncoded ? new URITemplate(p).encodeLiteralCharacters() : p;
                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(), fromEncoded);
                }
            }
        }
        buildMatrix(sb, matrix, fromEncoded);
        return sb.toString();
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.