config-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/Query.java
public static Query parameterExists(final String name)
   {
      Assert.notNull(name, "Parameter name pattern must not be null.");

      return new Query() {
         final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser("{" + name + "}");
         final String parameterName = name;

         @Override
         public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context)
         {
            QueryStringBuilder queryString = QueryStringBuilder.createFromEncoded(event.getAddress().getQuery())
                     .decode();

            for (String name : queryString.getParameterNames()) {
               String[] parameterValues = queryString.getParameterValues(name);
               if (parameterName.equals(name))
               {
                  if (parameterValues == null || (parameterValues.length == 0))
                  {
                     return pattern.parse("").matches();
                  }
                  else
                  {
                     for (String value : parameterValues) {

                        ParameterizedPatternResult parseResult = pattern.parse(value);
                        if (parseResult.matches())
                        {
                           return parseResult.submit(event, context);
                        }
                     }
                  }
               }
            }

            return false;
         }

         @Override
         public String toString()
         {
            return "Query.parameterExists(\"" + name + "\")";
         }

         @Override
         public Set<String> getRequiredParameterNames()
         {
            return pattern.getRequiredParameterNames();
         }

         @Override
         public void setParameterStore(ParameterStore store)
         {
            pattern.setParameterStore(store);
         }
      };
   }
public static Query parameterExists(final String name)
   {
      Assert.notNull(name, "Parameter name pattern must not be null.");

      return new Query() {
         final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser("{" + name + "}");
         final String parameterName = name;

         @Override
         public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context)
         {
            QueryStringBuilder queryString = QueryStringBuilder.createFromEncoded(event.getAddress().getQuery())
                     .decode();

            for (String name : queryString.getParameterNames()) {
               String[] parameterValues = queryString.getParameterValues(name);
               if (parameterName.equals(name))
               {
                  if (parameterValues == null || (parameterValues.length == 0))
                  {
                     return pattern.parse("").matches();
                  }
                  else
                  {
                     for (String value : parameterValues) {

                        ParameterizedPatternResult parseResult = pattern.parse(value);
                        if (parseResult.matches())
                        {
                           return parseResult.submit(event, context);
                        }
                     }
                  }
               }
            }

            return false;
         }

         @Override
         public String toString()
         {
            return "Query.parameterExists(\"" + name + "\")";
         }

         @Override
         public Set<String> getRequiredParameterNames()
         {
            return pattern.getRequiredParameterNames();
         }

         @Override
         public void setParameterStore(ParameterStore store)
         {
            pattern.setParameterStore(store);
         }
      };
   }
public static Query parameterExists ( final String name ) { Assert . notNull ( name , "Parameter name pattern must not be null." ) ; return new Query ( ) { final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser ( "{" + name + "}" ) ; final String parameterName = name ; @ Override public boolean evaluateHttp ( final HttpServletRewrite event , final EvaluationContext context ) { QueryStringBuilder queryString = QueryStringBuilder . createFromEncoded ( event . getAddress ( ) . getQuery ( ) ) . decode ( ) ; for ( String name : queryString . getParameterNames ( ) ) { String [ ] parameterValues = queryString . getParameterValues ( name ) ; if ( parameterName . equals ( name ) ) { if ( parameterValues == null || ( parameterValues . length == 0 ) ) { return pattern . parse ( "" ) . matches ( ) ; } else { for ( String value : parameterValues ) { ParameterizedPatternResult parseResult = pattern . parse ( value ) ; if ( parseResult . matches ( ) ) { return parseResult . submit ( event , context ) ; } } } } } return false ; } @ Override public String toString ( ) { return "Query.parameterExists(\"" + name + "\")" ; } @ Override public Set < String > getRequiredParameterNames ( ) { return pattern . getRequiredParameterNames ( ) ; } @ Override public void setParameterStore ( ParameterStore store ) { pattern . setParameterStore ( store ) ; } } ; }
Create a {@link Condition} asserting the existence of specific parameter names within the current
{@link Address#getQuery()}
<p>
The given parameter name is automatically parameterized:
<p>
<code>
Query.paramterExists("param") <br>
...<br/>
Forward.to("/{param}/page.jsp")
</code>
<p>

@param pattern name of the {@link Parameter} matching query parameter names within the current
{@link Address#getQuery()}.

@see ConfigurationRuleParameterBuilder#where(String)
Create a { @link Condition } asserting the existence of specific parameter names within the current { @link Address#getQuery () } <p > The given parameter name is automatically parameterized : <p > <code > Query . paramterExists ( param ) <br > ... <br / > Forward . to ( / { param } / page . jsp ) < / code > <p >