1 package net.myvietnam.mvncore.configuration; 2 3 56 57 import java.util.Enumeration ; 58 import java.util.Iterator ; 59 import java.util.Properties ; 60 import org.apache.commons.collections.ExtendedProperties; 61 62 63 71 public class ConfigurationConverter 72 { 73 79 public static Configuration getConfiguration(ExtendedProperties ep) 80 { 81 Configuration config = new BaseConfiguration(); 82 for (Iterator i = ep.getKeys(); i.hasNext();) 83 { 84 String key = (String ) i.next(); 85 config.setProperty(key, ep.getProperty(key)); 86 } 87 return config; 88 } 89 90 96 public static Configuration getConfiguration(Properties p) 97 { 98 Configuration config = new BaseConfiguration(); 99 for (Enumeration e = p.keys(); e.hasMoreElements();) 100 { 101 String key = (String ) e.nextElement(); 102 config.setProperty(key, p.getProperty(key)); 103 } 104 return config; 105 } 106 107 113 public static ExtendedProperties getExtendedProperties(Configuration c) 114 { 115 ExtendedProperties props = new ExtendedProperties(); 116 for (Iterator i = c.getKeys(); i.hasNext();) 117 { 118 String key = (String ) i.next(); 119 props.setProperty(key, c.getProperty(key)); 120 } 121 return props; 122 } 123 124 131 public static Properties getProperties(Configuration c) 132 { 133 Properties props = new Properties (); 134 135 Iterator iter = c.getKeys(); 136 137 while (iter.hasNext()) 138 { 139 String key = (String ) iter.next(); 140 props.setProperty(key, c.getString(key)); 141 } 142 143 return props; 144 } 145 } 146 | Popular Tags |