1 16 17 package org.apache.jetspeed.util; 18 19 import java.util.Hashtable ; 21 import java.util.Map ; 22 import java.util.Iterator ; 23 24 32 33 public class BaseConfig extends Hashtable implements Config 34 { 35 36 private String name = null; 37 38 41 public String getName() 42 { 43 return this.name; 44 } 45 46 49 public void setName(String name) 50 { 51 this.name = name; 52 } 53 54 57 public void setInitParameters( Map init_params ) 58 { 59 clear(); 60 putAll( init_params ); 61 } 62 63 66 public void addInitParameters( Map init_params ) 67 { 68 Iterator keys = init_params.keySet().iterator(); 69 70 while (keys.hasNext() ) 71 { 72 String key = (String )keys.next(); 73 74 if( ! containsKey( key ) ) 75 { 76 put( key , (String )init_params.get( key ) ); 77 } 78 } 79 } 80 81 82 85 public Map getInitParameters() 86 { 87 return this; 88 } 89 90 91 95 public void setInitParameter(String name, Object value) 96 { 97 if (name!=null) 98 { 99 if (value==null) 100 { 101 remove(name); 102 } 103 else 104 { 105 put(name,value); 106 } 107 } 108 } 109 110 113 public String getInitParameter(String name) 114 { 115 return getInitParameter( name, null ); 116 } 117 118 121 public String getInitParameter(String name, String defaultValue) 122 { 123 String value = null; 124 125 try 126 { 127 value=(String )get(name); 128 if (value==null) value=defaultValue; 129 } 130 catch (RuntimeException e) 131 { 132 value=defaultValue; 133 } 134 135 return value; 136 } 137 138 141 public Iterator getInitParameterNames() 142 { 143 return keySet().iterator(); 144 } 145 146 } 147 | Popular Tags |