Package: ProcessConsolePrinter

ProcessConsolePrinter

nameinstructionbranchcomplexitylinemethod
ProcessConsolePrinter(ConsoleWriter, InputStream, PdfGenerator)
M: 26 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
detectFail(String)
M: 18 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getFails()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
run()
M: 36 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.plugins.latex
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.latex.utility;
23:
24: import java.io.BufferedReader;
25: import java.io.IOException;
26: import java.io.InputStream;
27: import java.io.InputStreamReader;
28: import java.util.ArrayList;
29: import java.util.List;
30:
31: import org.overture.ide.ui.internal.util.ConsoleWriter;
32:
33: public class ProcessConsolePrinter extends Thread
34: {
35:         ConsoleWriter cw = null;
36:         InputStream stream = null;
37:         List<String> fails = new ArrayList<String>();
38:         PdfGenerator generator = null;
39:
40:         public ProcessConsolePrinter(ConsoleWriter cw, InputStream inputStream,
41:                         PdfGenerator pdfLatex)
42:         {
43:                 this.cw = cw;
44:                 this.stream = inputStream;
45:                 this.generator = pdfLatex;
46:         }
47:
48:         @Override
49:         public void run()
50:         {
51:
52:                 String line = null;
53:                 BufferedReader input = new BufferedReader(new InputStreamReader(stream));
54:                 try
55:                 {
56:•                        while ((line = input.readLine()) != null)
57:                         {
58:                                 detectFail(line);
59:•                                if (cw != null)
60:                                 {
61:                                         cw.println(line);
62:                                 } else
63:                                 {
64:                                         System.out.println(line);
65:                                 }
66:                         }
67:                 } catch (IOException e)
68:                 {
69:                         // TODO Auto-generated catch block
70:                         e.printStackTrace();
71:                 }
72:         }
73:
74:         public List<String> getFails()
75:         {
76:                 return this.fails;
77:         }
78:
79:         private void detectFail(String line)
80:         {
81:•                if (line.contains("Emergency stop") || line.contains("LaTeX Error"))
82:                 {
83:                         fails.add(line);
84:                         generator.setFail(true);
85:                 }
86:
87:         }
88: }