%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.configuration.web.AppletConfiguration |
|
|
1 | /* |
|
2 | * Copyright 2004-2005 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
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 | 24 | { |
48 | 24 | this.applet = applet; |
49 | 24 | } |
50 | ||
51 | public Object getProperty(String key) |
|
52 | { |
|
53 | 21 | Object value = applet.getParameter(key); |
54 | 21 | List list = PropertyConverter.split((String) value, getDelimiter()); |
55 | ||
56 | 21 | return list.size() > 1 ? list : value; |
57 | } |
|
58 | ||
59 | public Iterator getKeys() |
|
60 | { |
|
61 | 9 | String[][] paramsInfo = applet.getParameterInfo(); |
62 | 9 | String[] keys = new String[paramsInfo != null ? paramsInfo.length : 0]; |
63 | 27 | for (int i = 0; i < keys.length; i++) |
64 | { |
|
65 | 18 | keys[i] = paramsInfo[i][0]; |
66 | } |
|
67 | ||
68 | 9 | return new ArrayIterator(keys); |
69 | } |
|
70 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |