1 package net.logAnalyzer.handlers;
2
3 import java.io.FileNotFoundException;
4 import java.io.IOException;
5 import java.util.Vector;
6
7 import net.logAnalyzer.utils.FilesSetReader;
8
9 /***
10 * This log handler saves messageLabel in memory. You must not use it for large log
11 * files.
12 *
13 * @author Karim REFEYTON
14 * @version 0.1
15 */
16 public class MemoryLogHandler extends AbstractLogHandler {
17 /***
18 * Maximum log file size recommended to use a MemoryLogHangler. If the file
19 * is longer than MAXSIZE_RECOMMENDED, you must use a
20 * {@link OnDemandLogHandler} for better performances and to avoid
21 * {@link OutOfMemoryError}.
22 */
23 public static final int MAXSIZE_RECOMMENDED = 10485760;
24
25 /***
26 * Parsed log messages.
27 */
28 private Vector messages = new Vector();
29
30 /***
31 * @param input
32 * @param pattern
33 * @throws FileNotFoundException
34 * @throws NoConverterException
35 */
36 public MemoryLogHandler(FilesSetReader input, String pattern)
37 throws FileNotFoundException, NoConverterException {
38 super(input, pattern);
39 }
40
41 /***
42 * Modification to the inherited behavior.
43 *
44 * @see net.logAnalyzer.handlers.LALogHandler#getSize()
45 */
46 public int getSize() {
47 return messages.size();
48 }
49
50 /***
51 * Modification to the inherited behavior.
52 *
53 * @see AbstractLogHandler#loadMessage(int)
54 */
55 protected LAMessage loadMessage(int index) {
56 return (LAMessage) messages.get(index);
57 }
58
59 /***
60 * Modification to the inherited behavior.
61 *
62 * @see AbstractLogHandler#saveMessage(LAMessage, long)
63 */
64 protected void saveMessage(LAMessage message, long pointer) {
65 messages.add(message);
66 }
67
68 /***
69 * Modification to the inherited behavior.
70 *
71 * @see AbstractLogHandler#initParsing()
72 */
73 protected void initParsing() throws IOException {
74 super.initParsing();
75 messages = new Vector();
76 }
77 }