Class NumericFormatPackedDecimal
java.lang.Object
com.softwaremining.wrappers.format.Format
com.softwaremining.wrappers.format.AbstractNumericFormat
com.softwaremining.wrappers.format.NumericFormat
com.softwaremining.wrappers.format.NumericFormatCompressed
com.softwaremining.wrappers.format.NumericFormatPackedDecimal
Provides a formatter that emulates COBOL's NumericFormatPackedDecimal (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 format (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 data back into numeric values, respecting sign and scale
4) enforces correct byte length based on total digit count
This implementation delivers a reliable, high-performance Java equivalent
of COBOL's packed decimal format for mission-critical data-conversion workflows.
-
Field Summary
Fields inherited from class com.softwaremining.wrappers.format.NumericFormat
P_onLeft, P_onRight, P_SizeFields inherited from class com.softwaremining.wrappers.format.AbstractNumericFormat
DECIMAL_POINT_ON_SYSTEMFields inherited from class com.softwaremining.wrappers.format.Format
additionalParamsPostfixesMap, justifiedRight, totalRuntime_convertFromDisplayToStorage, totalRuntime_getInstance -
Method Summary
Modifier and TypeMethodDescriptionfinal intfinal StringconvertFromCompressedStorageToDisplayFormat(String formattedString) Convert from Storage-Compressed to Display This methods returns the actual stored value, even it is bigger than the defined format.final StringconvertFromDisplayToStorage(double value, boolean[] sizeError) format a value according to the PIC definitionfinal StringconvertFromDisplayToStorage(String _value, boolean[] sizeError) format a value according to the PIC definitionfinal StringconvertFromDisplayToStorage(BigDecimal value, boolean[] sizeError) format a value according to the PIC definitionfinal StringconvertFromDisplayToStorage(BigInteger value, boolean[] sizeError) format a value according to the PIC definitionfinal StringconvertFromStorageToDisplayFormat(String formattedString) final StringconvertFromStorageToDisplayFormatOld(String formattedString, boolean cutLeft) formatted string is typically a binary value eg.protected final StringformatHelper(long value, boolean isNegative) Methods inherited from class com.softwaremining.wrappers.format.NumericFormatCompressed
isCompressedMethods inherited from class com.softwaremining.wrappers.format.NumericFormat
getIntegerSize, getNumberOfDigits, getSQLObject, getStorageCellSizeMethods inherited from class com.softwaremining.wrappers.format.AbstractNumericFormat
adjustPercision, getFractionSize, getSystemDecimalPoint, isDecimal, isSignedMethods inherited from class com.softwaremining.wrappers.format.Format
assignJustifiedRight, convertFromDisplayToStorage, convertFromDisplayToStorage, convertFromDisplayToStorage, convertFromDisplayToStorage, getAllFormatInstances, getInstance, getInstance, getPicture, isJustifiedRight, setPicture, toString
-
Method Details
-
calculateFormattedCellSize
public final int calculateFormattedCellSize() -
convertFromDisplayToStorage
format a value according to the PIC definition- Overrides:
convertFromDisplayToStoragein classNumericFormatCompressed
-
convertFromDisplayToStorage
format a value according to the PIC definition- Overrides:
convertFromDisplayToStoragein classNumericFormatCompressed
-
convertFromDisplayToStorage
format a value according to the PIC definition- Overrides:
convertFromDisplayToStoragein classNumericFormatCompressed
-
convertFromDisplayToStorage
format a value according to the PIC definition- Overrides:
convertFromDisplayToStoragein classNumericFormatCompressed
-
convertFromStorageToDisplayFormatOld
formatted string is typically a binary value eg. (chars {17, 44)) .. which in hex is {11,2c}, means decimal number 112C - where 'C' represent the sign- Parameters:
formattedString-cutLeft-- Returns:
-
convertFromStorageToDisplayFormat
- Specified by:
convertFromStorageToDisplayFormatin classFormat
-
convertFromCompressedStorageToDisplayFormat
Description copied from class:NumericFormatCompressedConvert 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".- Specified by:
convertFromCompressedStorageToDisplayFormatin classNumericFormatCompressed- Returns:
-
formatHelper
-