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 package com.unitesk.atp.text.filters;
32
33 import java.io.File;
34 import java.io.FileNotFoundException;
35 import java.io.IOException;
36
37 import com.unitesk.atp.messages.FileNotFoundMessage;
38 import com.unitesk.atp.messages.IOErrorMessage;
39 import com.unitesk.atp.messages.InternalErrorMessage;
40 import com.unitesk.atp.messages.MessageBox;
41
42 /***
43 * Implementation of exception handler that put message in given message box.
44 *
45 * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
46 * @version $Id: MessageBoxExceptionHandler.java,v 1.1 2005/07/06 12:37:11 all-x Exp $
47 * @since 3.4
48 */
49 public class MessageBoxExceptionHandler implements ExceptionHandler
50 {
51 private MessageBox mbox;
52 private File file;
53
54 public MessageBoxExceptionHandler( MessageBox mbox, File file )
55 {
56 setMessageBox( mbox );
57 setFile( file );
58 }
59
60 public MessageBox getMessageBox()
61 {
62 return mbox;
63 }
64
65 public void setMessageBox( MessageBox mbox )
66 {
67 this.mbox = mbox;
68 }
69
70 public File getFile()
71 {
72 return file;
73 }
74
75 public void setFile( File file )
76 {
77 this.file = file;
78 }
79
80 public void process( Exception e )
81 {
82 if( e instanceof IOException )
83 {
84 mbox.fatal( new IOErrorMessage( file ) );
85 } else
86 if( e instanceof FileNotFoundException )
87 {
88 mbox.fatal( new FileNotFoundMessage( file ) );
89 } else {
90 mbox.fatal( new InternalErrorMessage( e.toString() ) );
91 }
92 }
93 }