Added Configuration.getKeys().

This commit is contained in:
sk89q 2011-01-16 13:28:59 -08:00
parent 8eeb293d2b
commit 816da0fb61

View File

@ -150,6 +150,25 @@ public abstract class ConfigurationNode {
} }
} }
/**
* Get a list of keys at a location. If the map at the particular location
* does not exist or it is not a map, null will be returned.
*
* @param path path to node (dot notation)
* @return list of keys
*/
@SuppressWarnings("unchecked")
public List<String> getKeys(String path) {
Object o = getProperty(path);
if (o == null) {
return null;
} else if (o instanceof Map) {
return new ArrayList<String>(((Map<String,Object>)o).keySet());
} else {
return null;
}
}
/** /**
* Gets a list of objects at a location. If the list is not defined, * Gets a list of objects at a location. If the list is not defined,
* null will be returned. The node must be an actual list. * null will be returned. The node must be an actual list.