gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
metrics_csv wrong parameter for expression handling
[mjc2wsl.git] / src / com / quemaster / transformations / TransMessages.java
1 package com.quemaster.transformations;
2 /*
3 Copyright (C) 2014, 2018 Doni Pracner
5 This file is part of mjc2wsl.
7 mjc2wsl is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 mjc2wsl 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.
17 You should have received a copy of the GNU General Public License
18 along with mjc2wsl. If not, see <http://www.gnu.org/licenses/>.
19 */
20 import java.io.PrintStream;
22 /**
23 * Handle the messages that the translator (or someone else) will
24 * give to this class depending on the print level.
25 *
26 */
27 public class TransMessages {
28 private int printLevel;
29 private int[] messageCounters;
30 public static final int M_DEB = 0;
31 public static final int M_WAR = 1;
32 public static final int M_NOTIFY = 2;
33 public static final int M_ERR = 5;
34 public static final int M_QUIET = 10;
35 private PrintStream outStream = System.out;
37 public TransMessages() {
38 this.setPrintLevel(M_ERR);
39 this.messageCounters = new int[TransMessages.M_QUIET];
40 }
42 public void message(String mes, int level){
43 if (level>=getPrintLevel()) {
44 outStream.println(mes);
45 }
46 messageCounters[level]++;
47 }
49 public void message(String string) {
50 message(string,M_NOTIFY);
51 }
53 public int getLevelMessageCount(int level){
54 if (level < messageCounters.length){
55 return messageCounters[level];
56 }
57 return 0;
58 }
60 public void printMessageCounters(PrintStream out){
61 if (printLevel < M_QUIET)
62 out.println("total errors:" + messageCounters[TransMessages.M_ERR]
63 + " warnings:" + messageCounters[TransMessages.M_WAR]
64 + " notifications:" + messageCounters[TransMessages.M_NOTIFY]
65 );
66 }
68 public void printMessageCounters(){
69 printMessageCounters(outStream);
70 }
72 public int getPrintLevel() {
73 return printLevel;
74 }
76 public void setPrintLevel(int printLevel) {
77 this.printLevel = printLevel;
78 }
80 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner