01: /*
02: *
03: * Out.java - Show a message on the output
04: * Copyright (C) 2003 Alexandre THOMAS
05: * alexthomas@free.fr
06: * http://helpgui.sourceforge.net
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: */
22:
23: package salomeTMF_plug.helpgui.util;
24:
25: import java.lang.StringBuffer;
26: import salomeTMF_plug.helpgui.HelpGui;
27:
28: /**
29: * Class aible to write a simple message on the console
30: *
31: * @author Alexandre THOMAS
32: */
33: public class Out {
34:
35: public static int OK = 0;
36:
37: public static int FAILED = 1;
38:
39: private static String[] _state = { "[ OK ]", "[FAILED]" };
40:
41: public static int length = 80;
42:
43: /** Add '.' at the end of the message. */
44: private static String addPoints(String msg) {
45: StringBuffer result = new StringBuffer(msg);
46: for (int i = msg.length(); i < length; ++i)
47: result.append(".");
48: return result.toString();
49: }
50:
51: /** Write a message on the standar output and finish it by [ OK ]. */
52: public static void msg(String msg) {
53: if (HelpGui.debug)
54: System.out.println(addPoints(msg) + _state[0]);
55: }
56:
57: /**
58: * Write a message on the standar output and finish it by the specify state
59: * (OK, or FAILED).
60: */
61: public static void msg(String msg, int state) {
62: if (HelpGui.debug)
63: System.out.println(addPoints(msg) + _state[state]);
64: }
65:
66: }
|