View Javadoc

1   package com.explosion.utilities.preferences.persist;
2   
3   import com.explosion.utilities.preferences.Preference;
4   import com.explosion.utilities.preferences.groups.PreferencePersistenceException;
5   
6   
7   
8   
9   /* =============================================================================
10   *       
11   *     Copyright 2004 Stephen Cowx
12   *
13   *     Licensed under the Apache License, Version 2.0 (the "License");
14   *     you may not use this file except in compliance with the License.
15   *     You may obtain a copy of the License at
16   *
17   *     http://www.apache.org/licenses/LICENSE-2.0
18   *
19   *     Unless required by applicable law or agreed to in writing, software
20   *     distributed under the License is distributed on an "AS IS" BASIS,
21   *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22   *     See the License for the specific language governing permissions and
23   *     limitations under the License.
24   * 
25   * =============================================================================
26   */
27  
28  /***
29   * @author Stephen Cowx
30   * Created on 14-Mar-2005
31   */
32  public interface PreferencePersister
33  {
34  	
35  	public static final String ITEM_COUNT = "count";
36  	public static final String ITEM_NAME = "item_";
37      
38      /***
39       * Returns a reference to the backing store as understood by the PreferencePersister
40       * @return
41       */
42      public Object getReferenceToStore();
43      
44      /***
45       * Sets the reference to the backing store as understood by the PreferencePersister
46       * Effectively moving it from one store to another or moving it from one location in the same store to another
47       * @return
48       */
49      public void setReferenceToStore(Object referenceToStore);
50      
51      /***
52       * This method saves the property to preference storage, if the value is
53       * null, it should delete the entire key/value pair persisted if it exists
54       * or not save it if it does.
55       * 
56       * @throws Exception
57       */
58      public void save(Preference preference) throws PreferencePersistenceException;
59  
60      /***
61       * This method loads the preference from persistent storage if it is there, if
62       * it is not it should not populate the value.
63       * 
64       * @throws Exception
65       */
66      public void load(Preference preference) throws PreferencePersistenceException;
67  
68  }