Examples of UriTemplateMatcher


Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

        } catch (IllegalStateException e) {
        }

        // compiled but not matched
        processor.compile("/path1/{var1}");
        UriTemplateMatcher matcher = processor.matcher();
        assertFalse(matcher.matches("/path2"));

        try {
            matcher.getVariables(false);
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getVariableValue("var1");
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getVariableValue("var1", false);
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getVariableValues("var1");
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getVariableValues("var1", false);
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getTail();
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }

        try {
            matcher.getTail(false);
            fail("expected IllegalStateException to be thrown");
        } catch (IllegalStateException e) {
        }
    }
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

         * expensive UriTemplateMatcher.matches()
         */
        previousMatched = uriToResourceCache.get(isContinuedSearchPolicy).get(uri);
        if (previousMatched != null) {
            for (ResourceRecord record : previousMatched) {
                UriTemplateMatcher matcher = record.getTemplateProcessor().matcher();
                if (matcher.matches(uri)) {
                    found.add(new ResourceInstance(record, matcher));
                }
            }
            return found;
        }

        readersLock.lock();
        try {

            previousMatched = new ArrayList<ResourceRecord>();

            // the list of root resource records is already sorted
            for (ResourceRecord record : rootResources) {
                UriTemplateMatcher matcher = record.getTemplateProcessor().matcher();
                if (matcher.matches(uri)) {
                    if (matcher.isExactMatch() || record.hasSubResources()) {
                        previousMatched.add(record);
                        found.add(new ResourceInstance(record, matcher));
                        if (!isContinuedSearchPolicy) {
                            break;
                        }
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

                                                             boolean method,
                                                             boolean locator) {
        List<SubResourceInstance> list = new LinkedList<SubResourceInstance>();
        // add records according to the request uri
        for (SubResourceRecord record : subResources) {
            UriTemplateMatcher matcher = record.getTemplateProcessor().matcher();
            // if the uri is a match to the uri template
            if (matcher.matches(uri)) {
                if (method && record instanceof SubResourceMethodRecord && matcher.isExactMatch()) {
                    list.add(new SubResourceInstance(record, matcher));
                }
                if (locator && record instanceof SubResourceLocatorRecord) {
                    list.add(new SubResourceInstance(record, matcher));
                }
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = templateMatcher.getTail(false);
        if (tail == null) {
            tail = ""; //$NON-NLS-1$
        }
        if (tail.startsWith("/")) { //$NON-NLS-1$
            tail = tail.substring(1);
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

                                         HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();
        SubResourceRecord subResourceRecord = subResourceInstance.getRecord();
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();
        String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
        // dispatch to one of the sub-resource methods.
        SubResourceInstance method = null;
        try {
            // if no method is found then a RequestMatchingException exception
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

                                          List<SubResourceInstance> subResources,
                                          MessageContext context,
                                          HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();

        // // dispatch to the sub-resource locator.
        // result.setFound(true);
        // result.setMethod(subResourceInstance);
        // // save the matched template variables for UriInfo
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

        pattern = Pattern.compile(".*");
      }
     
    };
    processor.compile("{.*}");
    final UriTemplateMatcher uriTemplateMatcher = processor.matcher();
    uriTemplateMatcher.match("foo");
    return new ResourceInstance(rootResource,
        new ResourceRecord(metadata, objectFactory, processor), uriTemplateMatcher);
  }
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = templateMatcher.getTail(false);
        if (tail == null) {
            tail = ""; //$NON-NLS-1$
        }
        if (tail.startsWith("/")) { //$NON-NLS-1$
            tail = tail.substring(1);
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

            // couldn't find a method
            result.setError(e);
            return;
        }

        UriTemplateMatcher matcher = method.getMatcher();
        saveFoundMethod(result, matcher, method, context);

        // continue the chain to invoke the method
        if (logger.isTraceEnabled()) {
            MethodMetadata metadata = (method == null) ? null : method.getMetadata();
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateMatcher

                                          List<SubResourceInstance> subResources,
                                          MessageContext context,
                                          HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();

        // // dispatch to the sub-resource locator.
        // result.setFound(true);
        // result.setMethod(subResourceInstance);
        // // save the matched template variables for UriInfo
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.