package com.ejie.m62fb.utils.serializers;

import java.io.IOException;
import java.math.BigDecimal;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import com.ejie.m62fb.utils.format.FormatUtils;

/**
 * JsonBigDecimalSerializer.
 * 
XXXX
 */
public class JsonBigDecimalSerializer extends JsonSerializer<BigDecimal> {

	/**
	 * 
	 * @param number
	 *            BigDecimal
	 * @param jsonGenerator
	 *            JsonGenerator
	 * @param paramSerializerProvider
	 *            SerializerProvider
	 * @throws IOException
	 *             e
	 * @throws JsonProcessingException
	 *             e
	 * 
	 */
	@Override
	public void serialize(BigDecimal number, JsonGenerator jsonGenerator,
			SerializerProvider paramSerializerProvider) throws IOException,
			JsonProcessingException {
		jsonGenerator.writeString(FormatUtils.bigDecimalToString(number, 2));
	}
}