gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
mjc2wsl, typo
[mjc2wsl.git] / src / com / quemaster / transformations / TransMessages.java
1 package com.quemaster.transformations;
2 /*
3 Copyright (C) 2014 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_ERR = 2;
33 public static final int M_QUIET = 3;
34 private PrintStream outStream = System.out;
36 public TransMessages() {
37 this.setPrintLevel(M_ERR);
38 this.messageCounters = new int[TransMessages.M_QUIET];
39 }
41 public void message(String mes, int level){
42 if (level>=getPrintLevel()) {
43 outStream.println(mes);
44 }
45 messageCounters[level]++;
46 }
48 public int getLevelMessageCount(int level){
49 if (level < messageCounters.length){
50 return messageCounters[level];
51 }
52 return 0;
53 }
55 public void printMessageCounters(PrintStream out){
56 out.println("total errors:"+messageCounters[TransMessages.M_ERR]+" warnings:"+messageCounters[TransMessages.M_WAR]);
57 }
59 public void printMessageCounters(){
60 printMessageCounters(outStream);
61 }
63 public int getPrintLevel() {
64 return printLevel;
65 }
67 public void setPrintLevel(int printLevel) {
68 this.printLevel = printLevel;
69 }
70 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner