1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.configuration.web;
18
19 import java.applet.Applet;
20 import java.util.Iterator;
21 import java.util.List;
22
23 import org.apache.commons.collections.iterators.ArrayIterator;
24 import org.apache.commons.configuration.PropertyConverter;
25
26 /***
27 * A configuration wrapper to read applet parameters. This configuration is
28 * read only, adding or removing a property will throw an
29 * UnsupportedOperationException.
30 *
31 * @author <a href="mailto:ebourg@apache.org">Emmanuel Bourg</a>
32 * @version $Revision$, $Date: 2005-10-12 21:01:43 +0200 (Wed, 12 Oct 2005) $
33 * @since 1.1
34 */
35 public class AppletConfiguration extends BaseWebConfiguration
36 {
37 /*** Stores the wrapped applet.*/
38 protected Applet applet;
39
40 /***
41 * Create an AppletConfiguration using the initialization parameters of
42 * the specified Applet.
43 *
44 * @param applet the applet
45 */
46 public AppletConfiguration(Applet applet)
47 {
48 this.applet = applet;
49 }
50
51 public Object getProperty(String key)
52 {
53 Object value = applet.getParameter(key);
54 List list = PropertyConverter.split((String) value, getDelimiter());
55
56 return list.size() > 1 ? list : value;
57 }
58
59 public Iterator getKeys()
60 {
61 String[][] paramsInfo = applet.getParameterInfo();
62 String[] keys = new String[paramsInfo != null ? paramsInfo.length : 0];
63 for (int i = 0; i < keys.length; i++)
64 {
65 keys[i] = paramsInfo[i][0];
66 }
67
68 return new ArrayIterator(keys);
69 }
70 }