コード例 #1
0
 /**
  * Return a list of resource model configuration
  *
  * @param props properties
  * @return List of Maps, each map containing "type": String, "props":Properties
  */
 public static List<Map<String, Object>> listResourceModelConfigurations(final Properties props) {
   final ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
   int i = 1;
   boolean done = false;
   while (!done) {
     final String prefix = RESOURCES_SOURCE_PROP_PREFIX + "." + i;
     if (props.containsKey(prefix + ".type")) {
       final String providerType = props.getProperty(prefix + ".type");
       final Properties configProps = new Properties();
       final int len = (prefix + ".config.").length();
       for (final Object o : props.keySet()) {
         final String key = (String) o;
         if (key.startsWith(prefix + ".config.")) {
           configProps.setProperty(key.substring(len), props.getProperty(key));
         }
       }
       final HashMap<String, Object> map = new HashMap<String, Object>();
       map.put("type", providerType);
       map.put("props", configProps);
       list.add(map);
     } else {
       done = true;
     }
     i++;
   }
   return list;
 }