summaryrefslogtreecommitdiff
path: root/support/makeglossariesgui/src/java/GlossaryBatchMessage.java
blob: 250c7f7156e182f5b40661526074bc0992afc25f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.dickimawbooks.makeglossariesgui;

import java.io.File;

public class GlossaryBatchMessage implements GlossaryMessage
{
   public GlossaryBatchMessage(MakeGlossariesInvoker invoker)
   {
      this.invoker = invoker;
   }

   public void message(String msg)
   {
      if (msg == null)
      {
         throw new NullPointerException();
      }

      if (!invoker.isQuiet())
      {
         System.out.println(msg);
      }
   }

   public void debug(String msg)
   {
      if (msg == null)
      {
         throw new NullPointerException();
      }

      if (invoker.isDebugMode())
      {
         System.out.println(msg);
      }
   }

   public void debug(Throwable e)
   {
      if (invoker.isDebugMode())
      {
         e.printStackTrace();
      }
   }

   public void message(GlossaryException e)
   {
      if (!invoker.isQuiet())
      {
         System.out.println(e.getMessage());

         String msg = e.getDiagnosticMessage();

         if (msg != null)
         {
            System.out.println(msg);
         }

         if (invoker.isDebugMode())
         {
            e.printStackTrace();
         }
      }
   }

   public void error(Exception e)
   {
      System.err.println(e.getMessage());
   }

   public void error(String message)
   {
      if (message == null)
      {
         throw new NullPointerException();
      }

      System.err.println(message);
   }

   public void showMessages()
   {
   }

   public void aboutToExec(String[] cmdArray, File dir)
   {
      if (invoker.isDryRunMode() || !invoker.isQuiet())
      {
         if (invoker.isDryRunMode())
         {
            System.out.println(invoker.getLabel("diagnostics.dry_run"));

         }

         for (int i = 0, n = cmdArray.length-1; i < cmdArray.length; i++)
         {
            if (i == n)
            {
               System.out.println(String.format("\"%s\"", cmdArray[i]));
            }
            else
            {
               System.out.print(String.format("\"%s\" ", cmdArray[i]));
            }
         }
      }
   }

   private MakeGlossariesInvoker invoker;
}