1 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.AbstractConfiguration; 25 import org.apache.commons.configuration.PropertyConverter; 26 27 36 public class AppletConfiguration extends AbstractConfiguration 37 { 38 protected Applet applet; 39 40 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 65 protected void addPropertyDirect(String key, Object obj) 66 { 67 throw new UnsupportedOperationException ("Read only configuration"); 68 } 69 70 public boolean isEmpty() 71 { 72 return !getKeys().hasNext(); 73 } 74 75 public boolean containsKey(String key) 76 { 77 return getProperty(key) != null; 78 } 79 80 86 public void clearProperty(String key) 87 { 88 throw new UnsupportedOperationException ("Read only configuration"); 89 } 90 91 public Iterator getKeys() 92 { 93 String [][] paramsInfo = applet.getParameterInfo(); 94 String [] keys = new String [paramsInfo != null ? paramsInfo.length : 0]; 95 for (int i = 0; i < keys.length; i++) 96 { 97 keys[i] = paramsInfo[i][0]; 98 } 99 100 return new ArrayIterator(keys); 101 } 102 } 103 | Popular Tags |