Package org.ocpsoft.rewrite.param

Examples of org.ocpsoft.rewrite.param.ParameterStore


   private boolean handleBindings(final Rewrite event, final EvaluationContextImpl context,
            ParameterValueStore values)
   {
      boolean result = true;
      ParameterStore store = (ParameterStore) context.get(ParameterStore.class);

      for (Entry<String, Parameter<?>> entry : store) {
         Parameter<?> parameter = entry.getValue();
         String value = values.retrieve(parameter);
View Full Code Here


               public void call(Parameterized parameterized)
               {
                  Set<String> names = parameterized.getRequiredParameterNames();
                  if (rule instanceof RuleBuilder)
                  {
                     ParameterStore store = ((RuleBuilder) rule).getParameterStore();

                     for (Entry<String, Parameter<?>> entry : parent) {
                        String name = entry.getKey();
                        Parameter<?> parentParam = entry.getValue();

                        if (!store.contains(name)) {
                           store.get(name, parentParam);
                        }
                        else
                        {
                           Parameter<?> parameter = store.get(name);
                           for (Binding binding : parameter.getBindings()) {
                              if (!parentParam.getBindings().contains(binding))
                                 throwRedefinitionError(rule, name);
                           }

                           for (Constraint<?> constraint : parameter.getConstraints()) {
                              if (!parentParam.getConstraints().contains(constraint))
                                 throwRedefinitionError(rule, name);
                           }

                           for (Transposition<?> transposition : parameter.getTranspositions()) {
                              if (!parentParam.getTranspositions().contains(transposition))
                                 throwRedefinitionError(rule, name);
                           }

                           if (parentParam.getConverter() != null
                                    && !parentParam.getConverter().equals(parameter.getConverter()))
                              throwRedefinitionError(rule, name);

                           if (parentParam.getValidator() != null
                                    && !parentParam.getValidator().equals(parameter.getValidator()))
                              throwRedefinitionError(rule, name);
                        }
                     }

                     for (String name : names) {
                        Parameter<?> parameter = store.get(name, new DefaultParameter(name));
                        if (parameter instanceof ConfigurableParameter<?>)
                           ((ConfigurableParameter<?>) parameter).bindsTo(Evaluation.property(name));
                     }
                     parameterized.setParameterStore(store);
                  }
View Full Code Here

                      * use a converter to directly bind and store the object we want into a binding. {@link Evaluation}
                      * is an low-level construct, and binds array values that must be dereferenced. If using other
                      * bindings such as {@link El}, the value will be bound directly to the type of the referenced
                      * property type, and this array downcast is not necessary.
                      */
                     ParameterStore store = (ParameterStore) context.get(ParameterStore.class);
                     Product product = (Product) Evaluation.property("pid").retrieveConverted(event, context,
                              store.get("pid"));

                     /**
                      * Marshal the Product into XML using JAXB. This has been extracted into a utility class.
                      */
                     try {
View Full Code Here

   @Test
   public void testMultipleParameterStoreInvocationsReturnSameParam()
   {
      Path path = Path.matches("/something/#{param}");
      ParameterStore store = new DefaultParameterStore();
      ParameterUtils.initialize(store, path);

      Parameter<?> p1 = store.get("param");
      Parameter<?> p2 = store.get("param");
      assertTrue(p1 == p2);
   }
View Full Code Here

   private boolean handleBindings(final HttpServletRewrite event, final EvaluationContextImpl context,
            DefaultParameterValueStore values)
   {
      boolean result = true;
      ParameterStore store = (ParameterStore) context.get(ParameterStore.class);

      for (Entry<String, Parameter<?>> entry : store)
      {
         Parameter<?> parameter = entry.getValue();
         String value = values.retrieve(parameter);
View Full Code Here

      Header header = Header.matches("Accept-Charset", "{enc}");

      MockEvaluationContext context = new MockEvaluationContext();
      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

   @Test
   public void testCannotUseRegexes()
   {
      Header header = Header.matches(".*Accept-Charset", "blah");

      ParameterStore parameters = new DefaultParameterStore();
      ParameterUtils.initialize(parameters, header);

      Assert.assertFalse(header.evaluate(rewrite, new MockEvaluationContext()));
   }
View Full Code Here

   @Test
   public void testDoesNotMatchNonHttpRewrites()
   {
      Header header = Header.exists("Accept-Charset");

      ParameterStore parameters = new DefaultParameterStore();
      ParameterUtils.initialize(parameters, header);

      Assert.assertFalse(header.evaluate(new MockRewrite(), new MockEvaluationContext()));
   }
View Full Code Here

      URL url = URL.matches("{prefix}/application/{seg}{suffix}");

      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

      MockEvaluationContext context = new MockEvaluationContext();
      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

TOP

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

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.