Source code: com/virtuosotechnologies/lib/propertyset/PropertySet.java
1 /*
2 ================================================================================
3
4 FILE: PropertySet.java
5
6 PROJECT:
7
8 Virtuoso Utilities
9
10 CONTENTS:
11
12 A set of constrained properties
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.lib.propertyset;
43
44 import com.virtuosotechnologies.lib.base.ConstrainedKey;
45
46
47 /**
48 * A set of constrained properties. This is basically a hash table with several
49 * additional features: constraints on property values, default values, and
50 * listeners on state changes. In most cases, the BasicPropertySet implementation
51 * can be used.
52 */
53 public interface PropertySet
54 {
55 /**
56 * Get a property.
57 *
58 * @param key key object for the property
59 * @return value for the property
60 */
61 public Object getValue(
62 ConstrainedKey key);
63
64
65 /**
66 * Get the default value for a property, or null if there is no default.
67 *
68 * @param key key object for the property
69 * @return default value for the property
70 */
71 public Object getDefaultValue(
72 ConstrainedKey key);
73
74
75 /**
76 * Set a property.
77 *
78 * @param key key object for the property.
79 * @param value new value for the property.
80 */
81 public void putValue(
82 ConstrainedKey key,
83 Object value);
84
85
86 /**
87 * Reset a property to the default. Sets it to null if there is no default.
88 *
89 * @param key key object for the property
90 */
91 public void resetValue(
92 ConstrainedKey key);
93
94
95 /**
96 * Add a PropertySetListener. Listeners should be added via weak
97 * references.
98 *
99 * @param listener new listener
100 */
101 public void addPropertySetListener(
102 PropertySetListener listener);
103
104
105 /**
106 * Remove a PropertySetListener. Does nothing if the listener is
107 * not already present.
108 *
109 * @param listener listener to remove
110 */
111 public void removePropertySetListener(
112 PropertySetListener listener);
113 }