View Javadoc
1   package net.logAnalyzer.handlers;
2   
3   import net.logAnalyzer.analysis.LAAnalyzer;
4   import net.logAnalyzer.converters.LAConverter;
5   import net.logAnalyzer.converters.UnknownOrLiteralConverterException;
6   
7   /***
8    * 
9    * @author Karim REFEYTON
10   *
11   */
12  public class EmptyLogHandler implements LALogHandler {
13      /***
14       * Analyzers to apply.
15       */
16      private LAAnalyzer[] analyzers = null;
17  
18      /***
19       * Converters defined in the log4j pattern.
20       */
21      private LAConverter[] converters = null;
22  
23      /***
24       * Last exception thrown by the parsing or analysis processes.
25       */
26      private Exception lastException = null;
27  
28      /***
29       * <tt>true</tt> if the handler is currently parsing the log.
30       */
31      private boolean parsing = false;
32  
33      /***
34       * Creates a new empty log handler.
35       */
36      public EmptyLogHandler() {
37          super();
38          analyzers = new LAAnalyzer[0];
39          converters = new LAConverter[0];
40      }
41  
42      /*
43       * @see net.logAnalyzer.handlers.LALogHandler#addLogHandlerListener(net.logAnalyzer.handlers.LALogHandlerListener)
44       */
45      public void addLogHandlerListener(LALogHandlerListener listener) {
46      }
47  
48      /*
49       * @see net.logAnalyzer.handlers.LALogHandler#fireEndParsing()
50       */
51      public void fireEndParsing() {
52      }
53  
54      /*
55       * @see net.logAnalyzer.handlers.LALogHandler#fireStartParsing()
56       */
57      public void fireStartParsing() {
58      }
59  
60      /*
61       * @see net.logAnalyzer.handlers.LALogHandler#getAnalyzers()
62       */
63      public LAAnalyzer[] getAnalyzers() {
64          return analyzers;
65      }
66  
67      /*
68       * @see net.logAnalyzer.handlers.LALogHandler#getConverter(int)
69       */
70      public LAConverter getConverter(int index) {
71          return null;
72      }
73  
74      /*
75       * @see net.logAnalyzer.handlers.LALogHandler#getConverter(java.lang.String)
76       */
77      public LAConverter getConverter(String literal)
78              throws UnknownOrLiteralConverterException {
79          return null;
80      }
81  
82      /*
83       * @see net.logAnalyzer.handlers.LALogHandler#getConverterIndex(java.lang.String)
84       */
85      public int getConverterIndex(String literal)
86              throws UnknownOrLiteralConverterException {
87          return 0;
88      }
89  
90      /*
91       * @see net.logAnalyzer.handlers.LALogHandler#getConverters()
92       */
93      public LAConverter[] getConverters() {
94          return converters;
95      }
96  
97      /*
98       * @see net.logAnalyzer.handlers.LALogHandler#getLastException()
99       */
100     public Exception getLastException() {
101         return lastException;
102     }
103 
104     /*
105      * @see net.logAnalyzer.handlers.LALogHandler#getMaxRecords()
106      */
107     public int getMaxRecords() {
108         return 0;
109     }
110 
111     /*
112      * @see net.logAnalyzer.handlers.LALogHandler#getMessage(int)
113      */
114     public LAMessage getMessage(int index) {
115         return null;
116     }
117 
118     /*
119      * @see net.logAnalyzer.handlers.LALogHandler#getMessageConverter()
120      */
121     public LAConverter getMessageConverter() {
122         return null;
123     }
124 
125     /*
126      * @see net.logAnalyzer.handlers.LALogHandler#getMessages(int, int)
127      */
128     public LAMessage[] getMessages(int start, int end) {
129         return new LAMessage[0];
130     }
131 
132     /*
133      * @see net.logAnalyzer.handlers.LALogHandler#getPercentDone()
134      */
135     public int getPercentDone() {
136         return 100;
137     }
138 
139     /*
140      * @see net.logAnalyzer.handlers.LALogHandler#getSize()
141      */
142     public int getSize() {
143         return 0;
144     }
145 
146     /*
147      * @see net.logAnalyzer.handlers.LALogHandler#isParsing()
148      */
149     public boolean isParsing() {
150         return parsing;
151     }
152 
153     /***
154      * Do nothing expected sending
155      * {@link LALogHandlerListener#startParsing(LALogHandler)} and
156      * {@link LALogHandlerListener#endParsing(LALogHandler)} events.
157      * 
158      * @see net.logAnalyzer.handlers.LALogHandler#parse()
159      */
160     public void parse() throws ParsingException {
161         fireStartParsing();
162         fireEndParsing();
163     }
164 
165     /*
166      * @see net.logAnalyzer.handlers.LALogHandler#removeLogHandlerListener(net.logAnalyzer.handlers.LALogHandlerListener)
167      */
168     public void removeLogHandlerListener(LALogHandlerListener listener) {
169     }
170 
171     /*
172      * 
173      * 
174      * @see net.logAnalyzer.handlers.LALogHandler#setAnalyzers(net.logAnalyzer.analysis.LAAnalyzer[])
175      */
176     public void setAnalyzers(LAAnalyzer[] newAnalyzers) {
177         analyzers = newAnalyzers;
178     }
179 
180     /*
181      * 
182      * 
183      * @see net.logAnalyzer.handlers.LALogHandler#setMaxRecords(int)
184      */
185     public void setMaxRecords(int maxRecords) {
186     }
187 
188     /*
189      * 
190      * 
191      * @see java.lang.Runnable#run()
192      */
193     public void run() {
194         try {
195             parsing = true;
196             parse();
197         } catch (ParsingException e) {
198             lastException = e;
199         } finally {
200             parsing = false;
201         }
202     }
203 }