Added getAll().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4300 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-08-07 19:04:48 +00:00
parent e2a292e0fb
commit e4d7da7d19
@@ -22,6 +22,8 @@
package com.threerings.util;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.Enumeration;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -193,6 +195,28 @@ public class MessageBundle
return (msg != null) ? msg : key;
}
/**
* Adds all messages whose key starts with the specified prefix to the
* supplied collection.
*
* @param includeParent if true, messages from our parent bundle (and its
* parent bundle, all the way up the chain will be included).
*/
public void getAll (String prefix, Collection<String> messages,
boolean includeParent)
{
Enumeration<String> iter = _bundle.getKeys();
while (iter.hasMoreElements()) {
String key = iter.nextElement();
if (key.startsWith(prefix)) {
messages.add(get(key));
}
}
if (includeParent && _parent != null) {
_parent.getAll(prefix, messages, includeParent);
}
}
/**
* Returns true if we have a translation mapping for the supplied key,
* false if not.