1 8 package org.ozoneDB.collections; 9 10 import java.util.Enumeration ; 11 import java.util.Iterator ; 12 import java.util.Map ; 13 import java.util.Properties ; 14 import org.ozoneDB.OzoneObject; 15 16 23 public class BasePropertiesImpl extends OzoneObject implements OzoneProperties { 24 25 private static final long serialVersionUID = 1L; 26 27 protected OzoneTreeMap backingMap; 28 29 protected BasePropertiesImpl() { 30 } 31 32 public void load(Properties properties) { 33 for(Iterator i = properties.keySet().iterator(); i.hasNext(); ) { 34 String key = (String ) i.next(); 35 setProperty(key, properties.getProperty(key)); 36 } 37 } 38 39 public String getProperty(String key) { 40 return (String ) backingMap.get(key); 41 } 42 43 public String getProperty(String key, String defaultValue) { 44 String result = getProperty(key); 45 return result == null ? defaultValue : result; 46 } 47 48 public Enumeration propertyNames() { 49 return new IteratorEnumerationAdaptor(backingMap.keySet().iterator()); 50 } 51 52 public String setProperty(String key, String value) { 53 return (String ) backingMap.put(key, value); 54 } 55 56 public Properties getClientProperties() { 57 Properties result = new Properties (); 58 for(Iterator i = backingMap.entrySet().iterator(); i.hasNext(); ) { 59 Map.Entry entry = (Map.Entry ) i.next(); 60 result.setProperty((String ) entry.getKey(), (String ) entry.getValue()); 61 } 62 return result; 63 } 64 65 } 66 | Popular Tags |