01: /*
02: * Sun Public License Notice
03: *
04: * The contents of this file are subject to the Sun Public License
05: * Version 1.0 (the "License"). You may not use this file except in
06: * compliance with the License. A copy of the License is available at
07: * http://www.sun.com/
08: *
09: * The Original Code is NetBeans. The Initial Developer of the Original
10: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
11: * Microsystems, Inc. All Rights Reserved.
12: */
13:
14: package org.netbeans.editor;
15:
16: import java.util.HashMap;
17:
18: /**
19: * This singleton class is an editor state encapsulation object. Every part of
20: * the editor could store its state-holder here and it will be automatically
21: * persistent across restarts. It is intended for any state informations that
22: * are not "Settings", like the contents of the input field histories,
23: * persistent, named bookmarks or so. The implementation is just like a HashMap
24: * indexed by state-holders' names. Typical usage is <CODE>myState =
25: * EditorState.get( MY_STATE_NAME );</CODE> There is no support for state
26: * change notifications, but the inserted value objects could be singletons as
27: * well and could do its own notifications.
28: *
29: * @author Petr Nejedly
30: * @version 1.0
31: */
32: public class EditorState {
33: private static HashMap state = new HashMap();
34:
35: /** This is fixed singleton, don't need instances */
36: private EditorState() {
37: }
38:
39: /** Retrieve the object specified by the key. */
40: public static Object get(Object key) {
41: return state.get(key);
42: }
43:
44: /** Store the object under specified key */
45: public static void put(Object key, Object value) {
46: state.put(key, value);
47: }
48:
49: public static HashMap getStateObject() {
50: return state;
51: }
52:
53: public static void setStateObject(HashMap stateObject) {
54: state = stateObject;
55: }
56: }
|