Source code: org/alicebot/server/core/FlatFileMultiplexor.java
1 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.geocities.com/kpdus/jad.html
3 // Decompiler options: packimports(3)
4
5 package org.alicebot.server.core;
6
7 import java.io.*;
8 import java.util.Hashtable;
9 import java.util.Properties;
10 import org.alicebot.server.core.util.DeveloperError;
11 import org.alicebot.server.core.util.Toolkit;
12
13 // Referenced classes of package org.alicebot.server.core:
14 // Multiplexor, NoSuchPredicateException
15
16 public class FlatFileMultiplexor extends Multiplexor
17 {
18
19 public FlatFileMultiplexor()
20 {
21 }
22
23 public boolean checkUser(String s, String s1, String s2, String s3)
24 {
25 return true;
26 }
27
28 public boolean createUser(String s, String s1, String s2, String s3)
29 {
30 return true;
31 }
32
33 public boolean changePassword(String s, String s1, String s2, String s3)
34 {
35 return true;
36 }
37
38 public void savePredicate(String s, String s1, String s2, String s3)
39 {
40 if(predicateSets == null)
41 predicateSets = new Hashtable();
42 Properties properties = loadPredicates(s2, s3);
43 properties.setProperty(s, s1);
44 savePredicates(properties, s2, s3);
45 }
46
47 public String loadPredicate(String s, String s1, String s2)
48 throws NoSuchPredicateException
49 {
50 if(predicateSets == null)
51 predicateSets = new Hashtable();
52 Properties properties = loadPredicates(s1, s2);
53 String s3 = properties.getProperty(s);
54 if(s3 == null)
55 throw new NoSuchPredicateException(s);
56 else
57 return s3;
58 }
59
60 private static Properties loadPredicates(String s, String s1)
61 {
62 Properties properties = new Properties();
63 String s2 = "ffm" + File.separator + s1 + File.separator + s + ".predicates";
64 Toolkit.checkOrCreate(s2, "FlatFileMultiplexor predicates file");
65 File file = new File(s2);
66 if(file.canRead())
67 try
68 {
69 properties.load(new FileInputStream(file));
70 }
71 catch(IOException ioexception)
72 {
73 throw new DeveloperError("Error trying to load predicates.", ioexception);
74 }
75 return properties;
76 }
77
78 private static void savePredicates(Properties properties, String s, String s1)
79 {
80 String s2 = "ffm" + File.separator + s1 + File.separator + s + ".predicates";
81 Toolkit.checkOrCreate(s2, "FlatFileMultiplexor predicates file");
82 try
83 {
84 properties.store(new FileOutputStream(s2), null);
85 }
86 catch(IOException ioexception)
87 {
88 System.err.println(System.getProperty("user.dir"));
89 System.err.println(ioexception.getMessage());
90 throw new DeveloperError("Error trying to save predicates.", ioexception);
91 }
92 }
93
94 public int useridCount(String s)
95 {
96 return 0;
97 }
98
99 private static Hashtable predicateSets;
100 private static final String FFM_DIR_NAME = "ffm";
101 private static final String PREDICATES_SUFFIX = ".predicates";
102 private static final String FFM_FILE_LABEL = "FlatFileMultiplexor predicates file";
103 }