1 package com.explosion.utilities.preferences.persist;
2
3 import java.util.Map;
4 import java.util.prefs.Preferences;
5
6 import com.explosion.utilities.preferences.impl.inmemory.InMemoryPreferencePersister;
7 import com.explosion.utilities.preferences.impl.sun.SunPreferencePersister;
8 import com.explosion.utilities.preferences.impl.xml.XMLPreferencePersistenceRequirement;
9 import com.explosion.utilities.preferences.impl.xml.XMLPreferencePersister;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 /***
32 * @author Stephen Cowx
33 * Created on 14-Mar-2005
34 */
35 public class PreferencePersisterFactory
36 {
37
38 /***
39 *
40 */
41 public PreferencePersisterFactory()
42 {
43 }
44
45 public static PreferencePersister createPreferencePersister(Object referenceToStore)
46 {
47 PreferencePersister persister = null;
48
49 if (referenceToStore instanceof Map)
50 {
51 return InMemoryPreferencePersister.createPreferencePersistor(referenceToStore);
52 }
53 else if (referenceToStore instanceof Preferences)
54 {
55 return SunPreferencePersister.createPreferencePersistor(referenceToStore);
56 }
57 else if (referenceToStore instanceof XMLPreferencePersistenceRequirement)
58 {
59 return XMLPreferencePersister.createPreferencePersistor(referenceToStore);
60 }
61
62 return persister;
63 }
64
65 }