gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
array assignment simplified
[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 = System.out;
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.println(mes);
43 }
44 messageCounters[level]++;
45 }
47 void printMessageCounters(PrintStream out){
48 out.println("total errors:"+messageCounters[TransMessages.M_ERR]+" warnings:"+messageCounters[TransMessages.M_WAR]);
49 }
51 void printMessageCounters(){
52 printMessageCounters(outStream);
53 }
55 public int getPrintLevel() {
56 return printLevel;
57 }
59 public void setPrintLevel(int printLevel) {
60 this.printLevel = printLevel;
61 }
62 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner