Coverage Report - org.apache.tapestry.form.validator.ValidatorFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidatorFactory
N/A
N/A
1
 
 1  
 // Copyright 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.form.validator;
 16  
 
 17  
 import java.util.List;
 18  
 
 19  
 import org.apache.tapestry.IComponent;
 20  
 
 21  
 /**
 22  
  * Constructs {@link org.apache.tapestry.form.validator.Validator} instances from a specification. A
 23  
  * specification is a comma-seperated list of entries. Each entry is in one of the following forms:
 24  
  * <ul>
 25  
  * <li><em>name</em>
 26  
  * <li><em>name</em>=<em>value</em>
 27  
  * <li><em>name[<em>message</em>]</em>
 28  
  * <li><em>name</em>=<em>value</em>[<em>message</em>]
 29  
  * <li>$<em>name</em>
 30  
  * </ul>
 31  
  * <p>
 32  
  * Most validator classes are <em>configurable</em>: they have a property that matches their
 33  
  * name. For example, {@link org.apache.tapestry.form.validator.MinDate} (which is named "minDate"
 34  
  * has a <code>minDate</code> property. A few validators are not configurable ("required" =>
 35  
  * {@link org.apache.tapestry.form.validator.Required}, for example).
 36  
  * <p>
 37  
  * Validators are expected to have a public no-args constructor. They are also expected to have a
 38  
  * <code>message</code> property which is set from the value in brackets.
 39  
  * The message is either a literal string, or may be prefixed with a '%' character, to indicate
 40  
  * a localized key, resolved using the component's message catalog.
 41  
  * <p>
 42  
  * When the name is prefixed with a dollary sign, it indicates a reference to a <em>bean</em>
 43  
  * with the given name.
 44  
  * <p>
 45  
  * A full validator specification might be:
 46  
  * <code>required,email[%email-format],minLength=20[Email addresses must be at least 20 characters long.]</code>
 47  
  * 
 48  
  * @author Howard Lewis Ship
 49  
  * @since 4.0
 50  
  */
 51  
 public interface ValidatorFactory
 52  
 {
 53  
     /**
 54  
      * Constructs a new (immutable) List of {@link Validator}, or returns a previously constructed
 55  
      * List.
 56  
      * 
 57  
      * @param component
 58  
      *            the component for which the list is being created
 59  
      * @param specification
 60  
      *            a string identifying which validators and their configuration
 61  
      * @return List of {@link Validator} (possibly empty)
 62  
      */
 63  
     List constructValidatorList(IComponent component, String specification);
 64  
 }