1
2
3
4
5
6
7
8
9 package com.bbn.swede.core.libraries;
10
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.io.OutputStream;
14 import java.util.Properties;
15
16 /***
17 * Classes which implement this interface represent a meta-data
18 * store. String values are associated with keys, and can be
19 * separated into two mutually exclusive categories, System and
20 * User properties.
21 *
22 * Implementers are expected to extend this interface to specify
23 * accessors and mutators for domain-specific configuration
24 * options.
25 *
26 * @author aperezlo
27 */
28 public interface IConfiguration
29 {
30
31
32
33
34 /***
35 * Suffix used for all user property keys in Ontology Library metadata.
36 */
37 String USER_SUFFIX = ".user";
38 /***
39 * Suffix used for all system property keys in Ontology Library metadata.
40 */
41 String SYSTEM_SUFFIX = ".system";
42
43 /***
44 * Retrieves all system properties for this configuration.
45 * @return a {@link Properties} class containing all of the
46 * System properties.
47 */
48 Properties getSystemProperties();
49 /***
50 * Retrieves all user properties for this configuration.
51 * @return a {@link Properties} class containing all of the
52 * User properties.
53 */
54 Properties getUserProperties();
55
56 /***
57 * Mutator method for IConfiguration.
58 *
59 * @param p a {@link Properties} containing all of the System
60 * properties
61 */
62 void setSystemProperties(Properties p);
63 /***
64 * Mutator method for IConfiguration.
65 *
66 * @param p a {@link Properties} containing all of the User
67 * properties
68 */
69 void setUserProperties(Properties p);
70
71
72 /***
73 * This method is used to set System and User properties in a single
74 * operation. The method by which this is accomplished is specific to the
75 * implementation of the interface.
76 *
77 * @param p a single {@link Properties} object containing all of the System
78 * and User properties.
79 */
80 void setProperties(Properties p);
81
82 /***
83 * This method is used to get System and User properties in a single
84 * operation. The method by which this is accomplished is specific to the
85 * implementation of the interface.
86 *
87 * @return p a single {@link Properties} object containing all of the System
88 * and User properties.
89 */
90 Properties getProperties();
91 /***
92 * Mutator method to set a System property.
93 *
94 * @param key the key
95 * @param value the value associated with <code>key</code>
96 */
97 void setSystemProperty(String key, String value);
98 /***
99 * Accessor method to get a System property.
100 *
101 * @param key the key
102 * @return value the value associated with <code>key</code>
103 */
104 String getSystemProperty(String key);
105 /***
106 * Mutator method to remove a System property.
107 *
108 * @param key the key to remove from the System properties
109 */
110 void removeSystemProperty(String key);
111
112 /***
113 * Mutator method to set a User property.
114 *
115 * @param key the key
116 * @param value the value associated with <code>key</code>
117 */
118 void setUserProperty(String key, String value);
119 /***
120 * Accessor method to get a User property.
121 *
122 * @param key the key
123 * @return value the value associated with <code>key</code>
124 */
125 String getUserProperty(String key);
126 /***
127 * Mutator method to remove a User property.
128 *
129 * @param key the key to be removed from the User properties
130 */
131 void removeUserProperty(String key);
132
133 /***
134 * Loads a set of System and User properties from a file. The
135 * behaviour of this method mimics that of
136 * {@link Properties#load(java.io.InputStream)}.
137 * @param arg0 The input stream
138 * @throws IOException if an error occured when reading from the input stream
139 * @see Properties#load(java.io.InputStream)
140 */
141 void load(InputStream arg0) throws IOException;
142
143 /***
144 * Stores a set of System and User properties in a file. The
145 * behaviour of this method mimics that of
146 * {@link Properties#store(java.io.OutputStream, java.lang.String)}.
147 *
148 * @param arg0 A property stream
149 * @param arg1 A description of the property list
150 * @throws IOException if an error occurred writing to the output stream
151 * @see Properties#store(java.io.OutputStream, java.lang.String)
152 */
153 void store(OutputStream arg0, String arg1) throws IOException;
154
155 /***
156 * Retrieves the name of this configuration object.
157 * @return The name
158 */
159 String getName();
160
161 /***
162 * Returns an IConfigurationValidator object capable of
163 * validating this IConfiguration object.
164 *
165 * @return an appropriate IConfigurationValidator object
166 */
167 IConfigurationValidator getPropertiesValidator();
168 }