View Javadoc

1   /***
2    * Memento.java
3    *
4    * This file is part of the creme library.
5    * The creme library intends to ease the development effort of large
6    * applications by providing easy to use support classes.
7    *
8    * Copyright (C) 2003 Denis Bregeon
9    *
10   * This library is free software; you can redistribute it and/or
11   * modify it under the terms of the GNU Lesser General Public
12   * License as published by the Free Software Foundation; either
13   * version 2.1 of the License, or (at your option) any later version.
14   *
15   * This library is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18   * Lesser General Public License for more details.
19   *
20   * You should have received a copy of the GNU Lesser General Public
21   * License along with this library; if not, write to the Free Software
22   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23   *
24   * contact information: dbregeon@sourceforge.net
25   */
26  package org.jcreme.state;
27  
28  import java.util.prefs.Preferences;
29  
30  /***
31   * This interface specifies Mementos. Mementos are classes used to store the
32   * state of presentation objects. Functional objects states should be persisted
33   * differently. Mementos are designed to be stored in Preferences, whatever the
34   * actual implementation of these.
35   * 
36   * @author $Author: dbregeon $
37   * @version $Revision: 1.2 $
38   */
39  public interface Memento {
40      /***
41       * This method enables to store the Memento into Preferences.
42       * 
43       * @param preferences
44       *            the Preferences node where the Memento should be stored.
45       * @throws MementoException if an error occured while storing the memento contents
46       * in the preferences.
47       */
48      void store(Preferences preferences) throws MementoException;
49  
50      /***
51       * This method enables to restore a Memento from Preferences.
52       * 
53       * @param preferences
54       *            the Preferences node from which the Memento should be loaded.
55       * @throws MementoException if an error occured while loading the memento contents
56       * from the preferences.
57       */
58      void load(Preferences preferences) throws MementoException;
59      /***
60       * Updates the contents of the Memento from values in o.
61       * @param o the Object to remember.
62       * @throws IllegalArgumentException if this Memento can not handle o.
63       * @throws MementoException if an error occured while updating the memento contents.
64       */
65      void updateMemento(Object o) throws IllegalArgumentException, MementoException;
66      /***
67       * Updates the Object o with values stored in this Memento.
68       * @param o the Object to update.
69       * @throws IllegalArgumentException if this Memento can not handle o.
70       * @throws MementoException if an error occured while updating the object.
71       */
72      void updateObject(Object o) throws IllegalArgumentException, MementoException;
73  }