![JAR search and dependency download from the Maven repository](/logo.png)
com.jrodeo.bson.marshallers.BigDecimalMarshaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bson-marshaller Show documentation
Show all versions of bson-marshaller Show documentation
A tool to create Java marshallers to and from bson. Currently used in a data access
layer serialize Json to Bson for MongoDB storage.
package com.jrodeo.bson.marshallers;
import org.bson.BsonReader;
import org.bson.BsonWriter;
import java.math.BigDecimal;
/**
* A hand coded Marshaller
to serialize java.math.BigDecimal
.
*/
public class BigDecimalMarshaller extends AbstractSimpleMarshaller {
@Override
public Class getForClass() {
return BigDecimal.class;
}
@Override
public void write(BsonWriter writer, BigDecimal obj) {
String s = obj.toString();
writer.writeString(s);
}
@Override
public BigDecimal read(BsonReader reader) {
String s = reader.readString();
BigDecimal bigDecimal = new BigDecimal(s);
return bigDecimal;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy