maia/.svn/pristine/71/7150d5a0a70cdbf0ec5b0e9ee6a...

28 lines
845 B
Plaintext
Executable File

package com.fp.dto.json;
import java.math.BigDecimal;
import net.sf.json.JSONArray;
import net.sf.json.JSONNull;
import net.sf.json.processors.DefaultValueProcessor;
import net.sf.json.util.JSONUtils;
public class ObjectValueProcessor implements DefaultValueProcessor {
@SuppressWarnings("unchecked")
public Object getDefaultValue( Class type ) {
if( JSONUtils.isArray( type ) ){
return new JSONArray();
}else if( JSONUtils.isNumber( type ) ){
if( JSONUtils.isDouble( type ) ){
return new BigDecimal("0" );
}else{
return new Long( 0 );
}
}else if( JSONUtils.isBoolean( type ) ){
return Boolean.FALSE;
}else if( JSONUtils.isString( type ) ){
return "";
}
return JSONNull.getInstance();
}
}