Class DMinMax
- java.lang.Object
-
- org.supercsv.cellprocessor.CellProcessorAdaptor
-
- org.supercsv.cellprocessor.constraint.DMinMax
-
- All Implemented Interfaces:
CellProcessor
,StringCellProcessor
public class DMinMax extends CellProcessorAdaptor implements StringCellProcessor
Converts the input data to a Double and ensures that number is within a specified numeric range (inclusive). If the data has no upper bound (or lower bound), you should use either ofMIN
orMAX
constants provided in the class.
-
-
Field Summary
Fields Modifier and Type Field Description private double
max
static int
MAX_8_BIT_SIGNED
Maximum value for 8 bits (signed)static int
MAX_8_BIT_UNSIGNED
Maximum value for 8 bits (unsigned)static double
MAX_CHAR
Maximum value for a Characterstatic double
MAX_DOUBLE
Maximum value for a Doublestatic double
MAX_SHORT
Maximum value for a Shortprivate double
min
static int
MIN_8_BIT_SIGNED
Minimum value for 8 bits (signed)static int
MIN_8_BIT_UNSIGNED
Minimum value for 8 bits (unsigned)static double
MIN_CHAR
Minimum value for a Characterstatic double
MIN_DOUBLE
Minimum value for a Doublestatic double
MIN_SHORT
Minimum value for a Short-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
Constructor Summary
Constructors Constructor Description DMinMax(double min, double max)
Constructs a new DMinMax processor, which converts the input to a Double and ensures the value is between the supplied min and max values.DMinMax(double min, double max, DoubleCellProcessor next)
Constructs a new DMinMax processor, which converts the input to a Double, ensures the value is between the supplied min and max values, then calls the next processor in the chain.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkPreconditions(double min, double max)
Checks the preconditions for creating a new DMinMax processor.java.lang.Object
execute(java.lang.Object value, CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.-
Methods inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
-
-
-
Field Detail
-
MAX_DOUBLE
public static final double MAX_DOUBLE
Maximum value for a Double- See Also:
- Constant Field Values
-
MIN_DOUBLE
public static final double MIN_DOUBLE
Minimum value for a Double- See Also:
- Constant Field Values
-
MAX_SHORT
public static final double MAX_SHORT
Maximum value for a Short- See Also:
- Constant Field Values
-
MIN_SHORT
public static final double MIN_SHORT
Minimum value for a Short- See Also:
- Constant Field Values
-
MAX_CHAR
public static final double MAX_CHAR
Maximum value for a Character- See Also:
- Constant Field Values
-
MIN_CHAR
public static final double MIN_CHAR
Minimum value for a Character- See Also:
- Constant Field Values
-
MAX_8_BIT_UNSIGNED
public static final int MAX_8_BIT_UNSIGNED
Maximum value for 8 bits (unsigned)- See Also:
- Constant Field Values
-
MIN_8_BIT_UNSIGNED
public static final int MIN_8_BIT_UNSIGNED
Minimum value for 8 bits (unsigned)- See Also:
- Constant Field Values
-
MAX_8_BIT_SIGNED
public static final int MAX_8_BIT_SIGNED
Maximum value for 8 bits (signed)- See Also:
- Constant Field Values
-
MIN_8_BIT_SIGNED
public static final int MIN_8_BIT_SIGNED
Minimum value for 8 bits (signed)- See Also:
- Constant Field Values
-
min
private final double min
-
max
private final double max
-
-
Constructor Detail
-
DMinMax
public DMinMax(double min, double max)
Constructs a new DMinMax processor, which converts the input to a Double and ensures the value is between the supplied min and max values.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)- Throws:
java.lang.IllegalArgumentException
- ifmax < min
-
DMinMax
public DMinMax(double min, double max, DoubleCellProcessor next)
Constructs a new DMinMax processor, which converts the input to a Double, ensures the value is between the supplied min and max values, then calls the next processor in the chain.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)next
- the next processor in the chain- Throws:
java.lang.IllegalArgumentException
- ifmax < min
java.lang.NullPointerException
- if next is null
-
-
Method Detail
-
checkPreconditions
private static void checkPreconditions(double min, double max)
Checks the preconditions for creating a new DMinMax processor.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)- Throws:
java.lang.IllegalArgumentException
- ifmax < min
-
execute
public java.lang.Object execute(java.lang.Object value, CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
execute
in interfaceCellProcessor
- Parameters:
value
- the value to be processedcontext
- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException
- if value is null or can't be parsed as a DoubleSuperCsvConstraintViolationException
- if value doesn't lie between min and max (inclusive)
-
-