net.sourceforge.stripes.controller
Class BindingPolicyManager

java.lang.Object
  extended by net.sourceforge.stripes.controller.BindingPolicyManager

@StrictBinding(defaultPolicy=ALLOW)
public class BindingPolicyManager
extends Object

Manages the policies observed by DefaultActionBeanPropertyBinder when binding properties to an ActionBean.

Author:
Ben Gunter
See Also:
StrictBinding

Constructor Summary
protected BindingPolicyManager(Class<?> beanClass)
          Create a new instance to handle binding security for the given type.
 
Method Summary
protected  StrictBinding getAnnotation(Class<?> beanType)
          Get the StrictBinding annotation for a class, checking all its superclasses if necessary.
 Class<?> getBeanClass()
          Get the bean class.
 StrictBinding.Policy getDefaultPolicy()
          Get the default policy.
static BindingPolicyManager getInstance(Class<?> beanType)
          Get the policy manager for the given class.
protected  String[] getValidatedProperties(Class<?> beanClass)
          Get all the properties and nested properties of the given class for which there is a corresponding ValidationMetadata, as returned by ValidationMetadataProvider.getValidationMetadata(Class, ParameterName).
protected  Pattern globToPattern(String... globArray)
          Converts a glob to a regex Pattern.
 boolean isBindingAllowed(PropertyExpressionEvaluation eval)
          Indicates if binding is allowed for the given expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BindingPolicyManager

protected BindingPolicyManager(Class<?> beanClass)
Create a new instance to handle binding security for the given type.

Parameters:
beanClass - the class to which the binding policy applies
Method Detail

getInstance

public static BindingPolicyManager getInstance(Class<?> beanType)
Get the policy manager for the given class. Instances are cached and returned on subsequent calls.

Parameters:
beanType - the class whose policy manager is to be retrieved
Returns:
a policy manager

isBindingAllowed

public boolean isBindingAllowed(PropertyExpressionEvaluation eval)
Indicates if binding is allowed for the given expression.

Parameters:
eval - a property expression that has been evaluated against an ActionBean
Returns:
true if binding is allowed; false if not

getAnnotation

protected StrictBinding getAnnotation(Class<?> beanType)
Get the StrictBinding annotation for a class, checking all its superclasses if necessary. If no annotation is found, then one will be returned whose default policy is to allow binding to all properties.

Parameters:
beanType - the class to get the StrictBinding annotation for
Returns:
An annotation. This method never returns null.

getValidatedProperties

protected String[] getValidatedProperties(Class<?> beanClass)
Get all the properties and nested properties of the given class for which there is a corresponding ValidationMetadata, as returned by ValidationMetadataProvider.getValidationMetadata(Class, ParameterName). The idea here is that if the bean property must be validated, then it is expected that the property may be bound to the bean.

Parameters:
beanClass - a class
Returns:
The validated properties. If no properties are annotated then null.
See Also:
ValidationMetadataProvider.getValidationMetadata(Class)

getBeanClass

public Class<?> getBeanClass()
Get the bean class.

Returns:
the bean class

getDefaultPolicy

public StrictBinding.Policy getDefaultPolicy()
Get the default policy.

Returns:
the policy

globToPattern

protected Pattern globToPattern(String... globArray)
Converts a glob to a regex Pattern.

Parameters:
globArray - an array of property name globs, each of which may be a comma separated list of globs
Returns:
the pattern


? Copyright 2005-2006, Stripes Development Team.