if(type == null)
throw new IllegalArgumentException("need to specify the type of field in filter json: " + json);
if ("int".equals(type)) {
MetaType metaType = DefaultSenseiInterpreter.CLASS_METATYPE_MAP.get(int.class);
String formatString = DefaultSenseiInterpreter.DEFAULT_FORMAT_STRING_MAP.get(metaType);
DecimalFormat formatter = new DecimalFormat(formatString, new DecimalFormatSymbols(Locale.US));
fromPadded = formatter.format(Integer.parseInt(from));
toPadded = formatter.format(Integer.parseInt(to));
}
else if ("short".equals(type)) {
MetaType metaType = DefaultSenseiInterpreter.CLASS_METATYPE_MAP.get(short.class);
String formatString = DefaultSenseiInterpreter.DEFAULT_FORMAT_STRING_MAP.get(metaType);
DecimalFormat formatter = new DecimalFormat(formatString, new DecimalFormatSymbols(Locale.US));
fromPadded = formatter.format(Short.parseShort(from));
toPadded = formatter.format(Short.parseShort(to));
}
else if ("long".equals(type)) {
MetaType metaType = DefaultSenseiInterpreter.CLASS_METATYPE_MAP.get(long.class);
String formatString = DefaultSenseiInterpreter.DEFAULT_FORMAT_STRING_MAP.get(metaType);
DecimalFormat formatter = new DecimalFormat(formatString, new DecimalFormatSymbols(Locale.US));
fromPadded = formatter.format(Long.parseLong(from));
toPadded = formatter.format(Long.parseLong(to));
}
else if ("date".equals(type)) {
if(dateFormat == null)
throw new IllegalArgumentException("Date format cannot be empty in filter json when type is date: " + json);
else{
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
fromPadded = formatter.format(new Date(Long.parseLong(from)));
toPadded = formatter.format(new Date(Long.parseLong(to)));
}
}
else if ("float".equals(type)) {
MetaType metaType = DefaultSenseiInterpreter.CLASS_METATYPE_MAP.get(float.class);
String formatString = DefaultSenseiInterpreter.DEFAULT_FORMAT_STRING_MAP.get(metaType);
DecimalFormat formatter = new DecimalFormat(formatString, new DecimalFormatSymbols(Locale.US));
fromPadded = formatter.format(Float.parseFloat(from));
toPadded = formatter.format(Float.parseFloat(to));
}
else if ("double".equals(type)) {
MetaType metaType = DefaultSenseiInterpreter.CLASS_METATYPE_MAP.get(double.class);
String formatString = DefaultSenseiInterpreter.DEFAULT_FORMAT_STRING_MAP.get(metaType);
DecimalFormat formatter = new DecimalFormat(formatString, new DecimalFormatSymbols(Locale.US));
fromPadded = formatter.format(Double.parseDouble(from));
toPadded = formatter.format(Double.parseDouble(to));
}