01: /*
02: * Created on Mar 12, 2003
03: *
04: * Dbmjui is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License version 2 as
06: * published by the Free Software Foundation.
07: *
08: * Dbmjui is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * General Public License for more details.
12: *
13: * You should have received a copy of the GNU General Public
14: * License along with dbmjui; see the file COPYING. If not,
15: * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16: * Boston, MA 02111-1307, USA.
17: *
18: */
19: package fr.aliacom.form.storage;
20:
21: import java.io.InputStream;
22:
23: /**
24: * @author tom
25: *
26: * (c) 2001, 2003 Thomas Cataldo
27: */
28: public final class RessourceRepository implements IFormRepository,
29: IIconRepository, IScriptRepository {
30:
31: private String formsDir;
32: private String iconsDir;
33: private String iconsExtension;
34: private String scriptsDir;
35:
36: /**
37: * Loads forms parts from ressources (directories in classpath or jar files)
38: * @param formsDir without /
39: * @param iconsDir without /
40: * @param iconsExtension e.g. .gif
41: * @param scriptsDir without /
42: */
43: public RessourceRepository(String formsDir, String iconsDir,
44: String iconsExtension, String scriptsDir) {
45: this .formsDir = formsDir + "/";
46: this .iconsDir = iconsDir + "/";
47: this .iconsExtension = iconsExtension;
48: this .scriptsDir = scriptsDir + "/";
49: }
50:
51: /* (non-Javadoc)
52: * @see fr.aliacom.form.storage.IFormStore#loadForm(java.lang.String)
53: */
54: public InputStream loadForm(String formName) {
55: return ClassLoader.getSystemResourceAsStream(formsDir
56: + formName);
57: }
58:
59: /* (non-Javadoc)
60: * @see fr.aliacom.form.storage.IIconStore#loadIcon(java.lang.String)
61: */
62: public InputStream loadIcon(String iconName) {
63: return ClassLoader.getSystemResourceAsStream(iconsDir
64: + iconName + iconsExtension);
65: }
66:
67: /* (non-Javadoc)
68: * @see fr.aliacom.form.storage.IScriptStore#loadScript(java.lang.String)
69: */
70: public InputStream loadScript(String scriptName) {
71: return ClassLoader.getSystemResourceAsStream(scriptsDir
72: + scriptName);
73: }
74:
75: }
|