View Javadoc

1   package org.codehaus.mojo.fitnesse.log;
2   
3   /*
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, version 2.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU General Public License for more details.
12   *
13   * You should have received a copy of the GNU General Public License
14   * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
15   */
16  
17  import org.codehaus.plexus.util.cli.StreamConsumer;
18  
19  public class MultipleConsumer
20      implements FitnesseStreamConsumer
21  {
22      LogConsumer mLog;
23  
24      FileConsumer mFile;
25  
26      private boolean mHasGeneratedResultFile = false;
27  
28      public MultipleConsumer( LogConsumer pLog, FileConsumer pFile )
29      {
30          super();
31          mLog = pLog;
32          mFile = pFile;
33      }
34  
35      public void consumeLine( String pMessage )
36      {
37          mLog.consumeLine( pMessage );
38          mFile.consumeLine( pMessage );
39          mHasGeneratedResultFile = mHasGeneratedResultFile || pMessage.startsWith( "Formatting as html" );
40      }
41  
42      public boolean hasGeneratedResultFile()
43      {
44          return mHasGeneratedResultFile;
45      }
46  
47      public StreamConsumer getLogConsumer()
48      {
49          return mLog;
50      }
51  
52      public FileConsumer getFileConsumer()
53      {
54          return mFile;
55      }
56  
57  }