More type safety.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4244 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2006-07-05 00:51:22 +00:00
parent a89473d1b5
commit 94b79826d4
9 changed files with 59 additions and 54 deletions
@@ -98,7 +98,7 @@ public abstract class ConfigRegistry
*/
public DObject getObject (String key)
{
ObjectRecord record = (ObjectRecord)_configs.get(key);
ObjectRecord record = _configs.get(key);
return (record == null) ? null : record.object;
}
@@ -108,7 +108,7 @@ public abstract class ConfigRegistry
*/
public String[] getKeys ()
{
return (String[])_configs.keySet().toArray(new String[_configs.size()]);
return _configs.keySet().toArray(new String[_configs.size()]);
}
/**
@@ -365,7 +365,8 @@ public abstract class ConfigRegistry
}
/** A mapping from identifying key to config object. */
protected HashMap _configs = new HashMap();
protected HashMap<String,ObjectRecord> _configs =
new HashMap<String,ObjectRecord>();
protected static final int[] INT_ARRAY_PROTO = new int[0];
protected static final float[] FLOAT_ARRAY_PROTO = new float[0];
@@ -86,14 +86,14 @@ public class DatabaseConfigRegistry extends ConfigRegistry
Log.warning("Failed to load object configuration " +
"[path=" + _path + "].");
Log.logStackTrace(pe);
_data = new HashMap();
_data = new HashMap<String,String>();
}
super.init();
}
protected boolean getValue (String field, boolean defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
if (value != null) {
return "true".equalsIgnoreCase(value);
}
@@ -101,7 +101,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected short getValue (String field, short defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
return Short.parseShort(value);
@@ -113,7 +113,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected int getValue (String field, int defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
return Integer.parseInt(value);
@@ -125,7 +125,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected long getValue (String field, long defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
return Long.parseLong(value);
@@ -137,7 +137,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected float getValue (String field, float defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
return Float.parseFloat(value);
@@ -149,12 +149,12 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected String getValue (String field, String defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
return (value == null) ? defval : value;
}
protected int[] getValue (String field, int[] defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
int[] avalue = StringUtil.parseIntArray(value);
@@ -169,7 +169,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected float[] getValue (String field, float[] defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
float[] avalue = StringUtil.parseFloatArray(value);
@@ -184,7 +184,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected long[] getValue (String field, long[] defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
long[] avalue = StringUtil.parseLongArray(value);
@@ -199,7 +199,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected String[] getValue (String field, String[] defval) {
String value = (String)_data.get(field);
String value = _data.get(field);
try {
if (value != null) {
return StringUtil.parseStringArray(value);
@@ -259,7 +259,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry
}
protected String _path;
protected HashMap _data;
protected HashMap<String,String> _data;
}
protected ConfigRepository _repo;
@@ -59,14 +59,14 @@ public class ConfigRepository extends JORARepository
* @return a map containing field/value pairs for all stored configuration
* data.
*/
public HashMap loadConfig (String object)
public HashMap<String,String> loadConfig (String object)
throws PersistenceException
{
ArrayList list = loadAll(
ArrayList<ConfigDatum> list = loadAll(
_ctable, "where OBJECT = " + JDBCUtil.escape(object));
HashMap data = new HashMap();
HashMap<String,String> data = new HashMap<String,String>();
for (int ii = 0, ll = list.size(); ii < ll; ii++) {
ConfigDatum datum = (ConfigDatum)list.get(ii);
ConfigDatum datum = list.get(ii);
data.put(datum.field, datum.value);
}
return data;