01: package net.suberic.pooka.resource;
02:
03: import net.suberic.util.*;
04: import net.suberic.pooka.ssl.*;
05: import net.suberic.pooka.*;
06: import javax.activation.*;
07:
08: import java.net.*;
09: import java.io.*;
10:
11: /**
12: * A ResourceManager which uses files.
13: */
14: public class FileResourceManager extends ResourceManager {
15:
16: /**
17: * Creates a VariableBundle to be used.
18: */
19: public VariableBundle createVariableBundle(String fileName,
20: VariableBundle defaults) {
21: try {
22: java.io.File f = new java.io.File(fileName);
23: if (!f.exists())
24: f.createNewFile();
25: return new net.suberic.util.VariableBundle(f, defaults);
26: } catch (java.io.IOException ioe) {
27: //new net.suberic.util.VariableBundle(url.openStream(), "net.suberic.pooka.Pooka");
28: return defaults;
29: }
30:
31: }
32:
33: /**
34: * Creates a MailcapCommandMap to be used.
35: */
36: public MailcapCommandMap createMailcap(String fileName)
37: throws java.io.IOException {
38: return new FullMailcapCommandMap(fileName);
39: }
40:
41: /**
42: * Creates a PookaTrustManager.
43: */
44: public PookaTrustManager createPookaTrustManager(
45: javax.net.ssl.TrustManager[] pTrustManagers, String fileName) {
46: return new PookaTrustManager(pTrustManagers, fileName);
47: }
48:
49: public java.io.InputStream getInputStream(String pFileName)
50: throws java.io.IOException {
51: try {
52: URL url = new URL(pFileName);
53: return url.openStream();
54: } catch (MalformedURLException mue) {
55: return new FileInputStream(new File(pFileName));
56: }
57: }
58:
59: public java.io.OutputStream getOutputStream(String pFileName)
60: throws java.io.IOException {
61: return new FileOutputStream(new File(pFileName));
62: }
63: }
|