summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/base/IConfigStore.java
blob: b53e7c66f3d67c45f991f50529d0d6574cec6f8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.base;


import java.util.Enumeration;
import java.math.BigInteger;


/**
 * An interface represents a configuration store. 
 * A configuration store is an abstraction of a hierarchical store 
 * to keep arbitrary data indexed by string names.<p>
 * In the following example: 
 * <pre>
 *      param1=value1
 *      configStore1.param11=value11
 *      configStore1.param12=value12
 *      configStore1.subStore1.param111=value111
 *      configStore1.subStore1.param112=value112
 *      configStore2.param21=value21
 * </pre>
 * The top config store has parameters <i>param1</i> and sub-stores 
 * <i>configStore1</i> and <i>configStore2</i>. <br>
 * The following illustrates how a config store is used.
 * <pre>
 *     // the top config store is passed to the following method. 
 *     public void init(IConfigStore config) throws EBaseException {
 *       IConfigStore store = config;
 *       String valx = config.getString("param1");  
 *       // valx is "value1" <p>
 *
 *       IConfigStore substore1 = config.getSubstore("configStore1");
 *       String valy = substore1.getString("param11"); 
 *       // valy is "value11" <p>
 *	
 *       IConfigStore substore2 = config.getSubstore("configStore2");
 *       String valz = substore2.getString("param21"); 
 *       // valz is "value21" <p>
 *     }
 * </pre>
 *		
 * @version $Revision$, $Date$
 */
public interface IConfigStore extends ISourceConfigStore {

    /**
     * Gets the name of this Configuration Store.
     * <P>
     * @return The name of this Configuration store
     */
    public String getName();

    /**
     * Retrieves the value of the given property as a string.
     * <p>
     * @param name The name of the property to get
     * @return The value of the property as a String
     * @exception EPropertyNotFound If the property is not present
     * @exception EBaseException If an internal error occurred
     */
    public String getString(String name) 
        throws EPropertyNotFound, EBaseException;

    /**
     * Retrieves the value of a given property as a string or the 
     * given default value if the property is not present.
     * <P>
     * @param name The property to retrive
     * @param defval The default value to return if the property is not present
     * @return The roperty value as a string
     * @exception EBaseException If an internal error occurred
     */
    public String getString(String name, String defval) 
        throws EBaseException;

    /**
     * Stores a property and its value as a string. 
     * <p>
     * @param name The name of the property
     * @param value The value as a string
     */ 
    public void putString(String name, String value);

    /**
     * Retrieves the value of a property as a byte array.
     * <P>
     * @param name The property name
     * @return The property value as a byte array
     * @exception EPropertyNotFound If the property is not present
     * @exception EBaseException If an internal error occurred
     */
    public byte[] getByteArray(String name) 
        throws EPropertyNotFound, EBaseException;

    /**
     * Retrieves the value of a property as a byte array, using the 
     * given default value if property is not present.
     * <P>
     * @param name The name of the property
     * @param defval The default value if the property is not present.
     * @return The property value as a byte array.
     * @exception EBaseException If an internal error occurred
     */
    public byte[] getByteArray(String name, byte defval[]) 
        throws EBaseException;

    /**
     * Stores the given property and value as a byte array.
     * <p>
     * @param name The property name
     * @param value The value as a byte array to store
     */
    public void putByteArray(String name, byte value[]);

    /**
     * Retrieves the given property as a boolean.
     * <P>
     * @param name The name of the property as a string.
     * @return The value of the property as a boolean.
     * @exception EPropertyNotFound If the property is not present
     * @exception EBaseException If an internal error occurred
     */
    public boolean getBoolean(String name) 
        throws EPropertyNotFound, EBaseException;

    /**
     * Retrieves the given property as a boolean.
     * <P>
     * @param name The name of the property
     * @param defval The default value to turn as a boolean if 
     * property is not present
     * @return The value of the property as a boolean.
     * @exception EBaseException If an internal error occurred
     */
    public boolean getBoolean(String name, boolean defval) 
        throws EBaseException;

    /**
     * Stores the given property and its value as a boolean.
     * <P>
     * @param name The property name
     * @param value The value as a boolean
     */
    public void putBoolean(String name, boolean value);

    /**
     * Retrieves the given property as an integer.
     * <P>
     * @param name The property name
     * @return The property value as an integer
     * @exception EPropertyNotFound If property is not found
     * @exception EBaseException If an internal error occurred
     */
    public int getInteger(String name) 
        throws EPropertyNotFound, EBaseException;

    /**
     * Retrieves the given property as an integer.
     * <P>
     * @param name The property name
     * @return int The default value to return as an integer
     * @exception EBaseException If the value cannot be converted to a 
     * integer
     */
    public int getInteger(String name, int defval) 
        throws EBaseException;

    /**
     * Sets a property and its value as an integer.
     * <P>
     * @param name parameter name
     * @param value integer value
     */
    public void putInteger(String name, int value);

    /**
     * Retrieves the given property as a big integer.
     * <P>
     * @param name The property name
     * @return The property value as a big integer
     * @exception EPropertyNotFound If property is not found
     * @exception EBaseException If an internal error occurred
     */
    public BigInteger getBigInteger(String name) 
        throws EPropertyNotFound, EBaseException;

    /**
     * Retrieves the given property as a big integer.
     * <P>
     * @param name The property name
     * @return int The default value to return as a big integer
     * @exception EBaseException If the value cannot be converted to a 
     * integer
     */
    public BigInteger getBigInteger(String name, BigInteger defval) 
        throws EBaseException;

    /**
     * Sets a property and its value as an integer.
     * <P>
     * @param name parameter name
     * @param value big integer value
     */
    public void putBigInteger(String name, BigInteger value);

    /**
     * Creates a nested sub-store with the specified name.
     * <P>
     * @param name The name of the sub-store
     * @return The sub-store created
     */
    public IConfigStore makeSubStore(String name);

    /**
     * Retrieves the given sub-store. 
     * <P>
     * @param name The name of the sub-store
     * @return The sub-store
     */
    public IConfigStore getSubStore(String name);

    /**
     * Removes sub-store with the given name. 
     * (Removes all properties and sub-stores under this sub-store.)
     * <P>
     * @param name The name of the sub-store to remove
     */
    public void removeSubStore(String name);

    public void remove(String name);

    /**
     * Retrives and enumeration of all properties in this config-store.
     * @return An enumeration of all properties in this config-store
     */
    public Enumeration getPropertyNames();

    /**
     * Returns an enumeration of the names of the substores of 
     * this config-store.
     * <P>
     * @return An enumeration of the names of the sub-stores of this 
     * config-store
     */
    public Enumeration getSubStoreNames();

    /**
     * Commits all the data into file immediately.
     *
     * @param createBackup true if a backup file should be created
     * @exception EBaseException failed to commit
     */
    public void commit(boolean createBackup) throws EBaseException;

    /**
     * Return the number of items in this substore
     */
    public int size();
}