You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by rd...@apache.org on 2010/08/30 14:06:45 UTC

svn commit: r990776 [3/3] - in /myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator: core/el/ core/factory/ core/initializer/component/ core/initializer/configuration/ core/interceptor/ core/mapper/ core/metada...

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapter.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapter.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapter.java Mon Aug 30 12:06:42 2010
@@ -22,13 +22,13 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 
 /**
- * it isn't linked to jsr 303
+ * Adapter to connect validation strategies with meta-data transformers,
+ * if the validation strategy is defined as bean and e.g. spring creates a proxy.
+ *
+ * it isn't linked to jsr 303.
  *
  * it's just a helper for proxies - you just need it, if you define the validation strategy as bean and
  * e.g. spring creates a proxy for it.
-
- * adapter to connect validation strategies with meta-data transformers,
- * if the validation strategy is defined as bean and e.g. spring creates a proxy
  *
  * @author Gerhard Petracek
  * @since 1.x.1
@@ -36,8 +36,18 @@ import org.apache.myfaces.extensions.val
 @UsageInformation({UsageCategory.REUSE})
 public interface BeanValidationStrategyAdapter extends ValidationStrategy
 {
-    //to get back the internal cashing
+    //to get back the internal caching
+    /**
+     * Must return the class name of ValidationStrategy wrapped by this adapter.
+     *
+     * @return class name of the wrapped ValidationStrategy
+     */
     String getValidationStrategyClassName();
 
+    /**
+     * Must return the class name of the MetaDataTransformer for the wrapped ValidationStrategy of the adapter.
+     *
+     * @return class name of the MetaDataTransformer for the wrapped ValidationStrategy.
+     */
     String getMetaDataTransformerClassName();
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapterImpl.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapterImpl.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/BeanValidationStrategyAdapterImpl.java Mon Aug 30 12:06:42 2010
@@ -29,13 +29,13 @@ import javax.faces.context.FacesContext;
 import java.util.logging.Logger;
 
 /**
- * it isn't linked to jsr 303
+ * Adapter to connect validation strategies with meta-data transformers,
+ * if the validation strategy is defined as bean and e.g. spring creates a proxy.
+ *
+ * it isn't linked to jsr 303.
  *
  * it's just a helper for proxies - you just need it, if you define the validation strategy as bean and
  * e.g. spring creates a proxy for it.
-
- * adapter to connect validation strategies with meta-data transformers,
- * if the validation strategy is defined as bean and e.g. spring creates a proxy
  *
  * @author Gerhard Petracek
  * @since 1.x.1
@@ -47,7 +47,7 @@ public class BeanValidationStrategyAdapt
 
     private MetaDataTransformer metaDataTransformer;
     private ValidationStrategy validationStrategy;
-    //optional fallback for internal cashing
+    //optional fallback for internal caching
     private String validationStrategyClassName;
 
     public BeanValidationStrategyAdapterImpl()
@@ -55,6 +55,10 @@ public class BeanValidationStrategyAdapt
         logger.fine(getClass().getName() + " instantiated");
     }
 
+    /**
+     * {@inheritDoc}
+     * Delegates to the validation to the wrapped ValidationStrategy.
+     */
     public void validate(FacesContext facesContext,
                          UIComponent uiComponent,
                          MetaDataEntry metaDataEntry,
@@ -72,6 +76,11 @@ public class BeanValidationStrategyAdapt
         return validationStrategyClassName;
     }
 
+    /**
+     * {@inheritDoc}
+     * When a metaDataTransformer is set, the class name is returned.  When the metaDataTransformer is an adapter
+     * (BeanMetaDataTransformerAdapter) we ask the adapter for the name.
+     */
     public String getMetaDataTransformerClassName()
     {
         if(metaDataTransformer != null)
@@ -109,11 +118,19 @@ public class BeanValidationStrategyAdapt
         return validationStrategy;
     }
 
+    /**
+     * Sets the wrapped ValidationStrategy of this adapter.
+     * @param validationStrategy The ValidationStrategy to wrap by this adapter.
+     */
     public void setValidationStrategy(ValidationStrategy validationStrategy)
     {
         this.validationStrategy = validationStrategy;
     }
 
+    /**
+     * The class name returned by the  {link getValidationStrategyClassName()} method when no ValidationStrategy is set.
+     * @param validationStrategyClassName  The class name to return.
+     */
     public void setValidationStrategyClassName(String validationStrategyClassName)
     {
         this.validationStrategyClassName = validationStrategyClassName;

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/IdentifiableValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/IdentifiableValidationStrategy.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/IdentifiableValidationStrategy.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/IdentifiableValidationStrategy.java Mon Aug 30 12:06:42 2010
@@ -22,15 +22,27 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 
 /**
- * if an adapter is used for several constraints, this interface allows to identify instances
- *
+ * if an adapter (ValidationStrategy only used for component initialization) is used for several constraints, this
+ * interface allows to identify instances.
+ * For the moment only used for JSR-303 validation strategies.
+ * 
  * @author Gerhard Petracek
  * @since x.x.3
  */
 @UsageInformation(UsageCategory.API)
 public interface IdentifiableValidationStrategy extends ValidationStrategy
 {
+    /**
+     * Separator used in the unique key that identifies validationStrategyName when multiple constraints are processed
+     * by a MetaDataTransformer.
+     * @see org.apache.myfaces.extensions.validator.core.metadata.transformer.DefaultMetaDataTransformerFactory
+     */
     String ID_PREFIX = ":";
 
+    /**
+     * Returns the unique part of the key of the  validationStrategyName when multiple constraints are processed
+     * by a MetaDataTransformer.
+     * @return Unique String to identify the Validation.
+     */
     String getId();
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/ValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/ValidationStrategy.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/ValidationStrategy.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/strategy/ValidationStrategy.java Mon Aug 30 12:06:42 2010
@@ -26,15 +26,27 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 
 /**
- * Base interface for ValidationStrategies
+ * Base interface for ValidationStrategies. A validation strategy is responsible for validating a certain rule, like
+ * required or a custom validation rule.  A convenient abstract base class is AbstractValidationStrategy.
  *
  * @author Gerhard Petracek
  * @since 1.x.1
+ * @see org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractValidationStrategy
  */
 @UsageInformation(UsageCategory.API)
 //*ValidationStrategy instead of *Validator to avoid naming confusion 
 public interface ValidationStrategy
 {
+    /**
+     * Validates the value in the convertedObject parameter which the user entered as value of the uiComponent.
+     * Additional validation information can be found in the metaDataEntry parameter.
+     *
+     * @param facesContext The JSF Context
+     * @param uiComponent The JSF component that contained the value entered by the user.
+     * @param metaDataEntry The data holder which stores the meta-data and some information where the meta-data was
+     * around.
+     * @param convertedObject Converted object of the user entered value.
+     */
     void validate(FacesContext facesContext, UIComponent uiComponent,
                   MetaDataEntry metaDataEntry, Object convertedObject);
 }

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java Mon Aug 30 12:06:42 2010
@@ -31,6 +31,8 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 
 /**
+ * Contains helper methods that deal with annotation usage in the context of ExtVal.
+ *
  * @author Gerhard Petracek
  * @since r4
  */

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java?rev=990776&r1=990775&r2=990776&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java Mon Aug 30 12:06:42 2010
@@ -37,6 +37,8 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.Priority;
 
 /**
+ * Contains helper methods that are dealing with annotation usage in the context of ExtVal.
+ *
  * @author Gerhard Petracek
  * @since r4
  */
@@ -47,6 +49,15 @@ public class ExtValAnnotationUtils
     private static final Logger LOGGER = Logger.getLogger(ExtValAnnotationUtils.class.getName());
 
     @ToDo(value = Priority.HIGH, description = "add cache")
+    /**
+     * Extract all annotations found on a property.  It looks for them on getter method, the field and all getters
+     * that are defined in interfaces. The name of the property for which the annotations are searched, is passed
+     * as value of the field property of the parameter propertyDetails.
+     *
+     * @param entityClass Class object where the annotations are searched.
+     * @param propertyDetails Information on the property where are interested in.
+     * @return Object with information and metaDataEntries for the annotations.
+     */
     public static PropertyInformation extractAnnotations(Class entityClass, PropertyDetails propertyDetails)
     {
         PropertyInformation propertyInformation = new DefaultPropertyInformation();
@@ -68,6 +79,15 @@ public class ExtValAnnotationUtils
     }
 
     @ToDo(value = Priority.HIGH, description = "add cache")
+    /**
+     * Extract all annotations found on the getter method of a property. The annotations are added to the
+     * propertyInformation MetaDataEntries.
+     *
+     * @param storage PropertyStorage where the getter method could be cached.
+     * @param entity Class object where the annotations are searched.
+     * @param property Name of the property we are interested.
+     * @param propertyInformation Where the MetaDataEntries for the annotations are added.
+     */
     public static void addPropertyAccessAnnotations(PropertyStorage storage, Class entity,
                                                     String property,
                                                     PropertyInformation propertyInformation)
@@ -81,6 +101,14 @@ public class ExtValAnnotationUtils
     }
 
     @ToDo(value = Priority.HIGH, description = "add cache")
+    /**
+     * Extract all annotations found the field of the property. A field name with an additional _ (underscore) is also
+     * searched. The annotations are added to the propertyInformation MetaDataEntries.
+     * @param storage PropertyStorage where the field could be cached.
+     * @param entity Class object where the annotations are searched.
+     * @param property Name of the property we are interested.
+     * @param propertyInformation Where the MetaDataEntries for the annotations are added.
+     */
     public static void addFieldAccessAnnotations(PropertyStorage storage, Class entity,
                                                  String property,
                                                  PropertyInformation propertyInformation)
@@ -126,8 +154,19 @@ public class ExtValAnnotationUtils
         return entry;
     }
 
+    /**
+     * Extract the value of the annotation property named value. The value is cast as a value of the parameter
+     * targetClass.
+     *
+     * @param annotation The annotations that is used to extract the property value from.
+     * @param targetClass Type of the property named value.
+     * @param <T> Result class
+     * @return value of the annotation property named value
+     */
     public static <T> T extractValueOf(Annotation annotation, Class<T> targetClass)
     {
+        // Since we can't be sure of the type, we can't use the
+        // annotation.annotationType().getDeclaredMethod(String, Class...) method.
         for (Method annotationMethod : annotation.annotationType().getDeclaredMethods())
         {
             if ("value".equals(annotationMethod.getName()))