Coverage Report - net.sf.jmatchparser.util.csv.fieldreader.SimpleFieldDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleFieldDefinition
66%
12/18
N/A
1
 
 1  
 /*
 2  
  * Copyright (c) 2008 - 2011 Michael Schierl
 3  
  * 
 4  
  * All rights reserved.
 5  
  * 
 6  
  * Redistribution and use in source and binary forms, with or without
 7  
  * modification, are permitted provided that the following conditions
 8  
  * are met:
 9  
  * 
 10  
  * - Redistributions of source code must retain the above copyright notice,
 11  
  *   this list of conditions and the following disclaimer.
 12  
  *   
 13  
  * - Redistributions in binary form must reproduce the above copyright
 14  
  *   notice, this list of conditions and the following disclaimer in the
 15  
  *   documentation and/or other materials provided with the distribution.
 16  
  *   
 17  
  * - Neither name of the copyright holders nor the names of its
 18  
  *   contributors may be used to endorse or promote products derived from
 19  
  *   this software without specific prior written permission.
 20  
  *   
 21  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE CONTRIBUTORS
 22  
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 23  
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 24  
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 25  
  * HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 26  
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 27  
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 28  
  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 29  
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 30  
  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 31  
  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32  
  */
 33  
 package net.sf.jmatchparser.util.csv.fieldreader;
 34  
 
 35  
 import java.text.Format;
 36  
 import java.util.regex.Pattern;
 37  
 
 38  
 /**
 39  
  * A {@link FieldDefinition} that does not use an additional {@link Format}, and
 40  
  * therefore always produces Strings.
 41  
  */
 42  
 public class SimpleFieldDefinition extends FieldDefinition<String> {
 43  
 
 44  
         /**
 45  
          * Create an unconstraint field definition.
 46  
          */
 47  
         public SimpleFieldDefinition() {
 48  9
                 this(".*");
 49  9
         }
 50  
 
 51  
         /**
 52  
          * Create a field definition with the given maximum length.
 53  
          */
 54  
         public SimpleFieldDefinition(int maxLength) {
 55  1
                 this(".*", maxLength);
 56  1
         }
 57  
 
 58  
         /**
 59  
          * Create a field definition with the given maximum length and mandatory
 60  
          * state.
 61  
          */
 62  
         public SimpleFieldDefinition(int maxLength, MandatoryState mandatory) {
 63  3
                 this(".*", maxLength, mandatory);
 64  3
         }
 65  
 
 66  
         /**
 67  
          * Create a field definition with the given regex mask.
 68  
          */
 69  
         public SimpleFieldDefinition(Pattern mask) {
 70  0
                 this(mask, Integer.MAX_VALUE);
 71  0
         }
 72  
 
 73  
         /**
 74  
          * Create a field definition with the given regex mask.
 75  
          */
 76  
         public SimpleFieldDefinition(String mask) {
 77  9
                 this(mask, Integer.MAX_VALUE);
 78  9
         }
 79  
 
 80  
         /**
 81  
          * Create a field definition with the given regex mask and maximum length.
 82  
          */
 83  
         public SimpleFieldDefinition(Pattern mask, int maxLength) {
 84  0
                 this(mask, maxLength, MandatoryState.OPTIONAL);
 85  0
         }
 86  
 
 87  
         /**
 88  
          * Create a field definition with the given regex mask and maximum length.
 89  
          */
 90  
         public SimpleFieldDefinition(String mask, int maxLength) {
 91  10
                 this(mask, maxLength, MandatoryState.OPTIONAL);
 92  10
         }
 93  
 
 94  
         /**
 95  
          * Create a field definition with the given regex mask, maximum length and
 96  
          * mandatory state.
 97  
          */
 98  
         public SimpleFieldDefinition(Pattern mask, int maxLength, MandatoryState mandatory) {
 99  0
                 super(mask, maxLength, mandatory, ParseFormat.IDENTITY);
 100  0
         }
 101  
 
 102  
         /**
 103  
          * Create a field definition with the given regex mask, maximum length and
 104  
          * mandatory state.
 105  
          */
 106  
         public SimpleFieldDefinition(String mask, int maxLength, MandatoryState mandatory) {
 107  13
                 super(mask, maxLength, mandatory, ParseFormat.IDENTITY);
 108  13
         }
 109  
 }