Coverage Report - com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck
 
Classes in this File Line Coverage Branch Coverage Complexity
RegexpSinglelineCheck
76%
13/17
N/A
1
 
 1  
 ////////////////////////////////////////////////////////////////////////////////
 2  
 // checkstyle: Checks Java source code for adherence to a set of rules.
 3  
 // Copyright (C) 2001-2014  Oliver Burn
 4  
 //
 5  
 // This library is free software; you can redistribute it and/or
 6  
 // modify it under the terms of the GNU Lesser General Public
 7  
 // License as published by the Free Software Foundation; either
 8  
 // version 2.1 of the License, or (at your option) any later version.
 9  
 //
 10  
 // This library is distributed in the hope that it will be useful,
 11  
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 // Lesser General Public License for more details.
 14  
 //
 15  
 // You should have received a copy of the GNU Lesser General Public
 16  
 // License along with this library; if not, write to the Free Software
 17  
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 ////////////////////////////////////////////////////////////////////////////////
 19  
 package com.puppycrawl.tools.checkstyle.checks.regexp;
 20  
 
 21  
 import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
 22  
 import java.io.File;
 23  
 import java.util.List;
 24  
 
 25  
 /**
 26  
  * Implementation of a check that looks for a single line in any file type.
 27  
  * @author Oliver Burn
 28  
  */
 29  4
 public class RegexpSinglelineCheck extends AbstractFileSetCheck
 30  
 {
 31  
     /** The detection options to use. */
 32  4
     private DetectorOptions mOptions = new DetectorOptions(0, this);
 33  
     /** The detector to use. */
 34  
     private SinglelineDetector mDetector;
 35  
 
 36  
     @Override
 37  
     public void beginProcessing(String aCharset)
 38  
     {
 39  4
         super.beginProcessing(aCharset);
 40  4
         mDetector = new SinglelineDetector(mOptions);
 41  4
     }
 42  
 
 43  
     @Override
 44  
     protected void processFiltered(File aFile, List<String> aLines)
 45  
     {
 46  4
         mDetector.processLines(aLines);
 47  4
     }
 48  
 
 49  
     /**
 50  
      * Set the format of the regular expression to match.
 51  
      * @param aFormat the format of the regular expression to match.
 52  
      */
 53  
     public void setFormat(String aFormat)
 54  
     {
 55  4
         mOptions.setFormat(aFormat);
 56  4
     }
 57  
 
 58  
     /**
 59  
      * Set the message to report for a match.
 60  
      * @param aMessage the message to report for a match.
 61  
      */
 62  
     public void setMessage(String aMessage)
 63  
     {
 64  1
         mOptions.setMessage(aMessage);
 65  1
     }
 66  
 
 67  
     /**
 68  
      * Set the minimum number of matches required per file.
 69  
      * @param aMinimum the minimum number of matches required per file.
 70  
      */
 71  
     public void setMinimum(int aMinimum)
 72  
     {
 73  0
         mOptions.setMinimum(aMinimum);
 74  0
     }
 75  
 
 76  
     /**
 77  
      * Set the maximum number of matches required per file.
 78  
      * @param aMaximum the maximum number of matches required per file.
 79  
      */
 80  
     public void setMaximum(int aMaximum)
 81  
     {
 82  0
         mOptions.setMaximum(aMaximum);
 83  0
     }
 84  
 
 85  
     /**
 86  
      * Set whether to ignore case when matching.
 87  
      * @param aIgnore whether to ignore case when matching.
 88  
      */
 89  
     public void setIgnoreCase(boolean aIgnore)
 90  
     {
 91  2
         mOptions.setIgnoreCase(aIgnore);
 92  2
     }
 93  
 }