Class NumericEditedFormat
java.lang.Object
com.softwaremining.wrappers.format.Format
com.softwaremining.wrappers.format.AbstractNumericFormat
com.softwaremining.wrappers.format.NumericEditedFormat
- All Implemented Interfaces:
NumericEditedDisplay
public final class NumericEditedFormat
extends AbstractNumericFormat
implements NumericEditedDisplay
Provides a formatter that emulates COBOL's Numeric-Edited PICTURE functionality in Java.
Given a pattern containing edit symbols (e.g. "+", "-", "Z", "*", ".", etc.), digit counts (9),
and repetition markers (n), this class renders a numeric value by:
1) inserting and positioning edit symbols (signs, currency, decimal points)
2) suppressing leading zeros or replacing them with blanks or alternative symbols
3) enforcing fixed field widths via repetition counts
4) supporting implied decimal points with explicit "." in the pattern
This implementation delivers a faithful, high-performance Java equivalent
of COBOL's numeric-edited formatting for use in mission-critical data-conversion workflows.
-
Field Summary
FieldsFields inherited from class com.softwaremining.wrappers.format.AbstractNumericFormat
DECIMAL_POINT_ON_SYSTEM
Fields inherited from class com.softwaremining.wrappers.format.Format
additionalParamsPostfixesMap, justifiedRight, totalRuntime_convertFromDisplayToStorage, totalRuntime_getInstance
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
NumericEditedFormat
(String picture) protected
NumericEditedFormat
(String picture, boolean signIsTrailing) -
Method Summary
Modifier and TypeMethodDescriptionfinal String
convertFromDisplayToStorage
(double val, boolean[] sizeError) format a value according to the PIC definitionfinal String
convertFromDisplayToStorage
(String value, boolean[] sizeError) format a value according to the PIC definitionconvertFromDisplayToStorage
(BigDecimal value, boolean[] sizeError) format a value according to the PIC definitionconvertFromDisplayToStorage
(BigInteger value, boolean[] sizeError) format a value according to the PIC definitionfinal String
convertFromStorageToDisplayFormat
(String formattedString) static final String
int
int
Returns the number of integer digits of used for Integer and Decimal parts of a number.protected final String[]
getParts
(double val) final Object
getSQLObject
(String formattedString) final int
This is the number of characters in field.boolean
final boolean
final void
setCellSize
(int cellSize) Methods inherited from class com.softwaremining.wrappers.format.AbstractNumericFormat
adjustPercision, getFractionSize, getSystemDecimalPoint, isDecimal, isSigned
Methods inherited from class com.softwaremining.wrappers.format.Format
assignJustifiedRight, convertFromDisplayToStorage, convertFromDisplayToStorage, convertFromDisplayToStorage, convertFromDisplayToStorage, getAllFormatInstances, getInstance, getInstance, getPicture, isJustifiedRight, setPicture, toString
-
Field Details
-
smDecimalFormat
-
blankWhenZero
protected boolean blankWhenZero
-
-
Constructor Details
-
NumericEditedFormat
-
NumericEditedFormat
-
-
Method Details
-
setCellSize
public final void setCellSize(int cellSize) -
isBlankWhenZero
public boolean isBlankWhenZero()- Returns:
- Returns the blankWhenZero.
-
getIntegerSize
public int getIntegerSize() -
getNumberOfDigits
public int getNumberOfDigits()Returns the number of integer digits of used for Integer and Decimal parts of a number. For example, given a definition of S9(5)v9(3); the NumberOfDigists is 11.- Specified by:
getNumberOfDigits
in classFormat
- Returns:
-
getStorageCellSize
public final int getStorageCellSize()Description copied from class:Format
This is the number of characters in field.
For example, PIC X(10) will have 10 characters
or PIC 9(16) will have 16 characters
but PIC 9(16) COMP-3 will have 8 characters- Specified by:
getStorageCellSize
in classFormat
- Returns:
- cellsize
-
getSQLObject
- Specified by:
getSQLObject
in classFormat
-
isCompressed
public final boolean isCompressed()- Specified by:
isCompressed
in classFormat
-
convertFromStorageToDisplayFormat
- Specified by:
convertFromStorageToDisplayFormat
in classFormat
-
convertFromDisplayToStorage
format a value according to the PIC definition- Specified by:
convertFromDisplayToStorage
in classFormat
-
convertFromDisplayToStorage
format a value according to the PIC definition- Specified by:
convertFromDisplayToStorage
in classFormat
-
convertFromDisplayToStorage
format a value according to the PIC definition- Specified by:
convertFromDisplayToStorage
in classFormat
-
convertFromDisplayToStorage
format a value according to the PIC definition- Specified by:
convertFromDisplayToStorage
in classFormat
-
getParts
-
fitToSize
-