org.apache.cocoon.transformation.helpers
Class FormValidatorHelper

java.lang.Object
  extended by org.apache.cocoon.transformation.helpers.FormValidatorHelper

public class FormValidatorHelper
extends Object

The ValidatorActionResult object helper

Version:
CVS $Id: FormValidatorHelper.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Christian Haul

Constructor Summary
FormValidatorHelper(String descriptor, boolean reloadable, Logger logger, SourceResolver resolver)
           
FormValidatorHelper(String descriptor, boolean reloadable, Logger logger, SourceResolver resolver, String constraintset)
           
 
Method Summary
static Object getAttribute(Map objectModel, String name)
          Get the specified attribute
protected static Configuration getConfiguration(String descriptor, SourceResolver resolver, boolean reloadable, Logger logger)
          Set up the complementary configuration file.
protected static Configuration getConfigurationByName(Configuration[] conf, String name, Logger logger)
          Iterate over a set of configurations and return the one whose name matches the given one.
 String getParameterAttribute(String attribute)
          Get an attribute for the context's current parameter as specified in descriptor.xml.
 String getParameterAttribute(String parameter, String attribute)
          Get an attribute for a parameter as specified in descriptor.xml.
static String getParameterAttributes(String descriptor, SourceResolver resolver, boolean reloadable, String constraintset, String parameter, String attribute, Logger logger)
          Get an attribute for a parameter as specified in descriptor.xml.
 ValidatorActionResult getParamResult(Map objectModel)
          Extracts the validation results from the request attribute for the context's current request parameter
static ValidatorActionResult getParamResult(Map objectModel, String name)
          Extracts the validation results from the request attribute for a specific request parameter
static Map getResults(Map objectModel)
          Extracts the validation results from the request attribute
 boolean isError(Map objectModel)
          Test whether the validation returned an error for the context's current parameter.
static boolean isError(Map objectModel, String name)
          Test whether the validation returned an error for this parameter.
 boolean isNoMatch(Map objectModel)
          Test whether the context's current parameter wasn't matched by the requested regular expression.
static boolean isNoMatch(Map objectModel, String name)
          Test whether the validated parameter wasn't matched by the requested regular expression.
 boolean isNotPresent(Map objectModel)
          Test whether the context's current parameter wasn't validated
static boolean isNotPresent(Map objectModel, String name)
          Test whether the validated parameter wasn't validated
 boolean isNull(Map objectModel)
          Test whether the context's current parameter as validated was null but wasn't allowed to.
static boolean isNull(Map objectModel, String name)
          Test whether the validated parameter was null but wasn't allowed to.
 boolean isOK(Map objectModel)
          Test whether the validation returned no error for the context's current parameter.
static boolean isOK(Map objectModel, String name)
          Test whether the validation returned no error for this parameter.
 boolean isTooLarge(Map objectModel)
          Test whether the context's current parameter was too large.
static boolean isTooLarge(Map objectModel, String name)
          Test whether the validated parameter was too large.
 boolean isTooSmall(Map objectModel)
          Test whether the context's current parameter was too small.
static boolean isTooSmall(Map objectModel, String name)
          Test whether the validated parameter was too small.
 void setConstraintSet(String constraintset)
          keep track of current constraint-set context (probably this is not needed?)
 void setParameter(String parameter)
          keep track of current parameter context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormValidatorHelper

public FormValidatorHelper(String descriptor,
                           boolean reloadable,
                           Logger logger,
                           SourceResolver resolver)

FormValidatorHelper

public FormValidatorHelper(String descriptor,
                           boolean reloadable,
                           Logger logger,
                           SourceResolver resolver,
                           String constraintset)
Method Detail

setParameter

public void setParameter(String parameter)
keep track of current parameter context


setConstraintSet

public void setConstraintSet(String constraintset)
keep track of current constraint-set context (probably this is not needed?)


getAttribute

public static Object getAttribute(Map objectModel,
                                  String name)
Get the specified attribute

Parameters:
objectModel - The Map objectModel
name - The parameter name

getResults

public static Map getResults(Map objectModel)
Extracts the validation results from the request attribute

Parameters:
objectModel - The Map objectModel
Returns:
Map with ValidatorActionResults
See Also:
ValidatorActionResult

getParamResult

public static ValidatorActionResult getParamResult(Map objectModel,
                                                   String name)
Extracts the validation results from the request attribute for a specific request parameter

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
See Also:
ValidatorActionResult

getParamResult

public ValidatorActionResult getParamResult(Map objectModel)
Extracts the validation results from the request attribute for the context's current request parameter

Parameters:
objectModel - The Map objectModel
See Also:
ValidatorActionResult

isOK

public static boolean isOK(Map objectModel,
                           String name)
Test whether the validation returned no error for this parameter.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true only if the parameter was validated and the validation did not return an error.

isOK

public boolean isOK(Map objectModel)
Test whether the validation returned no error for the context's current parameter.

Parameters:
objectModel - The Map objectModel
Returns:
true only if the parameter was validated and the validation did not return an error.

isError

public static boolean isError(Map objectModel,
                              String name)
Test whether the validation returned an error for this parameter.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was either not validated or the validation returned an error.

isError

public boolean isError(Map objectModel)
Test whether the validation returned an error for the context's current parameter.

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was either not validated or the validation returned an error.

isNull

public static boolean isNull(Map objectModel,
                             String name)
Test whether the validated parameter was null but wasn't allowed to.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was validated and the validation returned an error because the parameter was null but wasn't allowd to.

isNull

public boolean isNull(Map objectModel)
Test whether the context's current parameter as validated was null but wasn't allowed to.

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was validated and the validation returned an error because the parameter was null but wasn't allowd to.

isTooSmall

public static boolean isTooSmall(Map objectModel,
                                 String name)
Test whether the validated parameter was too small.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was validated and the validation returned an error because either its value or its length was too small.

isTooSmall

public boolean isTooSmall(Map objectModel)
Test whether the context's current parameter was too small.

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was validated and the validation returned an error because either its value or its length was too small.

isTooLarge

public static boolean isTooLarge(Map objectModel,
                                 String name)
Test whether the validated parameter was too large.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was validated and the validation returned an error because either its value or its length was too large.

isTooLarge

public boolean isTooLarge(Map objectModel)
Test whether the context's current parameter was too large.

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was validated and the validation returned an error because either its value or its length was too large.

isNoMatch

public static boolean isNoMatch(Map objectModel,
                                String name)
Test whether the validated parameter wasn't matched by the requested regular expression.

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was validated and the validation returned an error because its value wasn't matched by the requested regular expression.

isNoMatch

public boolean isNoMatch(Map objectModel)
Test whether the context's current parameter wasn't matched by the requested regular expression.

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was validated and the validation returned an error because its value wasn't matched by the requested regular expression.

isNotPresent

public static boolean isNotPresent(Map objectModel,
                                   String name)
Test whether the validated parameter wasn't validated

Parameters:
objectModel - The Map objectModel
name - Request parameter's name
Returns:
true if the parameter was not validated.

isNotPresent

public boolean isNotPresent(Map objectModel)
Test whether the context's current parameter wasn't validated

Parameters:
objectModel - The Map objectModel
Returns:
true if the parameter was not validated.

getConfiguration

protected static Configuration getConfiguration(String descriptor,
                                                SourceResolver resolver,
                                                boolean reloadable,
                                                Logger logger)
                                         throws ConfigurationException
Set up the complementary configuration file. Please note that multiple Actions can share the same configurations. By using this approach, we can limit the number of config files. Also note that the configuration file does not have to be a file. This is based on the similar named functions in org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction with the addition of reloadable configuration files, reloadable flagg, manager, and logger parameter.

Parameters:
descriptor - URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
resolver -
reloadable - set to true if changes of descriptor should trigger a reload. Note that this only works if Source is able to determine the modification time @see org.apache.cocoon.environment.Source
logger - used to send debug and error messages to
Returns:
up-to-date configuration, either (re)loaded or cached.
Throws:
ConfigurationException

getConfigurationByName

protected static Configuration getConfigurationByName(Configuration[] conf,
                                                      String name,
                                                      Logger logger)
Iterate over a set of configurations and return the one whose name matches the given one.

Parameters:
conf - set of configurations
name - name of configuration
logger -
Returns:
specified configuration or null if not found.

getParameterAttributes

public static String getParameterAttributes(String descriptor,
                                            SourceResolver resolver,
                                            boolean reloadable,
                                            String constraintset,
                                            String parameter,
                                            String attribute,
                                            Logger logger)
Get an attribute for a parameter as specified in descriptor.xml.

Parameters:
descriptor - URL of descriptor.xml file @see org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction
resolver -
reloadable - set to true if changes of descriptor should trigger a reload. Note that this only works if Source is able to determine the modification time @see org.apache.cocoon.environment.Source
logger - used to send debug and error messages to
attribute - attribute name
Returns:
attribute value or null

getParameterAttribute

public String getParameterAttribute(String attribute)
Get an attribute for the context's current parameter as specified in descriptor.xml.

Parameters:
attribute - attribute name
Returns:
attribute value or null

getParameterAttribute

public String getParameterAttribute(String parameter,
                                    String attribute)
Get an attribute for a parameter as specified in descriptor.xml.

Parameters:
attribute - attribute name
Returns:
attribute value or null


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.