public abstract class CobolDecimalType<T extends Number> extends CobolPrimitiveType<T>
This is a broad class that covers pretty much all COBOL numerics apart from Float/Double.
The parameterized type T determines which java Number type this COBOL decimal is converted to.
| Modifier and Type | Class and Description |
|---|---|
static class |
CobolDecimalType.Builder<T extends Number,B extends CobolDecimalType.Builder<T,B>> |
| Modifier and Type | Field and Description |
|---|---|
protected static char |
JAVA_DECIMAL_POINT |
| Constructor and Description |
|---|
CobolDecimalType(CobolDecimalType.Builder<T,?> builder) |
| Modifier and Type | Method and Description |
|---|---|
FromHostPrimitiveResult<T> |
fromHost(Class<T> javaClass,
CobolContext cobolContext,
byte[] hostData,
int start)
Convert mainframe data into a Java object.
|
protected abstract FromHostPrimitiveResult<T> |
fromHostInternal(Class<T> javaClass,
CobolContext cobolContext,
byte[] hostData,
int start)
Convert mainframe data into a java Number.
|
char |
getDigit(int index)
Convert a nibble content to a java digit.
|
int |
getFractionDigits() |
T |
getMaxInclusive() |
T |
getMinInclusive() |
int |
getTotalDigits() |
boolean |
isDigit(int nibble)
Check if a nibble contains a valid digit.
|
boolean |
isSigned() |
boolean |
isValid(Class<T> javaClass,
CobolContext cobolContext,
byte[] hostData,
int start)
Check if a byte array contains valid mainframe data for this type
characteristics.
|
protected abstract boolean |
isValidInternal(Class<T> javaClass,
CobolContext cobolContext,
byte[] hostData,
int start)
Check if a byte array contains a valid type with this instance
characteristics.
|
void |
setNibbles(int[] nibbles,
byte hostByte)
A nibble is a half byte.
|
static <D extends Number> |
valueOf(Class<D> clazz,
ByteBuffer bb,
int fractionDigits)
Given a byte buffer containing the 2's complement representation of an
unscaled numeric, convert that to the target java Number type.
|
static <D extends Number> |
valueOf(Class<D> clazz,
String str)
Given a string representation of a numeric value, convert that to the
target java Number type.
|
accept, fromHost, getBytesLen, getCobolName, getDependingOn, getJavaClass, getMaxBytesLen, getMinBytesLen, isCustomVariable, isOdoObject, isValidprotected static final char JAVA_DECIMAL_POINT
public CobolDecimalType(CobolDecimalType.Builder<T,?> builder)
public final boolean isValid(Class<T> javaClass, CobolContext cobolContext, byte[] hostData, int start)
isValid in class CobolPrimitiveType<T extends Number>javaClass - target java typecobolContext - host COBOL configuration parametershostData - the byte array containing mainframe datastart - the start position for the expected type in the byte arrayprotected abstract boolean isValidInternal(Class<T> javaClass, CobolContext cobolContext, byte[] hostData, int start)
javaClass - java Number class mapped to this COBOL decimalcobolContext - host COBOL configuration parametershostData - the byte array containing mainframe datastart - the start position for the expected type in the byte arraypublic FromHostPrimitiveResult<T> fromHost(Class<T> javaClass, CobolContext cobolContext, byte[] hostData, int start)
fromHost in class CobolPrimitiveType<T extends Number>javaClass - target java typecobolContext - host COBOL configuration parametershostData - the byte array containing mainframe datastart - the start position for the expected type in the byte arrayprotected abstract FromHostPrimitiveResult<T> fromHostInternal(Class<T> javaClass, CobolContext cobolContext, byte[] hostData, int start)
javaClass - java Number class mapped to this COBOL decimalcobolContext - host COBOL configuration parametershostData - the byte array containing mainframe datastart - the start position for the expected type in the byte arraypublic void setNibbles(int[] nibbles,
byte hostByte)
nibbles - to be populatedhostByte - the incoming bytepublic char getDigit(int index)
index - the nibble content is a value between 0 and 9 givig the
index of the digitpublic boolean isDigit(int nibble)
nibble - the nibble to checkpublic static <D extends Number> D valueOf(Class<D> clazz, String str)
If the target is an integer type, we trim any fractional part.
D - a number typeclazz - the java Number typestr - the string representation of a numeric valueNumberFormatException - if umber cannot be derived from the input
stringpublic static <D extends Number> D valueOf(Class<D> clazz, ByteBuffer bb, int fractionDigits)
Note that there is an assumption that the byte buffer contains at least 8
D - a number typeclazz - the java Number typebb - byte buffer containing the 2's complement representation of an
unscaled numericfractionDigits - the number of fraction digits in the COBOL typepublic boolean isSigned()
public int getTotalDigits()
public int getFractionDigits()
public T getMinInclusive()
public T getMaxInclusive()
Copyright © 2021 LegSem. All rights reserved.