1 16 17 package org.apache.commons.configuration.web; 18 19 import java.util.Iterator ; 20 import java.util.List ; 21 import javax.servlet.FilterConfig ; 22 23 import org.apache.commons.collections.iterators.EnumerationIterator; 24 import org.apache.commons.configuration.AbstractConfiguration; 25 import org.apache.commons.configuration.PropertyConverter; 26 27 36 public class ServletFilterConfiguration extends AbstractConfiguration 37 { 38 protected FilterConfig config; 39 40 43 public ServletFilterConfiguration(FilterConfig config) 44 { 45 this.config = config; 46 } 47 48 public Object getProperty(String key) 49 { 50 Object value = config.getInitParameter(key); 51 List list = PropertyConverter.split((String ) value, getDelimiter()); 52 53 return list.size() > 1 ? list : value; 54 } 55 56 62 protected void addPropertyDirect(String key, Object obj) 63 { 64 throw new UnsupportedOperationException ("Read only configuration"); 65 } 66 67 public boolean isEmpty() 68 { 69 return !getKeys().hasNext(); 70 } 71 72 public boolean containsKey(String key) 73 { 74 return getProperty(key) != null; 75 } 76 77 83 public void clearProperty(String key) 84 { 85 throw new UnsupportedOperationException ("Read only configuration"); 86 } 87 88 public Iterator getKeys() 89 { 90 return new EnumerationIterator(config.getInitParameterNames()); 91 } 92 } 93 | Popular Tags |