2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.validator.tag.IntegerValidatorTag
 
Classes in this File Line Coverage Branch Coverage Complexity
IntegerValidatorTag
0% 
0% 
2.333
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.shale.validator.tag;
 19  
 
 20  
 import javax.faces.context.FacesContext;
 21  
 import javax.faces.el.ValueBinding;
 22  
 import javax.faces.validator.Validator;
 23  
 import javax.faces.webapp.UIComponentTag;
 24  
 import javax.faces.webapp.ValidatorTag;
 25  
 import org.apache.shale.util.ConverterHelper;
 26  
 import org.apache.shale.validator.validator.IntegerValidator;
 27  
 
 28  
 /**
 29  
  * <p>JSP custom action for <code>IntegerValidator</code>.</p>
 30  
  */
 31  0
 public final class IntegerValidatorTag extends ValidatorTag {
 32  
     
 33  
 
 34  
     // -------------------------------------------------------- Static Variables
 35  
 
 36  
 
 37  
     /**
 38  
      * Serial version UID.
 39  
      */
 40  
     private static final long serialVersionUID = 1L;
 41  
 
 42  
 
 43  
     /**
 44  
      * <p>Helper object for performing conversions.</p>
 45  
      */
 46  0
     private static final ConverterHelper HELPER =
 47  
             new ConverterHelper();
 48  
 
 49  
 
 50  
     // -------------------------------------------------------------- Properties
 51  
 
 52  
 
 53  0
     private String client = null;
 54  
     public void setClient(String client) {
 55  0
         this.client = client;
 56  0
     }
 57  
 
 58  
 
 59  0
     private String maximum = null;
 60  
     public void setMaximum(String maximum) {
 61  0
         this.maximum = maximum;
 62  0
     }
 63  
 
 64  
 
 65  0
     private String message = null;
 66  
     public void setMessage(String message) {
 67  0
         this.message = message;
 68  0
     }
 69  
 
 70  
 
 71  0
     private String minimum = null;
 72  
     public void setMinimum(String minimum) {
 73  0
         this.minimum = minimum;
 74  0
     }
 75  
 
 76  
 
 77  
     // ------------------------------------------------------------- Tag Methods
 78  
 
 79  
 
 80  
     /**
 81  
      * <p>Release resources allocated for this instance.</p>
 82  
      */
 83  
     public void release() {
 84  
 
 85  0
         client = null;
 86  0
         maximum = null;
 87  0
         message = null;
 88  0
         minimum = null;
 89  
 
 90  0
         super.release();
 91  
 
 92  0
     }
 93  
 
 94  
 
 95  
     // ---------------------------------------------------- ValidatorTag Methods
 96  
 
 97  
 
 98  
     /**
 99  
      * <p>Create and return a new <code>Validator</code> instance to be
 100  
      * registered on our corresponding <code>UIComponent</code>.</p>
 101  
      */
 102  
     protected Validator createValidator() {
 103  
 
 104  0
         FacesContext context = FacesContext.getCurrentInstance();
 105  0
         IntegerValidator validator = new IntegerValidator();
 106  
 
 107  0
         if (client != null) {
 108  0
             Boolean value = null;
 109  0
             if (UIComponentTag.isValueReference(client)) {
 110  0
                 ValueBinding vb = context.getApplication().createValueBinding(client);
 111  0
                 value = (Boolean) vb.getValue(context);
 112  0
             } else {
 113  0
                 value = (Boolean) HELPER.asObject(context, Boolean.class, client);
 114  
             }
 115  0
             validator.setClient(value.booleanValue());
 116  
         }
 117  
 
 118  0
         if (maximum != null) {
 119  0
             Integer value = null;
 120  0
             if (UIComponentTag.isValueReference(maximum)) {
 121  0
                 ValueBinding vb = context.getApplication().createValueBinding(maximum);
 122  0
                 value = (Integer) vb.getValue(context);
 123  0
             } else {
 124  0
                 value = (Integer) HELPER.asObject(context, Integer.class, maximum);
 125  
             }
 126  0
             validator.setMaximum(value.intValue());
 127  
         }
 128  
 
 129  0
         if (message != null) {
 130  0
             String value = null;
 131  0
             if (UIComponentTag.isValueReference(message)) {
 132  0
                 ValueBinding vb = context.getApplication().createValueBinding(message);
 133  0
                 value = (String) vb.getValue(context);
 134  0
             } else {
 135  0
                 value = message;
 136  
             }
 137  0
             validator.setMessage(value);
 138  
         }
 139  
 
 140  0
         if (minimum != null) {
 141  0
             Integer value = null;
 142  0
             if (UIComponentTag.isValueReference(minimum)) {
 143  0
                 ValueBinding vb = context.getApplication().createValueBinding(minimum);
 144  0
                 value = (Integer) vb.getValue(context);
 145  0
             } else {
 146  0
                 value = (Integer) HELPER.asObject(context, Integer.class, minimum);
 147  
             }
 148  0
             validator.setMinimum(value.intValue());
 149  
         }
 150  
 
 151  0
         return validator;
 152  
 
 153  
     }
 154  
 
 155  
 
 156  
 }