1 /* Open Log Viewer
2 *
3 * Copyright 2011
4 *
5 * This file is part of the OpenLogViewer project.
6 *
7 * OpenLogViewer software is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * OpenLogViewer software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with any OpenLogViewer software. If not, see http://www.gnu.org/licenses/
19 *
20 * I ask that if you make any changes to this file you fork the code on github.com!
21 *
22 */
23
24 package org.diyefi.openlogviewer.decoder;
25
26 import java.io.File;
27 import org.diyefi.openlogviewer.genericlog.GenericLog;
28
29 /**
30 * Typical constructor for this class would look like this <br>
31 * <code>
32 * public CSVTypeLog(File f) {<br>
33 this.setLogFile(f);<br>
34 this.setDecodedLog(new GenericLog());<br>
35 this.setT(new Thread(this, "CSV Type Log Loading"));<br>
36 this.getT().setPriority(Thread.MAX_PRIORITY);<br>
37 this.getT().start();<br>
38
39 }</code>
40 * @author Bryan Harris
41 */
42 public abstract class AbstractDecoder implements Runnable {
43
44 /**
45 * logFile is the <code>File</code> object that points to the file you are
46 * attempting to open.
47 */
48 private File logFile;
49
50 /**
51 * decodedLog is the outcome of parsing the log file, this will be injected into the program
52 * through property change listeners and this object will be come null when finished or fail.
53 */
54 private GenericLog decodedLog;
55
56 /**
57 * this object is threaded so that the gui does not freeze while parsing
58 */
59 private Thread t;
60
61 /**
62 * used for getting the decided log for injection to the main pieces of the program that will use it
63 * @return GenericLog
64 */
65 public final GenericLog getDecodedLog() {
66 return decodedLog;
67 }
68
69 /**
70 * sets the GenericLog
71 * @param decodedLog
72 */
73 public final void setDecodedLog(final GenericLog decodedLog) {
74 this.decodedLog = decodedLog;
75 }
76
77 /**
78 * get the log File
79 * @return File
80 */
81 public final File getLogFile() {
82 return logFile;
83 }
84
85 /**
86 * set the log File
87 * @param logFile
88 */
89 public final void setLogFile(final File logFile) {
90 this.logFile = logFile;
91 }
92
93 /**
94 * get the thread, use this if you would like to give the thread a name such as "TYPEOFLOG Thread"<br>
95 * can also be used to set the thread priority
96 * after initialization of all variables required by the extended class you <b>MUST</b> call:<br>
97 * this.getT().start();
98 * @return the thread that this decoder is running in.
99 */
100 public final Thread getT() {
101 return t;
102 }
103
104 /**
105 * set the Thread
106 * @param t
107 */
108 public final void setT(final Thread t) {
109 this.t = t;
110 }
111 }