Coverage Report - org.apache.tapestry.valid.IValidator
 
Classes in this File Line Coverage Branch Coverage Complexity
IValidator
N/A
N/A
1
 
 1  
 // Copyright 2004, 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.valid;
 16  
 
 17  
 import org.apache.tapestry.IMarkupWriter;
 18  
 import org.apache.tapestry.IRequestCycle;
 19  
 import org.apache.tapestry.engine.IScriptSource;
 20  
 import org.apache.tapestry.form.IFormComponent;
 21  
 
 22  
 /**
 23  
  * An object that works with an {@link IFormComponent} to format output (convert object values to
 24  
  * strings values) and to process input (convert strings to object values and validate them).
 25  
  * <p>
 26  
  * Note that this interface represents validation as supported in Tapestry 2.x to 3.0. It has been
 27  
  * outdated (and will eventually be deprecated) by new support in Tapestry 4.0, centered around the
 28  
  * {@link org.apache.tapestry.form.translator.Translator} and
 29  
  * {@link org.apache.tapestry.form.validator.Validator} interfaces.
 30  
  * 
 31  
  * @author Howard Lewis Ship
 32  
  * @since 1.0.8
 33  
  */
 34  
 
 35  
 public interface IValidator
 36  
 {
 37  
     /**
 38  
      * All validators must implement a required property. If true, the client must supply a non-null
 39  
      * value.
 40  
      */
 41  
 
 42  
     boolean isRequired();
 43  
 
 44  
     /**
 45  
      * Invoked during rendering to convert an object value (which may be null) to a String. It is
 46  
      * acceptible to return null. The string will be the VALUE attribute of the HTML text field.
 47  
      */
 48  
 
 49  
     String toString(IFormComponent field, Object value);
 50  
 
 51  
     /**
 52  
      * Converts input, submitted by the client, into an object value. May return null if the input
 53  
      * is null (and the required flag is false).
 54  
      * <p>
 55  
      * The input string will already have been trimmed. It may be null.
 56  
      * 
 57  
      * @throws ValidatorException
 58  
      *             if the string cannot be converted into an object, or the object is not valid (due
 59  
      *             to other constraints).
 60  
      */
 61  
 
 62  
     Object toObject(IFormComponent field, String input) throws ValidatorException;
 63  
 
 64  
     /**
 65  
      * Invoked by the field after it finishes rendering its tag (but before the tag is closed) to
 66  
      * allow the validator to provide a contribution to the rendering process. Validators typically
 67  
      * generated client-side JavaScript to peform validation.
 68  
      * 
 69  
      * @since 2.2
 70  
      */
 71  
 
 72  
     void renderValidatorContribution(IFormComponent field, IMarkupWriter writer,
 73  
             IRequestCycle cycle);
 74  
 
 75  
     /**
 76  
      * Sets the script source used to resolve script paths.
 77  
      * 
 78  
      * @param scriptSource
 79  
      */
 80  
     void setScriptSource(IScriptSource scriptSource);
 81  
 }