01 /*
02 * This class is part of DocWhatsUp, a bug profiling and -reporting lib.
03 *
04 * Copyright (C)
05 *
06 * This library is free software; you can redistribute it and/or modify it
07 * under the terms of the GNU General Public License as published by the
08 * Free Software Foundation; either version 2 of the License, or (at your
09 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * EXTENSION:
21 * Linking DocWhatsUp statically or dynamically with other modules is making a
22 * combined work based on DocWhatsUp. Thus, the terms and conditions of the
23 * GNU General Public License cover the whole combination.
24 *
25 * As a special exception, the copyright holder of DocWhatsUp give you
26 * permission to link DocWhatsUp with independent modules that communicate with
27 * DocWhatsUp solely through the DocWhatsUp.java interface, regardless of the
28 * license terms of these independent modules, and to copy and distribute the
29 * resulting combined work under terms of your choice, provided that
30 * every copy of the combined work is accompanied by a complete copy of
31 * the source code of DocWhatsUp (the version of DocWhatsUp used to produce the
32 * combined work), being distributed under the terms of the GNU General
33 * Public License plus this exception. An independent module is a module
34 * which is not derived from or based on DocWhatsUp.
35
36 * Note that people who make modified versions of DocWhatsUp are not obligated
37 * to grant this special exception for their modified versions; it is
38 * their choice whether to do so. The GNU General Public License gives
39 * permission to release a modified version without this exception; this
40 * exception also makes it possible to release a modified version which
41 * carries forward this exception.
42 *
43 * Author: Philipp Bartsch; codeshaker@gmx.net
44 */
45
46 package org.shaker.dwu;
47
48 import java.io.BufferedReader;
49 import java.io.File;
50 import java.io.FileReader;
51
52 import javax.swing.filechooser.FileFilter;
53
54 /**
55 * This is a abstract basic class for import filters.
56 *
57 * @author <A HREF="mailto:codeshaker@gmx.net">
58 * Philipp Bartsch (codeshaker@gmx.net)</A>,
59 * <A HREF="../../../../gpl.txt">GPL License</A>
60 */
61 public abstract class ExtendedFilter
62 extends FileFilter {
63
64
65 /**
66 * This method will extract the data out of a preferences file.
67 *
68 * @param file the file
69 * @return boolean a success flag
70 */
71 protected abstract boolean resolvePropFile (final File file);
72
73 /**
74 * Reads the content of a textual file into a String.
75 *
76 * @param file requested file
77 * @return String the filecontent
78 */
79 final static String readFileToString (final File file) {
80 String line;
81 final StringBuffer buffer = new StringBuffer();
82 try {
83 BufferedReader reader = new BufferedReader(new FileReader(file));
84 while ((line = reader.readLine()) != null)
85 buffer.append(line);
86 reader.close();
87 return buffer.toString();
88 } catch (Exception e) {
89 ToolBox.logException(e);
90 return "";
91 }
92 }
93 }
|