View Javadoc

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.InMemoryPreferenceGroupPersister;
7   import com.explosion.utilities.preferences.impl.sun.SunPreferenceGroupPersister;
8   import com.explosion.utilities.preferences.impl.xml.XMLPreferencePersistenceRequirement;
9   
10  
11  /* =============================================================================
12   *       
13   *     Copyright 2004 Stephen Cowx
14   *
15   *     Licensed under the Apache License, Version 2.0 (the "License");
16   *     you may not use this file except in compliance with the License.
17   *     You may obtain a copy of the License at
18   *
19   *     http://www.apache.org/licenses/LICENSE-2.0
20   *
21   *     Unless required by applicable law or agreed to in writing, software
22   *     distributed under the License is distributed on an "AS IS" BASIS,
23   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24   *     See the License for the specific language governing permissions and
25   *     limitations under the License.
26   * 
27   * =============================================================================
28   */
29  
30  /***
31   * @author Stephen Cowx
32   * Created on 14-Mar-2005
33   */
34  public class PreferenceGroupPersisterFactory
35  {
36  
37      /***
38       * 
39       */
40      public PreferenceGroupPersisterFactory()
41      {
42      }
43      
44      public static PreferenceGroupPersister createPreferenceGroupPersister(Object referenceToStore)
45      {
46      	if (referenceToStore instanceof Map)
47          {
48              return InMemoryPreferenceGroupPersister.createPreferenceGroupPersistor(referenceToStore);
49          }
50          else if (referenceToStore instanceof Preferences)
51          {
52              return SunPreferenceGroupPersister.createPreferenceGroupPersistor(referenceToStore);
53          }
54          else if (referenceToStore instanceof XMLPreferencePersistenceRequirement)
55          {
56              return null;
57          }
58          
59          return null;
60      }
61  
62  }