Coverage Report - us.daveread.utility.formatcheck.format.RegExDataType
 
Classes in this File Line Coverage Branch Coverage Complexity
RegExDataType
100%
4/4
N/A
1
 
 1  
 package us.daveread.utility.formatcheck.format;
 2  
 
 3  
 /**
 4  
  * <p>Title: RegExDataType
 5  
  * <p>Description: Represents a regular expression-based data type
 6  
  * <p>Copyright: Copyright (c) 2005
 7  
  * <p>This program is free software; you can redistribute it and/or modify
 8  
  * it under the terms of the GNU General Public License as published by
 9  
  * the Free Software Foundation; either version 2 of the License, or
 10  
  * (at your option) any later version.
 11  
  * <p>This program is distributed in the hope that it will be useful,
 12  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  
  * GNU General Public License for more details.
 15  
  * <p>You should have received a copy of the GNU General Public License
 16  
  * along with this program; if not, write to the Free Software
 17  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
  * </p>
 19  
  *
 20  
  * @author David Read
 21  
  * @version $Id: RegExDataType.java,v 1.2 2006/06/14 23:29:40 daveread Exp $
 22  
  */
 23  
 public class RegExDataType extends DataType {
 24  
 
 25  
     /**
 26  
      * Creates a RegExDataType basd on the regular expression supplied.
 27  
      * Validation will be made by seeing that the data matches
 28  
      * the regular expression.  The optional description is useful for
 29  
      * creating a more meaningful error message if a data validation
 30  
      * error occurs.
 31  
      *
 32  
      * @param aRegEx String The regular expression defining this RegEx data type
 33  
      * @param aDescription String A human-readable description of this data type
 34  
      */
 35  
     public RegExDataType(String aRegEx, String aDescription) {
 36  72
         super(aRegEx, aDescription);
 37  72
         setTypeName("Regular Expression");
 38  72
     }
 39  
 
 40  
     /**
 41  
      * Tests whether the field value matches the regular expression defined
 42  
      * in this data type.
 43  
      *
 44  
      * @param fieldValue String The value being checked
 45  
      *
 46  
      * @return boolean True if the value is valid, false otherwise
 47  
      */
 48  
     public boolean isValid(String fieldValue) {
 49  27
         return fieldValue.matches(getFormatDefinition());
 50  
     }
 51  
 }