Package org.ocpsoft.rewrite.param

Examples of org.ocpsoft.rewrite.param.RegexConstraint


                  context.getJavaField().getName());
      }

      // add a corresponding RegexConstraint
      String expr = annotation.value();
      parameterBuilder.constrainedBy(new RegexConstraint(expr));

      if (log.isTraceEnabled()) {
         log.trace("Parameter [{}] has been constrained by [{}]", parameterBuilder.getName(), expr);
      }
View Full Code Here


   {
      if (captureIn != null)
      {
         Parameter<?> parameter = store.get(captureIn);
         if (parameter instanceof ConfigurableParameter<?>)
            ((ConfigurableParameter<?>) parameter).constrainedBy(new RegexConstraint(".*"));
      }
      if (withRequestBinding)
      {
         for (String param : getRequiredParameterNames())
         {
View Full Code Here

   {
      if (captureIn != null)
      {
         Parameter<?> parameter = store.get(captureIn);
         if (parameter instanceof ConfigurableParameter<?>)
            ((ConfigurableParameter<?>) parameter).constrainedBy(new RegexConstraint(".*"));
      }
      if (withRequestBinding)
      {
         for (String param : getRequiredParameterNames()) {
            Parameter<?> parameter = store.get(param);
View Full Code Here

   }

   @Test
   public void testQueryStringMatchesPattern()
   {
      store.get("x", new DefaultParameter("x").constrainedBy(new RegexConstraint(".*&one=1.*")));
      Query query = Query.matches("{x}");
      query.setParameterStore(store);
      Assert.assertTrue(query.evaluate(rewrite, context));
   }
View Full Code Here

   }

   @Test
   public void testQueryStringBindsToEntireValue()
   {
      store.get("x", new DefaultParameter("x").constrainedBy(new RegexConstraint(".*&one=1.*")));
      Query query = Query.matches("{x}");
      query.setParameterStore(store);
      Assert.assertTrue(query.evaluate(rewrite, context));

      Assert.assertTrue(query.evaluate(rewrite, context));
View Full Code Here

      ParameterUtils.initialize(context, header);

      ParameterStore parameters = DefaultParameterStore.getInstance(context);
      Parameter<?> parameter = parameters.get("enc");
      if (parameter instanceof ConfigurableParameter<?>)
         ((ParameterConfiguration<?>) parameter).constrainedBy(new RegexConstraint("(ISO|UTF)-\\d+"));

      Assert.assertTrue(header.evaluate(rewrite, context));
   }
View Full Code Here

      MockEvaluationContext context = new MockEvaluationContext();
      ParameterUtils.initialize(context, url);

      ParameterStore store = DefaultParameterStore.getInstance(context);
      ((ParameterConfiguration<?>) store .get("prefix")).constrainedBy(new RegexConstraint(".*"));
      ((ParameterConfiguration<?>) store.get("suffix")).constrainedBy(new RegexConstraint("\\?.*"));

      Assert.assertTrue(url.evaluate(rewrite, context));
   }
View Full Code Here

      ParameterUtils.initialize(context, parameter);
      Assert.assertTrue(parameter.evaluate(rewrite, context));

      ParameterStore store = DefaultParameterStore.getInstance(context);
      Parameter<?> p = store.get("value");
      ((ParameterConfiguration<?>) p).constrainedBy(new RegexConstraint("(bar|baz)"));
      Assert.assertFalse(parameter.evaluate(rewrite, context));
   }
View Full Code Here

      RequestParameter parameter = RequestParameter.matchesAll("{name}", "{value}");
      MockEvaluationContext context = new MockEvaluationContext();
      ParameterUtils.initialize(context, parameter);

      ParameterStore store = DefaultParameterStore.getInstance(context);
      ((ParameterConfiguration<?>) store.get("value")).constrainedBy(new RegexConstraint("nothing"));
      Assert.assertFalse(parameter.evaluate(rewrite, context));
   }
View Full Code Here

      RequestParameter requestParam = RequestParameter.matchesAll("{name}", "{value}");
      MockEvaluationContext context = new MockEvaluationContext();
      ParameterUtils.initialize(context, requestParam);

      ParameterStore store = DefaultParameterStore.getInstance(context);
      ((ParameterConfiguration<?>) store.get("name")).constrainedBy(new RegexConstraint("nothing"));
      Assert.assertFalse(requestParam.evaluate(rewrite, new MockEvaluationContext()));
   }
View Full Code Here

TOP

Related Classes of org.ocpsoft.rewrite.param.RegexConstraint

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.