Class NumericFormatCompressed
java.lang.Object
com.softwaremining.wrappers.format.Format
com.softwaremining.wrappers.format.AbstractNumericFormat
com.softwaremining.wrappers.format.NumericFormat
com.softwaremining.wrappers.format.NumericFormatCompressed
- Direct Known Subclasses:
NumericFormatBinary
,NumericFormatBinaryX
,NumericFormatDouble
,NumericFormatPackedDecimal
Provides a formatter that emulates COBOL's NumericFormatCompressed (COMP-3) functionality in Java.
Given a decimal value and specified integer and fractional digit counts, this class:
1) encodes the value into packed decimal (two digits per byte, high-order nibble first)
2) appends a sign nibble ('C','D','F') in the low-order nibble of the last byte
3) decodes packed decimal back into numeric values, respecting sign and scale
4) enforces correct byte length based on digit counts
This implementation delivers a reliable, high-performance Java equivalent of COBOL's compressed numeric format for mission-critical data-conversion workflows.
1) encodes the value into packed decimal (two digits per byte, high-order nibble first)
2) appends a sign nibble ('C','D','F') in the low-order nibble of the last byte
3) decodes packed decimal back into numeric values, respecting sign and scale
4) enforces correct byte length based on digit counts
This implementation delivers a reliable, high-performance Java equivalent of COBOL's compressed numeric format for mission-critical data-conversion workflows.
-
Field Summary
Fields inherited from class com.softwaremining.wrappers.format.NumericFormat
P_onLeft, P_onRight, P_Size
Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String
convertFromCompressedStorageToDisplayFormat
(String formattedString) Convert from Storage-Compressed to Display This methods returns the actual stored value, even it is bigger than the defined format.convertFromDisplayToStorage
(double value, boolean[] sizeError) format a value according to the PIC definitionconvertFromDisplayToStorage
(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 boolean
Methods inherited from class com.softwaremining.wrappers.format.NumericFormat
getIntegerSize, getNumberOfDigits, getSQLObject, getStorageCellSize
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, convertFromStorageToDisplayFormat, getAllFormatInstances, getInstance, getInstance, getPicture, isJustifiedRight, setPicture, toString
-
Constructor Details
-
NumericFormatCompressed
-
-
Method Details
-
isCompressed
public final boolean isCompressed()- Specified by:
isCompressed
in classFormat
-
convertFromCompressedStorageToDisplayFormat
Convert from Storage-Compressed to Display This methods returns the actual stored value, even it is bigger than the defined format.
E.g. PIC 9(2) COMP can store a value of 30000 ! This method will return "30000", but convertFromStorageToDisplayFormat will return "30".- Parameters:
formattedString
-- Returns:
-
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
-