Coverage Report - net.sf.jmatchparser.template.ChainedFormatter
 
Classes in this File Line Coverage Branch Coverage Complexity
ChainedFormatter
100%
8/8
100%
2/2
1,333
 
 1  
 /*
 2  
  * Copyright (c) 2006 - 2011 Michael Schierl
 3  
  * All rights reserved.
 4  
  * 
 5  
  * This program is free software: you can redistribute it and/or modify
 6  
  * it under the terms of the GNU General Public License as published by
 7  
  * the Free Software Foundation, either version 2 of the License, or
 8  
  * (at your option) any later version.
 9  
  * 
 10  
  * This program 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
 13  
  * GNU General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 package net.sf.jmatchparser.template;
 19  
 
 20  
 import java.io.IOException;
 21  
 import java.io.PrintStream;
 22  
 
 23  
 /**
 24  
  * A formatter that calls multiple formatters in sequence.
 25  
  */
 26  
 public class ChainedFormatter implements Formatter {
 27  
         private final Formatter[] formatters;
 28  
         private final String name;
 29  
 
 30  
         /**
 31  
          * Create a new chained formatter.
 32  
          * 
 33  
          * @param name
 34  
          *            Name of the formatter
 35  
          * @param formatters
 36  
          *            Formatters to call
 37  
          */
 38  212
         public ChainedFormatter(String name, Formatter... formatters) {
 39  212
                 this.name = name;
 40  212
                 this.formatters = formatters;
 41  212
         }
 42  
 
 43  
         @Override
 44  
         public String getName() {
 45  203
                 return name;
 46  
         }
 47  
 
 48  
         @Override
 49  
         public String format(String content, PrintStream debugStream) throws IOException {
 50  24
                 for (Formatter formatter : formatters) {
 51  13
                         content = formatter.format(content, debugStream);
 52  
                 }
 53  11
                 return content;
 54  
         }
 55  
 }