Class WicaDoubleArraySerializer
java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<double[]>
ch.psi.wica.infrastructure.channel.WicaDoubleArraySerializer
- All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable
@Immutable
class WicaDoubleArraySerializer
extends com.fasterxml.jackson.databind.JsonSerializer<double[]>
Provides a means of serializing objects of type double[] in such a way that
a configurable number of digits appear after the decimal point.
This class works in conjunction with Jackson library module class with whom it must be registered.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
com.fasterxml.jackson.databind.JsonSerializer.None
-
Constructor Summary
ConstructorsConstructorDescriptionWicaDoubleArraySerializer
(int numericScale) Constructs a new custom serializer for double arrays. -
Method Summary
Modifier and TypeMethodDescriptionvoid
serialize
(double[] values, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) Serialize the Double Array.Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer
acceptJsonFormatVisitor, getDelegatee, handledType, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId
-
Constructor Details
-
WicaDoubleArraySerializer
WicaDoubleArraySerializer(int numericScale) Constructs a new custom serializer for double arrays.The serializer generates a string representation with the specified numeric scale (that's to say with the specified number of digits after the decimal point).
Where the numeric scale forces rounding, then a RoundingMode.HALF_UP strategy is implemented.
The JSON generator associated with this serializer can be configured to determine whether this serializer writes special values NaN and Infinity as numbers or strings.
- Parameters:
numericScale
- a positive number specifying the number of digits to appear after the decimal point in the serialized representation.- Throws:
IllegalArgumentException
- if the requested numeric scale is negative.
-
-
Method Details
-
serialize
public void serialize(double[] values, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers) throws IOException Serialize the Double Array.- Specified by:
serialize
in classcom.fasterxml.jackson.databind.JsonSerializer<double[]>
- Parameters:
values
- the array of values to be serialized.gen
- reference to a Java generator object that provides methods for generating the output string.serializers
- reference to a serializer provider (not needed by this implementation)- Throws:
IOException
-