gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
applied GPL to sources in src
[mjc2wsl.git] / src / TransMessages.java
1 /*
2 Copyright (C) 2014 Doni Pracner
4 This file is part of mjc2wsl.
6 mjc2wsl is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 mjc2wsl is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with mjc2wsl. If not, see <http://www.gnu.org/licenses/>.
18 */
19 import java.io.PrintStream;
21 /**
22 * Handle the messages that the translator (or someone else) will
23 * give to this class depending on the print level.
24 *
25 */
26 public class TransMessages {
27 private int printLevel;
28 public int[] messageCounters;
29 public static final int M_DEB = 0;
30 public static final int M_WAR = 1;
31 public static final int M_ERR = 2;
32 public static final int M_QUIET = 3;
33 private PrintStream outStream;
35 public TransMessages() {
36 this.setPrintLevel(M_ERR);
37 this.messageCounters = new int[TransMessages.M_QUIET];
38 }
40 void message(String mes, int level){
41 if (level>=getPrintLevel()) {
42 outStream = System.out;
43 outStream.println(mes);
44 }
45 messageCounters[level]++;
46 }
48 void printMessageCounters(PrintStream out){
49 out.println("total errors:"+messageCounters[TransMessages.M_ERR]+" warnings:"+messageCounters[TransMessages.M_WAR]);
50 }
52 void printMessageCounters(){
53 printMessageCounters(outStream);
54 }
56 public int getPrintLevel() {
57 return printLevel;
58 }
60 public void setPrintLevel(int printLevel) {
61 this.printLevel = printLevel;
62 }
63 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner