Package org.apache.clerezza.triaxrs.util

Examples of org.apache.clerezza.triaxrs.util.URITemplate


import org.apache.clerezza.triaxrs.util.URITemplate;

public class URITemplateTest {
  @Test
  public void simpleTemplateMatching() {
    Assert.assertNull(new URITemplate("/foo/bar").match("/foo"));
    Assert.assertNotNull(new URITemplate("/foo").match("/foo/bar"));
    Assert.assertNotNull(new URITemplate("foo").match("/foo/bar"));
  }
View Full Code Here


    Assert.assertNotNull(new URITemplate("foo").match("/foo/bar"));
  }
 
  @Test
  public void simpleParameterizedeMatching() {
    URITemplate template1 = new URITemplate("widgets/{id}");
    Assert.assertEquals("Hello", template1.match(
        "widgets/Hello").getParameters().get("id"));
    URITemplate template2 = new URITemplate("widgets/{id}/{id2}");
    Assert.assertEquals("foo", template2.match(
        "widgets/foo/bar").getParameters().get("id"));
    Assert.assertEquals("foo", template2.match(
    "widgets/foo/bar/ignore").getParameters().get("id"));
    SortedSet<URITemplate> set = new TreeSet<URITemplate>();
    set.add(template1);
    set.add(template2);
    Assert.assertEquals(template2, set.first());
View Full Code Here

   * @param method a sub-resource method or sub-resource locator
   * @param encodedPathTemplate
   */
  MethodDescriptor(Method method, String encodedPathTemplate) {
    this.method = method;
    this.uriTemplate = new URITemplate(encodedPathTemplate)
    subResourceLocator = !MethodUtil.isResourceMethod(method);
  }
View Full Code Here

      Map<String, String> inheritedPathParams) throws HandlerException,
      UnsupportedFieldType {
    SortedSet<MethodDescriptor> methodDescriptors = getSubThingMethodDescriptors(instance.getClass());
    Set<Method> result;
    result = new HashSet<Method>();
    URITemplate uriTemplateOfFirstMatchingRM = null;
    Map<String, String> subPathParam = null;
    for (MethodDescriptor methodDescriptor : methodDescriptors) {
      final URITemplate currentUriTemplate = methodDescriptor.getUriTemplate();
      if (uriTemplateOfFirstMatchingRM != null) {
        if (uriTemplateOfFirstMatchingRM.equals(currentUriTemplate)
            && !methodDescriptor.isSubResourceLocator()) {
          result.add(methodDescriptor.getMethod());
          method2PathParams.put(methodDescriptor.getMethod(),
              subPathParam);
          continue;
        }
        break;
      }
      PathMatching subPathMatching = currentUriTemplate.match(remainingPath);
      if (subPathMatching == null) {
        continue;
      }
      subPathParam = new HashMap<String, String>(inheritedPathParams);
      subPathParam.putAll(subPathMatching.getParameters());
View Full Code Here

  private Object instance;
  private Logger logger = LoggerFactory.getLogger(RootResourceDescriptor.class);

  public RootResourceDescriptor(Class<?> clazz, String pathTemplate) {
    super();
    uriTemplate = new URITemplate(pathTemplate);
    this.clazz = clazz;
  //store methods of the class
  //httpMethodsOfClass = ReflectionUtil.getMethodsOfClass(clazz);
  }
View Full Code Here

  }

  public RootResourceDescriptor(Class<?> clazz, Object instance,
      String pathTemplate, Providers providers) {
    super();
    uriTemplate = new URITemplate(pathTemplate);
    this.clazz = clazz;
    this.instance = instance;
    if (instance != null) {
      try {
        WebRequest requestProxy = WebRequestProxy.createProxy();
View Full Code Here

TOP

Related Classes of org.apache.clerezza.triaxrs.util.URITemplate

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.