@@ -0,0 +1,1319 @@
+package to.etc.domui.converter;%0A%0Aimport java.util.*;%0A%0Aimport to.etc.domui.trouble.*;%0Aimport to.etc.domui.util.*;%0Aimport to.etc.util.*;%0A%0A/**%0A * Converter to convert a computer %22size%22 to a size in bytes, KB, MB, GB etc.%0A *%0A * @author %3Ca href=%22mailto:jal@etc.to%22%3EFrits Jalvingh%3C/a%3E%0A * Created on Jul 30, 2009%0A */%0Apublic class LongSizeConverter implements IConverter%3CLong%3E %7B%0A%09public String convertObjectToString(Locale loc, Long in) throws UIException %7B%0A%09%09return StringTool.strSize(in.longValue());%0A%09%7D%0A%0A%09public Long convertStringToObject(Locale loc, String val) throws UIException %7B%0A%09%09val = val.trim();%0A%09%09if(val.length() == 0)%0A%09%09%09throw new ValidationException(Msgs.V_INVALID);%0A%0A%09%09int lindex = val.length();%0A%09%09while(lindex %3E 0 && !Character.isDigit(val.charAt(lindex - 1)))%0A%09%09%09lindex--;%0A%09%09if(lindex %3C= 0)%0A%09%09%09throw new ValidationException(Msgs.V_INVALID);%0A%0A%09%09String f = val.substring(lindex).toLowerCase();%0A%09%09val = val.substring(0, lindex);%0A%09%09double size = Double.parseDouble(val);%0A%09%09if(%22k%22.equals(f))%0A%09%09%09size *= 1024;%0A%09%09else if(%22m%22.equals(f))%0A%09%09%09size *= 1024 * 1024;%0A%09%09else if(%22g%22.equals(f))%0A%09%09%09size *= 1024l * 1024l * 1024l;%0A%09%09else if(%22t%22.equals(f))%0A%09%09%09size *= 1024l * 1024l * 1024l * 1024l;%0A%09%09else if(f.length() == 0)%0A%09%09%09;%0A%09%09else%0A%09%09%09throw new ValidationException(Msgs.V_INVALID);%0A%0A%09%09return Long.valueOf((long) size);%0A%09%7D%0A%7D%0A

Add long to size converter