//private static HashMap deserializers = getDeserializers();
static HashMap getDeserializers(){
final HashMap hmap = new HashMap();
populate(hmap, boolean.class, new Deserializer(){
public Object deserialize(String str){
return toBoolean(str);
}
});
populate(hmap, char.class, new Deserializer(){
public Object deserialize(String str){
if(str.length()!=1){
throw new IllegalArgumentException("cannot convert string to character");
}
return new Character(str.charAt(0));
}
});
populate(hmap, byte.class, new Deserializer(){
public Object deserialize(String str){
return Byte.valueOf(str);
}
});
populate(hmap, short.class, new Deserializer(){
public Object deserialize(String str){
return Short.valueOf(str);
}
});
final Deserializer int_des = new Deserializer(){
public Object deserialize(String str){
return Integer.valueOf(str);
}
};
populate(hmap, int.class, int_des);
populate(hmap, Number.class, int_des);
populate(hmap, long.class, new Deserializer(){
public Object deserialize(String str){
return Long.valueOf(str);
}
});
populate(hmap, float.class, new Deserializer(){
public Object deserialize(String str){
return Float.valueOf(str);
}
});
populate(hmap, double.class, new Deserializer(){
public Object deserialize(String str){
return Double.valueOf(str);
}
});
populate(hmap, BigInteger.class, new Deserializer(){
public Object deserialize(String str){
return new BigInteger(str);
}
});
populate(hmap, BigDecimal.class, new Deserializer(){
public Object deserialize(String str){
return new BigDecimal(str);
}
});
final Deserializer component_des = new Deserializer(){
public Object deserialize(String str){
return asComponent(str);
}
};
populate(hmap, Creator.class, component_des);
populate(hmap, Component.class, component_des);
populate(hmap, URL.class, new Deserializer(){
public Object deserialize(String str)
throws MalformedURLException{
return new URL(str);
}
});
populate(hmap, URI.class, new Deserializer(){
public Object deserialize(String str)
throws URISyntaxException{
return toUri(str);
}
});
populate(hmap, Date.class, new Deserializer(){
public Object deserialize(String str)
throws ParseException{
return DateFormat.getInstance().parseObject(str);
}
});
populate(hmap, Locale.class, new Deserializer(){
public Object deserialize(String str){
return DateUtil.parseLocale(str);
}
});
populate(hmap, TimeZone.class, new Deserializer(){
public Object deserialize(String str){
return TimeZone.getTimeZone(str);
}
});
populate(hmap, Class.class, new Deserializer(){
public Object deserialize(String str)
throws ClassNotFoundException{
return Class.forName(str);
}
});
populate(hmap, File.class, new Deserializer(){
public Object deserialize(String str){
return new File(str);
}
});
return hmap;