Source code: org/dinopolis/util/Resources.java
1 /***********************************************************************
2 * @(#)$RCSfile: Resources.java,v $ $Revision: 1.7 $ $Date: 2003/11/18 11:23:07 $
3 *
4 * Copyright (c) 2001 IICM, Graz University of Technology
5 * Inffeldgasse 16c, A-8010 Graz, Austria.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License (LGPL)
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the
19 * Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ***********************************************************************/
22
23
24 package org.dinopolis.util;
25
26 import java.awt.Color;
27 import java.beans.PropertyChangeListener;
28 import java.io.File;
29 import java.io.IOException;
30 import java.net.URL;
31 import java.util.Enumeration;
32 import java.util.MissingResourceException;
33
34 import javax.swing.Icon;
35
36 //----------------------------------------------------------------------
37 /**
38 * This Interface is used to access any Resources. Resources may be
39 * given in a file, database, memory or wherever. Resources may also
40 * be locale-specific. (see {@link java.util.ResourceBundle} for
41 * further details.)<p>
42 *
43 * Stored resources can not only be requested as <code>Strings</code>,
44 * but also in many different other types, like <code>integers</code>,
45 * <code>StringArrays</code>, <code>booleans</code>, <code>Colors</code>,
46 * <code>Icons</code> and others.<p>
47 *
48 * When your program needs a specific object, it loads the
49 * <code>ResourceManager</code> class using one of the
50 * <code>getResources</code> methods:
51 *
52 * <blockquote><pre> Resources my_resources = ResourceManager.getResources(this,
53 * "MyResources");</pre></blockquote>
54 *
55 * If a lookup fails, <code>getBundle()</code> throws a
56 * <code>MissingResourceException</code>.<p>
57 *
58 * Resource files contain key/value pairs. The keys uniquely
59 * identify a locale-specific object in the bundle. Here's an
60 * example resource file that contains two key/value pairs:
61 * <blockquote>
62 * <pre>
63 * my_app.dimension.width=300
64 * my_app.dimension.height=200
65 * </pre>
66 * </blockquote>
67 *
68 * Keys are always <code>String</code>s.
69 * In this example, the keys are <code>my_app.dimension.width</code>
70 * and <code>my_app.dimension.height</code>.
71 *
72 * In the above example, the values
73 * are also <code>String</code>s--<code>200</code> and <code>300</code>--but
74 * they may also be interpreted as integer values using the method
75 * {@link #getInt}.<p>
76 *
77 * The single argumented getter methods all require the key as an
78 * argument and return the object if found. If the object is not
79 * found, the getter method throws a
80 * <code>MissingResourceException</code>. To avoid this behavior, it
81 * is also possible to use the corresponding methods that take two
82 * arguments, the key and the default value. If no property was bound
83 * under the given key, the default value will be returned instead of
84 * throwing a <code>MissingResourceException</code>.
85 *
86 * @author Dieter Freismuth
87 * @version $Revision: 1.7 $
88 */
89
90 public interface Resources
91 {
92
93 /** the delimiter used in resources for string arrays */
94 public final static String KEY_DELIMITER = ".";
95
96 /** the delimiter used in resources for string arrays */
97 public final static String RESOURCE_STRING_ARRAY_DELIMITER = ",";
98
99 /** the delimiter used for variable replacement. So '$key$' will be
100 * replace by the value of 'key' */
101 public final static String VAR_IDENTIFIER = "$";
102
103 /** the length of VAR_IDENTIFIER */
104 public final static int VAR_LENGTH = VAR_IDENTIFIER.length();
105
106 /** the delimiter used for swallow replacs. eg.: '$%key%$' is
107 * equivalent to 'key', but '$%k*%$' will be expanded to all keys of
108 * the resource that start with the letter 'k'. '$k$' will be
109 * expanded to all values of keys that start with the letter 'k'. */
110 public final static String SWALLOW_IDENTIFIER = "%";
111
112 /** the length of SWALLOW_IDENTIFIER */
113 public final static int SWALLOW_LENGTH = SWALLOW_IDENTIFIER.length();
114
115 /** the key of the 'resource.groups' property */
116 public final static String GROUPS = "resource.groups";
117
118 //----------------------------------------------------------------------
119 /**
120 * Removes the bound value for the given key, if no value was bound
121 * under the given key, this method does nothing.
122 *
123 * @param key the key of the resource to delete.
124 * @exception UnsupportedOperationException if the resources is not
125 * capable of deleting values, or in particular the given key.
126 */
127
128 public void unset(String key)
129 throws UnsupportedOperationException;
130
131 //----------------------------------------------------------------------
132 /**
133 * Resets the bound value to its default value (if supported).
134 *
135 * @param key the key of the resource to reset.
136 * @exception UnsupportedOperationException if the resources is not
137 * capable of resetting values, or in particular the given key.
138 */
139
140 public void reset(String key)
141 throws UnsupportedOperationException;
142
143 //----------------------------------------------------------------------
144 /**
145 * Returns true, if this resources is capable of storing and
146 * deleting resources, false otherwise.
147 *
148 * @return true, if this resources is capable of storing and
149 * deleting resources, false otherwise.
150 */
151
152 public boolean isModificationSupported();
153
154 //----------------------------------------------------------------------
155 /**
156 * Call this method to make all changes performed by unset and
157 * setter methods persistent.
158 *
159 * @exception IOException in case of an IOError.
160 * @exception UnsupportedOperationException if the resources is not
161 * capable of persistently storing the resources.
162 */
163
164 public void store()
165 throws IOException, UnsupportedOperationException;
166
167
168 //----------------------------------------------------------------------
169 /**
170 * Attach another set of resources. After they are attached, all
171 * getXXX() operations are able to read the values from the
172 * resources as well as the attached resources. To set any values
173 * (add new or change old values), the methods of the original
174 * resources must be used or otherwise the keys/values are contained
175 * in this resources (new value) and in the attached resources (old
176 * values).
177 * <p>
178 * As soon as additional resources are attached, the getXXX()
179 * methods read from them. If there are duplicate keys in the
180 * resources and in the attached resources, the original resources
181 * have priority (take care!!).
182 * <p>
183 * The {@link #store()} method calls <code>store()<code> on all
184 * attached resources as well.
185 * <p>
186 * Attaching resources has the advantage that read access to
187 * resources is easy for different resources (e.g. in the resource
188 * editor), but the place where the resources are stored can still
189 * be held separated.
190 *
191 * @exception UnsupportedOperationException if the resources is not
192 * capable of attaching other resources.
193 */
194
195 public void attachResources(Resources resources)
196 throws UnsupportedOperationException;
197
198 //----------------------------------------------------------------------
199 /**
200 * Detach previously attached resources.
201 *
202 * @exception UnsupportedOperationException if the resources is not
203 * capable of attaching other resources.
204 */
205
206 public void detachResources(Resources resources)
207 throws UnsupportedOperationException;
208
209 //----------------------------------------------------------------------
210 /**
211 * Returns the title for the given key. If no title for this key is
212 * available, <code>null</code> is returned.
213 *
214 * @param key the key to get the title for.
215 * @return the title for the given key.
216 */
217
218 public String getTitle(String key);
219
220 //----------------------------------------------------------------------
221 /**
222 * Sets the title for the given key.
223 * Deleted the title if title is 'null'.
224 *
225 * @param key the key to set the title for.
226 * @param title the title to set.
227 * @exception UnsupportedOperationException if setTitle operations
228 * are not supported.
229 * @exception IllegalArgumentException if key is 'null'.
230 */
231
232 public void setTitle(String key, String title)
233 throws UnsupportedOperationException;
234
235 //----------------------------------------------------------------------
236 /**
237 * Returns a string that describes the key and its possible values.
238 * If no description for this key is available, <code>null</code> is
239 * returned.
240 *
241 * @param key the key to get the description for.
242 * @return the description of the given key and its possible values.
243 */
244
245 public String getDescription(String key);
246
247 //----------------------------------------------------------------------
248 /**
249 * Sets the description for the given key.
250 * Deleted the description if description is 'null'.
251 *
252 * @param key the key to set the description for.
253 * @param description the description to set.
254 * @exception UnsupportedOperationException if setDescription
255 * operations are not supported.
256 * @exception IllegalArgumentException if key is 'null'.
257 */
258
259 public void setDescription(String key, String description)
260 throws UnsupportedOperationException;
261
262 //----------------------------------------------------------------------
263 /**
264 * Returns the type of the value bound under the given key. Note
265 * that the returned "Class" object may describe a built-in Java
266 * type such as "int" (Integer.TYPE). For arrays, this may be e.g.:
267 * <code>int[].class</code>. If no type for this key is available,
268 * <code>null</code> is returned.
269 *
270 * @param key the key to get the type for.
271 * @return the type of the value bound under the given key.
272 */
273
274 public Class getType(String key);
275
276 //----------------------------------------------------------------------
277 /**
278 * Sets the type for the given key.
279 * Deleted the kype if type is 'null'.
280 *
281 * @param key the key to set the type for.
282 * @param type the type to set.
283 * @exception UnsupportedOperationException if setType operations
284 * are not supported.
285 * @exception IllegalArgumentException if key is 'null'.
286 */
287
288 public void setType(String key, Class type)
289 throws UnsupportedOperationException;
290
291 //----------------------------------------------------------------------
292 /**
293 * Returns an array of all values that are valid. This is usefull if
294 * a value may be choosen out of a predifined set of possible
295 * values.
296 * If no set of valid values exists <code>null</code> is returned.
297 *
298 * @param key the key to get the type for.
299 * @return the possible values.
300 */
301
302 public String[] getPossibleValues(String key);
303
304 //----------------------------------------------------------------------
305 /**
306 * Sets the possible Values for the given key.
307 * Deleted the possible Values if possible_values are 'null'.
308 *
309 * @param key the key to set the possible Values for.
310 * @param possible_values the possible Values to set.
311 * @exception UnsupportedOperationException if setPossibleValues
312 * operations are not supported.
313 * @exception IllegalArgumentException if is 'null'.
314 */
315
316 public void setPossibleValues(String key, String[] possible_values)
317 throws UnsupportedOperationException;
318
319 //----------------------------------------------------------------------
320 /**
321 * Returns the native value loaded from the resource bundle. If variables
322 * are given in the value, they will be replaced
323 * recursively. Variables are Strings that start and end with a
324 * '$'. To escape the $-sign use $$. In case of a deadlock (a
325 * contains variable b, and b contains variable a), the variable
326 * will not be replaced. Variables that are not given within the
327 * resources are also not replaced. The return value will be of type
328 * String, if the Resources are not type save, which means, that the
329 * getType() call with the given key returns <code>null</code>. If
330 * the resource is invalid to its type (e.g.: "x" as Integer),
331 * an IllegalArgumentException will be thrown.
332 *
333 * @param key the key of the resource property to look for.
334 * @return the native object loaded from the resource bundle.
335 * @exception MissingResourceException if the given key is not defined
336 * within the resources.
337 * @exception IllegalArgumentException if key is 'null', or the
338 * value is not of the registerd type.
339 */
340
341 public Object get(String key)
342 throws MissingResourceException, IllegalArgumentException;
343
344 //----------------------------------------------------------------------
345 /**
346 * Returns the string loaded from the resource bundle. If variables
347 * are given in the value, they will be replaced
348 * recursively. Variables are Strings that start and end with a
349 * '$'. To escape the $-sign use $$. In case of a deadlock (a
350 * contains variable b, and b contains variable a), the variable
351 * will not be replaced. Variables that are not given within the
352 * resources are also not replaced.
353 *
354 * @param key the key of the resource property to look for.
355 * @return the replaced string loaded from the resource bundle.
356 * @exception MissingResourceException if the given key is not defined
357 * within the resources.
358 * @exception IllegalArgumentException if key is 'null'.
359 */
360
361 public String getString(String key)
362 throws MissingResourceException;
363
364 //----------------------------------------------------------------------
365 /**
366 * Returns the string loaded from the resource bundle. If the key
367 * was not found within the resources, <code>default_value</code>
368 * will be returned. Any variables found within the properties value
369 * will be replaced.
370 *
371 * @param key the key of the resource property to look for.
372 * @param default_value the default value that will be returned if no
373 * resource of the given key was found.
374 * @return the string loaded from the resource bundle.
375 * @see #getString(java.lang.String)
376 */
377
378 public String getString(String key, String default_value);
379
380 //----------------------------------------------------------------------
381 /**
382 * Registers the given value under the given key.
383 *
384 * @param key the key of the resource property to set.
385 * @param value the value of the resource property to set.
386 * @exception UnsupportedOperationException if set operations are
387 * not supported.
388 * @exception IllegalArgumentException if key or value is 'null'.
389 */
390
391 public void setString(String key, String value)
392 throws UnsupportedOperationException;
393
394 //----------------------------------------------------------------------
395 /**
396 * Returns the string array, loaded from the resource
397 * bundle. Returns an empty array instead of <code>null</code>. Any
398 * variables found within the properties value will be replaced.
399 *
400 * @param key the key of the resource property to look for.
401 * @return the string array, loaded from the resource bundle. Returns
402 * an empty array instead of <code>null</code>.
403 * @exception MissingResourceException if the given key is not defined
404 * within the resources.
405 */
406
407 public String[] getStringArray(String key)
408 throws MissingResourceException;
409
410 //----------------------------------------------------------------------
411 /**
412 * Returns the string array, loaded from the resource
413 * bundle. Returns an empty array instead of <code>null</code>. Any
414 * variables found within the properties value will be replaced.
415 *
416 * @param key the key of the resource property to look for.
417 * @return the string array, loaded from the resource bundle. Returns
418 * an empty array instead of <code>null</code>.
419 * @exception MissingResourceException if the given key is not defined
420 * within the resources.
421 */
422
423 public String[] getStringArray(String key, String delimiter)
424 throws MissingResourceException;
425
426 //----------------------------------------------------------------------
427 /**
428 * Returns the string array loaded from the resource bundle. If the
429 * key was not found within the resources,
430 * <code>default_values</code> will be returned. Any variables found
431 * within the properties value will be replaced.
432 *
433 * @param key the key of the resource property to look for.
434 * @param default_values the default value that will be returned if no
435 * resource of the given key was found.
436 * @return the string array loaded from the resource bundle.
437 */
438
439 public String[] getStringArray(String key, String[] default_values);
440
441 //----------------------------------------------------------------------
442 /**
443 * Registers the given values under the given key.
444 *
445 * @param key the key of the resource property to set.
446 * @param values the values of the resource property to set.
447 * @exception UnsupportedOperationException if set operations are
448 * not supported.
449 * @exception IllegalArgumentException if key or values is 'null'.
450 */
451
452 public void setStringArray(String key, String[] values)
453 throws UnsupportedOperationException;
454
455 //----------------------------------------------------------------------
456 /**
457 * Registers the given values under the given key.
458 *
459 * @param key the key of the resource property to set.
460 * @param values the values of the resource property to set.
461 * @param delimiter the delimiter to be used to seperate single
462 * values.
463 * @exception UnsupportedOperationException if set operations are
464 * not supported.
465 * @exception IllegalArgumentException if key or values is 'null'.
466 */
467
468 public void setStringArray(String key, String[] values, String delimiter)
469 throws UnsupportedOperationException;
470
471 //----------------------------------------------------------------------
472 /**
473 * Returns the int loaded from the resource bundle. Any variables
474 * found within the properties value will be replaced.
475 *
476 * @param key the key of the resource property to look for.
477 * @return the int loaded from the resource bundle.
478 * @exception MissingResourceException if the given key is not defined
479 * within the resources.
480 * @exception NumberFormatException if the stored value does not
481 * represent an int.
482 */
483
484 public int getInt(String key)
485 throws MissingResourceException, NumberFormatException;
486
487 //----------------------------------------------------------------------
488 /**
489 * Returns the int loaded from the resource bundle. If the key was
490 * not found within the resources, <code>default_value</code> will
491 * be returned. Any variables found within the properties value will
492 * be replaced.
493 *
494 * @param key the key of the resource property to look for.
495 * @param default_value the default value that will be returned if no
496 * resource of the given key was found, or the found value is not of
497 * type int.
498 * @return the int loaded from the resource bundle.
499 * @exception MissingResourceException if the given key is not defined
500 * within the resources.
501 * @exception NumberFormatException if the stored value does not
502 * represent an int.
503 */
504
505 public int getInt(String key, int default_value);
506
507 //----------------------------------------------------------------------
508 /**
509 * Registers the given value under the given key.
510 *
511 * @param key the key of the resource property to set.
512 * @param value the value of the resource property to set.
513 * @exception UnsupportedOperationException if set operations are
514 * not supported.
515 * @exception IllegalArgumentException if key is 'null'.
516 */
517
518 public void setInt(String key, int value)
519 throws UnsupportedOperationException;
520
521 //----------------------------------------------------------------------
522 /**
523 * Returns the int array loaded from the resource bundle. Any
524 * variables found within the properties value will be replaced.
525 *
526 * @param key the key of the resource property to look for.
527 * @return the int array loaded from the resource bundle.
528 * @exception MissingResourceException if the given key is not defined
529 * within the resources.
530 * @exception NumberFormatException if a stored value does not
531 * represent an int.
532 */
533
534 public int[] getIntArray(String key)
535 throws MissingResourceException, NumberFormatException;
536
537 //----------------------------------------------------------------------
538 /**
539 * Returns the int array loaded from the resource bundle. If the key
540 * was not found within the resources, <code>default_values</code>
541 * will be returned. Any variables found within the properties value
542 * will be replaced.
543 *
544 * @param key the key of the resource property to look for.
545 * @param default_values the default value that will be returned if no
546 * resource of the given key was found, or a found value is not of
547 * type int.
548 * @return the int array loaded from the resource bundle.
549 * @exception MissingResourceException if the given key is not defined
550 * within the resources.
551 * @exception NumberFormatException if a stored value does not
552 * represent an int.
553 */
554
555 public int[] getIntArray(String key, int[] default_values);
556
557 //----------------------------------------------------------------------
558 /**
559 * Registers the given values under the given key.
560 *
561 * @param key the key of the resource property to set.
562 * @param values the values of the resource property to set.
563 * @exception UnsupportedOperationException if set operations are
564 * not supported.
565 * @exception IllegalArgumentException if key or values is 'null'.
566 */
567
568 public void setIntArray(String key, int[] values)
569 throws UnsupportedOperationException;
570
571 //----------------------------------------------------------------------
572 /**
573 * Returns the double loaded from the resource bundle. Any variables
574 * found within the properties value will be replaced.
575 *
576 * @param key the key of the resource property to look for.
577 * @return the double loaded from the resource bundle.
578 * @exception MissingResourceException if the given key is not defined
579 * within the resources.
580 * @exception NumberFormatException if the stored value does not
581 * represent an double.
582 */
583
584 public double getDouble(String key)
585 throws MissingResourceException, NumberFormatException;
586
587 //----------------------------------------------------------------------
588 /**
589 * Returns the double loaded from the resource bundle. If the key was
590 * not found within the resources, <code>default_value</code> will
591 * be returned. Any variables found within the properties value will
592 * be replaced.
593 *
594 * @param key the key of the resource property to look for.
595 * @param default_value the default value that will be returned if no
596 * resource of the given key was found, or the found value is not of
597 * type double.
598 * @return the double loaded from the resource bundle.
599 * @exception MissingResourceException if the given key is not defined
600 * within the resources.
601 * @exception NumberFormatException if the stored value does not
602 * represent an double.
603 */
604
605 public double getDouble(String key, double default_value);
606
607 //----------------------------------------------------------------------
608 /**
609 * Registers the given value under the given key.
610 *
611 * @param key the key of the resource property to set.
612 * @param value the value of the resource property to set.
613 * @exception UnsupportedOperationException if set operations are
614 * not supported.
615 * @exception IllegalArgumentException if key is 'null'.
616 */
617
618 public void setDouble(String key, double value)
619 throws UnsupportedOperationException;
620
621 //----------------------------------------------------------------------
622 /**
623 * Returns the double array loaded from the resource bundle. Any
624 * variables found within the properties value will be replaced.
625 *
626 * @param key the key of the resource property to look for.
627 * @return the double array loaded from the resource bundle.
628 * @exception MissingResourceException if the given key is not defined
629 * within the resources.
630 * @exception NumberFormatException if a stored value does not
631 * represent an double.
632 */
633
634 public double[] getDoubleArray(String key)
635 throws MissingResourceException, NumberFormatException;
636
637 //----------------------------------------------------------------------
638 /**
639 * Returns the double array loaded from the resource bundle. If the key
640 * was not found within the resources, <code>default_values</code>
641 * will be returned. Any variables found within the properties value
642 * will be replaced.
643 *
644 * @param key the key of the resource property to look for.
645 * @param default_values the default value that will be returned if no
646 * resource of the given key was found, or a found value is not of
647 * type double.
648 * @return the double array loaded from the resource bundle.
649 * @exception MissingResourceException if the given key is not defined
650 * within the resources.
651 * @exception NumberFormatException if a stored value does not
652 * represent an double.
653 */
654
655 public double[] getDoubleArray(String key, double[] default_values);
656
657 //----------------------------------------------------------------------
658 /**
659 * Registers the given values under the given key.
660 *
661 * @param key the key of the resource property to set.
662 * @param values the values of the resource property to set.
663 * @exception UnsupportedOperationException if set operations are
664 * not supported.
665 * @exception IllegalArgumentException if key or values is 'null'.
666 */
667
668 public void setDoubleArray(String key, double[] values)
669 throws UnsupportedOperationException;
670
671
672
673 //----------------------------------------------------------------------
674 /**
675 * Returns the boolean loaded from the resource bundle. Boolean value
676 * that are interpreted as <code>true</code> within the resource file
677 * are: "true", "True", "yes", "Yes" and "1". All other values will be
678 * interpreted to be <code>false</code>. Any variables found within
679 * the properties value will be replaced.
680 *
681 * @param key the key of the resource property to look for.
682 * @return the boolean loaded from the resource bundle.
683 * @exception MissingResourceException if the given key is not defined
684 * within the resources.
685 */
686
687 public boolean getBoolean(String key)
688 throws MissingResourceException;
689
690 //----------------------------------------------------------------------
691 /**
692 * Returns the boolean loaded from the resource bundle. Boolean
693 * value that are interpreted as <code>true</code> within the
694 * resource file are: "true", "True", "yes", "Yes" and "1". All
695 * other values will be interpreted to be <code>false</code>. If the
696 * key was not found within the resources,
697 * <code>default_value</code> will be returned. Any variables found
698 * within the properties value will be replaced.
699 *
700 * @param key the key of the resource property to look for.
701 * @param default_value the default value that will be returned if no
702 * resource of the given key was found.
703 * @return the boolean loaded from the resource bundle.
704 */
705
706 public boolean getBoolean(String key, boolean default_value);
707
708 //----------------------------------------------------------------------
709 /**
710 * Registers the given value under the given key.
711 *
712 * @param key the key of the resource property to set.
713 * @param value the value of the resource property to set.
714 * @exception UnsupportedOperationException if set operations are
715 * not supported.
716 * @exception IllegalArgumentException if key is 'null'.
717 */
718
719 public void setBoolean(String key, boolean value)
720 throws UnsupportedOperationException;
721
722 //----------------------------------------------------------------------
723 /**
724 * Returns the icon loaded from the resource bundle. The filename of
725 * the icon in the resource file has to be relative to the resource
726 * file. Any variables found within the properties value will be
727 * replaced.
728 *
729 * @param key the key of the resource property to look for.
730 * @return the icon loaded from the resource bundle.
731 * @exception MissingResourceException if the given key is not defined
732 * within the resources.
733 */
734
735 public Icon getIcon(String key)
736 throws MissingResourceException;
737
738 //----------------------------------------------------------------------
739 /**
740 * Returns the icon loaded from the resource bundle. Icon value
741 * that are interpreted as <code>true</code> within the resource file
742 * are: "true", "True", "yes", "Yes" and "1". All other values will be
743 * interpreted to be <code>false</code>. If the key was not found
744 * within the resources, <code>default_value</code> will be
745 * returned. Any variables found within the properties value will be
746 * replaced.
747 *
748 * @param key the key of the resource property to look for.
749 * @param default_value the default value that will be returned if no
750 * resource of the given key was found.
751 * @return the icon loaded from the resource bundle.
752 */
753
754 public Icon getIcon(String key, Icon default_value);
755
756 //----------------------------------------------------------------------
757 /**
758 * Returns the color loaded from the resource bundle. Any variables
759 * found within the properties value will be replaced. Possible
760 * values for colors are: "white", "blue",... and "r,g,b" values
761 * like "255,96,96".
762 *
763 * @param key the key of the resource property to look for.
764 * @return the color loaded from the resource bundle.
765 * @exception MissingResourceException if the given key is not defined
766 * within the resources.
767 */
768
769 public Color getColor(String key)
770 throws MissingResourceException;
771
772 //----------------------------------------------------------------------
773 /**
774 * Returns the color loaded from the resource bundle. Any variables
775 * found within the properties value will be replaced. Possible
776 * values for colors are: "white", "blue",... and "r,g,b" values
777 * like 255,96,96. If the key was not found within the resources,
778 * <code>default_value</code> will be returned.
779 *
780 * @param key the key of the resource property to look for.
781 * @param default_value the default value that will be returned if no
782 * resource of the given key was found.
783 * @return the color loaded from the resource bundle.
784 */
785
786 public Color getColor(String key, Color default_value);
787
788 //----------------------------------------------------------------------
789 /**
790 * Registers the given value under the given key.
791 *
792 * @param key the key of the resource property to set.
793 * @param value the value of the resource property to set.
794 * @exception UnsupportedOperationException if set operations are
795 * not supported.
796 * @exception IllegalArgumentException if key or value is 'null'.
797 */
798
799 public void setColor(String key, Color value)
800 throws UnsupportedOperationException;
801
802 //----------------------------------------------------------------------
803 /**
804 * Returns the file loaded from the resource bundle. Any variables
805 * found within the properties value will be replaced.
806 *
807 * @param key the key of the resource property to look for.
808 * @return the file that is loaded from the resource bundle.
809 */
810
811 public File getFile(String key);
812
813 //----------------------------------------------------------------------
814 /**
815 * Returns the file loaded from the resource bundle. Any variables
816 * found within the properties value will be replaced. If the key
817 * was not found within the resources, <code>default_value</code>
818 * will be returned.
819 *
820 * @param key the key of the resource property to look for.
821 * @param default_value the default value that will be returned if no
822 * resource of the given key was found.
823 * @return the file that is loaded from the resource bundle.
824 */
825
826 public File getFile(String key, File default_value);
827
828 //----------------------------------------------------------------------
829 /**
830 * Returns the Url loaded from the resource bundle. Any variables
831 * found within the properties value will be replaced.
832 *
833 * @param key the key of the resource property to look for.
834 * @return the Url that is loaded from the resource bundle.
835 * @exception MissingResourceException if the given key is not defined
836 * within the resources, or is not a valid Url.
837 */
838
839 public URL getURL(String key)
840 throws MissingResourceException;
841
842 //----------------------------------------------------------------------
843 /**
844 * Returns the Url loaded from the resource bundle. Any variables
845 * found within the properties value will be replaced. If the key
846 * was not found within the resources, <code>default_value</code>
847 * will be returned.
848 *
849 * @param key the key of the resource property to look for.
850 * @param default_value the default value that will be returned if no
851 * resource of the given key was found.
852 * @return the Url that is loaded from the resource bundle.
853 */
854
855 public URL getURL(String key, URL default_value);
856
857 //----------------------------------------------------------------------
858 /**
859 * Returns an Enumeration containing all keys of all resources.
860 *
861 * @return an Enumeration containing all keys of all resources.
862 */
863
864 public Enumeration getKeys();
865
866 //----------------------------------------------------------------------
867 /**
868 * Add a PropertyChangeListener to the listener list.
869 * The listener is registered for all properties.
870 *
871 * @param listener The PropertyChangeListener to be added.
872 */
873
874 public void addPropertyChangeListener(PropertyChangeListener
875 listener);
876
877 //----------------------------------------------------------------------
878 /**
879 * Remove a PropertyChangeListener from the listener list.
880 * This removes a PropertyChangeListener that was registered
881 * for all properties.
882 *
883 * @param listener The PropertyChangeListener to be removed
884 */
885
886 public void removePropertyChangeListener(PropertyChangeListener
887 listener);
888
889 //----------------------------------------------------------------------
890 /**
891 * Add a PropertyChangeListener for a specific property. The listener
892 * will be invoked only when a call on firePropertyChange names that
893 * specific property.
894 *
895 * @param property_name The name of the property to listen on.
896 * @param listener The PropertyChangeListener to be added
897 */
898
899 public void addPropertyChangeListener(String property_name,
900 PropertyChangeListener
901 listener);
902
903 //----------------------------------------------------------------------
904 /**
905 * Remove a PropertyChangeListener for a specific property.
906 *
907 * @param property_name The name of the property that was listened on.
908 * @param listener The PropertyChangeListener to be removed
909 */
910
911 public void removePropertyChangeListener(String property_name,
912 PropertyChangeListener
913 listener);
914 }
915
916
917
918
919
920
921
922
923
924
925